From owner-freebsd-ports@FreeBSD.ORG Wed Jan 18 04:51:11 2012 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB8581065672 for ; Wed, 18 Jan 2012 04:51:11 +0000 (UTC) (envelope-from stephen@missouri.edu) Received: from wilberforce.math.missouri.edu (wilberforce.math.missouri.edu [128.206.184.213]) by mx1.freebsd.org (Postfix) with ESMTP id 830BD8FC14 for ; Wed, 18 Jan 2012 04:51:11 +0000 (UTC) Received: from [127.0.0.1] (wilberforce.math.missouri.edu [128.206.184.213]) by wilberforce.math.missouri.edu (8.14.5/8.14.5) with ESMTP id q0I4p9oD039009; Tue, 17 Jan 2012 22:51:10 -0600 (CST) (envelope-from stephen@missouri.edu) Message-ID: <4F164FBE.9050004@missouri.edu> Date: Tue, 17 Jan 2012 22:51:10 -0600 From: Stephen Montgomery-Smith User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111108 Thunderbird/3.1.16 MIME-Version: 1.0 To: Kevin Oberman References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------090707060508020500080607" Cc: ports@FreeBSD.org Subject: Re: Upgrading libs with many dependent ports X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jan 2012 04:51:12 -0000 This is a multi-part message in MIME format. --------------090707060508020500080607 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 01/17/2012 07:51 PM, Kevin Oberman wrote: > I have just been cleaning up the mess caused by the upgrade of xcb-utils. > On my systmes I have hundreds of ports that will be re-built by the methods > listed in UPDATING, even though the vast majority of them are only > dependent on other ports that are dependent on xcb-utils, but don't > actually load any of the libraries in xcb-utils. It is a huge waste of time > and CPU cycles. > > I think that I can see two ways of eliminating the rebuilding of ports that > don't need it. One is rather manual but can be done now while the other > wou;d be automatic, but would need to be written by someone who is far > better at writing shell scripts than I. > > The manual method would be to install sysutils/bsdadminscripts and use a > command like `pkg_libchk | grep -E "xcb-.+.so" | sort> tmpfile` to provide > a list of ports that actually are linked to the libraries in question. This > would be fed into portmaster to rebuild just these ports. (I guess I could > use awk and uniq to remove repeats.) > > Should this become a preferred method of handling this problem? You mean something like the attached script? Type perl pkg_libchk xcb-util-0.3.6,1 and it tells you all the ports that have xcb-util-0.3.6,1 as a lib-depends. On my system I get 38 ports that require upgrading. All the other 248 dependencies installed on my system are only run-depends, and so don't need to be upgraded. I wrote it using perl, because I think a shell script would be quite a bit slower. And it is already quite slow as it is. It looks worth implementing, because it looks like it could save considerable compilation time. If other people think this tool is useful, someone could clean up the script (e.g. it isn't PREFIX friendly, and assumes the port database is /var/db/pkg, etc). It could also be written as a C program without too much trouble. --------------090707060508020500080607 Content-Type: text/plain; name="pkg_libchk" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pkg_libchk" #!/usr/bin/perl -w use strict; my %lib_found; my %ldd; sub pkg_libchk { my $req="/var/db/pkg/$_[0]/+REQUIRED_BY"; return if ! -e $req; my @libs; open(my $C,"/var/db/pkg/$_[0]/+CONTENTS") || die; while (<$C>) { if (!/^\@/ && /\/(lib[^\/]+\.so)$/) { push @libs,$1; } } close $C; return if $#libs==-1; open(my $R,$req) || die; while (my $r=<$R>) { next if defined($lib_found{$r}); chomp $r; open(my $C,"/var/db/pkg/$r/+CONTENTS") || die; while (my $f=<$C>) { chomp $f; if ($f !~ /^@/) { if (!defined($ldd{$f})) { $ldd{$f} = `ldd "/usr/local/$f" 2>/dev/null`; } foreach my $l (@libs) { if ($ldd{$f} =~/$l/) { if (!defined($lib_found{$r})) { print "$r\n"; $lib_found{$r}=1; pkg_libchk($r); goto DONE; } } } } } DONE: close($C); } close($R); } die if ! -e "/var/db/pkg/$ARGV[0]"; pkg_libchk($ARGV[0]); --------------090707060508020500080607--