Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Dec 2003 23:48:59 +0100 (CET)
From:      Stefan Walter <sw@gegenunendlich.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Yen-Ming Lee <leeym@leeym.com>
Subject:   ports/60639: Update port: sysutils/pkg_cutleaves to pkg_cutleaves-20031227
Message-ID:  <20031227224859.D2F0F3926@kyuzo.dunkelkammer.void>
Resent-Message-ID: <200312272250.hBRMoK9m087481@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         60639
>Category:       ports
>Synopsis:       Update port: sysutils/pkg_cutleaves to pkg_cutleaves-20031227
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 27 14:50:20 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Walter
>Release:        FreeBSD 5.2-RC i386
>Organization:
Infinity Approximation Task Force
>Environment:
System: FreeBSD kyuzo.dunkelkammer.void 5.2-RC FreeBSD 5.2-RC #1: Thu Dec 25 20:45:48 CET 2003 root@kyuzo.dunkelkammer.void:/usr/obj/usr/src/sys/KYUZO i386
>Description:
- check for empty +REQUIRED_BY files, too (Yen-Ming Lee <leeym@leeym.com>)
- optionally run 'pkgdb -F' after each run (new parameter '-F')
- add info messages for progress status when deinstalling packages
- minor code cleanups, improvement of messages/comments
- remove the 'usage' text from the pkg-descr file
>How-To-Repeat:
	
>Fix:
--- pkg_cutleaves-20031227.patch begins here ---
diff -urN pkg_cutleaves.old/Makefile pkg_cutleaves/Makefile
--- pkg_cutleaves.old/Makefile	Sat Dec 27 23:05:37 2003
+++ pkg_cutleaves/Makefile	Sat Dec 27 23:16:08 2003
@@ -8,7 +8,7 @@
 #
 
 PORTNAME=	pkg_cutleaves
-PORTVERSION=	20031115
+PORTVERSION=	20031227
 CATEGORIES=	sysutils
 MASTER_SITES=	# none
 DISTFILES=	# none
@@ -42,6 +42,9 @@
 	  ${WRKDIR}/pkg_cutleaves
 	@${REINPLACE_CMD} -e \
 	  's,/usr/local/sbin/pkg_deinstall,${LOCALBASE}/sbin/pkg_deinstall,' \
+	  ${WRKDIR}/pkg_cutleaves
+	@${REINPLACE_CMD} -e \
+	  's,/usr/local/sbin/pkgdb,${LOCALBASE}/sbin/pkgdb,' \
 	  ${WRKDIR}/pkg_cutleaves
 	@${REINPLACE_CMD} -e \
 	  's,/var/db/pkg,${PKG_DBDIR},' \
diff -urN pkg_cutleaves.old/pkg-descr pkg_cutleaves/pkg-descr
--- pkg_cutleaves.old/pkg-descr	Sat Dec 27 23:05:37 2003
+++ pkg_cutleaves/pkg-descr	Sat Dec 27 23:22:29 2003
@@ -1,10 +1,3 @@
 pkg_cutleaves finds installed 'leaf' packages, i.e. packages that are
 not referenced by any other installed package, and lets you decide for
 each one if you want to keep or deinstall it (via pkg_deinstall(1)).
-
-Usage: pkg_cutleaves [-l] [-x] [-R]
-  -l: List leaf packages only, one per line, and don't ask for anything
-      to be deinstalled.
-  -x: Exclude packages matching expressions given in the exclude file.
-  -R: Run 'pkg_deinstall -R' instead of plain 'pkg_deinstall', so packages
-      the removed leaf packages depend(ed) on will be deinstalled, too.
diff -urN pkg_cutleaves.old/src/pkg_cutleaves pkg_cutleaves/src/pkg_cutleaves
--- pkg_cutleaves.old/src/pkg_cutleaves	Sat Dec 27 23:05:37 2003
+++ pkg_cutleaves/src/pkg_cutleaves	Sat Dec 27 23:11:38 2003
@@ -25,24 +25,26 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD: ports/sysutils/pkg_cutleaves/src/pkg_cutleaves,v 1.2 2003/11/16 18:50:53 pav Exp $
+# $FreeBSD$
 
 # Interactive script for deinstalling "leaf" packages;
 # requires the portupgrade tools
 #
-# Syntax: pkg_cutleaves [-c] [-l] [-x] [-R]
+# Syntax: pkg_cutleaves [-c] [-F] [-l] [-R] [-x]
 # Options:
 #   -c: Show comments, too; only works with '-l' (ignored otherwise)
+#   -F: Fix package db after each deinstallation run (via 'pkgdb -F')
 #   -l: List leaf packages only, don't ask if they should be deinstalled
-#   -x: Honor exclude list in $excludefile
 #   -R: Run 'pkg_deinstall -R' instead of plain 'pkg_deinstall'
+#   -x: Honor exclude list in $excludefile
 
 use strict;
 
 my $dbdir = "/var/db/pkg";
 my $excludefile = "/usr/local/etc/pkg_leaves.exclude";
 my $pkgdeinstall = "/usr/local/sbin/pkg_deinstall";
-my ($opt_comments, $opt_listonly, $opt_excludelist, $opt_recursive);
+my @pkgdb_args = ("/usr/local/sbin/pkgdb", "-F");
+my ($opt_comments, $opt_listonly, $opt_excludelist, $opt_recursive, $opt_pkgdb);
 my $exclpattern;
 
 # Read the exclude list if the file exists
@@ -84,7 +86,7 @@
 		my $reqlist = $path . '/+REQUIRED_BY';
 		my $commentfile = $path . '/+COMMENT';
 		# Exclude non-directories, "." and ".."
-		if (($file ne ".") && ($file ne "..") && (-d $path) && (!-e $reqlist)) {
+		if (($file ne ".") && ($file ne "..") && (-d $path) && (!-s $reqlist)) {
 			# Exclude packages matching exclude pattern, if requested
 			unless ($file =~ m/$excl_pattern/) {
 				# Read package's short description/comment
@@ -107,17 +109,20 @@
 # Examine command line arguments
 while(@ARGV) {
 	my $arg = shift(@ARGV);
-	if ($arg eq "-x") {
-		$opt_excludelist = 1;
+	if ($arg eq "-c") {
+		$opt_comments = 1;
+	}
+	elsif ($arg eq "-F") {
+		$opt_pkgdb = 1;
 	}
 	elsif ($arg eq "-l") {
 		$opt_listonly = 1;
 	}
-	elsif ($arg eq "-c") {
-		$opt_comments = 1;
-	}
 	elsif ($arg eq "-R") {
 		$opt_recursive = 1;
+	}
+	elsif ($arg eq "-x") {
+		$opt_excludelist = 1;
 	} else {
 		warn "Unrecognized command line argument $arg ignored.\n";
 	}
@@ -149,8 +154,11 @@
 	# Loop while the user wants to
 	my $again = "y";
 	ROUND: while($again eq "y") {
-		# Get list of packages and put them into an array
+		# Get list of leaf packages and put them into a hash
 		my %leaves = get_leaves($dbdir, $exclpattern);
+		# Always start with an empty list of leaves to cut
+		%leavestocut = ();
+
 		LEAVESLOOP: foreach my $leaf (sort keys %leaves) {
 			if (!$leavestokeep{$leaf}) {
 				print "$leaf - $leaves{$leaf}\n";
@@ -175,10 +183,14 @@
 				}
 			}
 		} # LEAVESLOOP
-		
+
+		# Initialize 'progress meter'
+		my $ncuts = keys %leavestocut;
+		my $noff = 0;
 		# loop through packages marked for removal and pkg_deinstall them
 		foreach my $leaf (sort keys %leavestocut) {
-			print "Deleting $leaf.\n";
+			$noff++;
+			print "Deleting $leaf, package $noff of $ncuts.\n";
 			my @deinstall_args;
 			if ($opt_recursive) {
 				@deinstall_args = ($pkgdeinstall, '-R', $leaf);
@@ -186,22 +198,32 @@
 				@deinstall_args = ($pkgdeinstall, $leaf);
 			}
 			if ((my $status = system(@deinstall_args) >> 8) != 0) {
-				print "\nError: pkg_deinstall returned $status - exiting, fix this first.\n\n";
+				print "\npkg_cutleaves: pkg_deinstall returned $status - exiting, fix this first.\n\n";
 				last ROUND;
 			}
 			@cutleaves = (@cutleaves, $leaf);
-			delete $leavestocut{$leaf};
 		}
-		
-		print "Once more ((y)es/[no])? ";
+
+		# Run 'pkgdb -F' if requested
+		if ($opt_pkgdb) {
+			print "Running 'pkgdb -F'.\n";
+			if ((my $status = system(@pkgdb_args) >> 8) != 0) {
+				print "\npkg_cutleaves: pkgdb returned $status - exiting, fix this first.\n\n";
+				last ROUND;
+			}
+		}
+
+		print "Go on with new leaf packages ((y)es/[no])? ";
 		$again = substr(lc(<STDIN>), 0, 1);
 		print "\n";
 	} # ROUND
 
-	# print list of removed packages, sorted lexically
+	# print list of removed packages, sorted lexically, and their number
 	print "** Deinstalled packages:\n";
 	foreach my $cutleaf (sort @cutleaves) {
 		print "$cutleaf\n";
 	}
+	my $noff = @cutleaves;
+	print "** Number of deinstalled packages: $noff\n";
 }
 
diff -urN pkg_cutleaves.old/src/pkg_cutleaves.1 pkg_cutleaves/src/pkg_cutleaves.1
--- pkg_cutleaves.old/src/pkg_cutleaves.1	Sat Dec 27 23:05:37 2003
+++ pkg_cutleaves/src/pkg_cutleaves.1	Sat Dec 27 23:13:13 2003
@@ -2,7 +2,7 @@
 .SH NAME
 pkg_cutleaves \- deinstall 'leaf' packages
 .SH SYNOPSIS
-.B pkg_cutleaves [-c] [-l] [-x] [-R]
+.B pkg_cutleaves [-c] [-F] [-l] [-R] [-x]
 .SH DESCRIPTION
 .B pkg_cutleaves
 finds installed 'leaf' packages, i.e. packages that are not referenced
@@ -21,14 +21,19 @@
 .IP -c
 When listing leaf packages, also print their comments/short
 descriptions. Will be ignored unless the '-l' parameter is given, too.
+.IP -F
+Run 'pkgdb -F' after each deinstallation run, to make sure the package
+registry database is up to date. (Note: This is mostly for convenience;
+it shouldn't be necessary to run 'pkgdb -F' after each run, but it
+doesn't hurt, either.)
 .IP -l
 List leaf packages only, one per line, and don't ask for anything to be
 deinstalled.
-.IP -x
-Exclude packages matching expressions given in the exclude file.
 .IP -R
 Run 'pkg_deinstall -R' instead of plain 'pkg_deinstall', so packages the
 removed leaf packages depend(ed) on will be deinstalled, too.
+.IP -x
+Exclude packages matching expressions given in the exclude file.
 .SH FILES
 .I /usr/local/etc/pkg_leaves.exclude
 .RS
@@ -40,4 +45,4 @@
 .SH AUTHOR
 Stefan Walter <sw@gegenunendlich.de>
 .SH SEE ALSO
-pkg_deinstall(1), portsclean(1)
+pkg_deinstall(1), pkgdb(1), portsclean(1)
--- pkg_cutleaves-20031227.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031227224859.D2F0F3926>