----- Original Message -----
From: "Thomas Schuerger" <[EMAIL PROTECTED]>
To: "Will Andrews" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, June 06, 2000 3:25 PM
Subject: Re: Check for ports updates
> > > Is there already a tool that checks the installed ports for available
> > > updates in /usr/ports?
> > >
> > > I've written such a tool, which seems to work fine already. Anyone
> > > interested?
> >
> > pkg_version(1)
>
> Ah, haven't seen that before. The output of pkg_version is very
> canonical, but not very readable for humans. And it's slower than my
> version... ;-)
>
> Here is my version called "ports_updates":
>
>
> ---------
>
> #!/usr/bin/perl
>
>
############################################################################
####
> # $Id: ports_updates,v 1.1 2000/06/01 20:24:06 schuerge Exp $
> #
> # 20000601 schuerge first checkin
> #
> # TODO: Make version check more sophisticated. Currently the version
strings are
> # compared lexicographically, which may sometimes not be what is
expected.
>
############################################################################
####
> #
> # ports_updates - fast check for available updates of installed ports
> #
> # (C) 2000 by Thomas Schürger Mail: [EMAIL PROTECTED]
> #
> # invocation:
> # ports_updates
> #
> # description:
> # Checks for each installed port if a newer version is
available
> # in /usr/ports. Ports are output in a sorted manner.
> #
> # Uses efficient merge-sort like algorithm for detecting
updated
> # port versions. The file /usr/ports/INDEX is inspected for
> # detecting updates, which is not updated daily in the ports
> # collection. Therefore the results are just almost exact.
> #
>
############################################################################
####
>
> $installedports = `\\ls -1 /var/db/pkg | sort -t "-" +0 -1`;
> @installedports = split(/\n/, $installedports);
>
> $c = 0;
> foreach $i ( @installedports )
> {
> next if($i =~ /^\./); # super-user ls also lists dot-files
> $i =~ /(.*)-([^\-].*)/;
> $installedname[$c] = $1;
> $installedversion[$c] = $2;
> $c++;
> }
>
> $ports = ` cut -f "1-2" -d "|" /usr/ports/INDEX | sort -t "-" +0 -1`;
> @ports = split(/\n/, $ports);
>
> $c = 0;
> foreach $i ( @ports )
> {
> $i =~ /^(.*)-([^\-\|].*)\|(.*)/;
> $name[$c] = $1;
> $version[$c] = $2;
> $location[$c] = $3;
> # $location[$c] =~ s/^\/usr\/ports\///;
> $c++;
> }
>
> @a = stat("/usr/ports/INDEX");
> $time = localtime($a[9]);
> $age = -M "/usr/ports/INDEX";
>
> if($age >= 30)
> {
> printf("Ports available: %4d (last port index update:
%s)\n",($#ports+1),$time);
> }
> else
> {
> printf("Ports available: %4d (last port index update %d day%s
ago)\n",($#ports+1),$age,$age == 1 ? "" : "s");
> }
>
> printf("Ports installed: %4d\n",($#installedname+1));
>
> $c = 0; # counter for @ports
> $d = 0; # counter for @installedports
>
> while($c <= $#name && $d <= $#installedname)
> {
> $a = $name[$c] cmp $installedname[$d];
>
> # printf("%4d %-30s %-10s %4d %-30s %-10s
$a\n",$c,$name[$c],$version[$c],$d,$installedname[$d],$installedversion[$d])
;
>
> if($a == 0)
> {
> $ver = $version[$c];
> $instver = $installedversion[$d];
>
> if($ver gt $instver) # newer version available?
> {
> if(!$header) # has the table header not been printed yet?
> {
> print "\nThe following installed ports should be
updated:\n\n";
> print "Port name /usr/ports Installed Port
location\n";
> print
"--------------------------------------------------------------------------\
n";
> $header = 1;
> }
>
> printf("%-20s %-12s %-10s
%s\n",$name[$c],$ver,$instver,$location[$c]);
> }
> }
>
> $c++ if($a <= 0);
>
> if($a > 0)
> {
> push(@obsolete,$installedname[$d]."-".$installedversion[$d]);
> }
>
> $d++ if($a >= 0);
> }
>
> if(!$header)
> {
> print "\nCongratulations, all installed ports are up-to-date!\n";
> }
>
> if($#obsolete >= 0)
> {
> print "\nThe following ports are installed but are no longer available
in /usr/ports\n";
> print "(or now have a different name) and should be considered for
deletion:\n\n";
>
> foreach $i (@obsolete)
> {
> print "$i\n",
> }
> }
>
> ------
>
>
> Ciao,
> Thomas Schürger. http://www.menden.org
>
>
Maybe you can submit this as a port :)
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message