Debian Codegraph @

3rdparty/vboot/scripts/image_signing/ensure_no_nonrelease_files.sh

raw symbols SCIP
1 #!/bin/bash
2
3 # Copyright 2012 The ChromiumOS Authors
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Abort on error.
8 set -e
9
10 # Load common constants and variables.
11 . "$(dirname "$0")/common.sh"
12
13 usage() {
14 echo "Usage $PROG image [config]"
15 }
16
17 main() {
18 # We want to catch all the discrepancies, not just the first one.
19 # So, any time we find one, we set testfail=1 and continue.
20 # When finished we will use testfail to determine our exit value.
21 local testfail=0
22
23 if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
24 usage
25 exit 1
26 fi
27
28 local image="$1"
29
30 # Default config location: same name/directory as this script,
31 # with a .config file extension, ie ensure_no_nonrelease_files.config.
32 local configfile="$(dirname "$0")/${0/%.sh/.config}"
33 # Or, maybe a config was provided on the command line.
34 if [[ $# -eq 2 ]]; then
35 configfile="$2"
36 fi
37 # Either way, load test-expectations data from config.
38 . "${configfile}" || return 1
39
40 local loopdev rootfs
41 if [[ -d "${image}" ]]; then
42 rootfs="${image}"
43 else
44 rootfs=$(make_temp_dir)
45 loopdev=$(loopback_partscan "${image}")
46 mount_loop_image_partition "${loopdev}" 3 "${rootfs}"
47 fi
48 # Pick the right set of test-expectation data to use.
49 local brdvar=$(get_boardvar_from_lsb_release "${rootfs}")
50 eval "release_file_blocklist=(\"\${RELEASE_FILE_BLOCKLIST_${brdvar}[@]}\")"
51
52 for file in ${release_file_blocklist}; do
53 if [ -e "${rootfs}/${file}" ]; then
54 error "${file} exists in this image!"
55 ls -al "${rootfs}/${file}"
56 testfail=1
57 fi
58 done
59
60 # Verify that session_manager isn't configured to pass additional
61 # environment variables or command-line arguments to Chrome.
62 local config_path="${rootfs}/etc/chrome_dev.conf"
63 local matches=$(grep -s "^[^#]" "${config_path}")
64 if [ -n "${matches}" ]; then
65 error "Found commands in ${config_path}:"
66 error "${matches}"
67 testfail=1
68 fi
69
70 exit ${testfail}
71 }
72 main "$@"