[pacman-dev] My thoughts for development

Jürgen Hötzel juergen at hoetzel.info
Wed Dec 20 14:53:08 EST 2006


Hi,

> 2. Remove use of multiple `` or $() calls to the same function. I have
> a local update of calling $(id -u) once and storing it to a variable
> for later use, I can publish a patch sometime.

I'm surprised by the usage of back-ticks do get the effective uid, the
shell already has an built-in READONLY variable (enclosed).

Jürgen
-------------- next part --------------
Index: scripts/makepkg
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/scripts/makepkg,v
retrieving revision 1.21
diff -u -p -r1.21 makepkg
--- scripts/makepkg	19 Dec 2006 07:39:44 -0000	1.21
+++ scripts/makepkg	20 Dec 2006 19:50:40 -0000
@@ -163,7 +163,7 @@ handledeps() {
 	local missingdeps=0
 	local deplist="$*"
 	local haveperm=0
-	if [ \( "`id -u`" = "0" -a "$INFAKEROOT" != "1" \) -o "$DEP_SUDO" = 1 ]; then
+	if [ \( "$EUID" = "0" -a "$INFAKEROOT" != "1" \) -o "$DEP_SUDO" = 1 ]; then
 		haveperm=1
 	fi
 
@@ -402,7 +402,7 @@ if [ "$CLEANCACHE" = "1" ]; then
         rm -rf "${SRCDEST}"/*
         exit 0
     else
-        if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
+        if [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
             msg "Cleaning up source files from the cache."
             rm -rf /var/cache/pacman/src/*
             exit 0
@@ -478,7 +478,7 @@ fi
 
 # Enter the fakeroot environment if necessary.  This will call the makepkg script again
 # as the fake root user.  We detect this by passing a sentinel option (-F) to makepkg
-if [ "`id -u`" != "0" ]; then
+if [ "$EUID" != "0" ]; then
 	if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
 		if [ `type -p fakeroot` ]; then
 			msg "Entering fakeroot environment"
@@ -577,11 +577,11 @@ for netfile in ${source[@]}; do
             exit 1
 			exit 1
 		fi
-		if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
+		if [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
 			mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
             if [ -n "$SRCDEST" ]; then
                 mkdir -p $SRCDEST && cp "$file" $SRCDEST
-            elif [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
+            elif [ "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
                 mkdir -p /var/cache/pacman/src && cp "$file" /var/cache/pacman/src
             else
                 cp "$file" ..
@@ -706,7 +706,7 @@ else
     done
 fi
 
-if [ "`id -u`" = "0" ]; then
+if [ "$EUID" = "0" ]; then
 	# chown all source files to root.root
 	chown -R root.root $startdir/src
 fi
@@ -920,7 +920,7 @@ if [ "$CLEANUP" = "1" ]; then
     rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
 fi
 
-if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
+if [ "$RMDEPS" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
 	msg "Removing installed dependencies..."
 	pacman $PACMAN_OPTS -R $makedeplist $deplist
 elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" ]; then
@@ -938,7 +938,7 @@ fi
 
 msg "Finished making: $pkgname  (`date`)"
 
-if [ "$INSTALL" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
+if [ "$INSTALL" = "1" -a "$EUID" = "0" -a "$INFAKEROOT" != "1" ]; then
 	msg "Installing package with pacman -U..."
 	pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}
 	exit $?


More information about the pacman-dev mailing list