Read PKGBUILD variables with CARCH set and refuse to queue a package whose version cannot be read
makepkg always exports CARCH, so PKGBUILDs may branch on it at file scope. Every place the tooling sourced a PKGBUILD did so without CARCH, taking the wrong branch or aborting partway, and check-versions turned the resulting empty pkgver/pkgrel into the version '-', which never matches a published version and queues an endless rebuild. package_pkgbuild_var reads one variable the way makepkg would see it, for the architecture being checked, and reports whether the source succeeded. check-versions, sync-rebuilds and omarchy-pkgs use it. check-versions now warns and skips a package whose pkgver or pkgrel is empty instead of comparing a partial version. A self-test covers a PKGBUILD that branches on CARCH before assigning its version.
This commit is contained in:
4 files changed
+70
-10
No files matched your search
@@ -144,6 +144,30 @@ package_has_pkgbuild() {
|
||||
[[ -f "$pkgdir/PKGBUILD" ]]
|
||||
}
|
||||
|
||||
# Read one variable from a PKGBUILD the way makepkg would see it.
|
||||
#
|
||||
# makepkg always exports CARCH, so PKGBUILDs may branch on it at file scope
|
||||
# (per-architecture sources, tarball suffixes, even `return` for an
|
||||
# unsupported architecture). Sourcing without CARCH takes the wrong branch or
|
||||
# aborts partway, which leaves pkgver and pkgrel empty — and an empty version
|
||||
# never equals the published one, so the package is queued for a rebuild that
|
||||
# promotion then refuses. Every read of a PKGBUILD goes through here.
|
||||
#
|
||||
# Prints the value; exit status is that of `source PKGBUILD` itself, so a
|
||||
# caller can tell "variable empty" from "PKGBUILD could not be read".
|
||||
package_pkgbuild_var() {
|
||||
local pkgdir="$1"
|
||||
local var="$2"
|
||||
local arch="${3:-${ARCH:-x86_64}}"
|
||||
|
||||
(cd "$pkgdir" && env -u OMARCHY_SRC CARCH="$arch" bash -c '
|
||||
source PKGBUILD >/dev/null 2>&1
|
||||
rc=$?
|
||||
printf "%s\n" "${!1:-}"
|
||||
exit "$rc"
|
||||
' _ "$var")
|
||||
}
|
||||
|
||||
# The architectures declared by a PKGBUILD. Set CARCH while reading it so a
|
||||
# conditional arch=() assignment is evaluated for the architecture we are
|
||||
# actually checking, even when the repository host is a different one.
|
||||
|
||||
Reference in new issue
Block a user