mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 14:11:07 +02:00
fix(board_options.sh): Move CHOST->ARCH mapping code.
Use the complete chost to portage arch mapping list from crossdev and move the logic to toolchain_util.sh where it can be used by other scripts.
This commit is contained in:
parent
b5816f7a8d
commit
41099eef6f
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user