summaryrefslogtreecommitdiffstats
path: root/scripts/makepkg
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/makepkg')
-rwxr-xr-xscripts/makepkg41
1 files changed, 35 insertions, 6 deletions
diff --git a/scripts/makepkg b/scripts/makepkg
index 31e78f97..0361e8bd 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -20,7 +20,7 @@
# USA.
#
-myver='2.9.6'
+myver='2.9.7'
startdir=`pwd`
PKGDEST=$startdir
USE_COLOR="n"
@@ -108,7 +108,7 @@ handledeps() {
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,15 @@ handledeps() {
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 dependencies..."
+ sudo pacman -D $deplist
+ 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 +172,8 @@ handledeps() {
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 +200,7 @@ usage() {
echo " -p <buildscript> 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 <destdir> Write package to <destdir> instead of the working dir"
echo
echo " if -p is not specified, makepkg will look for a PKGBUILD"
@@ -205,6 +215,7 @@ CLEANCACHE=0
INSTALL=0
GENMD5=0
DEP_BIN=0
+DEP_SUDO=0
DEP_SRC=0
NODEPS=0
FORCE=0
@@ -221,6 +232,7 @@ while [ "$#" -ne "0" ]; do
--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 +252,7 @@ while [ "$#" -ne "0" ]; do
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 +273,7 @@ while [ "$#" -ne "0" ]; do
p) BUILDSCRIPT=$OPTARG ;;
r) RMDEPS=1 ;;
s) DEP_BIN=1 ;;
+ S) DEP_SUDO=1 ;;
w) PKGDEST=$OPTARG ;;
-)
OPTIND=0
@@ -280,6 +293,12 @@ while [ "$#" -ne "0" ]; do
shift
done
+# check for sudo
+if [ "$DEP_SUDO" = "1" -a ! "`type -p sudo`" ]; then
+ error "Cannot find the sudo binary! Is sudo installed?"
+ exit 1
+fi
+
# convert a (possibly) relative path to absolute
cd $PKGDEST 2>/dev/null
if [ $? -ne 0 ]; then
@@ -320,6 +339,10 @@ if [ `echo $pkgrel | grep '-'` ]; then
error "pkgrel is not allowed to contain hyphens."
exit 1
fi
+if [ "$install" -a ! -f "$install" ]; then
+ error "install scriptlet ($install) does not exist."
+ exit 1
+fi
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then
if [ "$INSTALL" = "1" ]; then
@@ -631,7 +654,6 @@ echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
echo "pkgdesc = $pkgdesc" >>.PKGINFO
echo "url = $url" >>.PKGINFO
-echo "license = $license" >>.PKGINFO
echo "builddate = $builddate" >>.PKGINFO
echo "packager = $packager" >>.PKGINFO
echo "size = $size" >>.PKGINFO
@@ -639,6 +661,9 @@ if [ "$CARCH" != "" ]; then
echo "arch = $CARCH" >>.PKGINFO
fi
+for it in "${license[@]}"; do
+ echo "license = $it" >>.PKGINFO
+done
for it in "${replaces[@]}"; do
echo "replaces = $it" >>.PKGINFO
done
@@ -688,6 +713,10 @@ fi
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..."
+ sudo pacman -R $makedeplist $deplist
fi
msg "Finished making: $pkgname (`date`)"