1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-27 00:57:50 +00:00

Update to 20031115

PR:		ports/59304
Submitted by:	Stefan Walter (maintainer)
Approved by:	marcus (backup mentor)
This commit is contained in:
Pav Lucistnik 2003-11-16 18:50:53 +00:00
parent 702a86578e
commit 605bf1dfcf
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=94114
6 changed files with 80 additions and 32 deletions

View File

@ -8,7 +8,7 @@
#
PORTNAME= pkg_cutleaves
PORTVERSION= 20030727
PORTVERSION= 20031115
CATEGORIES= sysutils
MASTER_SITES= # none
DISTFILES= # none

View File

@ -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";
}
}

View File

@ -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.

View File

@ -8,7 +8,7 @@
#
PORTNAME= pkg_cutleaves
PORTVERSION= 20030727
PORTVERSION= 20031115
CATEGORIES= sysutils
MASTER_SITES= # none
DISTFILES= # none

View File

@ -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";
}
}

View File

@ -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.