FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 11-18-2009, 09:29 PM
Cedric Staniewski
 
Default 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>
---
scripts/makepkg.sh.in | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 3b7966e..d05b608 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -333,10 +333,10 @@ download_file() {

run_pacman() {
local ret=0
- if (( ! ASROOT )) && [[ $1 != "-T" ]]; then
- sudo pacman $PACMAN_OPTS "$@" || ret=$?
+ if (( ! ASROOT )) && [[ $1 != "-T" ]] && sudo -l $PACMAN &>/dev/null; then
+ sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
else
- pacman $PACMAN_OPTS "$@" || ret=$?
+ $PACMAN $PACMAN_OPTS "$@" || ret=$?
fi
return $ret
}
@@ -350,7 +350,7 @@ check_deps() {
if (( ret == 127 )); then #unresolved deps
echo "$pmout"
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
fi
}
@@ -372,7 +372,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
@@ -1100,9 +1100,9 @@ install_package() {
(( ! INSTALL )) && return

if (( ! SPLITPKG )); 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
@@ -1557,6 +1557,9 @@ if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf
fi

+# set pacman command if not already defined
+PACMAN=${PACMAN:-pacman}
+
# check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
if [[ -t 2 && ! $USE_COLOR = "n" && $(check_buildenv color) = "y" ]]; then
@@ -1810,7 +1813,7 @@ if (( NODEPS || NOBUILD || REPKG )); then
if (( NODEPS )); 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

@@ -1825,7 +1828,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.3
 
Old 12-02-2009, 05:04 PM
Cedric Staniewski
 
Default 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>
---
doc/makepkg.8.txt | 9 +++++++++
scripts/makepkg.sh.in | 19 +++++++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index 18ee6ed..703c1b0 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -162,6 +162,15 @@ Options
useful if you are redirecting makepkg output to file.


+Environment Variables
+---------------------
+*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 the variable is not set or
+ empty, makepkg will fall back to `pacman'.
+
+
Additional Features
-------------------
makepkg supports building development versions of packages without having to
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index ceaa8a6..d5f032f 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -344,9 +344,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
}
@@ -360,7 +360,7 @@ check_deps() {
if (( ret == 127 )); then #unresolved deps
echo "$pmout"
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
fi
}
@@ -382,7 +382,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
@@ -1119,9 +1119,9 @@ install_package() {
(( ! INSTALL )) && return

if (( ! SPLITPKG )); 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
@@ -1587,6 +1587,9 @@ if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf
fi

+# set pacman command if not already defined
+PACMAN=${PACMAN:-pacman}
+
# check if messages are to be printed using color
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
if [[ -t 2 && ! $USE_COLOR = "n" && $(check_buildenv color) = "y" ]]; then
@@ -1845,7 +1848,7 @@ if (( NODEPS || NOBUILD || REPKG )); then
if (( NODEPS )); 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

@@ -1860,7 +1863,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.3
 

Thread Tools




All times are GMT. The time now is 06:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org