From 692333aa2d7ffd02f8763862295f78b4c61e6fed Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 30 Jun 2023 14:21:33 +0200 Subject: [PATCH] Update generate-stackbrew-library.sh from upstream build pack 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 --- generate-stackbrew-library.sh | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index f3a0d992..55936a66 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -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 + } } ') ) @@ -29,9 +30,9 @@ 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 } ' '{}' + \ @@ -39,6 +40,7 @@ getArches() { | xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"' ) )" } +getArches 'phpmyadmin' if ! command -v bashbrew --version &> /dev/null then @@ -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 (@ibennetch), @@ -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%.*.*}" )