[pacman-dev] makepkg fix (FS #5923)

Dan McGee dpmcgee at gmail.com
Sat Jan 6 00:13:39 EST 2007


On 1/2/07, Aaron Griffin <aaronmgriffin at gmail.com> wrote:
> On 12/29/06, James Rosten <seinfeld90 at gmail.com> wrote:
> > This is a fix for Flyspray bug #5923
> > http://bugs.archlinux.org/task/5923.
>
> Committed, thanks alot!
>

While we are getting the refactoring bus moving, I thought this
duplicate code may be worth fixing. I moved the remove deps to a
function call, as it is used in three separate places throughout the
code. There is also one typo fix and an indentation fix in the patch.

-Dan

Index: scripts/makepkg
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/scripts/makepkg,v
retrieving revision 1.27
diff -u -u -r1.27 makepkg
--- scripts/makepkg	2 Jan 2007 16:34:50 -0000	1.27
+++ scripts/makepkg	6 Jan 2007 05:09:06 -0000
@@ -255,6 +255,24 @@
 	return $missingdeps
 }

+removedeps() {
+	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
+		msg "Removing installed dependencies..."
+		if [ "$INFAKEROOT" = "1" ]; then
+			FAKEROOTKEY2=$FAKEROOTKEY
+			unset FAKEROOTKEY
+		fi
+		sudo pacman $PACMAN_OPTS -R $makedeplist $deplist
+		if [ "$INFAKEROOT" = "1" ]; then
+			export FAKEROOTKEY=$FAKEROOTKEY2
+			unset FAKEROOTKEY2
+		fi
+	fi
+}
+
 usage() {
 	echo "makepkg version $myver"
 	echo
@@ -495,7 +513,7 @@
 unset deplist makedeplist
 # fix flyspray bug #5973
 if [ "$NODEPS" = "1" -o "$GENINTEG" = "1" -o "$NOBUILD" = "1" -o
"$REPKG" = "1" ]; then
-	warning "skipping dependecy checks"
+	warning "skipping dependency checks"
 elif [ $(type -p pacman) ]; then
 	msg "Checking Runtime Dependencies..."
 	deplist=$(checkdeps ${depends[@]})
@@ -752,21 +770,7 @@
 		if [ ${PIPESTATUS[0]} -gt 0 ]; then
 			error "Build Failed.  Aborting..."
 			# fix flyspray bug #5923
-			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
-				msg "Removing installed dependencies..."
-				if [ "$INFAKEROOT" = "1" ]; then
-					export FAKEROOTKEY2=$FAKEROOTKEY
-					unset $FAKEROOTKEY
-				fi
-				sudo pacman $PACMAN_OPTS -R $makedeplist $deplist
-				if [ "$INFAKEROOT" = "1" ]; then
-					export FAKEROOTKEY=$FAKEROOTKEY2
-					unset $FAKEROOTKEY2
-				fi
-			fi
+			removedeps
 			exit 2
 		fi
 	else
@@ -777,21 +781,7 @@
 		if [ $? -gt 0 ]; then
 			error "Build Failed.  Aborting..."
 			# fix flyspray bug #5923
-			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
-				msg "Removing installed dependencies..."
-				if [ "$INFAKEROOT" = "1" ]; then
-					export FAKEROOTKEY2=$FAKEROOTKEY
-					unset $FAKEROOTKEY
-				fi
-				sudo pacman $PACMAN_OPTS -R $makedeplist $deplist
-				if [ "$INFAKEROOT" = "1" ]; then
-					export FAKEROOTKEY=$FAKEROOTKEY2
-					unset $FAKEROOTKEY2
-				fi
-			fi
+			removedeps
 			exit 2
 		fi
 	fi
@@ -820,11 +810,11 @@
 	if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
 		# update symlinks to this manpage
 		find $startdir/pkg/{usr{,/local},opt/*}/man -lname "$fn" 2>
/dev/null | while read ln ; do
-		rm -f "$ln"
-		ln -sf "${fn}.gz" "${ln}.gz"
-	done
-	# compress the original
-	gzip -9 "$i"
+			rm -f "$ln"
+			ln -sf "${fn}.gz" "${ln}.gz"
+		done
+		# compress the original
+		gzip -9 "$i"
 	fi
 done

@@ -932,21 +922,8 @@
 	rm -rf ${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*
 fi

-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
-	msg "Removing installed dependencies..."
-	if [ "$INFAKEROOT" = "1" ]; then
-		FAKEROOTKEY2=$FAKEROOTKEY
-		unset FAKEROOTKEY
-	fi
-	sudo pacman $PACMAN_OPTS -R $makedeplist $deplist
-	if [ "$INFAKEROOT" = "1" ]; then
-		export FAKEROOTKEY=$FAKEROOTKEY2
-		unset FAKEROOTKEY2
-	fi
-fi
+# Remove installed deps moved to subroutine; needed above if build fails
+removedeps

 msg "Finished making: $pkgname  ($(date))"




More information about the pacman-dev mailing list