openbsd-ports/infrastructure/build/out-of-date
bernd f4a024d5a8 Rewrite in perl. It compares package signatures instead of package names.
This needs a lot of testing, so please test!

Suggestions and ideas from sturm@ and espie@.

ok espie@
2005-10-01 13:17:54 +00:00

92 lines
2.7 KiB
Perl
Executable File

#!/usr/bin/perl
# $OpenBSD: out-of-date,v 1.10 2005/10/01 13:17:54 bernd Exp $
#
# Copyright (c) 2005 Bernd Ahlers <bernd@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
use strict;
use warnings;
use OpenBSD::PackageInfo;
use OpenBSD::PackingList;
use OpenBSD::PackageName;
my $portsdir = $ENV{PORTSDIR} || "/usr/ports";
my $pkg = {};
my $port = {};
my $subdirs = "";
my @output = ();
my @notfound = ();
print STDERR "Collecting installed packages\n";
for my $name (installed_packages(1)) {
my ($stem, $version) = OpenBSD::PackageName::splitname($name);
my $plist = OpenBSD::PackingList->from_installation($name,
\&OpenBSD::PackingList::UpdateInfoOnly);
$pkg->{$stem}->{version} = $version;
$pkg->{$stem}->{subdir} = $plist->{extrainfo}->{subdir};
$pkg->{$stem}->{signature} = $plist->signature;
$pkg->{$stem}->{subdir} =~ s/mystuff\///;
$pkg->{$stem}->{subdir} =~ s/\/usr\/ports\///;
my ($dir) = split(/,/, $pkg->{$stem}->{subdir});
if (-d "$portsdir/$dir") {
$subdirs .= $pkg->{$stem}->{subdir} . " ";
} else {
push(@notfound, $pkg->{$stem}->{subdir});
}
}
print STDERR "Collecting port versions\n";
my @cmd = ("cd", "$portsdir", "&&", "SUBDIR=\"$subdirs\"", "ECHO_MSG=:",
"REPORT_PROBLEM=true", "make", "print-package-signature");
open(my $fh, join(' ', @cmd) . " |");
while (<$fh>) {
chomp;
next unless $_;
my ($name) = split(/,/, $_);
my ($stem, $version) = OpenBSD::PackageName::splitname($name);
$port->{$stem}->{version} = $version;
$port->{$stem}->{signature} = $_;
}
close($fh);
for my $stem (keys %{$pkg}) {
next unless $port->{$stem};
if ($pkg->{$stem}->{signature} eq $port->{$stem}->{signature}) {
next;
} else {
push(@output, sprintf("%-40s # %s -> %s\n",
$pkg->{$stem}->{subdir}, $pkg->{$stem}->{version},
$port->{$stem}->{version}));
}
}
print STDERR "Outdated ports:\n\n";
print $_ for sort @output;
print STDERR "\n";
if (@notfound > 0) {
print STDERR "Ports that can't be found in the official ports tree:\n";
for my $pkg (sort @notfound) {
print STDERR " ", $pkg, "\n";
}
}