Skip to content

Commit

Permalink
Merge pull request #393 from infosiftr/mawk
Browse files Browse the repository at this point in the history
Switch "generate-stackbrew-library.sh" from "switch" (gawk-ism) to if-else chain so it works in mawk
  • Loading branch information
yosifkit authored Feb 7, 2020
2 parents b78f8be + 24ff831 commit 56d87fd
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,17 @@ for javaVersion in "${versions[@]}"; do
variantAliases=()
fromTag="$(git show "$commit":"$dir/Dockerfile" | awk -v variant="$variant" '
$1 == "FROM" {
switch ($2) {
case /^mcr.microsoft.com\//:
$2 = ""
break
case /^(alpine|oraclelinux):/:
gsub(/:/, "", $2) # "alpine3.7", "alpine3.6", etc
gsub(/-slim$/, "", $2) # "oraclelinux:7-slim"
break
default:
gsub(/^[^:]+:/, "", $2) # peel off "debian:", "buildpack-deps:", etc
gsub(/-[^-]+$/, "", $2) # peel off "-scm", "-curl", etc
break
# "switch" is a gawk-ism
if ($2 ~ /^mcr.microsoft.com\//) {
$2 = ""
}
else if ($2 ~ /^(alpine|oraclelinux):/) {
gsub(/:/, "", $2) # "alpine3.7", "alpine3.6", etc
gsub(/-slim$/, "", $2) # "oraclelinux:7-slim"
}
else {
gsub(/^[^:]+:/, "", $2) # peel off "debian:", "buildpack-deps:", etc
gsub(/-[^-]+$/, "", $2) # peel off "-scm", "-curl", etc
}
fromTag = $2
}
Expand Down

0 comments on commit 56d87fd

Please sign in to comment.