2016-09-02 13:11:38 +00:00
|
|
|
#!/bin/bash
|
2017-04-26 20:14:40 +00:00
|
|
|
set -Eeuo pipefail
|
2016-09-02 13:11:38 +00:00
|
|
|
|
2018-03-21 13:01:49 +00:00
|
|
|
declare -A release_channel=(
|
|
|
|
[production]='12.0.6'
|
|
|
|
[stable]='13.0.1'
|
|
|
|
)
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
self="$(basename "$BASH_SOURCE")"
|
2016-09-02 13:11:38 +00:00
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
# Get the most recent commit which modified any of "$@".
|
|
|
|
fileCommit() {
|
|
|
|
git log -1 --format='format:%H' HEAD -- "$@"
|
|
|
|
}
|
2016-09-02 13:11:38 +00:00
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
# Get the most recent commit which modified "$1/Dockerfile" or any file that
|
|
|
|
# the Dockerfile copies into the rootfs (with COPY).
|
|
|
|
dockerfileCommit() {
|
|
|
|
local dir="$1"; shift
|
|
|
|
(
|
|
|
|
cd "$dir";
|
|
|
|
fileCommit Dockerfile \
|
2018-03-13 09:58:19 +00:00
|
|
|
$(awk '
|
2017-01-13 09:31:57 +00:00
|
|
|
toupper($1) == "COPY" {
|
|
|
|
for (i = 2; i < NF; i++)
|
|
|
|
print $i;
|
|
|
|
}
|
2018-03-13 09:58:19 +00:00
|
|
|
' Dockerfile)
|
2017-01-13 09:31:57 +00:00
|
|
|
)
|
|
|
|
}
|
2016-09-02 13:11:38 +00:00
|
|
|
|
2018-02-14 00:19:07 +00:00
|
|
|
getArches() {
|
|
|
|
local repo="$1"; shift
|
|
|
|
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
|
|
|
|
|
|
|
|
eval "declare -g -A parentRepoToArches=( $(
|
2018-02-14 01:44:38 +00:00
|
|
|
find -maxdepth 3 -name 'Dockerfile' -exec awk '
|
2018-02-14 00:19:07 +00:00
|
|
|
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
|
|
|
|
print "'"$officialImagesUrl"'" $2
|
|
|
|
}
|
|
|
|
' '{}' + \
|
|
|
|
| sort -u \
|
|
|
|
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
|
|
|
|
) )"
|
|
|
|
}
|
|
|
|
getArches 'nextcloud'
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
# Header.
|
|
|
|
cat <<-EOH
|
|
|
|
# This file is generated via https://github.com/nextcloud/docker/blob/$(fileCommit "$self")/$self
|
|
|
|
|
2017-01-21 15:31:10 +00:00
|
|
|
Maintainers: Nextcloud <docker@nextcloud.com> (@nextcloud)
|
2017-01-13 09:31:57 +00:00
|
|
|
GitRepo: https://github.com/nextcloud/docker.git
|
|
|
|
EOH
|
|
|
|
|
|
|
|
# prints "$2$1$3$1...$N"
|
|
|
|
join() {
|
|
|
|
local sep="$1"; shift
|
|
|
|
local out; printf -v out "${sep//%/%%}%s" "$@"
|
|
|
|
echo "${out#$sep}"
|
|
|
|
}
|
|
|
|
|
2017-06-06 13:24:08 +00:00
|
|
|
latest=$( curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \
|
2018-03-13 09:58:19 +00:00
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
sort -uV | \
|
|
|
|
tail -1 )
|
|
|
|
|
|
|
|
latest_rc=$( curl -fsSL 'https://download.nextcloud.com/server/prereleases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}RC[[:digit:]]+' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}RC[[:digit:]]+' | \
|
2017-06-06 13:24:08 +00:00
|
|
|
sort -uV | \
|
|
|
|
tail -1 )
|
2017-01-13 09:31:57 +00:00
|
|
|
|
|
|
|
# Generate each of the tags.
|
|
|
|
versions=( */ )
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
variants=( $version/*/ )
|
|
|
|
variants=( $(for variant in "${variants[@]%/}"; do
|
|
|
|
echo "$(basename "$variant")"
|
|
|
|
done) )
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
commit="$(dockerfileCommit "$version/$variant")"
|
2018-03-13 09:58:19 +00:00
|
|
|
fullversion_with_extension="$( awk '$1 == "ENV" && $2 == "NEXTCLOUD_VERSION" { print $3; exit }' "$version/$variant/Dockerfile" )"
|
|
|
|
fullversion="$( echo "$fullversion_with_extension" | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}')"
|
|
|
|
|
|
|
|
versionAliases=( )
|
|
|
|
versionPostfix=""
|
|
|
|
if [ "$fullversion_with_extension" != "$fullversion" ]; then
|
|
|
|
versionAliases=( "$fullversion_with_extension" )
|
|
|
|
versionPostfix="-rc"
|
|
|
|
fi
|
2017-01-13 09:31:57 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
versionAliases+=( "$fullversion$versionPostfix" "${fullversion%.*}$versionPostfix" "${fullversion%.*.*}$versionPostfix" )
|
|
|
|
if [ "$fullversion_with_extension" = "$latest" ]; then
|
2017-01-13 09:31:57 +00:00
|
|
|
versionAliases+=( "latest" )
|
|
|
|
fi
|
2018-03-13 09:58:19 +00:00
|
|
|
if [ "$fullversion_with_extension" = "$latest_rc" ]; then
|
|
|
|
versionAliases+=( "rc" )
|
|
|
|
fi
|
2017-01-13 09:31:57 +00:00
|
|
|
|
2018-03-21 13:01:49 +00:00
|
|
|
for channel in "${!release_channel[@]}"; do
|
|
|
|
if [ "$fullversion_with_extension" = "${release_channel[$channel]}" ]; then
|
|
|
|
versionAliases+=( "$channel" )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
variantAliases=( "${versionAliases[@]/%/-$variant}" )
|
|
|
|
variantAliases=( "${variantAliases[@]//latest-}" )
|
|
|
|
|
|
|
|
if [ "$variant" = "apache" ]; then
|
|
|
|
variantAliases+=( "${versionAliases[@]}" )
|
|
|
|
fi
|
|
|
|
|
2018-02-14 00:19:07 +00:00
|
|
|
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")"
|
|
|
|
variantArches="${parentRepoToArches[$variantParent]}"
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
cat <<-EOE
|
|
|
|
|
|
|
|
Tags: $(join ', ' "${variantAliases[@]}")
|
2018-02-14 00:19:07 +00:00
|
|
|
Architectures: $(join ', ' $variantArches)
|
2017-01-13 09:31:57 +00:00
|
|
|
GitCommit: $commit
|
|
|
|
Directory: $version/$variant
|
|
|
|
EOE
|
|
|
|
done
|
|
|
|
done
|