makepkg: allow to specify an alternative pacman command

If PACMAN environment variable is set, makepkg will try to use this
command to check for installed dependencies and to install or remove
packages. Otherwise, makepkg will fall back to pacman.

Implements FS#13028.

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
Signed-off-by: Allan McRae <allan@archlinux.org>
[Dan: move envvar section in manpage]
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Cedric Staniewski 2009-12-02 19:04:32 +01:00 committed by Dan McGee
parent b805fe58ae
commit 66c6d288fd
2 changed files with 20 additions and 8 deletions

View File

@ -170,6 +170,15 @@ separate utility 'versionpkg'. See linkman:PKGBUILD[5] for details on how to
set up a development PKGBUILD. set up a development PKGBUILD.
Environment Variables
---------------------
*PACMAN*::
The command that 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 the variable is not set or
empty, makepkg will fall back to `pacman'.
Configuration Configuration
------------- -------------
See linkman:makepkg.conf[5] for more details on configuring makepkg using the See linkman:makepkg.conf[5] for more details on configuring makepkg using the

View File

@ -344,9 +344,9 @@ download_file() {
run_pacman() { run_pacman() {
local ret=0 local ret=0
if (( ! ASROOT )) && [[ $1 != "-T" ]]; then if (( ! ASROOT )) && [[ $1 != "-T" ]]; then
sudo pacman $PACMAN_OPTS "$@" || ret=$? sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
else else
pacman $PACMAN_OPTS "$@" || ret=$? $PACMAN $PACMAN_OPTS "$@" || ret=$?
fi fi
return $ret return $ret
} }
@ -360,7 +360,7 @@ check_deps() {
if (( ret == 127 )); then #unresolved deps if (( ret == 127 )); then #unresolved deps
echo "$pmout" echo "$pmout"
elif (( ret )); then elif (( ret )); 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 exit 1
fi fi
} }
@ -382,7 +382,7 @@ handle_deps() {
msg "$(gettext "Installing missing dependencies...")" msg "$(gettext "Installing missing dependencies...")"
if ! run_pacman -S --asdeps $deplist; then 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 exit 1 # TODO: error code
fi fi
fi fi
@ -1124,9 +1124,9 @@ install_package() {
(( ! INSTALL )) && return (( ! INSTALL )) && return
if (( ! SPLITPKG )); then if (( ! SPLITPKG )); then
msg "$(gettext "Installing package ${pkgname} with pacman -U...")" msg "$(gettext "Installing package %s with %s -U...")" "$pkgname" "$PACMAN"
else else
msg "$(gettext "Installing ${pkgbase} package group with pacman -U...")" msg "$(gettext "Installing %s package group with %s -U...")" "$pkgbase" "$PACMAN"
fi fi
local pkglist local pkglist
@ -1592,6 +1592,9 @@ if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf source ~/.makepkg.conf
fi fi
# set pacman command if not already defined
PACMAN=${PACMAN:-pacman}
# check if messages are to be printed using color # check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW unset ALL_OFF BOLD BLUE GREEN RED YELLOW
if [[ -t 2 && ! $USE_COLOR = "n" && $(check_buildenv color) = "y" ]]; then if [[ -t 2 && ! $USE_COLOR = "n" && $(check_buildenv color) = "y" ]]; then
@ -1850,7 +1853,7 @@ if (( NODEPS || NOBUILD || REPKG )); then
if (( NODEPS )); then if (( NODEPS )); then
warning "$(gettext "Skipping dependency checks.")" warning "$(gettext "Skipping dependency checks.")"
fi fi
elif [ $(type -p pacman) ]; then elif [ $(type -p "${PACMAN%% *}") ]; then
unset pkgdeps # Set by resolve_deps() and used by remove_deps() unset pkgdeps # Set by resolve_deps() and used by remove_deps()
deperr=0 deperr=0
@ -1865,7 +1868,7 @@ elif [ $(type -p pacman) ]; then
exit 1 exit 1
fi fi
else 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 fi
# ensure we have a sane umask set # ensure we have a sane umask set