Skip to content

Commit f2626d4

Browse files
authored
Detect Linux runtime from host architecture if not specified (#2217)
Detect the runtime (linux-x64/linux-arm64/etc) from the current host architecture if not specified via the `--runtime` argument. We had already been doing this in the script, but after we already `die`-d when `--runtime` was missing! Oops. Let's move this auto-detection logic up-front, and also no longer rely on `dpkg-architecture` to determine the host arch; we can use `uname -m` instead.
2 parents 136f72b + a22cf9c commit f2626d4

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

src/linux/Packaging.Linux/pack.sh

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,30 @@ fi
5959
if [ -z "$SYMBOLS" ]; then
6060
die "--symbols was not set"
6161
fi
62-
if [ -z "$RUNTIME" ]; then
63-
die "--runtime was not set"
64-
fi
65-
6662
if [ -z "$OUTPUT_ROOT" ]; then
6763
OUTPUT_ROOT="$PROJ_OUT/$CONFIGURATION"
6864
fi
6965

66+
# Fall back to host architecture if no explicit runtime is given.
67+
if test -z "$RUNTIME"; then
68+
HOST_ARCH="`uname -m`"
69+
70+
case $HOST_ARCH in
71+
x86_64|amd64)
72+
RUNTIME="linux-x64"
73+
;;
74+
aarch64|arm64)
75+
RUNTIME="linux-arm64"
76+
;;
77+
armhf)
78+
RUNTIME="linux-arm"
79+
;;
80+
*)
81+
die "Could not determine host architecture! ($HOST_ARCH)"
82+
;;
83+
esac
84+
fi
85+
7086
TAROUT="$OUTPUT_ROOT/tar"
7187
TARBALL="$TAROUT/gcm-$RUNTIME.$VERSION.tar.gz"
7288
SYMTARBALL="$TAROUT/gcm-$RUNTIME.$VERSION-symbols.tar.gz"
@@ -108,26 +124,6 @@ INSTALL_TO="$DEBROOT/usr/local/share/gcm-core/"
108124
LINK_TO="$DEBROOT/usr/local/bin/"
109125
mkdir -p "$DEBROOT/DEBIAN" "$INSTALL_TO" "$LINK_TO" || exit 1
110126

111-
# Fall back to host architecture if no explicit runtime is given.
112-
if test -z "$RUNTIME"; then
113-
HOST_ARCH="`dpkg-architecture -q DEB_HOST_ARCH`"
114-
115-
case $HOST_ARCH in
116-
amd64)
117-
RUNTIME="linux-x64"
118-
;;
119-
arm64)
120-
RUNTIME="linux-arm64"
121-
;;
122-
armhf)
123-
RUNTIME="linux-arm"
124-
;;
125-
*)
126-
die "Could not determine host architecture!"
127-
;;
128-
esac
129-
fi
130-
131127
# Determine architecture for debian control file from the runtime architecture
132128
case $RUNTIME in
133129
linux-x64)

0 commit comments

Comments
 (0)