[pacman-dev] [PATCH 5/6] makepkg: replace bare eval with var extraction functions

Dave Reisner dreisner at archlinux.org
Thu Aug 7 19:22:25 EDT 2014


---
 scripts/makepkg.sh.in | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index a4f4494..34ffb25 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -866,7 +866,7 @@ get_pkg_arch() {
 		fi
 	else
 		local arch_override
-		eval $(declare -f package_$1 | sed -n 's/\(^[[:space:]]*arch=\)/arch_override=/p')
+		pkgbuild_get_attribute "$1" arch arch_override 0
 		(( ${#arch_override[@]} == 0 )) && arch_override=("${arch[@]}")
 		if [[ $arch_override = "any" ]]; then
 			printf "%s\n" "any"
@@ -2121,15 +2121,21 @@ create_srcpackage() {
 
 	local i
 	for i in 'changelog' 'install'; do
-		local file
-		while read -r file; do
-			# evaluate any bash variables used
-			eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
+		local file files
+
+		[[ $install ]] && files+=("$install")
+		for name in "${pkgname[@]}"; do
+			if extract_function_var "package_$name" "$i" 0 file; then
+				files+=("$file")
+			fi
+		done
+
+		for file in "${files[@]}"; do
 			if [[ $file && ! -f "${srclinks}/${pkgbase}/$file" ]]; then
 				msg2 "$(gettext "Adding %s file (%s)...")" "$i" "${file}"
 				ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
 			fi
-		done < <(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
+		done
 	done
 
 	local TAR_OPT
-- 
2.0.4


More information about the pacman-dev mailing list