Factor out architecture map

This commit is contained in:
Michael Aldridge 2017-08-13 17:44:25 -07:00
parent 2724ae0abb
commit 6e1d80b78b
2 changed files with 53 additions and 15 deletions

View File

@ -149,6 +149,14 @@ register_binfmt() {
# kernel select an alternate interpreter. More values for this # kernel select an alternate interpreter. More values for this
# map can be obtained from here: # map can be obtained from here:
# https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh # https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh
# If the XBPS_TARGET_ARCH is unset but the PLATFORM is known, it
# may be possible to set the architecture from the static
# platforms map.
if [ -z "$XBPS_TARGET_ARCH" ] && [ ! -z "$PLATFORM" ] ; then
set_target_arch_from_platform
fi
case "${XBPS_TARGET_ARCH}" in case "${XBPS_TARGET_ARCH}" in
armv*) armv*)
_cpu=arm _cpu=arm
@ -213,6 +221,34 @@ register_binfmt() {
fi fi
} }
set_target_arch_from_platform() {
# This function maintains a lookup from platform to target
# architecture. This is required for scripts that need to know
# the target architecture, but don't necessarily need to know it
# internally (i.e. only run_cmd_chroot).
case "$PLATFORM" in
bananapi*) XBPS_TARGET_ARCH="armv7l";;
beaglebone*) XBPS_TARGET_ARCH="armv7l";;
cubieboard2*|cubietruck*) XBPS_TARGET_ARCH="armv7l";;
dockstar*) XBPS_TARGET_ARCH="armv5tel";;
odroid-u2*) XBPS_TARGET_ARCH="armv7l";;
odroid-c2*) XBPS_TARGET_ARCH="aarch64";;
rpi3*) XBPS_TARGET_ARCH="aarch64";;
rpi2*) XBPS_TARGET_ARCH="armv7l";;
rpi*) XBPS_TARGET_ARCH="armv6l";;
usbarmory*) XBPS_TARGET_ARCH="armv7l";;
ci20*) XBPS_TARGET_ARCH="mipsel";;
i686*) XBPS_TARGET_ARCH="i686";;
x86_64*) XBPS_TARGET_ARCH="x86_64";;
GCP*) XBPS_TARGET_ARCH="x86_64";;
*) die "$PROGNAME: Unable to compute target architecture from platform";;
esac
if [ -z "${PLATFORM##*-musl}" ] ; then
XBPS_TARGET_ARCH="${XBPS_TARGET_ARCH}-musl"
fi
}
set_cachedir() { set_cachedir() {
# The package artifacts are cacheable, but they need to be isolated # The package artifacts are cacheable, but they need to be isolated
# from the host cache. # from the host cache.

View File

@ -105,29 +105,31 @@ check_tools
# noarch though, so we strip off the -musl extention if it was # noarch though, so we strip off the -musl extention if it was
# provided. # provided.
case "$PLATFORM" in case "$PLATFORM" in
bananapi*) XBPS_TARGET_ARCH="armv7l"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; bananapi*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
beaglebone*) XBPS_TARGET_ARCH="armv7l"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; beaglebone*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
cubieboard2*|cubietruck*) XBPS_TARGET_ARCH="armv7l"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; cubieboard2*|cubietruck*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
dockstar*) XBPS_TARGET_ARCH="armv5tel"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; dockstar*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
odroid-u2*) XBPS_TARGET_ARCH="armv7l"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; odroid-u2*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
odroid-c2*) XBPS_TARGET_ARCH="aarch64"; PKGS="$BASEPKG ${PLATFORM%-musl}-base" ;; odroid-c2*) PKGS="$BASEPKG ${PLATFORM%-musl}-base" ;;
rpi3*) XBPS_TARGET_ARCH="aarch64"; PKGS="$BASEPKG rpi3-base" ;; rpi3*) PKGS="$BASEPKG rpi3-base" ;;
rpi2*) XBPS_TARGET_ARCH="armv7l"; PKGS="$BASEPKG rpi-base" ;; rpi2*) PKGS="$BASEPKG rpi-base" ;;
rpi*) XBPS_TARGET_ARCH="armv6l"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; rpi*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
usbarmory*) XBPS_TARGET_ARCH="armv7l"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; usbarmory*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
ci20*) XBPS_TARGET_ARCH="mipsel"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; ci20*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
i686*) XBPS_TARGET_ARCH="i686"; PKGS="$BASEPKG" ;; i686*) PKGS="$BASEPKG" ;;
x86_64*) XBPS_TARGET_ARCH="x86_64"; PKGS="$BASEPKG" ;; x86_64*) PKGS="$BASEPKG" ;;
GCP*) XBPS_TARGET_ARCH="x86_64"; PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; GCP*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
*) die "$PROGNAME: invalid platform!";; *) die "$PROGNAME: invalid platform!";;
esac esac
# Check if we should be using the -musl variant # Check if we should be using the -musl variant
if [ -z "${BASE_TARBALL##*-musl-*}" ] ; then if [ -z "${BASE_TARBALL##*-musl-*}" ] ; then
XBPS_TARGET_ARCH="${XBPS_TARGET_ARCH}-musl"
PLATFORM="${PLATFORM}-musl" PLATFORM="${PLATFORM}-musl"
fi fi
# Derive the target architecture using the static map
set_target_arch_from_platform
# Append any additional packages if they were requested # Append any additional packages if they were requested
if [ -z "$EXTRA_PKGS" ] ; then if [ -z "$EXTRA_PKGS" ] ; then
PKGS="$PKGS $EXTRA_PKGS" PKGS="$PKGS $EXTRA_PKGS"