diff options
author | matthew <matthew@FreeBSD.org> | 2012-03-13 01:48:26 +0800 |
---|---|---|
committer | matthew <matthew@FreeBSD.org> | 2012-03-13 01:48:26 +0800 |
commit | a9ea0d135acd405a820af760e1e2e188d5741482 (patch) | |
tree | 26158ad22975219d508040caedae4493e6726ff4 /ports-mgmt | |
parent | eee881f4c6c56cc6329205e8e398549e8ea3635e (diff) | |
download | freebsd-ports-gnome-a9ea0d135acd405a820af760e1e2e188d5741482.tar.gz freebsd-ports-gnome-a9ea0d135acd405a820af760e1e2e188d5741482.tar.zst freebsd-ports-gnome-a9ea0d135acd405a820af760e1e2e188d5741482.zip |
Add patches to make pkg_cutleaves compatible with pkgng, conditional
on WITH_PKGNG being defined.
No change to the default package, so no version number or portrevision
bump.
Approved by: stefan (maintainer) shaun (mentor)
Feature safe: yes
Diffstat (limited to 'ports-mgmt')
-rw-r--r-- | ports-mgmt/pkg_cutleaves/Makefile | 14 | ||||
-rw-r--r-- | ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves | 117 | ||||
-rw-r--r-- | ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves.1 | 64 | ||||
-rw-r--r-- | ports-mgmt/pkg_cutleaves/pkg-descr | 3 |
4 files changed, 197 insertions, 1 deletions
diff --git a/ports-mgmt/pkg_cutleaves/Makefile b/ports-mgmt/pkg_cutleaves/Makefile index 3d4cbfdab6f4..769df470ffc2 100644 --- a/ports-mgmt/pkg_cutleaves/Makefile +++ b/ports-mgmt/pkg_cutleaves/Makefile @@ -23,6 +23,11 @@ MAN1= pkg_cutleaves.1 PLIST_FILES= sbin/pkg_cutleaves +.if defined(WITH_PKGNG) +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-pkg_cutleaves \ + ${FILESDIR}/extra-patch-pkg_cutleaves.1 +.endif + do-extract: ${MKDIR} ${WRKSRC} ${CP} ${FILESDIR}/pkg_cutleaves ${FILESDIR}/pkg_cutleaves.1 ${WRKSRC} @@ -31,6 +36,14 @@ post-patch: @${REINPLACE_CMD} -e \ 's,/usr/local/etc/pkg_leaves.exclude,${PREFIX}/etc/pkg_leaves.exclude,' \ ${WRKSRC}/pkg_cutleaves.1 +.if defined(WITH_PKGNG) + @${REINPLACE_CMD} \ + -e 's,/usr/local/etc/pkg_leaves.exclude,${PREFIX}/etc/pkg_leaves.exclude,' \ + -e 's,/usr/local/sbin/pkg delete -y,${PKG_DELETE},' \ + -e 's,/usr/local/sbin/pkg query,${PKG_QUERY},' \ + -e 's,/usr/bin/perl,${PERL},' \ + ${WRKSRC}/pkg_cutleaves +.else @${REINPLACE_CMD} \ -e 's,/usr/local/etc/pkg_leaves.exclude,${PREFIX}/etc/pkg_leaves.exclude,' \ -e 's,/usr/sbin/pkg_delete,${PKG_DELETE},' \ @@ -38,6 +51,7 @@ post-patch: -e 's,/var/db/pkg,${PKG_DBDIR},' \ -e 's,/usr/bin/perl,${PERL},' \ ${WRKSRC}/pkg_cutleaves +.endif do-install: ${INSTALL_SCRIPT} ${WRKSRC}/pkg_cutleaves ${PREFIX}/sbin/pkg_cutleaves diff --git a/ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves b/ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves new file mode 100644 index 000000000000..997850013632 --- /dev/null +++ b/ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves @@ -0,0 +1,117 @@ +Index: pkg_cutleaves +=================================================================== +RCS file: /home/ncvs/ports/ports-mgmt/pkg_cutleaves/files/pkg_cutleaves,v +retrieving revision 1.3 +diff -u -r1.3 pkg_cutleaves +--- pkg_cutleaves 12 Aug 2009 17:50:48 -0000 1.3 ++++ pkg_cutleaves 6 Mar 2012 12:39:29 -0000 +@@ -28,10 +28,9 @@ + + # Interactive script for deinstalling "leaf" packages + # +-# Syntax: pkg_cutleaves [-cFgLlRVx] ++# Syntax: pkg_cutleaves [-cgLlRVx] + # Options: + # -c: Show comments, too; only works with '-l' (ignored otherwise) +-# -F: Fix package db after each deinstallation run (via 'pkgdb -F') + # -g: Generate exclude list from kept/installed leaf packages + # -L: Interpret exclude file as list of packages that *should* be installed + # -l: List leaf packages only, don't ask if they should be deinstalled +@@ -43,15 +42,14 @@ + use Getopt::Std; + use strict; + +-my $dbdir = "/var/db/pkg"; + my $excludefile = "/usr/local/etc/pkg_leaves.exclude"; +-my $pkgdeinstall = "/usr/sbin/pkg_delete"; +-my @pkgdb_args = ("/usr/local/sbin/pkgdb", "-F"); ++my @pkgdeinstall = (qw{/usr/local/sbin/pkg delete -y}); ++my @pkgquery = (qw{/usr/local/sbin/pkg query}); + my $exclpattern; + my %leavestokeep; + my %opt; + +-getopts('cFgLlRVx', \%opt); ++getopts('cgLlRVx', \%opt); + set_excl_pattern(); + + # LIST MODE +@@ -77,7 +75,7 @@ + my ($file, $required) = @$pkg; + # Clobber any exclude patterns that match this package + for (my $i = 0; $i < @excludes; $i++) { +- if ($file =~ /\Q@excludes[$i]\E/) { ++ if ($file =~ /\Q$excludes[$i]\E/) { + splice(@excludes, $i--, 1); + } + } +@@ -219,7 +217,7 @@ + foreach my $leaf (sort keys %leavestocut) { + $noff++; + print "Deleting $leaf (package $noff of $ncuts).\n"; +- my @deinstall_args = ($pkgdeinstall, $leaf); ++ my @deinstall_args = (@pkgdeinstall, $leaf); + if ((my $status = system(@deinstall_args) >> 8) != 0) { + print STDERR "\n\n$0: pkg_deinstall returned $status - exiting, fix this first.\n\n"; + last ROUND; +@@ -227,15 +225,6 @@ + push @cutleaves, $leaf; + } + +- # Run 'pkgdb -F' if requested +- if ($opt{F}) { +- print "Running 'pkgdb -F'.\n"; +- if ((my $status = system(@pkgdb_args) >> 8) != 0) { +- print STDERR "\n\n$0: pkgdb returned $status - exiting, fix this first.\n\n"; +- last ROUND; +- } +- } +- + # Get new list of leaf packages and put them into a hash + %leaves = get_leaves(); + +@@ -328,15 +317,13 @@ + # + sub get_packages { + my @pkgs; +- opendir(DBDIR, $dbdir) +- or die "Can't open package db directory $dbdir!"; +- while (defined(my $file = readdir(DBDIR))) { +- my $path = join('/', $dbdir, $file); +- unless ($file =~ /^\.+$/o || !(-d $path)) { +- push @pkgs, [$file, -s $path . '/+REQUIRED_BY', join('/', $path, '+COMMENT')]; +- } ++ open(PKGQUERY, '-|', @pkgquery, '-a', '%n-%v\t%?r\t%c') ++ or die "Couldn't read output from $pkgquery[0]!"; ++ while (my $p = <PKGQUERY>) { ++ chomp($p); ++ push(@pkgs, [ split(/\t/, $p) ]); + } +- closedir DBDIR; ++ close PKGQUERY; + return @pkgs; + } + +@@ -347,19 +334,14 @@ + my %leaves; + my @pkgs = get_packages(); + foreach my $pkg (@pkgs) { +- my ($file, $required, $commentfile) = @$pkg; ++ my ($file, $required, $comment) = @$pkg; + unless ($required) { + if ($file =~ $exclpattern) { + $leavestokeep{$file} = 1; + } + else { +- # Read package's short description/comment +- my $comment; +- if ((-s $commentfile) && (open(COMMENT, $commentfile))) { +- chomp($comment = <COMMENT>); +- } +- else { +- $comment = 'No short description'; ++ unless($comment) { ++ $comment = 'No short description'; + } + $leaves{$file} = $comment; + } diff --git a/ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves.1 b/ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves.1 new file mode 100644 index 000000000000..4c48ee43c6e6 --- /dev/null +++ b/ports-mgmt/pkg_cutleaves/files/extra-patch-pkg_cutleaves.1 @@ -0,0 +1,64 @@ +Index: pkg_cutleaves.1 +=================================================================== +RCS file: /home/ncvs/ports/ports-mgmt/pkg_cutleaves/files/pkg_cutleaves.1,v +retrieving revision 1.2 +diff -u -r1.2 pkg_cutleaves.1 +--- pkg_cutleaves.1 25 Mar 2008 18:55:30 -0000 1.2 ++++ pkg_cutleaves.1 6 Mar 2012 14:14:47 -0000 +@@ -8,14 +8,14 @@ + .Nd deinstall 'leaf' packages + .Sh SYNOPSIS + .Nm +-.Op Fl cFglRVx ++.Op Fl cglRVx + .Sh DESCRIPTION + .Nm pkg_cutleaves + finds installed + .Dq Li "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_delete(1)). Once the packages marked for removal have been ++pkg-delete(1)). Once the packages marked for removal have been + flushed/deinstalled, you'll be asked if you want to do another run (i.e. to see + packages that have become 'leaves' now because you've deinstalled the package(s) + that depended on them. +@@ -24,10 +24,6 @@ + .Fl R + below to bypass interactive dependency removal). In every run you will be shown + only packages that you haven't marked for keeping, yet. +-.Pp +-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 + .Nm . + .Sh OPTIONS + .Pp +@@ -40,16 +36,6 @@ + .Fl l + parameter is given, too. + .Pp +-.It Fl F +-Run +-.Dq Li "pkgdb -F" +-after each deinstallation run, to make sure the package registry database +-is up to date. ( +-.Ar Note: +-This is mostly for convenience; it shouldn't be necessary to run +-.Dq Li "pkgdb -F" +-after each run, but it doesn't hurt, either.) +-.Pp + .It Fl L + Interpret exclude file as a list of leaf packages that + .Ar should +@@ -147,8 +133,9 @@ + .Xr vi 1 . + .El + .Sh SEE ALSO +-.Xr pkg_deinstall 1 , +-.Xr pkgdb 1 , ++.Xr pkg 8 , ++.Xr pkg-info 8 , ++.Xe pkg-delete 8 , + .Xr portsclean 1 + .Sh AUTHOR + .An Stefan Walter <sw@gegenunendlich.de> diff --git a/ports-mgmt/pkg_cutleaves/pkg-descr b/ports-mgmt/pkg_cutleaves/pkg-descr index 7aa045b16eac..cd7406a733cd 100644 --- a/ports-mgmt/pkg_cutleaves/pkg-descr +++ b/ports-mgmt/pkg_cutleaves/pkg-descr @@ -1,3 +1,4 @@ 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)). +each one if you want to keep or deinstall it (via pkg_deinstall(1) or +pkg-delete(8)). |