AUR lufux-git: pkgver() output sorts older than pkgver, so the package updates on every run
The AUR package lufux-git is offered as an update on every run of an AUR helper, and each "update" rebuilds and reinstalls the same version.
What happens
Aur (1) Old Version New Version
aur/lufux-git v1.4.2.stable.r1.g7024388-1 1.4.2-1
...
==> Starting pkgver()...
==> Updated version: lufux-git v1.4.2.stable.r1.g7024388-1
:: lufux-git-1.4.2-1 is up to date -- skipping build
warning: lufux-git-v1.4.2.stable.r1.g7024388-1 is up to date -- reinstalling
Cause
The tags are named like v1.4.2-stable, so pkgver() in the AUR PKGBUILD turns git describe output v1.4.2-stable-1-g7024388 into v1.4.2.stable.r1.g7024388. pacman sorts that older than the static pkgver=1.4.2 published in .SRCINFO, for two reasons:
- the leading
v(a segment starting with a letter is older than a numeric one) - the
.stablesuffix (a trailing alphabetic segment is older than no segment, like1.0a < 1.0)
$ vercmp v1.4.2.stable.r1.g7024388 1.4.2
-1
$ vercmp 1.4.2.stable.r1.g7024388 1.4.2 # stripping only the "v" is not enough
-1
$ vercmp 1.4.2.r1.g7024388 1.4.2
1
So the installed version always looks older than the AUR one.
Proposed fix
Strip both the v prefix and the -stable suffix in pkgver():
pkgver() {
cd "${pkgname%-git}"
- git describe --long --tags 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
+ git describe --long --tags 2>/dev/null | sed 's/^v//;s/-stable//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
On current main this gives 1.4.2.r1.g7024388, which is newer than both 1.4.2 and the currently installed v1.4.2.stable.r1.g7024388, so existing installs upgrade cleanly once and then stay quiet. No epoch is needed.
I would have sent a PR, but the AUR PKGBUILD (the git+ source one with pkgver()) lives only in the AUR repo; the PKGBUILD in this repo is a different, local-source one that doesn't have the problem.
Thanks, confirmed with vercmp and applied as proposed. The AUR package now builds as 1.4.2.r1.g7024388, so existing installs upgrade once and then stay quiet.