This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
update.sh
executable file
·64 lines (56 loc) · 1.66 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
57
58
59
60
61
62
63
64
#!/bin/bash
set -eo pipefail
defaultSuite='stretch'
declare -A suites=(
#[5.5]='jessie'
)
declare -A dpkgArchToBashbrew=(
[amd64]='amd64'
[armel]='arm32v5'
[armhf]='arm32v7'
[arm64]='arm64v8'
[i386]='i386'
[ppc64el]='ppc64le'
[s390x]='s390x'
)
getRemoteVersion() {
local version="$1"; shift # 10.3
local suite="$1"; shift # bionic
local dpkgArch="$1" shift # arm64
echo "$(
curl -fsSL "https://repo.percona.com/apt/dists/$suite/main/binary-$dpkgArch/Packages" 2>/dev/null \
| tac|tac \
| awk -v version="$version" -F ': ' '$1 == "Package" { pkg = $2; next } $1 == "Version" && pkg == "percona-server-server-"version { print $2; exit }'
)"
}
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
# fullVersion="$(grep -m1 -A10 "^Package: percona-server-server-$version\$" "$packages" | grep -m1 '^Version: ' | cut -d' ' -f2)"
for version in "${versions[@]}"; do
suite="${suites[$version]:-$defaultSuite}"
fullVersion="$(getRemoteVersion "$version" "$suite" 'amd64')"
if [ -z "$fullVersion" ]; then
echo >&2 "warning: cannot find $version in $suite"
continue
fi
arches=
sortedArches="$(echo "${!dpkgArchToBashbrew[@]}" | xargs -n1 | sort | xargs)"
for arch in $sortedArches; do
if ver="$(getRemoteVersion "$version" "$suite" "$arch")" && [ -n "$ver" ]; then
arches="$arches ${dpkgArchToBashbrew[$arch]}"
fi
done
(
set -x
sed \
-e 's/%%PERCONA_MAJOR%%/'"$version"'/g' \
-e 's/%%PERCONA_VERSION%%/'"$fullVersion"'/g' \
-e 's!%%SUITE%%!'"$suite"'!g' \
-e 's!%%ARCHES%%!'"$arches"'!g' \
Dockerfile.template > "$version/Dockerfile"
)
done