Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Nov 1995 21:37:44 GMT
From:      Chris Stenton <jacs@gnome.co.uk>
To:        asami@cs.berkeley.edu
Cc:        ports@freebsd.org
Subject:   new version of "updated" perl script.
Message-ID:  <jacs-9510302137.AA000119079@hawk.gnome.co.uk>
In-Reply-To: <199511161257.EAA00906@silvia.HIP.Berkeley.EDU>

next in thread | previous in thread | raw e-mail | index | archive | help


>> 
>> 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 = <INDEXFH>;
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";
}







Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?jacs-9510302137.AA000119079>