2018-05-24 21:20:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
|
|
|
|
declare -A release_channel=(
|
2021-01-05 20:01:54 +01:00
|
|
|
[stable]=$( cat latest.txt )
|
2018-05-24 21:20:25 +02:00
|
|
|
)
|
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
self="$(basename "${BASH_SOURCE[0]}")"
|
|
|
|
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
2018-05-24 21:20:25 +02:00
|
|
|
|
|
|
|
# Get the most recent commit which modified any of "$@".
|
|
|
|
fileCommit() {
|
2020-06-15 00:30:25 +02:00
|
|
|
commit="$(git log -1 --format='format:%H' HEAD -- "$@")"
|
|
|
|
if [ -z "$commit" ]; then
|
|
|
|
# return some valid sha1 hash to make bashbrew happy
|
|
|
|
echo '0000000000000000000000000000000000000000'
|
|
|
|
else
|
|
|
|
echo "$commit"
|
|
|
|
fi
|
2018-05-24 21:20:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get the most recent commit which modified "$1/Dockerfile" or any file that
|
|
|
|
# the Dockerfile copies into the rootfs (with COPY).
|
|
|
|
dockerfileCommit() {
|
2020-06-15 00:30:25 +02:00
|
|
|
local dir="$1"; shift
|
|
|
|
(
|
|
|
|
cd "$dir";
|
|
|
|
fileCommit Dockerfile \
|
2020-08-21 22:52:26 +02:00
|
|
|
$(awk '
|
2020-06-15 00:30:25 +02:00
|
|
|
toupper($1) == "COPY" {
|
|
|
|
for (i = 2; i < NF; i++)
|
|
|
|
print $i;
|
|
|
|
}
|
2020-08-21 22:52:26 +02:00
|
|
|
' Dockerfile)
|
2020-06-15 00:30:25 +02:00
|
|
|
)
|
2018-05-24 21:20:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getArches() {
|
2020-06-15 00:30:25 +02:00
|
|
|
local repo="$1"; shift
|
|
|
|
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
|
|
|
|
|
|
|
|
eval "declare -g -A parentRepoToArches=( $(
|
|
|
|
find -maxdepth 3 -name 'Dockerfile' -exec awk '
|
|
|
|
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
|
|
|
|
print "'"$officialImagesUrl"'" $2
|
|
|
|
}
|
|
|
|
' '{}' + \
|
|
|
|
| sort -u \
|
|
|
|
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
|
|
|
|
) )"
|
2018-05-24 21:20:25 +02:00
|
|
|
}
|
|
|
|
getArches 'friendica'
|
|
|
|
|
|
|
|
# Header.
|
|
|
|
cat <<-EOH
|
|
|
|
# This file is generated via https://github.com/friendica/docker/blob/$(fileCommit "$self")/$self
|
2018-12-13 20:17:18 +01:00
|
|
|
|
2018-05-24 21:20:25 +02:00
|
|
|
Maintainers: Friendica <info@friendi.ca> (@friendica), Philipp Holzer <admin@philipp.info> (@nupplaphil)
|
|
|
|
GitRepo: https://github.com/friendica/docker.git
|
|
|
|
EOH
|
|
|
|
|
|
|
|
# prints "$2$1$3$1...$N"
|
|
|
|
join() {
|
2020-06-15 00:30:25 +02:00
|
|
|
local sep="$1"; shift
|
|
|
|
local out; printf -v out "${sep//%/%%}%s" "$@"
|
|
|
|
echo "${out#$sep}"
|
2018-05-24 21:20:25 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 21:31:44 +02:00
|
|
|
latest=$( cat latest.txt )
|
|
|
|
develop=$( cat develop.txt )
|
|
|
|
|
2018-05-24 21:20:25 +02:00
|
|
|
# Generate each of the tags.
|
|
|
|
versions=( */ )
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
for version in "${versions[@]}"; do
|
2020-06-15 00:30:25 +02:00
|
|
|
variants=( $version/*/ )
|
|
|
|
variants=( $(for variant in "${variants[@]%/}"; do
|
|
|
|
basename "$variant"
|
|
|
|
done) )
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
commit="$(dockerfileCommit "$version/$variant")"
|
|
|
|
|
|
|
|
versionAliases=( )
|
|
|
|
versionPostfix=""
|
|
|
|
|
|
|
|
versionAliases+=( "$version$versionPostfix" )
|
2020-09-04 21:31:44 +02:00
|
|
|
if [ "$version" = "$latest" ]; then
|
|
|
|
versionAliases+=( "latest" )
|
|
|
|
fi
|
|
|
|
|
2020-06-15 00:30:25 +02:00
|
|
|
if [[ "$version" == *-rc ]]; then
|
|
|
|
versionAliases+=( "rc" )
|
|
|
|
fi
|
2020-09-04 21:31:44 +02:00
|
|
|
if [[ "$version" == "$develop" ]]; then
|
2020-06-15 00:30:25 +02:00
|
|
|
versionAliases+=( "dev" )
|
|
|
|
fi
|
|
|
|
|
|
|
|
for channel in "${!release_channel[@]}"; do
|
|
|
|
if [ "$version" = "${release_channel[$channel]}" ]; then
|
|
|
|
versionAliases+=( "$channel" )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
variantAliases=( "${versionAliases[@]/%/-$variant}" )
|
|
|
|
variantAliases=( "${variantAliases[@]//latest-}" )
|
|
|
|
|
|
|
|
if [ "$variant" = "apache" ]; then
|
|
|
|
variantAliases+=( "${versionAliases[@]}" )
|
|
|
|
fi
|
|
|
|
|
|
|
|
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")"
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
variantArches="${parentRepoToArches[$variantParent]}"
|
|
|
|
|
|
|
|
cat << EOE
|
|
|
|
|
|
|
|
Tags: $(join ', ' "${variantAliases[@]}")
|
2020-08-21 22:52:26 +02:00
|
|
|
Architectures: $(join ', ' $variantArches)
|
2020-06-15 00:30:25 +02:00
|
|
|
GitCommit: $commit
|
|
|
|
Directory: $version/$variant
|
|
|
|
EOE
|
|
|
|
done
|
|
|
|
done
|