History

lib.sh.in/mkrootfs.sh.in: proper native platform detection

q66 committed 7 years ago

Commit 7d30d331 parent 51d4a5f2 files · +31 −6Browse files

Unified · Split

2 files
  1. lib.sh.in +28 −3
  2. mkrootfs.sh.in +3 −3
lib.sh.in+28−3
@@ -6,6 +6,33 @@ · 5 unmodified lines
6readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe"6readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe"
7readonly HOSTARCH=$(xbps-uhelper arch)7readonly HOSTARCH=$(xbps-uhelper arch)
8 8
9is_target_native() {
10 # Because checking whether the target is runnable is ugly, stuff
11 # it into a single function. That makes it easy to check anywhere.
12 local target_arch
13
14 target_arch="$1"
15 # this will cover most
16 if [ "${target_arch%-musl}" = "${HOSTARCH%-musl}" ]; then
17 return 0
18 fi
19
20 case "$HOSTARCH" in
21 # ppc64le has no 32-bit variant, only runs its own stuff
22 ppc64le*) return 1 ;;
23 # x86_64 also runs i686
24 x86_64*) test -z "${target_arch##*86*}" ;;
25 # aarch64 also runs armv*
26 aarch64*) test -z "${target_arch##armv*}" ;;
27 # bigendian ppc64 also runs ppc
28 ppc64*) test "${target_arch%-musl}" = "ppc" ;;
29 # anything else is just their own
30 *) return 1 ;;
31 esac
32
33 return $?
34}
35
9info_msg() {36info_msg() {
10 # This function handles the printing that is bold within all37 # This function handles the printing that is bold within all
11 # scripts. This is a convenience function so that the rather ugly38 # scripts. This is a convenience function so that the rather ugly
@@ -80,9 +107,7 @@ umount_pseudofs() { · 68 unmodified lines
80 107
81run_cmd_target() {108run_cmd_target() {
82 info_msg "Running $* for target $XBPS_TARGET_ARCH ..."109 info_msg "Running $* for target $XBPS_TARGET_ARCH ..."
83 if [ "$XBPS_TARGET_ARCH" = "${HOSTARCH}" ] ||110 if is_target_native "$XBPS_TARGET_ARCH"; then
84 [ -z "${XBPS_TARGET_ARCH##*86*}" ] &&
85 [ -z "${HOSTARCH##*86*}" ] ; then
86 # This is being run on the same architecture as the host,111 # This is being run on the same architecture as the host,
87 # therefore we should set XBPS_ARCH.112 # therefore we should set XBPS_ARCH.
88 if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then113 if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then
mkrootfs.sh.in+3−3
@@ -168,9 +168,9 @@ info_msg "Reconfiguring packages for ${XBPS_TARGET_ARCH} ..." · 167 unmodified lines
168# This step sets up enough of the base-files that the chroot will work168# This step sets up enough of the base-files that the chroot will work
169# and they can be reconfigured natively. Without this step there169# and they can be reconfigured natively. Without this step there
170# isn't enough configured for ld to work. This step runs as the host170# isn't enough configured for ld to work. This step runs as the host
171# architecture, but on x86 some special extra steps have to be taken171# architecture, but we may need to set up XBPS_ARCH for the target
172# to make this work.172# architecture (but only when compatible).
173if [ -z "${XBPS_TARGET_ARCH##*86*}" ] && [ -z "${HOSTARCH##*86*}" ] ; then173if is_target_native "$XBPS_TARGET_ARCH"; then
174 run_cmd_target "xbps-reconfigure --rootdir $ROOTFS base-files"174 run_cmd_target "xbps-reconfigure --rootdir $ROOTFS base-files"
175else175else
176 run_cmd "xbps-reconfigure --rootdir $ROOTFS base-files"176 run_cmd "xbps-reconfigure --rootdir $ROOTFS base-files"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t