-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck
executable file
·49 lines (40 loc) · 1.4 KB
/
check
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
#!/bin/bash
set -ueo pipefail
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
payload=$(cat <&0)
source_family=$(jq -r '.source.family // empty' <<< "${payload}")
if [[ -z "${source_family}" ]]; then
echo >&2 "Source parameter 'family' is missing"
exit 1
fi
directory="${source_family}"
if [[ "${source_family}" == 0.9.* ]]; then
directory="0.9.x"
fi
if ! curl --head --silent --fail \
--url "https://artfiles.org/openssl.org/source/old/${directory}/" \
> /dev/null
then
>&2 echo "Unknown openssl version family '${source_family}'"
exit 1
fi
>&2 echo "Looking up versions of openssl '${source_family}'"
latest_version=$(
(
curl --silent --fail --show-error --location \
--url "https://artfiles.org/openssl.org/source/old/${directory}/" \
| sed -nEe 's/^.*href="openssl-([0-9.]+[a-z]{0,2})\.tar\.gz">.*/\1/p'
curl --silent --fail --show-error --location \
--url "https://artfiles.org/openssl.org/source/" \
| sed -nEe 's/^.*href="openssl-([0-9.]+[a-z]{0,2})\.tar\.gz">.*/\1/p'
) \
| grep --color="never" -F "${source_family}" \
| sort --version-sort \
| tail --lines="1"
)
>&2 echo "Latest version ${latest_version}"
jq --null-input \
--arg "version" "${latest_version}" \
'[ { version: $version } ]' \
>&3