gen-pacman-repo: fall back to dirname when PKG_VERSION is a shell expr

awk -F'"' '/^PKG_VERSION/ ...' pulls the literal string out of the
package.mk, but a handful of packages set their version dynamically:

    PKG_VERSION="$(get_pkg_version gstreamer)"

The build system resolves that at build time and the install_pkg dir
ends up correctly named (gst-libav-1.27.1/). The packager, though, was
storing the raw "$(get_pkg_version gstreamer)" string, which then
went through the charset filter and became ".get_pkg_version.gstreamer."
in the asset name. Five packages slipped through in the first
repo-dev release with broken names (gst-libav, gst-plugins-good,
vitaquake2-{rogue,xatrix,zaero}-lr).

Detect any '$(' or '${' in the version string and treat it as
"unresolved", which trips the existing dirname-suffix fallback.
27 ArchR packages use this pattern; the fix covers all of them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Douglas Teles
2026-06-24 00:32:18 -03:00
parent 190469075f
commit 2bb9ebb50a
+10
View File
@@ -74,6 +74,16 @@ build_one_pkg() {
if [ -n "${pkgmk}" ]; then
version="$(awk -F'"' '/^PKG_VERSION/ {print $2; exit}' "${pkgmk}")"
fi
# Some package.mk files set PKG_VERSION dynamically, e.g.:
# PKG_VERSION="$(get_pkg_version gstreamer)"
# awk pulls the unresolved shell expansion as a string, which then
# turns into garbage like "..get_pkg_version.gstreamer." after the
# charset filter. Detect any $( ... ), :- or ${ and bail to the
# dirname fallback below, which holds the version the build system
# actually substituted.
case "${version}" in
*'$('* | *'${'* ) version="" ;;
esac
# Fallback: pull the suffix back out of the dirname.
if [ -z "${version}" ]; then
version="${dirname#${name}-}"