2014-08-21 01:08:35 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2016-08-12 01:18:33 +02:00
|
|
|
declare -A gpgKeys=(
|
2016-09-06 21:31:18 +02:00
|
|
|
# https://wiki.php.net/todo/php71
|
|
|
|
# davey
|
|
|
|
[7.1]='A917B1ECDA84AEC2B568FED6F50ABC807BD5DCD0'
|
|
|
|
|
2016-09-06 21:24:23 +02:00
|
|
|
# https://wiki.php.net/todo/php70
|
|
|
|
# ab
|
2015-06-30 01:34:47 +02:00
|
|
|
[7.0]='1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763'
|
2016-09-06 21:24:23 +02:00
|
|
|
|
|
|
|
# https://wiki.php.net/todo/php56
|
|
|
|
# jpauli & tyrael
|
2015-08-07 21:01:25 +02:00
|
|
|
[5.6]='0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3'
|
2014-08-21 01:08:35 +02:00
|
|
|
)
|
2016-08-23 00:47:04 +02:00
|
|
|
# see https://secure.php.net/downloads.php
|
2015-07-08 18:32:37 +02:00
|
|
|
|
2014-08-21 01:08:35 +02:00
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
versions=( "$@" )
|
|
|
|
if [ ${#versions[@]} -eq 0 ]; then
|
|
|
|
versions=( */ )
|
|
|
|
fi
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
|
2016-08-01 18:55:39 +02:00
|
|
|
generated_warning() {
|
|
|
|
cat <<-EOH
|
|
|
|
#
|
|
|
|
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
|
|
|
|
#
|
|
|
|
# PLEASE DO NOT EDIT IT DIRECTLY.
|
|
|
|
#
|
|
|
|
|
|
|
|
EOH
|
|
|
|
}
|
|
|
|
|
2015-12-09 01:46:18 +01:00
|
|
|
jsonSh="$(curl -fsSL 'https://raw.githubusercontent.com/dominictarr/JSON.sh/ed3f9dd285ebd4183934adb54ea5a2fda6b25a98/JSON.sh')"
|
|
|
|
|
2016-03-18 21:26:18 +01:00
|
|
|
travisEnv=
|
2014-08-21 01:08:35 +02:00
|
|
|
for version in "${versions[@]}"; do
|
2015-12-09 01:46:18 +01:00
|
|
|
packagesJson="$(curl -fsSL "https://secure.php.net/releases/index.php?json&max=100&version=${version%%.*}" | bash -- <(echo "$jsonSh") -l)"
|
|
|
|
fullVersion=
|
|
|
|
filename=
|
|
|
|
sha256=
|
|
|
|
for comp in xz bz2 gz; do
|
2015-12-09 01:10:11 +01:00
|
|
|
fullVersion="$(
|
2015-12-09 01:46:18 +01:00
|
|
|
echo "$packagesJson" \
|
|
|
|
| grep '^\["'"$version"'[."].*,"filename"\].*\.'"$comp"'"' \
|
|
|
|
| cut -d'"' -f2 \
|
|
|
|
| head -1
|
2015-12-09 01:10:11 +01:00
|
|
|
)"
|
2015-06-30 01:47:09 +02:00
|
|
|
if [ "$fullVersion" ]; then
|
2015-12-09 01:46:18 +01:00
|
|
|
sourceNumber="$(
|
|
|
|
echo "$packagesJson" \
|
|
|
|
| grep '^\["'"$fullVersion"'","source",.*,"filename"\].*\.'"$comp"'"' \
|
|
|
|
| cut -d, -f3
|
|
|
|
)"
|
|
|
|
filename="$(
|
|
|
|
echo "$packagesJson" \
|
|
|
|
| grep '^\["'"$fullVersion"'","source",'"$sourceNumber"',"filename"\]' \
|
|
|
|
| cut -d$'\t' -f2 | cut -d'"' -f2
|
|
|
|
)"
|
|
|
|
sha256="$(
|
|
|
|
echo "$packagesJson" \
|
|
|
|
| grep '^\["'"$fullVersion"'","source",'"$sourceNumber"',"sha256"\]' \
|
|
|
|
| cut -d$'\t' -f2 | cut -d'"' -f2
|
|
|
|
)"
|
2015-06-30 01:47:09 +02:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2015-12-09 01:10:11 +01:00
|
|
|
if [ -z "$fullVersion" ]; then
|
2016-10-15 00:11:54 +02:00
|
|
|
echo >&2
|
2015-12-09 01:10:11 +01:00
|
|
|
echo >&2 "warning: missing full version for $version; skipping"
|
2016-10-15 00:11:54 +02:00
|
|
|
echo >&2
|
2015-12-09 01:10:11 +01:00
|
|
|
continue
|
|
|
|
fi
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2014-08-21 01:08:35 +02:00
|
|
|
gpgKey="${gpgKeys[$version]}"
|
|
|
|
if [ -z "$gpgKey" ]; then
|
2014-08-25 22:38:21 +02:00
|
|
|
echo >&2 "ERROR: missing GPG key fingerprint for $version"
|
2016-08-23 00:47:04 +02:00
|
|
|
echo >&2 " try looking on https://secure.php.net/downloads.php#gpg-$version"
|
2014-08-21 01:08:35 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2016-03-18 18:51:01 +01:00
|
|
|
dockerfiles=()
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2016-08-01 18:55:39 +02:00
|
|
|
{ generated_warning; cat Dockerfile-debian.template; } > "$version/Dockerfile"
|
2016-03-18 18:51:01 +01:00
|
|
|
cp -v docker-php-ext-* "$version/"
|
2016-07-13 02:12:43 +02:00
|
|
|
cp -v docker-php-source "$version/"
|
2016-03-18 18:51:01 +01:00
|
|
|
dockerfiles+=( "$version/Dockerfile" )
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2016-03-18 18:51:01 +01:00
|
|
|
if [ -d "$version/alpine" ]; then
|
2016-08-01 18:55:39 +02:00
|
|
|
{ generated_warning; cat Dockerfile-alpine.template; } > "$version/alpine/Dockerfile"
|
2016-03-18 18:51:01 +01:00
|
|
|
cp -v docker-php-ext-* "$version/alpine/"
|
2016-07-13 02:12:43 +02:00
|
|
|
cp -v docker-php-source "$version/alpine/"
|
2016-03-18 18:51:01 +01:00
|
|
|
dockerfiles+=( "$version/alpine/Dockerfile" )
|
|
|
|
fi
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2016-03-18 21:26:18 +01:00
|
|
|
for target in \
|
|
|
|
apache \
|
|
|
|
fpm fpm/alpine \
|
|
|
|
zts zts/alpine \
|
|
|
|
; do
|
2016-03-18 18:51:01 +01:00
|
|
|
[ -d "$version/$target" ] || continue
|
|
|
|
base="$version/Dockerfile"
|
|
|
|
variant="${target%%/*}"
|
|
|
|
if [ "$target" != "$variant" ]; then
|
|
|
|
variantVariant="${target#$variant/}"
|
|
|
|
[ -d "$version/$variantVariant" ] || continue
|
|
|
|
base="$version/$variantVariant/Dockerfile"
|
|
|
|
fi
|
|
|
|
echo "Generating $version/$target/Dockerfile from $base + $variant-Dockerfile-block-*"
|
2014-11-07 01:34:27 +01:00
|
|
|
awk '
|
|
|
|
$1 == "##</autogenerated>##" { ia = 0 }
|
|
|
|
!ia { print }
|
|
|
|
$1 == "##<autogenerated>##" { ia = 1; ab++; ac = 0 }
|
|
|
|
ia { ac++ }
|
|
|
|
ia && ac == 1 { system("cat '$variant'-Dockerfile-block-" ab) }
|
2016-03-18 18:51:01 +01:00
|
|
|
' "$base" > "$version/$target/Dockerfile"
|
|
|
|
cp -v docker-php-ext-* "$version/$target/"
|
2016-07-13 02:12:43 +02:00
|
|
|
cp -v docker-php-source "$version/$target/"
|
2016-03-18 18:51:01 +01:00
|
|
|
dockerfiles+=( "$version/$target/Dockerfile" )
|
2014-11-07 01:34:27 +01:00
|
|
|
done
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2014-08-21 01:08:35 +02:00
|
|
|
(
|
|
|
|
set -x
|
|
|
|
sed -ri '
|
2016-03-18 18:51:01 +01:00
|
|
|
s!%%PHP_VERSION%%!'"$fullVersion"'!;
|
|
|
|
s!%%PHP_FILENAME%%!'"$filename"'!;
|
|
|
|
s!%%PHP_SHA256%%!'"$sha256"'!;
|
|
|
|
s!%%GPG_KEYS%%!'"$gpgKey"'!;
|
|
|
|
' "${dockerfiles[@]}"
|
2014-08-21 01:08:35 +02:00
|
|
|
)
|
2016-10-15 00:11:54 +02:00
|
|
|
|
2016-03-18 21:26:18 +01:00
|
|
|
newTravisEnv=
|
|
|
|
for dockerfile in "${dockerfiles[@]}"; do
|
|
|
|
dir="${dockerfile%Dockerfile}"
|
|
|
|
dir="${dir%/}"
|
|
|
|
variant="${dir#$version}"
|
|
|
|
variant="${variant#/}"
|
|
|
|
newTravisEnv+='\n - VERSION='"$version VARIANT=$variant"
|
|
|
|
done
|
|
|
|
travisEnv="$newTravisEnv$travisEnv"
|
2014-08-21 01:08:35 +02:00
|
|
|
done
|
2016-03-18 21:26:18 +01:00
|
|
|
|
|
|
|
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
|
|
|
echo "$travis" > .travis.yml
|