diff options
author | Techcable | 2024-03-24 00:45:32 -0700 |
---|---|---|
committer | Techcable | 2024-03-24 00:50:13 -0700 |
commit | fc98681aa894840a7869f0a814fec398b403d249 (patch) | |
tree | 12e8404dedf059b349ca5e6f0dc944e1a25cec8b | |
parent | bece0397f262b29a9eba13ce01dbf97367797226 (diff) | |
download | aur-fc98681aa894840a7869f0a814fec398b403d249.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.
-rw-r--r-- | .SRCINFO | 3 | ||||
-rw-r--r-- | PKGBUILD | 40 |
2 files changed, 35 insertions, 8 deletions
@@ -1,6 +1,6 @@ pkgbase = zig-dev-bin pkgdesc = A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software - pkgver = 0.12.0_dev.700+376242e58 + pkgver = 0.12.0_dev.3433.g640acf862 pkgrel = 1 epoch = 1 url = https://ziglang.org/ @@ -10,6 +10,7 @@ pkgbase = zig-dev-bin makedepends = curl makedepends = jq makedepends = minisign + makedepends = ripgrep provides = zig conflicts = zig options = !strip @@ -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" |