|
6 | 6 | readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe" |
7 | 7 | readonly HOSTARCH=$(xbps-uhelper arch) |
8 | 8 |
|
| 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 | + |
9 | 36 | info_msg() { |
10 | 37 | # This function handles the printing that is bold within all |
11 | 38 | # scripts. This is a convenience function so that the rather ugly |
@@ -80,9 +107,7 @@ umount_pseudofs() { |
80 | 107 |
|
81 | 108 | run_cmd_target() { |
82 | 109 | 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 |
86 | 111 | # This is being run on the same architecture as the host, |
87 | 112 | # therefore we should set XBPS_ARCH. |
88 | 113 | if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then |
|
0 commit comments