summarylogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
authorTechcable2024-03-24 00:45:32 -0700
committerTechcable2024-03-24 00:50:13 -0700
commitfc98681aa894840a7869f0a814fec398b403d249 (patch)
tree12e8404dedf059b349ca5e6f0dc944e1a25cec8b /PKGBUILD
parentbece0397f262b29a9eba13ce01dbf97367797226 (diff)
downloadaur-zig-dev-bin.tar.gz
Change pkgver to avoid '+' in commit hash
Instead use the `.g` prefix for commit hashes similar to VCS packages: '0.12.0_dev.3433.g640acf862' Although this commit changes the versioning scheme, changing the epoch should not be needed since the format of the primary version number and revision count remains the same. This fixes an issue with '+' being a special character in URLs. The build script now requires 'ripgrep' in order to rewrite versions. I could have used python or jq but this is much more readable.
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD40
1 files changed, 33 insertions, 7 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 6b11fb7f9917..d263fe2c05e8 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -8,14 +8,14 @@ pkgname=zig-dev-bin
# Without changing the epoch, the old version scheme would be considered
# "newer" greater than the new version scheme
epoch=1
-# NOTE: Hyphen -> underscore
-pkgver=0.12.0_dev.700+376242e58
+# NOTE: Sanitize version '-' -> '_', '+' -> `.g`
+pkgver=0.12.0_dev.3433.g640acf862
pkgrel=1
pkgdesc="A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"
arch=('x86_64' 'aarch64')
url="https://ziglang.org/"
license=('MIT')
-makedepends=(curl jq minisign)
+makedepends=(curl jq minisign ripgrep)
options=('!strip')
provides=('zig')
conflicts=('zig')
@@ -76,9 +76,35 @@ fetch_version_index() {
echo "$index_file"
}
-pkgver() {
+# The original version of the zig package, without any sanitation
+original_pkgver() {
local index_file="$(fetch_version_index)"
- jq -r .master.version "$index_file" | sed 's/-/_/'
+ jq -r '.master.version' "$index_file";
+}
+
+# Sanitizes the package version, replacing special characters
+#
+# Specifically, we replace '-' with '_' because it's special-cased by makepkg & pacman,
+# and replace '+$commit" with '.g$commit' because '+' is special-cased in URLs.
+# Also the second form '.g$commit" is more consistent with the VCS package guidelines
+# https://wiki.archlinux.org/title/VCS_package_guidelines#The_pkgver()_function
+#
+# Unlike VCS packages, there aren't really any clear guidelines on versioning
+# for auto-updating binaries,
+# so the versioning format of the package has changed somewhat over time.
+pkgver() {
+ (
+ set -o pipefail;
+ # Sanitize `-` to `_`, `+` to `.g`
+ #
+ # So `0.12.0-dev.3429+13a9d94a8` becomes `0.12.0-dev.3429.g13a9d94a8`
+ #
+ # See VCS package guidelines for details:
+ original_pkgver | rg -e '^([\w\.]+)-(dev[\w\.]+)\+(\w+)$' -r '${1}_${2}.g${3}' || {
+ error "Version doesn't match pattern: '$(original_pkgver)'";
+ exit 1;
+ }
+ )
}
prepare() {
@@ -128,7 +154,7 @@ check() {
# Right now there is no way to disable the cache (see Zig issue #12317)
# Instead we shove everything in a local directory and delete it
cache_dir="${srcdir}/zig-cache"
- cd "${srcdir}/zig-linux-${CARCH}-${pkgver//_/-}";
+ cd "${srcdir}/zig-linux-${CARCH}-$(original_pkgver)"
echo "Running Zig Hello World"
./zig run --cache-dir "$cache_dir" --global-cache-dir "$cache_dir" "$hello_file"
./zig test --cache-dir "$cache_dir" --global-cache-dir "$cache_dir" "$hello_file"
@@ -161,7 +187,7 @@ check() {
}
package() {
- cd "${srcdir}/zig-linux-${CARCH}-${pkgver//_/-}"
+ cd "${srcdir}/zig-linux-${CARCH}-$(original_pkgver)"
install -d "${pkgdir}/usr/bin"
install -d "${pkgdir}/usr/lib/zig"
cp -R lib "${pkgdir}/usr/lib/zig/lib"