Date: 2005-07-20 Initial Package Version: 2.9.6 Origin: Miklos Vajna Description: Adds dependency auto-resolution support using sudo to makepkg. doc/makepkg.8.in | 5 +++++ scripts/makepkg | 41 +++++++++++++++++++++++++++++++++++++---- src/pacman.c | 6 +++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff -Naur pacman-2.9.6.orig/doc/makepkg.8.in pacman-2.9.6/doc/makepkg.8.in --- pacman-2.9.6.orig/doc/makepkg.8.in 2004-08-04 07:57:17.000000000 +0200 +++ pacman-2.9.6/doc/makepkg.8.in 2005-08-12 21:23:03.000000000 +0200 @@ -384,6 +384,11 @@ pacman will download the missing packages from a package repository and install them for you. .TP +.B "\-S, \-\-sudosync" +Install missing dependencies using pacman and sudo. This is the same as \fB-s\fP +except that makepkg will call pacman with sudo. This means you don't have to +build as root to use dependency auto-resolution. +.TP .B "\-w " Write the resulting package file to the directory \fI\fP instead of the current working directory. diff -Naur pacman-2.9.6.orig/scripts/makepkg pacman-2.9.6/scripts/makepkg --- pacman-2.9.6.orig/scripts/makepkg 2005-06-10 22:54:29.000000000 +0200 +++ pacman-2.9.6/scripts/makepkg 2005-08-12 21:23:03.000000000 +0200 @@ -108,7 +108,7 @@ local missingdeps=0 local deplist="$*" local haveperm=0 - if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then + if [ \( "`id -u`" = "0" -a "$INFAKEROOT" != "1" \) -o "$DEP_SUDO" = 1 ]; then haveperm=1 fi @@ -122,6 +122,23 @@ exit 1 fi # TODO: check deps again to make sure they were resolved + elif [ "$DEP_SUDO" = "1" ]; then + # install missing deps from binary packages (using pacman -S and sudo) + msg "Installing missing dependenciessss..." + if [ "$INFAKEROOT" = "1" ]; then + FAKEROOTKEY2=$FAKEROOTKEY + unset FAKEROOTKEY + fi + sudo pacman -D $deplist + if [ "$INFAKEROOT" = "1" ]; then + FAKEROOTKEY=$FAKEROOTKEY2 + unset FAKEROOTKEY2 + fi + if [ "$?" = "127" ]; then + error "Failed to install missing dependencies." + exit 1 + fi + # TODO: check deps again to make sure they were resolved elif [ "$DEP_SRC" = "1" ]; then # install missing deps by building them from source. # we look for each package name in $ABSROOT and build it. @@ -163,8 +180,8 @@ fi elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then - warning "Cannot auto-install missing dependencies as a normal user!" - plain "Run makepkg as root to resolve dependencies automatically." + warning "Cannot auto-install missing dependencies as a normal user without sudo!" + plain "Run makepkg as root or with -S to resolve dependencies automatically." fi missingdeps=1 fi @@ -191,6 +208,7 @@ echo " -p Use an alternate build script (instead of PKGBUILD)" echo " -r, --rmdeps Remove installed dependencies after a successful build" echo " -s, --syncdeps Install missing dependencies with pacman" + echo " -S, --sudosync Install missing dependencies with pacman and sudo" echo " -w Write package to instead of the working dir" echo echo " if -p is not specified, makepkg will look for a PKGBUILD" @@ -205,6 +223,7 @@ INSTALL=0 GENMD5=0 DEP_BIN=0 +DEP_SUDO=0 DEP_SRC=0 NODEPS=0 FORCE=0 @@ -221,6 +240,7 @@ --clean) CLEANUP=1 ;; --cleancache) CLEANCACHE=1 ;; --syncdeps) DEP_BIN=1 ;; + --sudosync) DEP_SUDO=1 ;; --builddeps) DEP_SRC=1 ;; --nodeps) NODEPS=1 ;; --noextract) NOEXTRACT=1 ;; @@ -240,7 +260,7 @@ exit 1 ;; -*) - while getopts "cCsbdehifgj:mnorp:w:-" opt; do + while getopts "cCsSbdehifgj:mnorp:w:-" opt; do case $opt in c) CLEANUP=1 ;; C) CLEANCACHE=1 ;; @@ -261,6 +281,7 @@ p) BUILDSCRIPT=$OPTARG ;; r) RMDEPS=1 ;; s) DEP_BIN=1 ;; + S) DEP_SUDO=1 ;; w) PKGDEST=$OPTARG ;; -) OPTIND=0 @@ -688,6 +709,18 @@ if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then msg "Removing installed dependencies..." pacman -R $makedeplist $deplist + +elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" ]; then + msg "Removing installed dependencies..." + if [ "$INFAKEROOT" = "1" ]; then + FAKEROOTKEY2=$FAKEROOTKEY + unset FAKEROOTKEY + fi + sudo pacman -R $makedeplist $deplist + if [ "$INFAKEROOT" = "1" ]; then + FAKEROOTKEY=$FAKEROOTKEY2 + unset FAKEROOTKEY2 + fi fi msg "Finished making: $pkgname (`date`)" diff -Naur pacman-2.9.6.orig/src/pacman.c pacman-2.9.6/src/pacman.c --- pacman-2.9.6.orig/src/pacman.c 2005-04-25 20:19:24.000000000 +0200 +++ pacman-2.9.6/src/pacman.c 2005-08-12 21:23:03.000000000 +0200 @@ -158,9 +158,9 @@ /* check for permission */ pm_access = READ_ONLY; - if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) { - if(pmo_op == PM_SYNC && !pmo_s_sync && - (pmo_s_search || pmo_s_printuris || pmo_group || pmo_q_list || pmo_q_info)) { + if(pmo_op != PM_MAIN && pmo_op != PM_QUERY) { + if((pmo_op == PM_SYNC && !pmo_s_sync && + (pmo_s_search || pmo_s_printuris || pmo_group || pmo_q_list || pmo_q_info)) || (pmo_op == PM_DEPTEST && !pmo_d_resolve)) { /* special case: PM_SYNC can be used w/ pmo_s_search by any user */ } else { if(myuid) {