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-06-2009, 06:47 PM
Cedric Staniewski
 
Default makepkg: move pacman calls to a function

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
---
I'm not sure about that part

pmout=$(run_pacman -T "$@")

for two reasons. First, we have to work around sudo in run_pacman, and
second, most of the pacman wrappers does not support -T or do not return
the same codes as pacman does. For this second reason, the following patch
would be (currently) useless for the majority of pacman wrapper users.


scripts/makepkg.sh.in | 39 +++++++++++++++------------------------
1 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index fbcdc70..cfc5736 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -328,10 +328,21 @@ download_file() {
fi
}

+run_pacman() {
+ local ret=0
+ if (( ! ASROOT )) && [[ $1 != -T ]]; then
+ sudo pacman $PACMAN_OPTS "$@" || ret=$?
+ else
+ pacman $PACMAN_OPTS "$@" || ret=$?
+ fi
+ return $ret
+}
+
check_deps() {
[ $# -gt 0 ] || return

- pmout=$(pacman $PACMAN_OPTS -T "$@")
+ local ret=0
+ pmout=$(run_pacman -T "$@")
ret=$?
if [ $ret -eq 127 ]; then #unresolved deps
echo "$pmout"
@@ -356,15 +367,8 @@ handle_deps() {
if [ "$DEP_BIN" -eq 1 ]; then
# install missing deps from binary packages (using pacman -S)
msg "$(gettext "Installing missing dependencies...")"
- local ret=0
-
- if [ "$ASROOT" -eq 0 ]; then
- sudo pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
- else
- pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
- fi

- if [ $ret -ne 0 ]; then
+ if ! run_pacman -S --asdeps $deplist; then
error "$(gettext "Pacman failed to install missing dependencies.")"
exit 1 # TODO: error code
fi
@@ -422,15 +426,9 @@ remove_deps() {
done

msg "Removing installed dependencies..."
- local ret=0
- if [ "$ASROOT" -eq 0 ]; then
- sudo pacman $PACMAN_OPTS -Rns $deplist || ret=$?
- else
- pacman $PACMAN_OPTS -Rns $deplist || ret=$?
- fi

# Fixes FS#10039 - exit cleanly as package has built successfully
- if [ $ret -ne 0 ]; then
+ if ! run_pacman -Rns $deplist; then
warning "$(gettext "Failed to remove installed dependencies.")"
return 0
fi
@@ -1113,14 +1111,7 @@ install_package() {
fi
done

- local ret=0
- if [ "$ASROOT" -eq 0 ]; then
- sudo pacman $PACMAN_OPTS -U ${pkglist} || ret=$?
- else
- pacman $PACMAN_OPTS -U ${pkglist} || ret=$?
- fi
-
- if [ $ret -ne 0 ]; then
+ if ! run_pacman -U $pkglist; then
warning "$(gettext "Failed to install built package(s).")"
return 0
fi
--
1.6.5.2
 
Old 11-06-2009, 07:20 PM
Cedric Staniewski
 
Default makepkg: move pacman calls to a function

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
---
scripts/makepkg.sh.in | 37 ++++++++++++++-----------------------
1 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index fbcdc70..125b4e0 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -328,9 +328,20 @@ download_file() {
fi
}

+run_pacman() {
+ local ret=0
+ if (( ! ASROOT )); then
+ sudo pacman $PACMAN_OPTS "$@" || ret=$?
+ else
+ pacman $PACMAN_OPTS "$@" || ret=$?
+ fi
+ return $ret
+}
+
check_deps() {
[ $# -gt 0 ] || return

+ local ret=0
pmout=$(pacman $PACMAN_OPTS -T "$@")
ret=$?
if [ $ret -eq 127 ]; then #unresolved deps
@@ -356,15 +367,8 @@ handle_deps() {
if [ "$DEP_BIN" -eq 1 ]; then
# install missing deps from binary packages (using pacman -S)
msg "$(gettext "Installing missing dependencies...")"
- local ret=0
-
- if [ "$ASROOT" -eq 0 ]; then
- sudo pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
- else
- pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
- fi

- if [ $ret -ne 0 ]; then
+ if ! run_pacman -S --asdeps $deplist; then
error "$(gettext "Pacman failed to install missing dependencies.")"
exit 1 # TODO: error code
fi
@@ -422,15 +426,9 @@ remove_deps() {
done

msg "Removing installed dependencies..."
- local ret=0
- if [ "$ASROOT" -eq 0 ]; then
- sudo pacman $PACMAN_OPTS -Rns $deplist || ret=$?
- else
- pacman $PACMAN_OPTS -Rns $deplist || ret=$?
- fi

# Fixes FS#10039 - exit cleanly as package has built successfully
- if [ $ret -ne 0 ]; then
+ if ! run_pacman -Rns $deplist; then
warning "$(gettext "Failed to remove installed dependencies.")"
return 0
fi
@@ -1113,14 +1111,7 @@ install_package() {
fi
done

- local ret=0
- if [ "$ASROOT" -eq 0 ]; then
- sudo pacman $PACMAN_OPTS -U ${pkglist} || ret=$?
- else
- pacman $PACMAN_OPTS -U ${pkglist} || ret=$?
- fi
-
- if [ $ret -ne 0 ]; then
+ if ! run_pacman -U $pkglist; then
warning "$(gettext "Failed to install built package(s).")"
return 0
fi
--
1.6.5.2
 
Old 11-18-2009, 09:29 PM
Cedric Staniewski
 
Default makepkg: move pacman calls to a function

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
---
same as [1], just rebased on master

[1] http://mailman.archlinux.org/pipermail/pacman-dev/2009-November/010046.html

scripts/makepkg.sh.in | 39 +++++++++++++++------------------------
1 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 3d776f0..3b7966e 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -331,10 +331,21 @@ download_file() {
fi
}

+run_pacman() {
+ local ret=0
+ if (( ! ASROOT )) && [[ $1 != "-T" ]]; then
+ sudo pacman $PACMAN_OPTS "$@" || ret=$?
+ else
+ pacman $PACMAN_OPTS "$@" || ret=$?
+ fi
+ return $ret
+}
+
check_deps() {
(( $# > 0 )) || return

- pmout=$(pacman $PACMAN_OPTS -T "$@")
+ local ret=0
+ pmout=$(run_pacman -T "$@")
ret=$?
if (( ret == 127 )); then #unresolved deps
echo "$pmout"
@@ -359,15 +370,8 @@ handle_deps() {
if (( DEP_BIN )); then
# install missing deps from binary packages (using pacman -S)
msg "$(gettext "Installing missing dependencies...")"
- local ret=0
-
- if (( ! ASROOT )); then
- sudo pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
- else
- pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$?
- fi

- if (( ret )); then
+ if ! run_pacman -S --asdeps $deplist; then
error "$(gettext "Pacman failed to install missing dependencies.")"
exit 1 # TODO: error code
fi
@@ -425,15 +429,9 @@ remove_deps() {
done

msg "Removing installed dependencies..."
- local ret=0
- if (( ! ASROOT )); then
- sudo pacman $PACMAN_OPTS -Rns $deplist || ret=$?
- else
- pacman $PACMAN_OPTS -Rns $deplist || ret=$?
- fi

# Fixes FS#10039 - exit cleanly as package has built successfully
- if (( ret )); then
+ if ! run_pacman -Rns $deplist; then
warning "$(gettext "Failed to remove installed dependencies.")"
return 0
fi
@@ -1116,14 +1114,7 @@ install_package() {
fi
done

- local ret=0
- if (( ! ASROOT )); then
- sudo pacman $PACMAN_OPTS -U ${pkglist} || ret=$?
- else
- pacman $PACMAN_OPTS -U ${pkglist} || ret=$?
- fi
-
- if (( ret )); then
+ if ! run_pacman -U $pkglist; then
warning "$(gettext "Failed to install built package(s).")"
return 0
fi
--
1.6.5.3
 

Thread Tools




All times are GMT. The time now is 07:46 AM.

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