diff --git a/archive_hwqual b/archive_hwqual index 6fa7498342..718bbdf742 100755 --- a/archive_hwqual +++ b/archive_hwqual @@ -10,20 +10,8 @@ # Load common CrOS utilities. Inside the chroot this file is installed in # /usr/lib/crosutils. Outside the chroot we find it relative to the script's # location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } # --- END COMMON.SH BOILERPLATE --- diff --git a/build_image b/build_image index c1ee826f7e..67564d96bb 100755 --- a/build_image +++ b/build_image @@ -9,7 +9,7 @@ # the given target's root with binary packages turned on. This script will # build the Chrome OS image using only pre-built binary packages. -SCRIPT_ROOT=$(dirname "$0") +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 diff --git a/build_kernel_image.sh b/build_kernel_image.sh index 3ea43372f9..dc111bc0d4 100755 --- a/build_kernel_image.sh +++ b/build_kernel_image.sh @@ -6,26 +6,8 @@ # Helper script that generates the signed kernel image -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- get_default_board diff --git a/clean_loopback_devices b/clean_loopback_devices index e2ea779517..d8ab5811b8 100755 --- a/clean_loopback_devices +++ b/clean_loopback_devices @@ -8,26 +8,8 @@ # failures. This script only affects mountpoints and loopback devices # that were created within this chroot. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1;} -# --- END COMMON.SH BOILERPLATE --- # Script must be run inside the chroot. assert_inside_chroot diff --git a/cros_generate_breakpad_symbols b/cros_generate_breakpad_symbols index 57bb3aa451..5b24ddba12 100755 --- a/cros_generate_breakpad_symbols +++ b/cros_generate_breakpad_symbols @@ -9,26 +9,8 @@ # NOTE: This script must be run from the chromeos build chroot environment. # -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Script must be run inside the chroot restart_in_chroot_if_needed "$@" diff --git a/cros_show_stacks b/cros_show_stacks index b54a92963d..b06a16e04c 100755 --- a/cros_show_stacks +++ b/cros_show_stacks @@ -6,27 +6,9 @@ # Script to generate stackdumps from a machine or dmp files. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- - . "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh" assert_inside_chroot diff --git a/get_latest_image.sh b/get_latest_image.sh index 66916b3545..884ab15cc6 100755 --- a/get_latest_image.sh +++ b/get_latest_image.sh @@ -6,26 +6,8 @@ # Prints the path to the most recently built image to stdout. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- get_default_board diff --git a/get_package_list b/get_package_list index 0408b46588..d5bafa8696 100755 --- a/get_package_list +++ b/get_package_list @@ -7,26 +7,8 @@ # Lists all package dependencies of a particular package. Useful to find out # all packages depended on by chromeos and chromeos-dev. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Script must be run inside the chroot. assert_inside_chroot diff --git a/image_to_usb.sh b/image_to_usb.sh index 1fcab9fdc5..a9bd42bd35 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -6,26 +6,8 @@ # Script to convert the output of build_image.sh to a usb or SD image. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Load functions and constants for chromeos-install [ -f /usr/lib/installer/chromeos-common.sh ] && \ diff --git a/make_netboot.sh b/make_netboot.sh index 94133a22b5..b8d97f196d 100755 --- a/make_netboot.sh +++ b/make_netboot.sh @@ -12,29 +12,9 @@ # shim kernel image, bundled as a uboot gz/uimg, and places them in a # "netboot" subfolder. -# This script is intended to be called mainly form archive_build.sh, where -# these files are added to the factory install artifacts generated on buildbot. - -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- + # Script must be run inside the chroot. restart_in_chroot_if_needed "$@" diff --git a/mod_image_for_recovery.sh b/mod_image_for_recovery.sh index e48b0ae5c7..973d5fa376 100755 --- a/mod_image_for_recovery.sh +++ b/mod_image_for_recovery.sh @@ -9,7 +9,7 @@ # kernel. Alternatively, a signed recovery kernel can be used to # create a Chromium OS recovery image. -SCRIPT_ROOT=$(dirname "$0") +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 # Default recovery kernel name. diff --git a/mod_image_for_test.sh b/mod_image_for_test.sh index 2e418eb75c..5124b1dc80 100755 --- a/mod_image_for_test.sh +++ b/mod_image_for_test.sh @@ -15,7 +15,7 @@ # # TODO(vlaviano): delete this script. -SCRIPT_ROOT=$(dirname "$0") +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 diff --git a/mod_test_image_for_pyauto.sh b/mod_test_image_for_pyauto.sh index 6d7079e50c..facd095f4e 100644 --- a/mod_test_image_for_pyauto.sh +++ b/mod_test_image_for_pyauto.sh @@ -6,30 +6,13 @@ # Script to modify a keyfob-based chromeos test image to install pyauto. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) +. "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } cleanup() { "${SCRIPTS_DIR}/mount_gpt_image.sh" -u -r "$ROOT_FS_DIR" -s "$STATEFUL_FS_DIR" } -find_common_sh -. "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Need to be inside the chroot to load chromeos-common.sh assert_inside_chroot diff --git a/ssh_test.sh b/ssh_test.sh index e23254a50d..6c1d2de9ba 100755 --- a/ssh_test.sh +++ b/ssh_test.sh @@ -8,27 +8,8 @@ # a code of 0 if successful and non-zero otherwise. Used by test infrastructure # scripts. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- - . "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh" function cleanup { diff --git a/start_devserver b/start_devserver index 1bbbe88be1..2feee177d1 100755 --- a/start_devserver +++ b/start_devserver @@ -5,26 +5,8 @@ # Start the Dev Server after making sure we are running under a chroot. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Script must be run inside the chroot if not in 'always serve' mode. if [[ "$1" != "--archive_dir" ]]; then diff --git a/update_bootloaders.sh b/update_bootloaders.sh index 8d443df6e0..163b281992 100755 --- a/update_bootloaders.sh +++ b/update_bootloaders.sh @@ -7,26 +7,8 @@ # Helper script that generates the legacy/efi bootloader partitions. # It does not populate the templates, but can update a loop device. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Need to be inside the chroot to load chromeos-common.sh assert_inside_chroot diff --git a/update_kernel.sh b/update_kernel.sh index d497317889..6d0156154a 100755 --- a/update_kernel.sh +++ b/update_kernel.sh @@ -6,27 +6,8 @@ # Script to update the kernel on a live running ChromiumOS instance. -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- - . "${SCRIPT_ROOT}/remote_access.sh" # Script must be run inside the chroot. diff --git a/upload_symbols b/upload_symbols index 73ce875da9..b0f93de37e 100755 --- a/upload_symbols +++ b/upload_symbols @@ -8,26 +8,8 @@ # symbols or to debug crashes on non-release builds (in which case try # to only upload the symbols for those executables involved). -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Script must be run inside the chroot restart_in_chroot_if_needed "$@" diff --git a/verify_rootfs_chksum.sh b/verify_rootfs_chksum.sh index df20a2623c..83b60a1f3d 100755 --- a/verify_rootfs_chksum.sh +++ b/verify_rootfs_chksum.sh @@ -6,26 +6,8 @@ # Script to verify integrity of root file system for a GPT-based image -# --- BEGIN COMMON.SH BOILERPLATE --- -# Load common CrOS utilities. Inside the chroot this file is installed in -# /usr/lib/crosutils. Outside the chroot we find it relative to the script's -# location. -find_common_sh() { - local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) - local path - - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} - -find_common_sh +SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- # Load functions and constants for chromeos-install [ -f /usr/lib/installer/chromeos-common.sh ] && \