-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapply-templates.sh
More file actions
executable file
·69 lines (53 loc) · 1.92 KB
/
Copy pathapply-templates.sh
File metadata and controls
executable file
·69 lines (53 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -Eeuo pipefail
jqt='.jq-template.awk'
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
jqt="$BASHBREW_SCRIPTS/jq-template.awk"
elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
# https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk'
fi
generated_warning() {
cat <<-EOH
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
EOH
}
wpCliVersion="$(jq -r '.wpCliVersion' versions.json)"
export wpCliVersion
versions="$(jq -r 'to_entries | map(select(.value | type == "object")) | map(.key) | map(@sh) | join(" ")' versions.json)"
eval "versions=( $versions )"
for version in "${versions[@]}"; do
export version
phpVersions="$(jq -r '.[env.version].phpVersions | map(@sh) | join(" ")' versions.json)"
eval "phpVersions=( $phpVersions )"
variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)"
eval "variants=( $variants )"
for phpVersion in "${phpVersions[@]}"; do
export phpVersion
for variant in "${variants[@]}"; do
export variant
dir="$version/php$phpVersion/$variant"
mkdir -p "$dir"
echo "processing $dir ..."
template="Dockerfile.template"
if [ -f "variants/$variant/Dockerfile.template" ]; then
template="variants/$variant/Dockerfile.template"
fi
{
generated_warning
gawk -f "$jqt" "$template"
} > "$dir/Dockerfile"
cp -a bin "$dir/"
cp -a templates "$dir/"
cp -a init "$dir/"
if [ -d "variants/$variant" ]; then
cp -a "variants/$variant/." "$dir/"
rm -f "$dir/Dockerfile.template"
fi
done
done
done