blob: e2ebe9fc94b8e3aeed1ccede3add8e70fee79f92 (
plain)
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
|
#!/usr/bin/env bash
set -euo pipefail
pkgbuild_path="PKGBUILD"
latest_url="https://dl.lazycatmicroserver.com/hclient-cli/latest-version.json"
if ! command -v curl >/dev/null 2>&1; then
echo "error: curl is required" >&2
exit 2
fi
if [[ ! -f "${pkgbuild_path}" ]]; then
echo "error: PKGBUILD not found: ${pkgbuild_path}" >&2
exit 2
fi
extract_pkgbuild_scalar() {
local key=$1
sed -nE "s/^${key}=([^[:space:]]+)$/\1/p" "${pkgbuild_path}" | head -n1
}
current_version=$(extract_pkgbuild_scalar "pkgver")
latest_json=$(curl -fsSL "${latest_url}")
latest_version=$(sed -nE 's/.*"version"[[:space:]]*:[[:space:]]*"v?([^"]+)".*/\1/p' <<<"${latest_json}" | head -n1)
if [[ -z "${current_version}" ]]; then
echo "error: failed to parse local PKGBUILD" >&2
exit 2
fi
if [[ -z "${latest_version}" ]]; then
echo "error: failed to parse ${latest_url}" >&2
exit 2
fi
if [[ "${current_version}" != "${latest_version}" ]]; then
echo "update required"
echo "local: version=${current_version}"
echo "remote: version=${latest_version}"
exit 10
fi
echo "PKGBUILD is up to date (${current_version})"
|