Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jul 2002 10:33:18 +0200
From:      Sheldon Hearn <sheldonh@starjuice.net>
To:        Eric Anholt <eta@lclark.edu>
Cc:        John Angelmo <john@veidit.net>, current@FreeBSD.ORG
Subject:   Re: Still no XFree86-4
Message-ID:  <20020722083318.GK15711@starjuice.net>
In-Reply-To: <1027307313.1068.32.camel@anholt.dyndns.org>
References:  <3D3929DF.4020200@veidit.net> <1027307313.1068.32.camel@anholt.dyndns.org>

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

--A6N2fC+uXW/VQSAv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On (2002/07/21 21:08), Eric Anholt wrote:

> You don't have XFree86-4 uninstalled, or don't have it uninstalled
> successfully.  Just removing the XFree86-4 metaport doesn't remove the
> miniports that contain the actual files.  If you are going to build
> without using portupgrade, you should start from scratch wrt XFree86
> (all XFree86-4 ports uninstalled along with imake-4).

I find the situation with the XFree86-4 metaports annoying, so allow me
to share my "portdeps" solution.

I use this perl script to build all dependencies of a port, in the
correct order, before building the port itself.

I use /usr/ports/makefile as follows:

| MY_STUFF?=	\
| 	archivers/unzip \
| 	...
| 	x11/XFree86-4 \
| 	...
| 	x11/xlockmore
| 
| MY_FULL_LIST!=  ${.CURDIR}/Tools/portdeps ${MY_STUFF}
| SUBDIR?=	${MY_FULL_LIST}
| 
| update:
| 	@cvs -qR update -dPA ${SUBDIR}
| 
| .include <bsd.port.subdir.mk>

The script /usr/ports/Tools/portdeps is attached.  I wrote it in a hurry
ages ago, so it's probably a little sucky.

Then, I can do this to build all the ports I want, along with all their
dependencies, in the correct order:

	cd /usr/ports
	make install
	make clean

Or, I can just build one particular port, with all its dependencies, in
the correct order:

	cd /usr/ports
	make MY_STUFF=x11/XFree86-4

Ciao,
Sheldon.

--A6N2fC+uXW/VQSAv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=portdeps

#!/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 {$_ eq $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;

--A6N2fC+uXW/VQSAv--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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