aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils
diff options
context:
space:
mode:
authorpav <pav@FreeBSD.org>2003-11-17 02:50:53 +0800
committerpav <pav@FreeBSD.org>2003-11-17 02:50:53 +0800
commit1bafb1f2176eb14bf01e154a0fe035fae264fc91 (patch)
treea3ba803830aaf5ae7fbae093cadfee860cca91f4 /sysutils
parentdb7436502f0e962ed7304018a068a8ceca6fd6d4 (diff)
downloadfreebsd-ports-gnome-1bafb1f2176eb14bf01e154a0fe035fae264fc91.tar.gz
freebsd-ports-gnome-1bafb1f2176eb14bf01e154a0fe035fae264fc91.tar.zst
freebsd-ports-gnome-1bafb1f2176eb14bf01e154a0fe035fae264fc91.zip
Update to 20031115
PR: ports/59304 Submitted by: Stefan Walter (maintainer) Approved by: marcus (backup mentor)
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/pkg_cutleaves/Makefile2
-rw-r--r--sysutils/pkg_cutleaves/src/pkg_cutleaves49
-rw-r--r--sysutils/pkg_cutleaves/src/pkg_cutleaves.15
3 files changed, 40 insertions, 16 deletions
diff --git a/sysutils/pkg_cutleaves/Makefile b/sysutils/pkg_cutleaves/Makefile
index 14b066efa08b..fa5b982f2faf 100644
--- a/sysutils/pkg_cutleaves/Makefile
+++ b/sysutils/pkg_cutleaves/Makefile
@@ -8,7 +8,7 @@
#
PORTNAME= pkg_cutleaves
-PORTVERSION= 20030727
+PORTVERSION= 20031115
CATEGORIES= sysutils
MASTER_SITES= # none
DISTFILES= # none
diff --git a/sysutils/pkg_cutleaves/src/pkg_cutleaves b/sysutils/pkg_cutleaves/src/pkg_cutleaves
index 355c4093d48d..874f28a4dd08 100644
--- a/sysutils/pkg_cutleaves/src/pkg_cutleaves
+++ b/sysutils/pkg_cutleaves/src/pkg_cutleaves
@@ -30,8 +30,9 @@
# 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 @@ use strict;
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 @@ sub get_excl_pattern {
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 @@ while(@ARGV) {
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_excludelist) {
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 @@ if ($opt_listonly) {
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 @@ if ($opt_listonly) {
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 --git a/sysutils/pkg_cutleaves/src/pkg_cutleaves.1 b/sysutils/pkg_cutleaves/src/pkg_cutleaves.1
index 52b3b3231287..39d22f272bb3 100644
--- a/sysutils/pkg_cutleaves/src/pkg_cutleaves.1
+++ b/sysutils/pkg_cutleaves/src/pkg_cutleaves.1
@@ -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 @@ Note that your package registry database should be up to date for this
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.