[pacman-dev] CVS update of pacman-lib/scripts (makepkg)

Dan McGee dan at archlinux.org
Thu Mar 8 23:35:06 EST 2007


    Date: Thursday, March 8, 2007 @ 23:35:06
  Author: dan
    Path: /home/cvs-pacman/pacman-lib/scripts

Modified: makepkg (1.56 -> 1.57)

* Added confirmation step to makepkg -C operation to ensure user is deleting
  exactly what they think they are.


---------+
 makepkg |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)


Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.56 pacman-lib/scripts/makepkg:1.57
--- pacman-lib/scripts/makepkg:1.56	Sat Mar  3 13:38:57 2007
+++ pacman-lib/scripts/makepkg	Thu Mar  8 23:35:04 2007
@@ -486,16 +486,28 @@
 
 if [ "$CLEANCACHE" = "1" ]; then
 	#fix flyspray feature request #5223
-	if [ -n "$SRCDEST" ]; then
-		msg "Cleaning up source files from the cache."
-		rm -rf "$SRCDEST"/*
-		if [ $? -ne 0 ]; then
-			error "Problem removing files; you may not have correct permissions in $SRCDEST"
-			exit 1
+	if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then
+		msg "Cleaning up ALL files from $SRCDEST."
+		echo -n "    Are you sure you wish to do this? [Y/n] "
+		read answer
+		answer=$(echo $answer | tr [:upper:] [:lower:])
+		if [ "$answer" = "yes" -o "$answer" = "y" ]; then
+			rm -rf "$SRCDEST"/*
+			if [ $? -ne 0 ]; then
+				error "Problem removing files; you may not have correct permissions in $SRCDEST"
+				exit 1
+			else
+				# removal worked
+				msg "Source cache cleaned."
+				exit 0
+			fi
 		else
+			# answer = no
+			"No files have been removed."
 			exit 0
 		fi
 	else
+		# SRCDEST undefined (should never happen)
 		error "Source destination must be defined in makepkg.conf."
 		exit 1
 	fi




More information about the pacman-dev mailing list