forked from rust-lang/docker-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·56 lines (48 loc) · 2.22 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
source '.metadata-lib'
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
# see http://stackoverflow.com/a/2705678/433558
sed_escape_rhs() {
echo "$@" | sed -e 's/[\/&]/\\&/g' | sed -e ':a;N;$!ba;s/\n/\\n/g'
}
travisEnv=
for version in "${versions[@]}"; do
rustupVersion=$(rustupVersion "$version")
linuxArchCase='dpkgArch="$(dpkg --print-architecture)"; '$'\\\n'
linuxArchCase+=$' ''case "${dpkgArch##*-}" in '$'\\\n'
for dpkgArch in $(dpkgArches "$version"); do
rustArch="$(dpkgToRustArch "$version" "$dpkgArch")"
sha256="$(curl -fsSL "https://static.rust-lang.org/rustup/archive/${rustupVersion}/${rustArch}/rustup-init.sha256" | awk '{ print $1 }')"
linuxArchCase+=$' '"$dpkgArch) rustArch='$rustArch'; rustupSha256='$sha256' ;; "$'\\\n'
done
linuxArchCase+=$' ''*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; '$'\\\n'
linuxArchCase+=$' ''esac'
for variant in jessie stretch; do
if [ -d "$version/$variant" ]; then
sed -r \
-e 's!%%RUST-VERSION%%!'"$version"'!g' \
-e 's!%%RUSTUP-VERSION%%!'"$rustupVersion"'!g' \
-e 's!%%DEBIAN-SUITE%%!'"$variant"'!g' \
-e 's!%%ARCH-CASE%%!'"$(sed_escape_rhs "$linuxArchCase")"'!g' \
Dockerfile-debian.template > "$version/$variant/Dockerfile"
travisEnv='\n - VERSION='"$version VARIANT=$variant$travisEnv"
fi
if [ -d "$version/$variant/slim" ]; then
sed -r \
-e 's!%%RUST-VERSION%%!'"$version"'!g' \
-e 's!%%RUSTUP-VERSION%%!'"$rustupVersion"'!g' \
-e 's!%%DEBIAN-SUITE%%!'"$variant"'!g' \
-e 's!%%ARCH-CASE%%!'"$(sed_escape_rhs "$linuxArchCase")"'!g' \
Dockerfile-slim.template > "$version/$variant/slim/Dockerfile"
travisEnv='\n - VERSION='"$version VARIANT=$variant/slim$travisEnv"
fi
done
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml