2014-09-09 07:44:22 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
versions=( "$@" )
|
|
|
|
if [ ${#versions[@]} -eq 0 ]; then
|
|
|
|
versions=( */ )
|
|
|
|
fi
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
|
2015-12-24 08:12:06 +08:00
|
|
|
pipVersion="$(curl -fsSL 'https://pypi.python.org/pypi/pip/json' | awk -F '"' '$2 == "version" { print $4 }')"
|
2015-05-20 00:35:37 +08:00
|
|
|
|
2016-01-15 06:34:45 +08:00
|
|
|
travisEnv=
|
2014-09-09 07:44:22 +08:00
|
|
|
for version in "${versions[@]}"; do
|
2014-10-04 04:52:08 +08:00
|
|
|
# <span class="release-number"><a href="/downloads/release/python-278/">Python 2.7.8</a></span>
|
|
|
|
# <span class="release-number"><a href="/downloads/release/python-341/">Python 3.4.1</a></span>
|
2015-12-24 08:12:06 +08:00
|
|
|
fullVersion="$(curl -fsSL 'https://www.python.org/downloads/' | awk -F 'Python |</a>' '/<span class="release-number"><a[^>]+>Python '"$version"'./ { print $2 }' | grep -v 'rc' | sort -V | tail -1)"
|
2016-07-02 02:55:17 +08:00
|
|
|
# TODO figure out a better way to handle RCs than just filtering them out
|
2015-07-18 01:17:57 +08:00
|
|
|
if [ -z "$fullVersion" ]; then
|
|
|
|
echo >&2 "warning: cannot find $version"
|
|
|
|
continue
|
|
|
|
fi
|
2014-09-09 07:44:22 +08:00
|
|
|
(
|
|
|
|
set -x
|
2015-05-20 00:35:37 +08:00
|
|
|
sed -ri '
|
|
|
|
s/^(ENV PYTHON_VERSION) .*/\1 '"$fullVersion"'/;
|
|
|
|
s/^(ENV PYTHON_PIP_VERSION) .*/\1 '"$pipVersion"'/;
|
2015-09-15 00:26:10 +08:00
|
|
|
' "$version"/{,*/}Dockerfile
|
2015-05-27 00:30:03 +08:00
|
|
|
sed -ri 's/^(FROM python):.*/\1:'"$version"'/' "$version/onbuild/Dockerfile"
|
2014-09-09 07:44:22 +08:00
|
|
|
)
|
2016-01-15 06:34:45 +08:00
|
|
|
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"
|
2014-09-09 07:44:22 +08:00
|
|
|
done
|
2016-01-15 06:34:45 +08:00
|
|
|
|
|
|
|
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
|
|
|
echo "$travis" > .travis.yml
|