Skip to content

Commit

Permalink
Update generate-stackbrew-library.sh from upstream build pack
Browse files Browse the repository at this point in the history
To reduce further diffs when it will be updated to use versions.json if this happens

Ref: https://github.com/docker-library/buildpack-deps/blob/master/generate-stackbrew-library.sh
  • Loading branch information
williamdes committed Jun 30, 2023
1 parent 8674356 commit 692333a
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
set -Eeuo pipefail

self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

# Get the most recent commit which modified any of "$@".
# 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 that
# the Dockerfile copies into the rootfs (with COPY).
dockerfileCommit() {
# 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 \
cd "$dir"
fileCommit \
Dockerfile \
$(git show HEAD:./Dockerfile | awk '
toupper($1) == "COPY" {
for (i = 2; i < NF; i++)
print $i;
for (i = 2; i < NF; i++) {
print $i
}
}
')
)
Expand All @@ -29,16 +30,17 @@ getArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'

eval "declare -g -A parentRepoToArches=( $(
eval "declare -A -g parentRepoToArches=( $(
find -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|.*\/.*)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
}
getArches 'phpmyadmin'

if ! command -v bashbrew --version &> /dev/null
then
Expand All @@ -47,9 +49,6 @@ then
exit 1
fi

getArches 'phpmyadmin'

# Header.
cat <<-EOH
# This file is generated via https://github.com/phpmyadmin/docker/blob/$(fileCommit "$self")/$self
Maintainers: Isaac Bennetch <[email protected]> (@ibennetch),
Expand All @@ -67,7 +66,7 @@ join() {
latest="$(curl -fsSL 'https://www.phpmyadmin.net/home_page/version.json' | jq -r '.version')"

for variant in apache fpm fpm-alpine; do
commit="$(dockerfileCommit "$variant")"
commit="$(dirCommit "$variant")"
fullversion="$(git show "$commit":"$variant/Dockerfile" | awk '$1 == "ENV" && $2 == "VERSION" { print $3; exit }')"

versionAliases=( "$fullversion" "${fullversion%.*}" "${fullversion%.*.*}" )
Expand Down

0 comments on commit 692333a

Please sign in to comment.