Permit users to set uname info

This allows users on multi-arch systems to explicitly set their architecture in their environment.

Overriding `ARCH` is necessary for systems which run without a `uname` binary which has been extended to "lie" about the system's architecture in different contexts. For example on a multi-arch build system `mongo` may be running in an execution mode which differs from the host execution mode; currently you either have to modify `mongo` or patch `uname` to "lie" in order to get the desired `ARCH`.

This change doesn't require a patched `mongo` or `uname` binary.
  Ex:
```
PATH="/usr/local/opt/gnu-coreutils/bin${PATH+:$PATH}" ARCH=x86_64;
export PATH ARCH;
/usr/bin/arch -x86_64 ~/.meteor/packages/meteor-tool/2.5.6/mt-os.osx.x86_64/meteor ARGS...;
```
For context `gnu-coreutils`'s `uname` is agnostic to the effects of `arch -x86_64` and would output `arm64` in this case when we actually want `x86_64`.
This commit is contained in:
aameen-tulip
2022-04-26 15:56:27 -05:00
committed by GitHub
parent 53f3c4442d
commit 296ce3ad89

13
meteor
View File

@@ -4,7 +4,12 @@ BUNDLE_VERSION=14.19.1.0
# OS Check. Put here because here is where we download the precompiled
# bundles that are arch specific.
UNAME=$(uname)
# Use of : "${ARCH:=$(uname)}" assignment permits users to set their
# architecture manually; this is useful for multi-arch systems whose
# uname executables may sometimes return different architectures in
# different contexts.
# Ex: ARCH=arm64 meteor ARGS...;
UNAME="$(uname)"
if [ "$UNAME" != "Linux" -a "$UNAME" != "Darwin" ] ; then
echo "Sorry, this OS is not supported."
exit 1
@@ -12,7 +17,7 @@ fi
if [ "$UNAME" = "Darwin" ] ; then
if [ "arm64" == "$(uname -m)" ]; then
ARCH="arm64"
: "${ARCH:=arm64}"
else
if [ "i386" != "$(uname -p)" -o "1" != "$(sysctl -n hw.cpu64bit_capable 2>/dev/null || echo 0)" ] ; then
@@ -21,10 +26,10 @@ if [ "$UNAME" = "Darwin" ] ; then
echo "Only 64-bit and arm64 processors are supported at this time."
exit 1
fi
ARCH="x86_64"
: "${ARCH:=x86_64}"
fi
elif [ "$UNAME" = "Linux" ] ; then
ARCH="$(uname -m)"
: "${ARCH:=$(uname -m)}"
if [ "$ARCH" != "x86_64" ] ; then
echo "Unsupported architecture: $ARCH"
echo "Meteor only supports x86_64"