From owner-svn-ports-all@FreeBSD.ORG Mon Oct 7 21:32:31 2013 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8F2DB3F6; Mon, 7 Oct 2013 21:32:31 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7C0CE25D0; Mon, 7 Oct 2013 21:32:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r97LWVWS076666; Mon, 7 Oct 2013 21:32:31 GMT (envelope-from bdrewery@svn.freebsd.org) Received: (from bdrewery@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r97LWV1A076664; Mon, 7 Oct 2013 21:32:31 GMT (envelope-from bdrewery@svn.freebsd.org) Message-Id: <201310072132.r97LWV1A076664@svn.freebsd.org> From: Bryan Drewery Date: Mon, 7 Oct 2013 21:32:31 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r329740 - in head: . Tools X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Oct 2013 21:32:31 -0000 Author: bdrewery Date: Mon Oct 7 21:32:30 2013 New Revision: 329740 URL: http://svnweb.freebsd.org/changeset/ports/329740 Log: - Fix 'make index' when system is built with WITHOUT_PORTSNAP by falling back on the perl make_index if needed. With hat: portmgr Reported by: ade Added: head/Tools/make_index - copied unchanged from r329674, head/Tools/make_index Modified: head/Makefile Modified: head/Makefile ============================================================================== --- head/Makefile Mon Oct 7 20:56:50 2013 (r329739) +++ head/Makefile Mon Oct 7 21:32:30 2013 (r329740) @@ -105,6 +105,12 @@ INDEX_SHELL= /bin/sh INDEX_PORTS=. .endif +.if exists(/usr/libexec/make_index) +MAKE_INDEX= /usr/libexec/make_index /dev/stdin +.else +MAKE_INDEX= perl ${.CURDIR}/Tools/make_index +.endif + ${INDEXDIR}/${INDEXFILE}: @${INDEX_ECHO_1ST} "Generating ${INDEXFILE} - please wait.."; \ if [ "${INDEX_PRISTINE}" != "" ]; then \ @@ -135,7 +141,7 @@ ${INDEXDIR}/${INDEXFILE}: echo; \ fi; \ exit 1); \ - cat $${tmpdir}/${INDEXFILE}.desc.* | (cd ${.CURDIR} ; /usr/libexec/make_index /dev/stdin) | \ + cat $${tmpdir}/${INDEXFILE}.desc.* | (cd ${.CURDIR} ; ${MAKE_INDEX}) | \ sed -e 's/ */ /g' -e 's/| */|/g' -e 's/ *|/|/g' -e 's./..g' | \ sort -t '|' +1 -2 | \ sed -e 's../.g' > ${INDEXDIR}/${INDEXFILE}.tmp; \ Copied: head/Tools/make_index (from r329674, head/Tools/make_index) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/Tools/make_index Mon Oct 7 21:32:30 2013 (r329740, copy of r329674, head/Tools/make_index) @@ -0,0 +1,180 @@ +#!/usr/bin/perl +# +# $FreeBSD$ +# +# INDEX builds visit each port once and write out each port's +# *-depends as a list of directories, using 'make describe'. This +# script goes back in and maps the directories back to pkgnames, +# fixes up the *-depends list, and writes out the new INDEX file. + +require 5.002; + +# Helper function to map a directory to a pkgname. +sub by_path { + my ($name, $port) = @_; + + # If a direct mapping exists, then use it. + return $by_path{$name} if (defined $by_path{$name}); + + # Make sure we have /usr/ports at the beginning. + $name =~ s!^$pwd!/usr/ports!o; + return $by_path{$name} if (defined $by_path{$name}); + + # Collapse all the '..' sequences. + my @f = split('/', $name), @p = (); + foreach (@f) { (/\.\./) ? pop(@p) : push(@p, $_); } + $name = join('/', @p); + return $by_path{$name} if (defined $by_path{$name}); + + print STDERR "make_index: $port: no entry for $name\n"; + return undef; +} + +# This routine replaces what used to be the time-consuming +# recursive 'depends-list' and 'package-depends' targets. +sub recurse { + my $pkg = shift(@_); + return if $pkg->{checked}; + + # extract-depends = extract-depends + recursive list of run-depends + # for each extract-depends + my @deps = (); + foreach $name (@{$pkg->{edep}}) { + recurse($index{$name}); + push(@deps, @{$index{$name}->{rdep}}); + } + $pkg->{edep} = uniqify(@{$pkg->{edep}}, @deps); + + # same as above except for patch-depends this time + @deps = (); + foreach $name (@{$pkg->{pdep}}) { + recurse($index{$name}); + push(@deps, @{$index{$name}->{rdep}}); + } + $pkg->{pdep} = uniqify(@{$pkg->{pdep}}, @deps); + + # same as above except for fetch-depends this time + @deps = (); + foreach $name (@{$pkg->{fdep}}) { + recurse($index{$name}); + push(@deps, @{$index{$name}->{rdep}}); + } + $pkg->{fdep} = uniqify(@{$pkg->{fdep}}, @deps); + $pkg->{checked} = 1; + + # same as above except for build-depends this time + @deps = (); + foreach $name (@{$pkg->{bdep}}) { + recurse($index{$name}); + push(@deps, @{$index{$name}->{rdep}}); + } + $pkg->{bdep} = uniqify(@{$pkg->{bdep}}, @deps); + $pkg->{checked} = 1; + + # same as above except for run-depends this time + @deps = (); + foreach $name (@{$pkg->{rdep}}) { + recurse($index{$name}); + push(@deps, @{$index{$name}->{rdep}}); + } + $pkg->{rdep} = uniqify(@{$pkg->{rdep}}, @deps); + $pkg->{checked} = 1; + +} + +# Given one or more lists as arguments return the set +# of unique elements among them. +sub uniqify { + my %seen = (); + my @unique = grep {! $seen{$_}++} (@_); + return \@unique; +} + +# Save where we are so that we can map all directories formed +# from ${PORTSDIR} to their canonical location '/usr/ports/...'. +chomp($pwd = `pwd`); + +# Read each line of output generated by the 'index' target. +while (<>) { + chomp; + s/\015$//; + + my @f = split(/\|/); + + # Force to canonical form. + $f[1] =~ s!^$pwd!/usr/ports!o; + $f[4] =~ s!^$pwd!/usr/ports!o; + + # Save directory -> pkgname relationship. + # Note: $f[0] gets clobbered by the splice below so we'll save + # it to a new $name first. + $by_path{$f[1]} = $name = $f[0]; + + # Create a hash table of the infomation we need about this port. + my $pkg = { + 'edep' => [split(/ /, $f[7])], + 'pdep' => [split(/ /, $f[8])], + 'fdep' => [split(/ /, $f[9])], + 'bdep' => [split(/ /, $f[10])], + 'rdep' => [split(/ /, $f[11])], + 'rest' => join('|', splice(@f, 12)), + 'text' => join('|', splice(@f, 0, 7)) + }; + $index{$name} = $pkg; + + # This is a cheap way of preserving the order of the entries. + push(@names, $name); +} + +# For each port perform the mapping between directory and pkgnames. +foreach $name (keys %index) { + my $pkg = $index{$name}; + # first the extract dependencies + if (@{$pkg->{edep}}) { + my @edep = map { by_path($_, $name) } @{$pkg->{edep}}; + $pkg->{edep} = \@edep; + } + # then the patch dependencies + if (@{$pkg->{pdep}}) { + my @pdep = map { by_path($_, $name) } @{$pkg->{pdep}}; + $pkg->{pdep} = \@pdep; + } + # then the fetch dependencies + if (@{$pkg->{fdep}}) { + my @fdep = map { by_path($_, $name) } @{$pkg->{fdep}}; + $pkg->{fdep} = \@fdep; + } + # then the build dependencies + if (@{$pkg->{bdep}}) { + my @bdep = map { by_path($_, $name) } @{$pkg->{bdep}}; + $pkg->{bdep} = \@bdep; + } + # then the run dependencies + if (@{$pkg->{rdep}}) { + my @rdep = map { by_path($_, $name) } @{$pkg->{rdep}}; + $pkg->{rdep} = \@rdep; + } +} + +# With all that done we're finally ready to write out the new +# INDEX file one port at a time. +foreach $name (@names) { + my $pkg = $index{$name}; + if (exists $pkg->{'PRINTED'}) { + print STDERR "Warning: Duplicate INDEX entry: $name\n"; + } else { + recurse($pkg); + print "$pkg->{text}|"; + print join(' ', sort(@{$pkg->{bdep}})) if @{$pkg->{bdep}}; + print "|"; + print join(' ', sort(@{$pkg->{rdep}})) if @{$pkg->{rdep}}; + print "|$pkg->{rest}|"; + print join(' ', sort(@{$pkg->{edep}})) if @{$pkg->{edep}}; + print "|"; + print join(' ', sort(@{$pkg->{pdep}})) if @{$pkg->{pdep}}; + print "|"; + print join(' ', sort(@{$pkg->{fdep}})) if @{$pkg->{fdep}}; + print "\n"; + ++$pkg->{'PRINTED'}; + } +}