diff --git a/build_image b/build_image index 3ac3fe9aae..17b514c619 100755 --- a/build_image +++ b/build_image @@ -99,7 +99,7 @@ fi check_blacklist() { info "Verifying that the base image does not contain a blacklisted package." info "Generating list of packages for chromeos-base/chromeos." - local package_blacklist_file="${SCRIPTS_DIR}/chromeos_blacklist" + local package_blacklist_file="${BUILD_LIBRARY_DIR}/chromeos_blacklist" if [ ! -e "${package_blacklist_file}" ]; then warn "Missing blacklist file." return @@ -236,7 +236,7 @@ emerge_to_image() { } # Check that the build root is sane. -"${SCRIPTS_DIR}/test_build_root" --root="${BOARD_ROOT}" +"${BUILD_LIBRARY_DIR}/test_build_root" --root="${BOARD_ROOT}" # Freshen kernel with correct USE flags. This is a noop if we have # the right kernel prebuilt. Factory install uses USE="initramfs". @@ -496,7 +496,7 @@ update_dev_packages() { # building a factory install shim, as the INSTALL_MASK for it will make # test_image fail. if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then - "${SCRIPTS_DIR}/test_image" \ + "${BUILD_LIBRARY_DIR}/test_image" \ --root="${ROOT_FS_DIR}" \ --target="${ARCH}" fi @@ -667,7 +667,7 @@ create_base_image() { enable_rootfs_verification="--enable_rootfs_verification" fi - ${SCRIPTS_DIR}/create_legacy_bootloader_templates.sh \ + ${BUILD_LIBRARY_DIR}/create_legacy_bootloader_templates.sh \ --arch=${ARCH} \ --to="${ROOT_FS_DIR}"/boot \ --boot_args="${FLAGS_boot_args}" \ @@ -676,7 +676,7 @@ create_base_image() { # Don't test the factory install shim if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then # Check that the image has been correctly created. - "${SCRIPTS_DIR}/test_image" \ + "${BUILD_LIBRARY_DIR}/test_image" \ --root="${ROOT_FS_DIR}" \ --target="${ARCH}" fi @@ -706,7 +706,7 @@ create_base_image() { trap delete_prompt EXIT # Create the GPT-formatted image. - ${SCRIPTS_DIR}/build_gpt.sh \ + ${BUILD_LIBRARY_DIR}/build_gpt.sh \ --arch=${ARCH} \ --board=${FLAGS_board} \ --rootfs_partition_size=${FLAGS_rootfs_partition_size} \ @@ -721,7 +721,7 @@ create_base_image() { } generate_au_zip () { - local lgenerateauzip="${SCRIPTS_DIR}/generate_au_zip.py" + local lgenerateauzip="${BUILD_LIBRARY_DIR}/generate_au_zip.py" local largs="-o ${OUTPUT_DIR}" test ! -d "${OUTPUT_DIR}" && mkdir -p "${OUTPUT_DIR}" info "Running ${lgenerateauzip} ${largs} for generating AU updater zip file" diff --git a/build_library/build_common.sh b/build_library/build_common.sh index a77f736b32..b299e2ebc1 100644 --- a/build_library/build_common.sh +++ b/build_library/build_common.sh @@ -17,5 +17,6 @@ restart_in_chroot_if_needed "$@" INSTALLER_ROOT=/usr/lib/installer . "${INSTALLER_ROOT}/chromeos-common.sh" || exit 1 +BUILD_LIBRARY_DIR=${SCRIPTS_DIR}/build_library locate_gpt get_default_board diff --git a/build_gpt.sh b/build_library/build_gpt.sh similarity index 74% rename from build_gpt.sh rename to build_library/build_gpt.sh index d8a1f98cca..b4a87890b9 100755 --- a/build_gpt.sh +++ b/build_library/build_gpt.sh @@ -1,40 +1,19 @@ #!/bin/bash -# -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# --- 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=$(readlink -f $(dirname "$0")/..) +. "${SCRIPT_ROOT}/common.sh" || exit 1 - SCRIPT_ROOT= - for path in "${common_paths[@]}"; do - if [ -r "${path}/common.sh" ]; then - SCRIPT_ROOT=${path} - break - fi - done -} +# We're invoked only by build_image, which runs in the chroot +assert_inside_chroot -find_common_sh -. "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- +INSTALLER_ROOT=/usr/lib/installer +. "${INSTALLER_ROOT}/chromeos-common.sh" || exit 1 -# Load functions and constants for chromeos-install -[ -f /usr/lib/installer/chromeos-common.sh ] && \ - INSTALLER_ROOT=/usr/lib/installer || \ - INSTALLER_ROOT=$(dirname "$(readlink -f "$0")") - -. "${INSTALLER_ROOT}/chromeos-common.sh" || \ - die "Unable to load chromeos-common.sh" - -# Script must be run inside the chroot. -restart_in_chroot_if_needed "$@" +BUILD_LIBRARY_DIR=${SCRIPTS_DIR}/build_library get_default_board @@ -139,7 +118,7 @@ install_gpt $OUTDEV $(numsectors $ROOTFS_IMG) $(numsectors $STATEFUL_IMG) \ $PMBRCODE $(numsectors $ESP_IMG) false $FLAGS_rootfs_partition_size # Emit helpful scripts for testers, etc. -${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" +${BUILD_LIBRARY_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" sudo= if [ ! -w "$OUTDEV" ] ; then diff --git a/check_deps b/build_library/check_deps similarity index 100% rename from check_deps rename to build_library/check_deps diff --git a/chromeos_blacklist b/build_library/chromeos_blacklist similarity index 100% rename from chromeos_blacklist rename to build_library/chromeos_blacklist diff --git a/create_legacy_bootloader_templates.sh b/build_library/create_legacy_bootloader_templates.sh similarity index 89% rename from create_legacy_bootloader_templates.sh rename to build_library/create_legacy_bootloader_templates.sh index da2af2b29f..884f8e9647 100755 --- a/create_legacy_bootloader_templates.sh +++ b/build_library/create_legacy_bootloader_templates.sh @@ -1,33 +1,17 @@ #!/bin/bash -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Helper script that generates the signed kernel image +# Helper script to generate GRUB bootloader configuration files for +# x86 platforms. -# --- 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=$(readlink -f $(dirname "$0")/..) +. "${SCRIPT_ROOT}/common.sh" || exit 1 - 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}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- - -get_default_board +# We're invoked only by build_image, which runs in the chroot +assert_inside_chroot # Flags. DEFINE_string arch "x86" \ diff --git a/emit_gpt_scripts.sh b/build_library/emit_gpt_scripts.sh similarity index 56% rename from emit_gpt_scripts.sh rename to build_library/emit_gpt_scripts.sh index d7590d7cd3..2c19c66751 100755 --- a/emit_gpt_scripts.sh +++ b/build_library/emit_gpt_scripts.sh @@ -1,37 +1,21 @@ #!/bin/bash -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # # Emit scripts to pack and unpack the partitions from a GPT disk 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=$(readlink -f $(dirname "$0")/..) +. "${SCRIPT_ROOT}/common.sh" || exit 1 - 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}/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 +# We're invoked only by build_image, which runs in the chroot assert_inside_chroot -# Load functions and constants for chromeos-install -. "/usr/lib/installer/chromeos-common.sh" || \ - die "Unable to load /usr/lib/installer/chromeos-common.sh" +INSTALLER_ROOT=/usr/lib/installer +. "${INSTALLER_ROOT}/chromeos-common.sh" || exit 1 + +locate_gpt set -e @@ -46,8 +30,6 @@ fi PACK="${DIR}/pack_partitions.sh" UNPACK="${DIR}/unpack_partitions.sh" -locate_gpt - TMP=$(mktemp) $GPT show "$IMAGE" > $TMP diff --git a/generate_au_zip.py b/build_library/generate_au_zip.py similarity index 100% rename from generate_au_zip.py rename to build_library/generate_au_zip.py diff --git a/test_build_root b/build_library/test_build_root similarity index 79% rename from test_build_root rename to build_library/test_build_root index 17d1549f5a..814ae690f3 100755 --- a/test_build_root +++ b/build_library/test_build_root @@ -1,29 +1,14 @@ #!/bin/bash -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# --- 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=$(readlink -f $(dirname "$0")/..) +. "${SCRIPT_ROOT}/common.sh" || exit 1 - 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}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- +# We're invoked only by build_image, which runs in the chroot +assert_inside_chroot # Flags DEFINE_string root "" \ diff --git a/test_image b/build_library/test_image similarity index 63% rename from test_image rename to build_library/test_image index 3adc675628..998bf9c422 100755 --- a/test_image +++ b/build_library/test_image @@ -1,29 +1,14 @@ #!/bin/bash -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# --- 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=$(readlink -f $(dirname "$0")/..) +. "${SCRIPT_ROOT}/common.sh" || exit 1 - 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}/common.sh" || { echo "Unable to load common.sh"; exit 1; } -# --- END COMMON.SH BOILERPLATE --- +# We're invoked only by build_image, which runs in the chroot +assert_inside_chroot # Flags DEFINE_string target "x86" \ @@ -75,7 +60,7 @@ done LIBS="`sudo find $ROOT -type f -name '*.so*'`" # Check that all .so files, plus the binaries, have the appropriate dependencies -if ! "${SCRIPTS_DIR}/check_deps" "$ROOT" $BINARIES $LIBS; then +if ! "${SCRIPTS_DIR}/build_library/check_deps" "$ROOT" $BINARIES $LIBS; then echo test_image: Failed dependency check EXITCODE=1 fi