| @@ -6,6 +6,33 @@ · 5 unmodified lines |
| 6 | readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe" | 6 | readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe" |
| 7 | readonly HOSTARCH=$(xbps-uhelper arch) | 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 | info_msg() { | 36 | info_msg() { |
| 10 | # This function handles the printing that is bold within all | 37 | # This function handles the printing that is bold within all |
| 11 | # scripts. This is a convenience function so that the rather ugly | 38 | # scripts. This is a convenience function so that the rather ugly |
| @@ -80,9 +107,7 @@ umount_pseudofs() { · 68 unmodified lines |
| 80 | | 107 | |
| 81 | run_cmd_target() { | 108 | run_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" "$@" ; then | 113 | if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then |