forked from docker-library/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·118 lines (104 loc) · 3.61 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e
shopt -s nullglob
declare -A gpgKeys=(
# gpg: key 18ADD4FF: public key "Benjamin Peterson <[email protected]>" imported
[2.7]='C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF'
# https://www.python.org/dev/peps/pep-0373/#release-manager-and-crew
# gpg: key 36580288: public key "Georg Brandl (Python release signing key) <[email protected]>" imported
[3.3]='26DEA9D4613391EF3E25C9FF0A5B101836580288'
# https://www.python.org/dev/peps/pep-0398/#release-manager-and-crew
# gpg: key F73C700D: public key "Larry Hastings <[email protected]>" imported
[3.4]='97FC712E4C024BBEA48A61ED3A5CA953F73C700D'
# https://www.python.org/dev/peps/pep-0429/#release-manager-and-crew
# gpg: key F73C700D: public key "Larry Hastings <[email protected]>" imported
[3.5]='97FC712E4C024BBEA48A61ED3A5CA953F73C700D'
# https://www.python.org/dev/peps/pep-0478/#release-manager-and-crew
# gpg: key AA65421D: public key "Ned Deily (Python release signing key) <[email protected]>" imported
[3.6]='0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D'
# https://www.python.org/dev/peps/pep-0494/#release-manager-and-crew
)
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
pipVersion="$(curl -fsSL 'https://pypi.python.org/pypi/pip/json' | awk -F '"' '$2 == "version" { print $4 }')"
generated_warning() {
cat <<-EOH
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
EOH
}
travisEnv=
for version in "${versions[@]}"; do
rcGrepV='-v'
rcVersion="${version%-rc}"
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
possibles=( $(curl -fsSL 'https://www.python.org/ftp/python/' | grep '<a href="'"$rcVersion." | sed -r 's!.*<a href="([^"/]+)/?".*!\1!' | sort -rV) )
fullVersion=
for possible in "${possibles[@]}"; do
possibleVersions=( $(curl -fsSL "https://www.python.org/ftp/python/$possible/" | grep '<a href="Python-'"$rcVersion"'.*\.tar\.xz"' | sed -r 's!.*<a href="Python-([^"/]+)\.tar\.xz".*!\1!' | grep $rcGrepV -E -- '[a-zA-Z]+' | sort -rV) )
if [ "${#possibleVersions[@]}" -gt 0 ]; then
fullVersion="${possibleVersions[0]}"
break
fi
done
if [ -z "$fullVersion" ]; then
{
echo
echo
echo " error: cannot find $version (alpha/beta/rc?)"
echo
echo
} >&2
exit 1
else
if [[ "$version" != 2.* ]]; then
for variant in \
debian \
alpine \
slim \
onbuild \
windows/windowsservercore \
; do
if [ "$variant" = 'debian' ]; then
dir="$version"
else
dir="$version/$variant"
variant="$(basename "$variant")"
fi
[ -d "$dir" ] || continue
template="Dockerfile-$variant.template"
{ generated_warning; cat "$template"; } > "$dir/Dockerfile"
done
if [ -d "$version/wheezy" ]; then
cp "$version/Dockerfile" "$version/wheezy/Dockerfile"
sed -ri 's/:jessie/:wheezy/g' "$version/wheezy/Dockerfile"
fi
fi
(
set -x
sed -ri \
-e 's/^(ENV GPG_KEY) .*/\1 '"${gpgKeys[$rcVersion]}"'/' \
-e 's/^(ENV PYTHON_VERSION) .*/\1 '"$fullVersion"'/' \
-e 's/^(ENV PYTHON_RELEASE) .*/\1 '"${fullVersion%%[a-z]*}"'/' \
-e 's/^(ENV PYTHON_PIP_VERSION) .*/\1 '"$pipVersion"'/' \
-e 's/^(FROM python):.*/\1:'"$version"'/' \
"$version"/{,*/,*/*/}Dockerfile
)
fi
for variant in wheezy alpine slim; do
[ -d "$version/$variant" ] || continue
travisEnv='\n - VERSION='"$version VARIANT=$variant$travisEnv"
done
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