-
Notifications
You must be signed in to change notification settings - Fork 84
/
apply-templates.sh
executable file
·104 lines (89 loc) · 3.32 KB
/
apply-templates.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
set -Eeuo pipefail
[ -f versions.json ] # run "versions.sh" first
jqt='.jq-template.awk'
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
jqt="$BASHBREW_SCRIPTS/jq-template.awk"
elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/5f0c26381fb7cc78b2d217d58007800bdcfbcfa1/scripts/jq-template.awk'
fi
# if no versions passed we load from versions.json
if [ "$#" -eq 0 ]; then
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
eval "set -- $versions"
fi
# the warning message to not update the docker files directly
generated_warning() {
cat <<-EOH
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
EOH
}
# set the Joomla maintainers of these docker images
joomlaMaintainers="$( jq -cr '. | map(.firstname + " " + .lastname + " <" + .email + "> (@" + .github + ")") | join(", ")' maintainers.json)"
export joomlaMaintainers
# loop over the version set above
for version; do
export version
# see if we version specific entrypoint file
if [[ -e "docker-entrypoint-${version}.sh" ]]; then
docker_entrypoint="docker-entrypoint-${version}.sh"
else
docker_entrypoint="docker-entrypoint.sh"
fi
# get this Joomla version details
joomlaVersionDetails="$(jq -r '.[env.version]' versions.json)"
# get this Joomla version
joomlaVersion="$(echo "${joomlaVersionDetails}" | jq -r '.version')"
export joomlaVersion
# get the PHP version
phpVersions="$(echo "${joomlaVersionDetails}" | jq -r '.phpVersions | map(@sh) | join(" ")')"
eval "phpVersions=( $phpVersions )"
# get the variants
variants="$(echo "${joomlaVersionDetails}" | jq -r '.variants | map(@sh) | join(" ")')"
eval "variants=( $variants )"
# get this version Joomla Sha512
joomlaSha512="$(echo "${joomlaVersionDetails}" | jq -r '.sha512')"
export joomlaSha512
# get this version Joomla Package URL
joomlaPackage="$(echo "${joomlaVersionDetails}" | jq -r '.package')"
export joomlaPackage
# get this version Joomla Package Type
joomlaPackageType="$(echo "${joomlaVersionDetails}" | jq -r '.packageType')"
export joomlaPackageType
for phpVersion in "${phpVersions[@]}"; do
export phpVersion
# get the pecl values (we may want to move this to versions.json)
peclValues="$(jq -r '.[env.version].phpVersions[env.phpVersion].pecl' versions-helper.json)"
# get the APCu values
pecl_APCu="$(echo "${peclValues}" | jq -r '.APCu')"
export pecl_APCu
# get the memcached values
pecl_memcached="$(echo "${peclValues}" | jq -r '.memcached')"
export pecl_memcached
# get the redis values
pecl_redis="$(echo "${peclValues}" | jq -r '.redis')"
export pecl_redis
# get the mcrypt values
pecl_mcrypt="$(echo "${peclValues}" | jq -r '.mcrypt')"
export pecl_mcrypt
for variant in "${variants[@]}"; do
export variant
# the path to this variant folder
dir="$version/php$phpVersion/$variant"
mkdir -p "$dir"
echo "processing $dir ..."
# move the entrypoint file into place
cp -a "$docker_entrypoint" "$dir/docker-entrypoint.sh"
# move the make database file into place
cp -a "makedb.php" "$dir/makedb.php"
{
generated_warning
gawk -f "$jqt" Dockerfile.template
} >"$dir/Dockerfile"
done
done
done