Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Nov 2003 17:47:40 +0100 (CET)
From:      Stefan Walter <sw@gegenunendlich.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/59304: Maintainer update: sysutils/pkg_cutleaves -> pkg_cutleaves-20031115
Message-ID:  <20031115164740.DD12B3975@kyuzo.dunkelkammer.void>
Resent-Message-ID: <200311151650.hAFGoNqM061511@freefall.freebsd.org>

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

>Number:         59304
>Category:       ports
>Synopsis:       Maintainer update: sysutils/pkg_cutleaves -> pkg_cutleaves-20031115
>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 Nov 15 08:50:23 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Walter
>Release:        FreeBSD 5.1-RELEASE-p2 i386
>Organization:
Infinity Approximation Task Force
>Environment:
System: FreeBSD kyuzo.dunkelkammer.void 5.1-RELEASE-p2 FreeBSD 5.1-RELEASE-p2 #0: Wed Sep 24 11:41:19 CEST 2003 root@kyuzo.dunkelkammer.void:/usr/src/sys/i386/compile/KYUZO i386

>Description:
Update sysutils/pkg_cutleaves.
A few minor changes:
- Show comment/short description of each package when it's offered for
  deinstallation
- Optionally ('-c') print comments when listing leaves, too
- _Sorted_ output of deinstalled packages
>How-To-Repeat:
Huh?
>Fix:
--- pkg_cutleaves-20031115.patch begins here ---
diff -urN pkg_cutleaves.old/Makefile pkg_cutleaves/Makefile
--- pkg_cutleaves.old/Makefile	Sat Nov 15 17:11:22 2003
+++ pkg_cutleaves/Makefile	Sat Nov 15 17:20:05 2003
@@ -8,7 +8,7 @@
 #
 
 PORTNAME=	pkg_cutleaves
-PORTVERSION=	20030727
+PORTVERSION=	20031115
 CATEGORIES=	sysutils
 MASTER_SITES=	# none
 DISTFILES=	# none
diff -urN pkg_cutleaves.old/src/pkg_cutleaves pkg_cutleaves/src/pkg_cutleaves
--- pkg_cutleaves.old/src/pkg_cutleaves	Sat Nov 15 17:11:22 2003
+++ pkg_cutleaves/src/pkg_cutleaves	Sat Nov 15 17:18:14 2003
@@ -25,13 +25,14 @@
 # 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.1 2003/09/30 14:19:27 leeym Exp $
+# $FreeBSD$
 
 # Interactive script for deinstalling "leaf" packages;
 # requires the portupgrade tools
 #
-# Syntax: pkg_cutleaves [-l] [-x] [-R]
+# Syntax: pkg_cutleaves [-c] [-l] [-x] [-R]
 # Options:
+#   -c: Show comments, too; only works with '-l' (ignored otherwise)
 #   -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'
@@ -41,7 +42,7 @@
 my $dbdir = "/var/db/pkg";
 my $excludefile = "/usr/local/etc/pkg_leaves.exclude";
 my $pkgdeinstall = "/usr/local/sbin/pkg_deinstall";
-my ($opt_listonly, $opt_excludelist, $opt_recursive);
+my ($opt_comments, $opt_listonly, $opt_excludelist, $opt_recursive);
 my $exclpattern;
 
 # Read the exclude list if the file exists
@@ -71,26 +72,36 @@
 	return $excl_pattern;
 }
 
-# Get a list of all leaves
+# Get a hash (name => comment) of all leaves
 sub get_leaves {
 	my $db_dir = $_[0];
 	my $excl_pattern = $_[1];
-	my @pkgdirs;
+	my %leaves;
 	opendir(DBDIR, $db_dir)
 		or die "Can't open package db directory $db_dir!";
 	while(defined(my $file = readdir(DBDIR))) {
 		my $path = $db_dir . '/' . $file;
 		my $reqlist = $path . '/+REQUIRED_BY';
+		my $commentfile = $path . '/+COMMENT';
 		# Exclude non-directories, "." and ".."
-		if (($file ne ".") && ($file ne "..") && (-d $path) && (!-s $reqlist)) {
+		if (($file ne ".") && ($file ne "..") && (-d $path) && (!-e $reqlist)) {
 			# Exclude packages matching exclude pattern, if requested
 			unless ($file =~ m/$excl_pattern/) {
-				@pkgdirs = (@pkgdirs, $file);
+				# Read package's short description/comment
+				my $comment;
+				if ((-s $commentfile) && (open(COMMENT, $commentfile))) {
+					$comment = <COMMENT>;
+					chomp($comment);
+					close(COMMENT);
+				} else {
+					$comment = "No short description";
+				}
+				$leaves{$file} = $comment;
 			}
 		}
 	}
 	closedir(DBDIR);
-	return @pkgdirs;
+	return %leaves;
 }
 
 # Examine command line arguments
@@ -102,8 +113,13 @@
 	elsif ($arg eq "-l") {
 		$opt_listonly = 1;
 	}
+	elsif ($arg eq "-c") {
+		$opt_comments = 1;
+	}
 	elsif ($arg eq "-R") {
 		$opt_recursive = 1;
+	} else {
+		warn "Unrecognized command line argument $arg ignored.\n";
 	}
 }
 
@@ -118,9 +134,13 @@
 
 if ($opt_listonly) {
 	# Just print out the list of leaves, one per line
-	my @leaveslist = get_leaves($dbdir, $exclpattern);
-	foreach my $leaf (sort @leaveslist) {
-		print "$leaf\n";
+	my %leaves = get_leaves($dbdir, $exclpattern);
+	foreach my $leaf (sort keys %leaves) {
+		if ($opt_comments) {
+			print "$leaf - $leaves{$leaf}\n";
+		} else {
+			print "$leaf\n";
+		}
 	}
 } else {
 	my %leavestokeep;
@@ -130,9 +150,10 @@
 	my $again = "y";
 	ROUND: while($again eq "y") {
 		# Get list of packages and put them into an array
-		my @leaves = get_leaves($dbdir, $exclpattern);
-		LEAVESLOOP: foreach my $leaf (sort @leaves) {
+		my %leaves = get_leaves($dbdir, $exclpattern);
+		LEAVESLOOP: foreach my $leaf (sort keys %leaves) {
 			if (!$leavestokeep{$leaf}) {
+				print "$leaf - $leaves{$leaf}\n";
 				print "$leaf - [keep]/(d)elete/(f)lush marked pkgs/(a)bort? ";
 				my $answer = substr(lc(<STDIN>), 0, 1);
 
@@ -177,9 +198,9 @@
 		print "\n";
 	} # ROUND
 
-	# print list of removed packages
+	# print list of removed packages, sorted lexically
 	print "** Deinstalled packages:\n";
-	foreach my $cutleaf (@cutleaves) {
+	foreach my $cutleaf (sort @cutleaves) {
 		print "$cutleaf\n";
 	}
 }
diff -urN pkg_cutleaves.old/src/pkg_cutleaves.1 pkg_cutleaves/src/pkg_cutleaves.1
--- pkg_cutleaves.old/src/pkg_cutleaves.1	Sat Nov 15 17:11:22 2003
+++ pkg_cutleaves/src/pkg_cutleaves.1	Sat Nov 15 17:12:04 2003
@@ -2,7 +2,7 @@
 .SH NAME
 pkg_cutleaves \- deinstall 'leaf' packages
 .SH SYNOPSIS
-.B pkg_cutleaves [-l] [-x] [-R]
+.B pkg_cutleaves [-c] [-l] [-x] [-R]
 .SH DESCRIPTION
 .B pkg_cutleaves
 finds installed 'leaf' packages, i.e. packages that are not referenced
@@ -18,6 +18,9 @@
 to work properly, so it might be a good idea to run pkgdb(1) before
 running pkg_cutleaves.
 .SH OPTIONS
+.IP -c
+When listing leaf packages, also print their comments/short
+descriptions. Will be ignored unless the '-l' parameter is given, too.
 .IP -l
 List leaf packages only, one per line, and don't ask for anything to be
 deinstalled.
--- pkg_cutleaves-20031115.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?20031115164740.DD12B3975>