diff --git a/bin/cros_make_image_bootable b/bin/cros_make_image_bootable index 6fb60d1ac0..6d33cf1cfd 100755 --- a/bin/cros_make_image_bootable +++ b/bin/cros_make_image_bootable @@ -33,6 +33,7 @@ assert_inside_chroot # Load functions and constants for chromeos-install . /usr/lib/installer/chromeos-common.sh || exit 1 +. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1 diff --git a/build_image b/build_image index 9800b25388..86f9b0a08c 100755 --- a/build_image +++ b/build_image @@ -71,6 +71,7 @@ check_gsutil_opts # N.B. Ordering matters for some of the libraries below, because # some of the files contain initialization used by later files. +. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/mount_gpt_util.sh" || exit 1 diff --git a/build_library/board_options.sh b/build_library/board_options.sh index 6281018824..5a75022048 100644 --- a/build_library/board_options.sh +++ b/build_library/board_options.sh @@ -9,24 +9,7 @@ fi BOARD="${FLAGS_board}" BOARD_ROOT="/build/${BOARD}" +ARCH=$(get_board_arch ${BOARD}) # What cross-build are we targeting? . "${BOARD_ROOT}/etc/make.conf.board_setup" - -# Figure out ARCH from the given toolchain. -# TODO(jrbarnette): There's a copy of this code in setup_board; -# it should be shared. -case "$(echo "${CHOST}" | awk -F'-' '{ print $1 }')" in - arm*) - ARCH="arm" - ;; - *86) - ARCH="x86" - ;; - *x86_64) - ARCH="amd64" - ;; - *) - error "Unable to determine ARCH from toolchain: ${CHOST}" - exit 1 -esac diff --git a/build_library/toolchain_util.sh b/build_library/toolchain_util.sh index 231f9b3ea8..2548330440 100644 --- a/build_library/toolchain_util.sh +++ b/build_library/toolchain_util.sh @@ -11,7 +11,8 @@ TOOLCHAIN_PKGS=( ) # Portage arguments to enforce the toolchain to only use binpkgs. -TOOLCHAIN_BINONLY=( "${TOOLCHAIN_PKGS[@]/#/--useoldpkg-atoms=}" ) +TOOLCHAIN_BINONLY=( "${TOOLCHAIN_PKGS[@]/#/--useoldpkg-atoms=}" + "${TOOLCHAIN_PKGS[@]/#/--rebuild-exclude=}" ) # Portage profile to use for building out the cross compiler's SYSROOT. # This is only used as an intermediate step to be able to use the cross @@ -26,6 +27,30 @@ BOARD_CHOST["amd64-generic"]="x86_64-cros-linux-gnu" BOARD_PROFILE["amd64-generic"]="coreos:coreos/amd64/generic" BOARD_NAMES=( "${!BOARD_CHOST[@]}" ) +### Generic metadata fetching functions ### + +# map CHOST to portage ARCH, list came from crossdev +# Usage: get_portage_arch chost +get_portage_arch() { + case "$1" in + aarch64*) echo arm;; + alpha*) echo alpha;; + arm*) echo arm;; + hppa*) echo hppa;; + ia64*) echo ia64;; + i?86*) echo x86;; + m68*) echo m68k;; + mips*) echo mips;; + powerpc64*) echo ppc64;; + powerpc*) echo ppc;; + sparc*) echo sparc;; + s390*) echo s390;; + sh*) echo sh;; + x86_64*) echo amd64;; + *) die "Unknown CHOST '$1'";; + esac +} + get_board_list() { local IFS=$'\n\t ' sort <<<"${BOARD_NAMES[*]}" @@ -41,6 +66,15 @@ get_profile_list() { sort -u <<<"${BOARD_PROFILE[*]}" } +# Usage: get_board_arch board [board...] +get_board_arch() { + local board + for board in "$@"; do + get_portage_arch $(get_board_chost "${board}") + done +} + +# Usage: get_board_chost board [board...] get_board_chost() { local board for board in "$@"; do @@ -52,6 +86,7 @@ get_board_chost() { done } +# Usage: get_board_profile board [board...] get_board_profile() { local board for board in "$@"; do @@ -63,6 +98,7 @@ get_board_profile() { done } +# Usage: get_cross_pkgs chost [chost2...] get_cross_pkgs() { local cross_chost native_pkg for cross_chost in "$@"; do diff --git a/build_packages b/build_packages index 4084ee3a4c..21234f69b3 100755 --- a/build_packages +++ b/build_packages @@ -126,6 +126,7 @@ fi "${SCRIPTS_DIR}"/setup_board --quiet --board=${FLAGS_board} "${UPDATE_ARGS[@]}" # set BOARD and BOARD_ROOT +. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1 # Setup all the emerge command/flags. diff --git a/image_to_vm.sh b/image_to_vm.sh index a617ea41e0..c6727987b1 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -12,6 +12,7 @@ # Helper scripts should be run from the same location as this script. SCRIPT_ROOT=$(dirname "$(readlink -f "$0")") . "${SCRIPT_ROOT}/common.sh" || exit 1 +. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/build_common.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1