[pacman-dev] [PATCH 2/2] makepkg: add a config file option for the pacman binary to be used

Cedric Staniewski cedric at gmx.ca
Fri Nov 6 14:47:43 EST 2009


Implements FS#13028.

Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
---
 doc/makepkg.conf.5.txt |    6 ++++++
 scripts/makepkg.sh.in  |   20 ++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt
index 704dccc..617ec84 100644
--- a/doc/makepkg.conf.5.txt
+++ b/doc/makepkg.conf.5.txt
@@ -178,6 +178,12 @@ Options
 *PKGEXT*, *SRCEXT*::
 	Do not touch these unless you know what you are doing.
 
+*PACMAN*::
+	The command which will be used to check for missing dependencies and to
+	install and remove packages. Pacman's -U, -T, -S and -Rns operations
+	must be supported by this command. If no command is specified, makepkg
+	will fall back to `pacman'.
+
 
 See Also
 --------
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index cfc5736..cf2b001 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -77,6 +77,7 @@ SPLITPKG=0
 # when dealing with svn/cvs/etc PKGBUILDs.
 FORCE_VER=""
 
+PACMAN=
 PACMAN_OPTS=
 
 ### SUBROUTINES ###
@@ -331,9 +332,9 @@ download_file() {
 run_pacman() {
 	local ret=0
 	if (( ! ASROOT )) && [[ $1 != -T ]]; then
-		sudo pacman $PACMAN_OPTS "$@" || ret=$?
+		sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
 	else
-		pacman $PACMAN_OPTS "$@" || ret=$?
+		$PACMAN $PACMAN_OPTS "$@" || ret=$?
 	fi
 	return $ret
 }
@@ -347,7 +348,7 @@ check_deps() {
 	if [ $ret -eq 127 ]; then #unresolved deps
 		echo "$pmout"
 	elif [ $ret -ne 0 ]; then
-		error "$(gettext "Pacman returned a fatal error (%i): %s")" "$ret" "$pmout"
+		error "$(gettext "%s returned a fatal error (%i): %s")" "$PACMAN" "$ret" "$pmout"
 		exit 1
 	fi
 }
@@ -369,7 +370,7 @@ handle_deps() {
 		msg "$(gettext "Installing missing dependencies...")"
 
 		if ! run_pacman -S --asdeps $deplist; then
-			error "$(gettext "Pacman failed to install missing dependencies.")"
+			error "$(gettext "%s failed to install missing dependencies.")" "$PACMAN"
 			exit 1 # TODO: error code
 		fi
 	fi
@@ -1097,9 +1098,9 @@ install_package() {
 	[ "$INSTALL" -eq 0 ] && return
 
 	if [ "$SPLITPKG" -eq 0 ]; then
-		msg "$(gettext "Installing package ${pkgname} with pacman -U...")"
+		msg "$(gettext "Installing package %s with %s -U...")" "$pkgname" "$PACMAN"
 	else
-		msg "$(gettext "Installing ${pkgbase} package group with pacman -U...")"
+		msg "$(gettext "Installing %s package group with %s -U...")" "$pkgbase" "$PACMAN"
 	fi
 
 	local pkglist
@@ -1550,6 +1551,9 @@ if [ -r ~/.makepkg.conf ]; then
 	source ~/.makepkg.conf
 fi
 
+# set pacman command if not defined in config files
+PACMAN=${PACMAN:-pacman}
+
 # check if messages are to be printed using color
 unset ALL_OFF BOLD BLUE GREEN RED YELLOW
 if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
@@ -1796,7 +1800,7 @@ if [ "$NODEPS" -eq 1 -o "$NOBUILD" -eq 1 -o "$REPKG" -eq 1 ]; then
 	if [ "$NODEPS" -eq 1 ]; then
 		warning "$(gettext "Skipping dependency checks.")"
 	fi
-elif [ $(type -p pacman) ]; then
+elif [ $(type -p "$PACMAN") ]; then
 	unset pkgdeps # Set by resolve_deps() and used by remove_deps()
 	deperr=0
 
@@ -1811,7 +1815,7 @@ elif [ $(type -p pacman) ]; then
 		exit 1
 	fi
 else
-	warning "$(gettext "pacman was not found in PATH; skipping dependency checks.")"
+	warning "$(gettext "%s was not found in PATH; skipping dependency checks.")" "$PACMAN"
 fi
 
 # ensure we have a sane umask set
-- 
1.6.5.2



More information about the pacman-dev mailing list