2020-08-18 07:12:07 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
versions=( "$@" )
|
|
|
|
if [ ${#versions[@]} -eq 0 ]; then
|
|
|
|
versions=( */ )
|
|
|
|
json='{}'
|
|
|
|
else
|
|
|
|
json="$(< versions.json)"
|
|
|
|
fi
|
|
|
|
versions=( "${versions[@]%/}" )
|
|
|
|
|
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
rcVersion="${version%-rc}"
|
|
|
|
export version rcVersion
|
|
|
|
|
|
|
|
# scrape the relevant API based on whether we're looking for pre-releases
|
|
|
|
if [ "$rcVersion" = "$version" ]; then
|
|
|
|
apiUrl="https://www.php.net/releases/index.php?json&max=100&version=${rcVersion%%.*}"
|
|
|
|
apiJqExpr='
|
|
|
|
(keys[] | select(startswith(env.rcVersion))) as $version
|
|
|
|
| [ $version, (
|
|
|
|
.[$version].source[]
|
|
|
|
| select(.filename | endswith(".xz"))
|
|
|
|
|
|
|
|
|
"https://www.php.net/distributions/" + .filename,
|
|
|
|
"https://www.php.net/distributions/" + .filename + ".asc",
|
2020-10-29 18:27:05 +01:00
|
|
|
.sha256 // ""
|
2020-08-18 07:12:07 +02:00
|
|
|
) ]
|
|
|
|
'
|
|
|
|
else
|
|
|
|
apiUrl='https://qa.php.net/api.php?type=qa-releases&format=json'
|
|
|
|
apiJqExpr='
|
2022-01-27 00:45:04 +01:00
|
|
|
(.releases // [])[]
|
2020-08-18 07:12:07 +02:00
|
|
|
| select(.version | startswith(env.rcVersion))
|
|
|
|
| [
|
|
|
|
.version,
|
|
|
|
.files.xz.path // "",
|
|
|
|
"",
|
2020-10-29 18:27:05 +01:00
|
|
|
.files.xz.sha256 // ""
|
2020-08-18 07:12:07 +02:00
|
|
|
]
|
|
|
|
'
|
|
|
|
fi
|
|
|
|
IFS=$'\n'
|
|
|
|
possibles=( $(
|
|
|
|
curl -fsSL "$apiUrl" \
|
|
|
|
| jq --raw-output "$apiJqExpr | @sh" \
|
|
|
|
| sort -rV
|
|
|
|
) )
|
|
|
|
unset IFS
|
|
|
|
|
|
|
|
if [ "${#possibles[@]}" -eq 0 ]; then
|
2022-01-27 00:45:04 +01:00
|
|
|
if [ "$rcVersion" = "$version" ]; then
|
|
|
|
echo >&2
|
|
|
|
echo >&2 "error: unable to determine available releases of $version"
|
|
|
|
echo >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo >&2 "warning: skipping/removing '$version' (does not appear to exist upstream)"
|
|
|
|
json="$(jq <<<"$json" -c '.[env.version] = null')"
|
|
|
|
continue
|
|
|
|
fi
|
2020-08-18 07:12:07 +02:00
|
|
|
fi
|
|
|
|
|
2020-10-29 18:27:05 +01:00
|
|
|
# format of "possibles" array entries is "VERSION URL.TAR.XZ URL.TAR.XZ.ASC SHA256" (each value shell quoted)
|
2020-08-18 07:12:07 +02:00
|
|
|
# see the "apiJqExpr" values above for more details
|
|
|
|
eval "possi=( ${possibles[0]} )"
|
|
|
|
fullVersion="${possi[0]}"
|
|
|
|
url="${possi[1]}"
|
|
|
|
ascUrl="${possi[2]}"
|
|
|
|
sha256="${possi[3]}"
|
|
|
|
|
2020-10-01 21:22:48 +02:00
|
|
|
if ! wget -q --spider "$url"; then
|
|
|
|
echo >&2 "error: '$url' appears to be missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-08-18 07:12:07 +02:00
|
|
|
# if we don't have a .asc URL, let's see if we can figure one out :)
|
|
|
|
if [ -z "$ascUrl" ] && wget -q --spider "$url.asc"; then
|
|
|
|
ascUrl="$url.asc"
|
|
|
|
fi
|
|
|
|
|
|
|
|
variants='[]'
|
|
|
|
# order here controls the order of the library/ file
|
|
|
|
for suite in \
|
2021-08-17 02:38:24 +02:00
|
|
|
bullseye \
|
2020-08-18 07:12:07 +02:00
|
|
|
buster \
|
2022-11-30 19:19:15 +01:00
|
|
|
alpine3.17 \
|
2022-05-24 10:37:00 +02:00
|
|
|
alpine3.16 \
|
2020-08-18 07:12:07 +02:00
|
|
|
; do
|
2022-11-30 19:19:15 +01:00
|
|
|
# https://github.com/docker-library/php/pull/1348
|
|
|
|
if [ "$rcVersion" = '8.0' ] && [[ "$suite" = alpine* ]] && [ "$suite" != 'alpine3.16' ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2020-08-18 07:12:07 +02:00
|
|
|
for variant in cli apache fpm zts; do
|
2021-08-17 02:38:24 +02:00
|
|
|
if [[ "$suite" = alpine* ]]; then
|
|
|
|
if [ "$variant" = 'apache' ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
2020-08-18 07:12:07 +02:00
|
|
|
export suite variant
|
|
|
|
variants="$(jq <<<"$variants" -c '. + [ env.suite + "/" + env.variant ]')"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "$version: $fullVersion"
|
|
|
|
|
2022-01-27 20:23:31 +01:00
|
|
|
export fullVersion url ascUrl sha256
|
2020-08-18 07:12:07 +02:00
|
|
|
json="$(
|
2022-05-25 00:31:35 +02:00
|
|
|
jq <<<"$json" -c --argjson variants "$variants" '
|
|
|
|
.[env.version] = {
|
2020-08-18 07:12:07 +02:00
|
|
|
version: env.fullVersion,
|
|
|
|
url: env.url,
|
|
|
|
ascUrl: env.ascUrl,
|
|
|
|
sha256: env.sha256,
|
|
|
|
variants: $variants,
|
2022-05-25 00:31:35 +02:00
|
|
|
}
|
|
|
|
'
|
2020-08-18 07:12:07 +02:00
|
|
|
)"
|
2022-05-25 00:31:35 +02:00
|
|
|
|
|
|
|
if [ "$version" = "$rcVersion" ]; then
|
|
|
|
json="$(jq <<<"$json" -c '
|
|
|
|
.[env.version + "-rc"] //= null
|
|
|
|
')"
|
|
|
|
fi
|
2020-08-18 07:12:07 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
jq <<<"$json" -S . > versions.json
|