Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b05480db4478b43113757549522f92c3eaa0b236

commit b05480db4478b43113757549522f92c3eaa0b236
Author: Michel Hermier <[email protected]>
Date:   Mon Mar 17 21:50:55 2014 +0100

makepkg: Add pacman(-g2) command that wraps and fix environment before calling 
pacman-g2.

diff --git a/scripts/makepkg b/scripts/makepkg
index b3b6bfc..6982878 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -681,6 +681,54 @@ makepkg_mount() {
}
_makepkg_commands[mount]=makepkg_mount

+makepkg_pacman_g2_usage() {
+       $ECHO "Usage: $0 pacman-g2 [OPTION]... [--] PACMAN_G2_OPTIONS..."
+       $ECHO "Run pacman -g2 in from makepkg."
+       $ECHO
+       $ECHO "Options for pacman-g2 command:"
+       $ECHO "  -h, --help             This help."
+       $ECHO "  --sudo                 Run pacman-g2 with sudo."
+}
+
+makepkg_pacman_g2() {
+       local _options_consumed
+       local _option_sudo
+
+       while [ $# -gt 0 ]; do
+               _options_consumed=1
+               case "$1" in
+               -h|--help)
+                       makepkg_pacman_g2_usage
+                       return 0 ;;
+               --sudo) _option_sudo=1 ;;
+               # special options
+               --)     shift; break ;; # End of options
+               --*|-?) break ;; # End of options
+               -*)     # Combined short options
+                       set -- \
+                               "$(echo "$1" | cut -c -2)" \
+                               "-$(echo "$1" | cut -c 3-)" \
+                               "${@:2}"
+                       continue ;;
+               *)      break ;; # End of options
+               esac
+               if ! shift "$_options_consumed"; then
+                       _options_consumed=$(($_options_consumed - 1))
+                       error "Option $1 expects $_options_consumed argument(s)"
+                       return 1
+               fi
+       done
+       set -- "$PACMAN" $PACMAN_OPTS "$@"
+       if [ "$_option_sudo" = 1 -a \( -v FAKEROOTKEY -o "$(id -u)" != 0 \) ]; 
then
+               unset FAKEROOTKEY # Make pacman-g2 not aware it is in fakeroot
+               set -- sudo "$@"
+       fi
+       "$@"
+       return $?
+}
+_makepkg_commands['pacman-g2']=makepkg_pacman_g2
+_makepkg_commands[pacman]=makepkg_pacman_g2
+
# FIXME: Make a command
makepkg_validate() {
# check for no-no's
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to