Skip to content

Commit 8f6d1fe

Browse files
committed
ci: Replace $1 with a binding in run-docker.sh
(backport <rust-lang#4124>) (cherry picked from commit 3faaf4d)
1 parent ec54c2e commit 8f6d1fe

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

ci/run-docker.sh

+11-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
set -eux
1010

11+
target="$1"
12+
1113
# Default to assuming the CARGO_HOME is one directory up (to account for a `bin`
1214
# subdir) from where the `cargo` binary in `$PATH` lives.
1315
default_cargo_home="$(dirname "$(dirname "$(command -v cargo)")")"
@@ -18,17 +20,17 @@ export CARGO_HOME="${CARGO_HOME:-$default_cargo_home}"
1820
echo "${HOME}"
1921
pwd
2022

21-
# Avoid "no space left on device" failure.
22-
if [ "${1}" = "aarch64-linux-android" ] ; then
23+
# Avoid "no space left on device" failure if running in CI
24+
if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ] ; then
2325
docker system prune -af
2426
docker system df
2527
fi
2628

2729
run() {
28-
echo "Building docker container for target ${1}"
30+
echo "Building docker container for target $target"
2931

3032
# use -f so we can use ci/ as build context
31-
docker build -t "libc-${1}" -f "ci/docker/${1}/Dockerfile" ci/
33+
docker build -t "libc-$target" -f "ci/docker/$target/Dockerfile" ci/
3234
mkdir -p target
3335
if [ -w /dev/kvm ]; then
3436
kvm="--volume /dev/kvm:/dev/kvm"
@@ -50,8 +52,8 @@ run() {
5052
$kvm \
5153
--init \
5254
--workdir /checkout \
53-
"libc-${1}" \
54-
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh ${1}"
55+
"libc-$target" \
56+
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh $target"
5557
}
5658

5759
build_switch() {
@@ -88,13 +90,13 @@ build_switch() {
8890
&& cargo build -Z build-std=core,alloc --target ci/switch.json"
8991
}
9092

91-
if [ -z "${1}" ]; then
93+
if [ -z "$target" ]; then
9294
for d in ci/docker/*; do
9395
run "${d}"
9496
done
9597
else
96-
if [ "${1}" != "switch" ]; then
97-
run "${1}"
98+
if [ "$target" != "switch" ]; then
99+
run "$target"
98100
else
99101
build_switch
100102
fi

0 commit comments

Comments
 (0)