Date: Fri, 06 Jul 2001 20:42:10 +0300 From: Maxim Sobolev <sobomax@FreeBSD.org> To: ports@FreeBSD.org Subject: Speeding up package registration Message-ID: <3B45F872.4FB26C6C@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------56A41750712AADB07913AB7A Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Hi, Is you all probably know, our current method for dependency list generation is significantly sub-optimal - it forks make(1) for each dependency's Makefile twice, which could be easily avoided. This is a problem for all ports with many dependencies especially on the slow machines and/or when ports tree is mounted remotely. For example `cd /usr/ports/www/galeon && make package-depends' on my machine takes about 1 minute of wall time to complete (/usr/ports mounted over NFS). This is very annoying, especially when it is necessary to do several install/deinstall cycles to debug/correct layout or update/test pkg-plist. Attached please find perl(1) script that does what the `package-depends' target does, but two times faster. I would like to know what people think about replacing performance-critical portions of bsd.port.mk with scripts in general and about this proposal particularly. Please note, however, that the attached script is not complete (error handling is absent), but it could be easily improved if there is sufficient interest in integrating it. -Maxim --------------56A41750712AADB07913AB7A Content-Type: application/x-perl; name="package-depends.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="package-depends.pl" #!/usr/bin/perl use strict; # Global "constants" my $makecmd = '/usr/bin/make'; if (defined $ENV{'MAKE'}) { $makecmd = $ENV{'MAKE'}; } my $currdir = '.'; # Global variables my %cache; sub get_rt_depends_nr($) { my $dir = shift; # First of all check if we have cached version my $arrayref = $cache{$dir}; if (defined $arrayref) { return @$arrayref; } chdir $dir or die("cannot cd to $dir: $!"); open(MAKEOUT, "$makecmd -V PKGNAME -V LIB_DEPENDS -V RUN_DEPENDS |") or die("cannot fork: $!"); my $pkgname = <MAKEOUT>; my $lib_depends = <MAKEOUT>; my $run_depends = <MAKEOUT>; close(MAKEOUT); chomp($pkgname); chomp($lib_depends); chomp($run_depends); my @runtime_depends; foreach my $dependency (split(/\s+/, $lib_depends), split(/\s+/, $run_depends)) { push(@runtime_depends, (split(/:/, $dependency))[1]); } # If we got thus far then we could print out package name if ($dir ne $currdir) { print "$pkgname\n"; } # Add resolved dependencies into cache $cache{$dir} = \@runtime_depends; return @runtime_depends; } sub get_rt_depends($) { my $dir = shift; my @top_depends = &get_rt_depends_nr($dir); foreach my $path (@top_depends) { &get_rt_depends($path); } } &get_rt_depends($currdir) --------------56A41750712AADB07913AB7A-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B45F872.4FB26C6C>