vp-build/common/wrappers/uname.sh
Đoàn Trần Công Danh 447bae0d3e uname.sh: fix cross uname -m when XBPS_ARCH is reseted
From commit cf6e6f14d3, (wrappers/uname: report correct machine type
on ethereal, 2020-02-10).

Some template use `env -i` to reset environment variable for building
host's binary file, thus the wrapped `uname -m` reports empty strings.

Fix it by falling back to the value reported by `/usr/bin/uname -m`.
We don't expect people cross-compile from i686-ethereal-chroot on top
of x86_64 machine, it was expected to use for travis to native compile
i686 only.
2020-03-24 03:59:36 +01:00

14 lines
298 B
Bash

#!/bin/sh
uname=$(/usr/bin/uname $@)
uname_m=$(/usr/bin/uname -m)
arch=${XBPS_ARCH%-musl}
# if XBPS_ARCH was reseted by `env -i` use original `/usr/bin/uname -m`
: ${arch:=$uname_m}
rv=$?
echo "$uname" |
sed "s/\(^\| \)$(/usr/bin/uname -n)\($\| \)/\1void\2/" |
sed "s/$uname_m/$arch/"
exit $rv