summarylogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
authorTechcable2023-10-01 18:31:08 -0700
committerTechcable2023-10-01 18:37:25 -0700
commitbece0397f262b29a9eba13ce01dbf97367797226 (patch)
tree16f66f71115a49bfec32c4943a91a037c9460a78 /PKGBUILD
parent1dfd03e669b34cfed360b6a4fb38c31db75f1a60 (diff)
downloadaur-bece0397f262b29a9eba13ce01dbf97367797226.tar.gz
Don't dynamically extend sources array
Arch Build System doesn't handle this. Instead, everything is downloaded manually in prepare() Avoid downloading version index twice in pkgver() Minor refactoring for downloading version index
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD46
1 files changed, 35 insertions, 11 deletions
diff --git a/PKGBUILD b/PKGBUILD
index f68aa9fca4fc..6b11fb7f9917 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -9,7 +9,7 @@ pkgname=zig-dev-bin
# "newer" greater than the new version scheme
epoch=1
# NOTE: Hyphen -> underscore
-pkgver=0.12.0_dev.381+1a0e6bcdb
+pkgver=0.12.0_dev.700+376242e58
pkgrel=1
pkgdesc="A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"
arch=('x86_64' 'aarch64')
@@ -46,29 +46,53 @@ error() {
echo "$@" >&2;
}
-pkgver() {
+# Fetch the version index, deleting any cached version.
+refresh_version_index() {
+ FORCE_REFRESH=1 fetch_version_index
+}
+# NOTE: If we put version-index in `source` then it would be cached
+#
+# Instead, fetch it by hand.
+fetch_version_index() {
local index_file="${srcdir}/zig-version-index.json";
- # Invalidate old verison-index.json
- #
- # If we put version-index in `source` then it would be cached...
- if [[ -x "$index_file" ]]; then
- rm "$index_file";
+ if [[ -f "$index_file" ]]; then
+ if [[ $FORCE_REFRESH -eq 1 ]]; then
+ # When ordered to 'refresh', we invalidate old verison-index.json
+ echo "Deleting existing version index file (refreshing)" >&2;
+ rm "$index_file";
+ else
+ echo $index_file;
+ return 0;
+ fi
fi
- curl -sS "https://ziglang.org/download/index.json" -o "$index_file"
+ # Fallthrough to download index file
+ echo "Downloading version index..." >&2;
+ if ! curl -sS "https://ziglang.org/download/index.json" -o "$index_file"; then
+ error "Failed to download version index";
+ exit 1;
+ else
+ echo "Successfully downloaded version index (date: $(jq -r .master.date $index_file))" >&2;
+ fi
+ echo "$index_file"
+}
+
+pkgver() {
+ local index_file="$(fetch_version_index)"
jq -r .master.version "$index_file" | sed 's/-/_/'
}
prepare() {
+ local index_file="$(refresh_version_index)";
local newver="$(pkgver)";
pushd "${srcdir}" > /dev/null;
- local index_file="zig-version-index.json";
local newurl="$(jq -r ".master.\"${CARCH}-linux\".tarball" $index_file)";
local newurl_sig="$newurl.minisig";
local newfile="zig-linux-${CARCH}-${newver}.tar.xz";
local newfile_sig="$newfile.minisig";
- source+=("${newfile}:${newurl}" "${newfile_sig}:${newurl_sig}")
+ # NOTE: The Arch Build System unfortunately doesn't handle dynamically added sources.
+ # source+=("${newfile}:${newurl}" "${newfile_sig}:${newurl_sig}")
local expected_hash="$(jq -r ".master.\"${CARCH}-linux\".shasum" "$index_file")"
- sha256sums+=("$expected_hash" "SKIP")
+ # sha256sums+=("$expected_hash" "SKIP")
if [[ -f "$newfile" && -f "$newfile_sig" ]]; then
echo "Reusing existing $newfile (and signature)";
else