makepkg: add PACMAN_AUTH configurable setting for sudo elevation
If specified, this will be used no matter what. If not, then we check if sudo exists and use that, or else fall back on su. Implements FS#32621 Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
d6f8659443
commit
2535611d6c
4 changed files with 26 additions and 4 deletions
|
@ -278,6 +278,14 @@ Options
|
||||||
`.tar.lzo`, `.tar.lrz`, `.tar.lz4`, `.tar.lz` and `.tar.Z`, or
|
`.tar.lzo`, `.tar.lrz`, `.tar.lz4`, `.tar.lz` and `.tar.Z`, or
|
||||||
simply `.tar` to disable compression entirely.
|
simply `.tar` to disable compression entirely.
|
||||||
|
|
||||||
|
**PACMAN_AUTH=()**::
|
||||||
|
Specify a command prefix for running pacman as root. If unset, makepkg will
|
||||||
|
check for the presence of sudo(8) and su(1) in turn, and try the first one
|
||||||
|
it finds.
|
||||||
|
+
|
||||||
|
If present, `%c` will be replaced with the shell-quoted form of the command
|
||||||
|
to run. Otherwise, the command to run is appended to the auth command.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
See Also
|
See Also
|
||||||
|
|
|
@ -147,3 +147,10 @@ COMPRESSLZ=(lzip -c -f)
|
||||||
#
|
#
|
||||||
PKGEXT='@PKGEXT@'
|
PKGEXT='@PKGEXT@'
|
||||||
SRCEXT='@SRCEXT@'
|
SRCEXT='@SRCEXT@'
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
# OTHER
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
#-- Command used to run pacman as root, instead of trying sudo and su
|
||||||
|
PACMAN_AUTH=()
|
||||||
|
|
|
@ -29,7 +29,7 @@ executable_functions+=('executable_sudo')
|
||||||
|
|
||||||
executable_sudo() {
|
executable_sudo() {
|
||||||
if (( DEP_BIN || RMDEPS || INSTALL )); then
|
if (( DEP_BIN || RMDEPS || INSTALL )); then
|
||||||
if ! type -p sudo >/dev/null; then
|
if (( ${#PACMAN_AUTH[@]} == 0 )) && ! type -p sudo >/dev/null; then
|
||||||
warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su"
|
warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -225,15 +225,22 @@ missing_source_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
run_pacman() {
|
run_pacman() {
|
||||||
local cmd
|
local cmd cmdescape
|
||||||
if [[ $1 = -@(T|Q)*([[:alpha:]]) ]]; then
|
if [[ $1 = -@(T|Q)*([[:alpha:]]) ]]; then
|
||||||
cmd=("$PACMAN_PATH" "$@")
|
cmd=("$PACMAN_PATH" "$@")
|
||||||
else
|
else
|
||||||
cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
|
cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
|
||||||
if type -p sudo >/dev/null; then
|
cmdescape="$(printf '%q ' "${cmd[@]}")"
|
||||||
|
if (( ${#PACMAN_AUTH[@]} )); then
|
||||||
|
if in_array '%c' "${PACMAN_AUTH[@]}"; then
|
||||||
|
cmd=("${PACMAN_AUTH[@]/\%c/$cmdescape}")
|
||||||
|
else
|
||||||
|
cmd=("${PACMAN_AUTH[@]}" "${cmd[@]}")
|
||||||
|
fi
|
||||||
|
elif type -p sudo >/dev/null; then
|
||||||
cmd=(sudo "${cmd[@]}")
|
cmd=(sudo "${cmd[@]}")
|
||||||
else
|
else
|
||||||
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
|
cmd=(su root -c "$cmdescape")
|
||||||
fi
|
fi
|
||||||
local lockfile="$(pacman-conf DBPath)/db.lck"
|
local lockfile="$(pacman-conf DBPath)/db.lck"
|
||||||
while [[ -f $lockfile ]]; do
|
while [[ -f $lockfile ]]; do
|
||||||
|
|
Loading…
Add table
Reference in a new issue