From owner-freebsd-ports Fri Jul 6 11:13:49 2001 Delivered-To: freebsd-ports@freebsd.org Received: from kalaid.f2f.com.ua (kalaid.f2f.com.ua [62.149.0.33]) by hub.freebsd.org (Postfix) with ESMTP id 0F5AB37B403; Fri, 6 Jul 2001 11:13:39 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Received: from Mail-In.Net (borey.f2f.com.ua [62.149.0.24]) by kalaid.f2f.com.ua (8.11.3/8.11.1) with ESMTP id f66IGQC19637; Fri, 6 Jul 2001 21:16:26 +0300 (EEST) (envelope-from sobomax@FreeBSD.org) Received: from vega.vega.com ([212.35.189.228]) by Mail-In.Net (8.11.3/8.H.Z) with ESMTP id f66IEYZ15896; Fri, 6 Jul 2001 21:14:34 +0300 (EEST) Received: from FreeBSD.org (big_brother.vega.com [192.168.1.1]) by vega.vega.com (8.11.4/8.11.3) with ESMTP id f66Hg4q73179; Fri, 6 Jul 2001 20:42:04 +0300 (EEST) (envelope-from sobomax@FreeBSD.org) Message-ID: <3B45F872.4FB26C6C@FreeBSD.org> Date: Fri, 06 Jul 2001 20:42:10 +0300 From: Maxim Sobolev Organization: Vega International Capital X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en,uk,ru MIME-Version: 1.0 To: ports@FreeBSD.org Subject: Speeding up package registration Content-Type: multipart/mixed; boundary="------------56A41750712AADB07913AB7A" Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 = ; my $lib_depends = ; my $run_depends = ; 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