Date: Mon, 14 Jan 2002 12:00:31 +0200 From: Sheldon Hearn <sheldonh@starjuice.net> To: Maxim Sobolev <sobomax@FreeBSD.org> Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: ports/Tools/scripts chkdepschain.py Message-ID: <85630.1011002431@axl.seasidesoftware.co.za> In-Reply-To: Your message of "Sun, 13 Jan 2002 04:07:05 PST." <200201131207.g0DC75t15510@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 13 Jan 2002 04:07:05 PST, Maxim Sobolev wrote:
> Modified files:
> Tools/scripts chkdepschain.py
> Log:
> Add license and cvs tag.
FWIW, I've been using the following perl script to do this for a while.
I usually use it with a Makefile like this:
MY_FAVOURITES?= \
graphics/xv \
mail/fetchmail \
www/linux-netscape47-navigator
...
MY_FULL_LIST!= ${.CURDIR}/Tools/portdeps ${MY_FAVOURITES}
SUBDIR?= ${MY_FULL_LIST}
update:
@cvs -qR update -dPA ${SUBDIR}
.include <bsd.port.subdir.mk>
I use this to ensure that every dependency of every one of my favourites is
rebuilt and reinstalled in the correct order.
Ciao,
Sheldon.
#!/usr/bin/perl -w
#
# Takes one or more "port name" arguments, each consisting of the name of a
# port, preceded by its primary category and a forward slash, e.g.
#
# databases/gnats
#
# EXAMPLE:
#
# cd /usr/ports
# portdeps `make -f ./makefile -V SUBDIR`
#
use strict;
my $PROGNAME = 'portdeps';
my %desired;
my %required_by;
my %mustbuild;
my %seen;
my %unresolved;
my @buildlist;
my $basedir;
my $loop_prot;
my $deps_only;
$basedir = `pwd`;
chomp $basedir;
if (defined($ARGV[0]) and $ARGV[0] eq '-d') {
$deps_only = 1;
shift @ARGV;
}
foreach (@ARGV) {
$unresolved{$_} = 1;
$desired{$_} = 1;
}
$loop_prot = 100;
while (keys %unresolved and $loop_prot--) {
foreach my $port (keys %unresolved) {
my (@index_parts, $make_out, @prereqs);
next if $seen{$port}++;
$mustbuild{$port} = 1;
delete $unresolved{$port};
chdir($basedir) or
die "$PROGNAME: chdir: $basedir: $!\n";
chdir($port) or
die "$PROGNAME: chdir: $port: $!\n";
$make_out = `make describe`;
if ($?) {
die "$PROGNAME can't make describe: $port\n";
}
@index_parts = split(/\|/, $make_out);
$index_parts[1] =~ /([^\/]+\/[^\/]+)$/;
$port = $1;
@prereqs = split(' ', "$index_parts[7] $index_parts[8]");
foreach my $req_path (@prereqs) {
my $req;
$req_path =~ /([^\/]+\/[^\/]+)$/;
$req = $1;
if (exists $required_by{$req}) {
push(@{$required_by{$req}}, $port);
} else {
$required_by{$req} = [ $port ];
$unresolved{$req} = 1;
}
}
}
}
$loop_prot = 100;
while (keys %mustbuild and $loop_prot--) {
CANDIDATE:
foreach my $candidate (keys %mustbuild) {
foreach my $dependency (@{$required_by{$candidate}}) {
if (not grep(/^$dependency$/, @buildlist)) {
next CANDIDATE;
}
}
unshift(@buildlist, $candidate);
delete($mustbuild{$candidate});
}
}
foreach my $port (@buildlist) {
if (not $deps_only or not exists $desired{$port}) {
print "$port\n";
}
}
exit 0;
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?85630.1011002431>
