From owner-freebsd-ports Thu Nov 30 13:38:19 1995 Return-Path: owner-ports Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id NAA25157 for ports-outgoing; Thu, 30 Nov 1995 13:38:19 -0800 Received: from hawk.gnome.co.uk (gnome.intecc.co.uk [194.72.95.90]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id NAA25145 for ; Thu, 30 Nov 1995 13:38:05 -0800 Received: (from jacs@localhost) by hawk.gnome.co.uk (8.6.12/8.6.12) id VAA19151; Thu, 30 Nov 1995 21:37:44 GMT Date: Thu, 30 Nov 1995 21:37:44 GMT From: Chris Stenton Subject: new version of "updated" perl script. To: asami@cs.berkeley.edu Cc: ports@freebsd.org Message-Id: In-Reply-To: <199511161257.EAA00906@silvia.HIP.Berkeley.EDU> Sender: owner-ports@freebsd.org Precedence: bulk >> >> I tried your second version, it looks real nice. The only remaining >> gripe is that if both the old and new versions are still in >> /var/db/pkg, it still reports it. >>Satoshi OK, this version is for the people that don't keep their packages clean. Just running "updated" should give the user a nice clean list of packages that s/he has installed but have since been updated. Chris ----cut---- #!/usr/bin/perl # # $Header: /home/jacs/perl/./updated,v 1.4 1995/11/30 21:17:25 jacs Exp $ # # $Log: updated,v $ # Revision 1.4 1995/11/30 21:17:25 jacs # test for older package versions # #use environment variable PORTSDIR if set unless ($ports = $ENV{'PORTSDIR'}) { $ports = "/usr/ports"; } # #read packages directory and sort in reverse order opendir(PKGDIR, "/var/db/pkg") || die "Could not open /var/db/pkg"; @allfiles = reverse(sort(grep(!/^\.\.?$/, readdir(PKGDIR)))); closedir(PKGDIR); #prune out older versions of the same package. #due to the reverse sorting of @allfiles need only keep #first occurrence of a package $lastpackage = ""; while (@allfiles) { $pkg = shift @allfiles; ($pruned = $pkg) =~ s/-[^-]*$/-/; if ($pruned ne $lastpackage) { push (@packages, $pkg); $lastpackage = $pruned; } } #read ports index open(INDEXFH, "$ports/INDEX") || die "Could not open $ports/INDEX"; @indexfile = ; close(INDEXFH); #search index file for each package ENTRY: foreach $pkg (@packages) { foreach $line(@indexfile) { if(index($line, $pkg) ==0) { next ENTRY; } } #package is not in the INDEX file #checking to see if it has been updated or removed printf "port %20s has been ", $pkg; $pkg =~ s/-[^-]*$/-/; foreach $line(@indexfile) { if(index($line, $pkg) ==0) { $line =~ s/\|.*//; print "updated to\t", $line; next ENTRY; } } print "removed \n"; }