Extracting function variables containing arbitrarily scoped variables of
arbitrary nature is a disaster, but let's at least cover the common case
of using the actual '$pkgname' in an install/changelog file. It's the
odd case of actually being basically justified use of disambiguating
between the same variable used in multiple different split packages and
is even recommended in the PKGBUILD(5) documentation...

... and also, --printsrcinfo already uses and overwrites the variable
'pkgname' in pkgbuild_extract_to_srcinfo, so this "works" in .SRCINFO
but doesn't work in .src.tar.gz

Fixes FS#64932

Signed-off-by: Eli Schwartz <[email protected]>
---
 scripts/makepkg.sh.in | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index ca3e7459..674e0d87 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -784,13 +784,14 @@ create_srcpackage() {
                fi
        done
 
-       local i
+       local pkgname_backup=(${pkgname[@]})
+       local i pkgname
        for i in 'changelog' 'install'; do
                local file files
 
                [[ ${!i} ]] && files+=("${!i}")
-               for name in "${pkgname[@]}"; do
-                       if extract_function_variable "package_$name" "$i" 0 
file; then
+               for pkgname in "${pkgname_backup[@]}"; do
+                       if extract_function_variable "package_$pkgname" "$i" 0 
file; then
                                files+=("$file")
                        fi
                done
@@ -802,6 +803,7 @@ create_srcpackage() {
                        fi
                done
        done
+       pkgname=(${pkgname_backup[@]})
 
        local fullver=$(get_full_version)
        local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
-- 
2.24.1

Reply via email to