forked from redis/docker-library-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·39 lines (32 loc) · 1.21 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
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
packagesUrl='https://raw.githubusercontent.com/antirez/redis-hashes/master/README'
packages="$(echo "$packagesUrl" | sed -r 's/[^a-zA-Z.-]+/-/g')"
curl -sSL "$packagesUrl" > "$packages"
travisEnv=
for version in "${versions[@]}"; do
line="$(awk '/^hash redis-'"$version"\.'/' "$packages" | sort -rV | head -1)"
fullVersion="$(echo "$line" | cut -d' ' -f2 | sed -r 's/^redis-|\.tar\..*$//g')"
downloadUrl="$(echo "$line" | cut -d' ' -f5 | sed 's/[\/&]/\\&/g')"
shaHash="$(echo "$line" | cut -d' ' -f4)"
[ "$(echo "$line" | cut -d' ' -f3)" = 'sha1' ]
(
set -x
sed -ri '
s/^(ENV REDIS_VERSION) .*/\1 '"$fullVersion"'/;
s/^(ENV REDIS_DOWNLOAD_URL) .*/\1 '"$downloadUrl"'/;
s/^(ENV REDIS_DOWNLOAD_SHA1) .*/\1 '"$shaHash"'/
' "$version"{/,/32bit/}"Dockerfile"
)
travisEnv='\n - VERSION='"$version VARIANT=32bit$travisEnv"
travisEnv='\n - VERSION='"$version VARIANT=$travisEnv"
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml
rm "$packages"