2014-08-21 01:50:02 +02:00
|
|
|
#!/bin/bash
|
2016-06-09 20:56:08 +02:00
|
|
|
set -eu
|
2014-08-21 01:50:02 +02:00
|
|
|
|
2016-06-09 19:34:11 +02:00
|
|
|
declare -A aliases=(
|
2015-12-02 15:43:41 +01:00
|
|
|
[5.6]='5'
|
2016-12-06 19:23:02 +01:00
|
|
|
[7.1]='7 latest'
|
|
|
|
[7.2-rc]='rc'
|
2014-08-21 01:50:02 +02:00
|
|
|
)
|
|
|
|
|
2016-06-09 20:56:08 +02:00
|
|
|
self="$(basename "$BASH_SOURCE")"
|
2014-08-21 01:50:02 +02:00
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
versions=( */ )
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
|
2016-06-09 20:56:08 +02:00
|
|
|
# sort version numbers with highest first
|
|
|
|
IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -rV) ); unset IFS
|
|
|
|
|
|
|
|
# get the most recent commit which modified any of "$@"
|
|
|
|
fileCommit() {
|
|
|
|
git log -1 --format='format:%H' HEAD -- "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# get the most recent commit which modified "$1/Dockerfile" or any file COPY'd from "$1/Dockerfile"
|
|
|
|
dirCommit() {
|
|
|
|
local dir="$1"; shift
|
|
|
|
(
|
|
|
|
cd "$dir"
|
|
|
|
fileCommit \
|
|
|
|
Dockerfile \
|
|
|
|
$(git show HEAD:./Dockerfile | awk '
|
|
|
|
toupper($1) == "COPY" {
|
|
|
|
for (i = 2; i < NF; i++) {
|
|
|
|
print $i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
')
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
cat <<-EOH
|
|
|
|
# this file is generated via https://github.com/docker-library/php/blob/$(fileCommit "$self")/$self
|
|
|
|
|
|
|
|
Maintainers: Tianon Gravi <admwiggin@gmail.com> (@tianon),
|
|
|
|
Joseph Ferguson <yosifkit@gmail.com> (@yosifkit)
|
|
|
|
GitRepo: https://github.com/docker-library/php.git
|
|
|
|
EOH
|
|
|
|
|
|
|
|
# prints "$2$1$3$1...$N"
|
|
|
|
join() {
|
|
|
|
local sep="$1"; shift
|
|
|
|
local out; printf -v out "${sep//%/%%}%s" "$@"
|
|
|
|
echo "${out#$sep}"
|
|
|
|
}
|
2014-08-21 01:50:02 +02:00
|
|
|
|
|
|
|
for version in "${versions[@]}"; do
|
2016-06-09 20:56:08 +02:00
|
|
|
commit="$(dirCommit "$version")"
|
|
|
|
|
|
|
|
fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "PHP_VERSION" { print $3; exit }')"
|
|
|
|
|
|
|
|
versionAliases=(
|
|
|
|
$fullVersion
|
|
|
|
$version
|
|
|
|
${aliases[$version]:-}
|
|
|
|
)
|
|
|
|
|
|
|
|
variant='cli'
|
|
|
|
variantAliases=( "${versionAliases[@]/%/-$variant}" )
|
|
|
|
variantAliases=( "${variantAliases[@]//latest-/}" )
|
|
|
|
variantAliases+=( "${versionAliases[@]}" )
|
|
|
|
|
2014-08-21 01:50:02 +02:00
|
|
|
echo
|
2016-06-09 20:56:08 +02:00
|
|
|
cat <<-EOE
|
|
|
|
Tags: $(join ', ' "${variantAliases[@]}")
|
|
|
|
GitCommit: $commit
|
|
|
|
Directory: $version
|
|
|
|
EOE
|
|
|
|
|
2016-03-18 22:37:47 +01:00
|
|
|
for variant in \
|
|
|
|
alpine \
|
|
|
|
apache \
|
|
|
|
fpm fpm/alpine \
|
|
|
|
zts zts/alpine \
|
|
|
|
; do
|
2016-06-09 20:56:08 +02:00
|
|
|
[ -f "$version/$variant/Dockerfile" ] || continue
|
|
|
|
|
|
|
|
commit="$(dirCommit "$version/$variant")"
|
|
|
|
|
2016-03-18 22:37:47 +01:00
|
|
|
slash='/'
|
2016-06-09 20:56:08 +02:00
|
|
|
variantAliases=( "${versionAliases[@]/%/-${variant//$slash/-}}" )
|
|
|
|
variantAliases=( "${variantAliases[@]//latest-/}" )
|
|
|
|
|
2014-08-21 01:50:02 +02:00
|
|
|
echo
|
2016-06-09 20:56:08 +02:00
|
|
|
cat <<-EOE
|
|
|
|
Tags: $(join ', ' "${variantAliases[@]}")
|
|
|
|
GitCommit: $commit
|
|
|
|
Directory: $version/$variant
|
|
|
|
EOE
|
2014-08-21 01:50:02 +02:00
|
|
|
done
|
|
|
|
done
|