diff --git a/build_image b/build_image index 75f791bfe2..1068d209c4 100755 --- a/build_image +++ b/build_image @@ -83,13 +83,13 @@ eval set -- "${FLAGS_ARGV}" # so will die prematurely if 'set -e' is specified before now. set -e -. "${SCRIPT_ROOT}/build_library/board_options.sh" || exit 1 - # Determine build version. OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/chromiumos-overlay/chromeos" . "${OVERLAY_CHROMEOS_DIR}/config/chromeos_version.sh" || exit 1 -. "${SCRIPT_ROOT}/build_library/build_gpt.sh" || exit 1 +. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1 +. "${BUILD_LIBRARY_DIR}/build_gpt.sh" || exit 1 +. "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1 EMERGE_BOARD_CMD="emerge-$BOARD" @@ -441,9 +441,7 @@ install_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 - "${BUILD_LIBRARY_DIR}/test_image" \ - --root="${ROOT_FS_DIR}" \ - --target="${ARCH}" + test_image_content "$ROOT_FS_DIR" fi echo "Developer image built and stored at ${image_name}" @@ -600,9 +598,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. - "${BUILD_LIBRARY_DIR}/test_image" \ - --root="${ROOT_FS_DIR}" \ - --target="${ARCH}" + test_image_content "$ROOT_FS_DIR" fi # Clean up symlinks so they work on a running target rooted at "/". diff --git a/build_library/test_image b/build_library/test_image deleted file mode 100755 index 998bf9c422..0000000000 --- a/build_library/test_image +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -# 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. - -SCRIPT_ROOT=$(readlink -f $(dirname "$0")/..) -. "${SCRIPT_ROOT}/common.sh" || exit 1 - -# We're invoked only by build_image, which runs in the chroot -assert_inside_chroot - -# Flags -DEFINE_string target "x86" \ - "The target architecture to test. One of { x86, arm }." -DEFINE_string root "" \ - "The root file system to check." - -# Parse command line -FLAGS "$@" || exit 1 -eval set -- "${FLAGS_ARGV}" - -# Die on any errors -set -e - -# Check all parts of a pipe -set -o pipefail - -ROOT="$FLAGS_root" -if [[ -z "$ROOT" ]]; then - echo "Error: --root is required." - exit 1 -fi -if [[ ! -d "$ROOT" ]]; then - echo "Error: Root FS does not exist ($ROOT)" - exit 1 -fi - -EXITCODE=0 - -BINARIES="$ROOT/usr/bin/Xorg - $ROOT/usr/bin/chromeos-wm - $ROOT/boot/vmlinuz - $ROOT/sbin/session_manager - $ROOT/bin/sed" - -if [[ $FLAGS_target != arm ]]; then - # chrome isn't present on arm - BINARIES="$BINARIES - $ROOT/opt/google/chrome/chrome" -fi - -for i in $BINARIES; do - if ! [[ -f $i ]]; then - echo test_image: Cannot find $i - EXITCODE=1 - fi -done - -LIBS="`sudo find $ROOT -type f -name '*.so*'`" - -# Check that all .so files, plus the binaries, have the appropriate dependencies -if ! "${SCRIPTS_DIR}/build_library/check_deps" "$ROOT" $BINARIES $LIBS; then - echo test_image: Failed dependency check - EXITCODE=1 -fi - -exit $EXITCODE diff --git a/build_library/test_image_content.sh b/build_library/test_image_content.sh new file mode 100644 index 0000000000..78197949e9 --- /dev/null +++ b/build_library/test_image_content.sh @@ -0,0 +1,36 @@ +# 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. + +test_image_content() { + local root="$1" + local returncode=0 + + local binaries=( + "$root/usr/bin/Xorg" + "$root/usr/bin/chromeos-wm" + "$root/boot/vmlinuz" + "$root/sbin/session_manager" + "$root/bin/sed" + "$root/opt/google/chrome/chrome" + ) + + for test_file in "${binaries[@]}"; do + if [ ! -f "$test_file" ]; then + error "test_image_content: Cannot find '$test_file'" + returncode=1 + fi + done + + local libs=( $(sudo find "$root" -type f -name '*.so*') ) + + # Check that all .so files, plus the binaries, have the appropriate + # dependencies. + local check_deps="${BUILD_LIBRARY_DIR}/check_deps" + if ! "$check_deps" "$root" "${binaries[@]}" "${libs[@]}"; then + error "test_image_content: Failed dependency check" + returncode=1 + fi + + return $returncode +}