From owner-freebsd-ports Sat Oct 9 8:20:33 1999 Delivered-To: freebsd-ports@freebsd.org Received: from rr.iij4u.or.jp (h048.p105.iij4u.or.jp [210.130.105.48]) by hub.freebsd.org (Postfix) with SMTP id 66BEC15032 for ; Sat, 9 Oct 1999 08:20:25 -0700 (PDT) (envelope-from sada@rr.iij4u.or.jp) Received: (qmail 3668 invoked by uid 1000); 10 Oct 1999 00:20:24 +0900 Date: 10 Oct 1999 00:20:24 +0900 Message-ID: <19991009152024.3667.sada@rr.iij4u.or.jp> To: kris@hub.freebsd.org Cc: mmuir@es.co.nz, scrappy@hub.org, freebsd-ports@FreeBSD.ORG, sada@FreeBSD.org Subject: pkg_remove (Re: install newer version over old one...) In-Reply-To: Your message of "Thu, 7 Oct 1999 11:03:38 JST". From: sada@rr.IIJ4U.OR.JP (SADA Kenji) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Mailer: mnews [version 1.21] 1997-12/23(Tue) Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >> Probably safer to manually pkg_delete all of the kde* packages first - >> this way you won't get bitten by any dependencies (e.g. linking against >> wrong library versions when you recompile, or 1.1.2 finding leftover files >> from 1.1.1 and acting weirdly, etc). Plus you won't have any port turds in >> your tree from files which disappeared or moved in 1.1.2. This script may help you. The script `pkg_remove' would remove specified package and whole packages which depends to it directry/indirectry. You can remove all netscape packages with 'pkg_remove netscape', all kde packages with 'pkg_remove kde' all packages which depends to libtool with 'pkg_remove libtool', all package with 'pkg_remove ALL'. -- #!/usr/bin/perl # $Id: pkg_remove,v 1.2 1999/09/13 13:46:12 sada Exp $ use Getopt::Std; getopts('n'); die("usage: x [-n] ALL| [, [..]]\n -n : only tell what will take place.\n") if (@ARGV < 1); $pkg_dbdir = "/var/db/pkg"; opendir(PKG_DBDIR, $pkg_dbdir); while ($pkg = readdir(PKG_DBDIR)) { next if $pkg =~ m/^\./; $req_by{$pkg} = ''; if (-f "$pkg_dbdir/$pkg/+REQUIRED_BY") { open(REQ_B, "$pkg_dbdir/$pkg/+REQUIRED_BY"); $req_by{$pkg} = join('', ); } } while ($a = shift) { while (($key, $val) = each(%req_by)) { if ($a eq 'ALL' || $key =~ m/^$a/) { &remove_package($key); } } } sub remove_package { my ($pkg) = @_; return if ($pkg_removed{$pkg}); my @r = split(/\n/, $req_by{$pkg}); my $p; &remove_package($p) while $p = shift(@r); print "remove: $pkg\n"; system "pkg_delete $pkg" unless ($opt_n); $pkg_removed{$pkg} = 'YES'; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message