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
66 readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe"
77 readonly HOSTARCH=$(xbps-uhelper arch)
88
9+is_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+
936 info_msg() {
1037 # This function handles the printing that is bold within all
1138 # scripts. This is a convenience function so that the rather ugly
@@ -80,9 +107,7 @@ umount_pseudofs() { · 68 unmodified lines
80107
81108 run_cmd_target() {
82109 info_msg "Running $* for target $XBPS_TARGET_ARCH ..."
83− if [ "$XBPS_TARGET_ARCH" = "${HOSTARCH}" ] ||
84− [ -z "${XBPS_TARGET_ARCH##*86*}" ] &&
85− [ -z "${HOSTARCH##*86*}" ] ; then
110+ if is_target_native "$XBPS_TARGET_ARCH"; then
86111 # This is being run on the same architecture as the host,
87112 # therefore we should set XBPS_ARCH.
88113 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
168168 # This step sets up enough of the base-files that the chroot will work
169169 # and they can be reconfigured natively. Without this step there
170170 # 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 taken
172−# to make this work.
173−if [ -z "${XBPS_TARGET_ARCH##*86*}" ] && [ -z "${HOSTARCH##*86*}" ] ; then
171+# architecture, but we may need to set up XBPS_ARCH for the target
172+# architecture (but only when compatible).
173+if is_target_native "$XBPS_TARGET_ARCH"; then
174174 run_cmd_target "xbps-reconfigure --rootdir $ROOTFS base-files"
175175 else
176176 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