[pacman-dev] [PATCH] Add --with-sudo configure option

Drew DeVault sir at cmpwn.com
Mon Mar 13 00:49:34 UTC 2017


Allows you to specify an alternate command for running things as root,
such as OpenBSD's doas.

Signed-off-by: Drew DeVault <sir at cmpwn.com>
---
 configure.ac          | 9 +++++++++
 scripts/Makefile.am   | 1 +
 scripts/makepkg.sh.in | 8 ++++----
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 10e4415c..825b29b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,12 @@ AC_ARG_WITH(scriptlet-shell,
 		[set the full path to the shell used to run install scriptlets]),
 	[SCRIPTLET_SHELL=$withval], [SCRIPTLET_SHELL=/bin/sh])
 
+# Help line for changing sudo command
+AC_ARG_WITH(sudo,
+	AS_HELP_STRING([--with-sudo=sudo],
+		[set the command used to run pacman as root]),
+	[SUDOCMD=$withval], [SUDOCMD=sudo])
+
 # Help line for ldconfig path
 AC_ARG_WITH(ldconfig,
 	AS_HELP_STRING([--with-ldconfig=path],
@@ -509,6 +515,9 @@ AC_DEFINE_UNQUOTED([TEMPLATE_DIR], "$TEMPLATE_DIR", [The template directory used
 # Set makepkg split debugging symbol package suffix
 AC_SUBST(DEBUGSUFFIX)
 AC_DEFINE_UNQUOTED([DEBUGSUFFIX], "$DEBUGSUFFIX", [The suffix for debugging symbol packages used by makepkg])
+# Set sudo command
+AC_SUBST(SUDOCMD)
+AC_DEFINE_UNQUOTED([SUDOCMD], "$SUDOCMD", [The command used to run pacman as root])
 # Set shell used by install scriptlets
 AC_SUBST(SCRIPTLET_SHELL)
 AC_DEFINE_UNQUOTED([SCRIPTLET_SHELL], "$SCRIPTLET_SHELL", [The full path of the shell used to run install scriptlets])
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 4bb08a24..ccfe7384 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -148,6 +148,7 @@ edit = sed \
 	-e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
 	-e 's|@TEMPLATE_DIR[@]|$(TEMPLATE_DIR)|g' \
 	-e 's|@DEBUGSUFFIX[@]|$(DEBUGSUFFIX)|g' \
+	-e 's|@SUDOCMD[@]|$(SUDOCMD)|g' \
 	-e "s|@INODECMD[@]|$(INODECMD)|g" \
 	-e "s|@OWNERCMD[@]|$(OWNERCMD)|g" \
 	-e "s|@MODECMD[@]|$(MODECMD)|g" \
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 29408929..5128216a 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -212,8 +212,8 @@ run_pacman() {
 		cmd=("$PACMAN_PATH" "$@")
 	fi
 	if [[ $1 != -@(T|Qq|Q) ]]; then
-		if type -p sudo >/dev/null; then
-			cmd=(sudo "${cmd[@]}")
+		if type -p @SUDOCMD@ >/dev/null; then
+			cmd=(@SUDOCMD@ "${cmd[@]}")
 		else
 			cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
 		fi
@@ -1015,8 +1015,8 @@ check_software() {
 
 	# check for sudo if we will need it during makepkg execution
 	if (( DEP_BIN || RMDEPS || INSTALL )); then
-		if ! type -p sudo >/dev/null; then
-			warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su"
+		if ! type -p @SUDOCMD@ >/dev/null; then
+			warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "@SUDOCMD@" "su"
 		fi
 	fi
 
-- 
2.12.0


More information about the pacman-dev mailing list