[pacman-dev] [PATCH 1/1] makepkg: Handle dependencies that contain spaces

morganamilo morganamilo at gmail.com
Fri Feb 23 00:45:34 UTC 2018


In {,opt,check,make}depends makepkg treats packages that contain
whitespace as separate packages. For example:
	depends=('foo bar')
Would be treated as two seperate packages instead of a single package.

Packages should not contain whitespace in their name. Pkgbuilds that
lists depends like the example above have probably done so in error.
Now we correctly error instead of ignoring the improper pkgbuild.

Signed-off-by: morganamilo <morganamilo at gmail.com>
---
 scripts/makepkg.sh.in | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 63b6c3e1..d695c09f 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -290,19 +290,19 @@ resolve_deps() {
 	# deplist cannot be declared like this: local deplist=$(foo)
 	# Otherwise, the return value will depend on the assignment.
 	local deplist
-	deplist=($(check_deps "$@")) || exit $E_INSTALL_DEPS_FAILED
+	deplist=("$(check_deps "$@")") || exit $E_INSTALL_DEPS_FAILED
 	[[ -z $deplist ]] && return $R_DEPS_SATISFIED
 
 	if handle_deps "${deplist[@]}"; then
 		# check deps again to make sure they were resolved
-		deplist=$(check_deps "$@") || exit $E_INSTALL_DEPS_FAILED
+		deplist=("$(check_deps "$@")") || exit $E_INSTALL_DEPS_FAILED
 		[[ -z $deplist ]] && return $R_DEPS_SATISFIED
 	fi
 
 	msg "$(gettext "Missing dependencies:")"
 	local dep
-	for dep in $deplist; do
-		msg2 "$dep"
+	for ((i = 0; i < ${#deplist[@]}; i++)); do
+		msg2 "${deplist[$i]}"
 	done
 
 	return $R_DEPS_MISSING
@@ -328,7 +328,7 @@ remove_deps() {
 
 	msg "Removing installed dependencies..."
 	# exit cleanly on failure to remove deps as package has been built successfully
-	if ! run_pacman -Rn ${deplist[@]}; then
+	if ! run_pacman -Rn "${deplist[@]}"; then
 		warning "$(gettext "Failed to remove installed dependencies.")"
 		return $E_REMOVE_DEPS_FAILED
 	fi
@@ -1612,7 +1612,7 @@ else
 	deperr=0
 
 	msg "$(gettext "Checking runtime dependencies...")"
-	resolve_deps ${depends[@]} || deperr=1
+	resolve_deps "${depends[@]}" || deperr=1
 
 	if (( RMDEPS && INSTALL )); then
 		original_pkglist=($(run_pacman -Qq))    # required by remove_dep
-- 
2.16.2


More information about the pacman-dev mailing list