DragonFly users List (threaded) for 2004-12
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
new version: Re: Fix for ports INDEX generation - should make portupgrade work normally
I have optimized the patch to make_index, halving the additional time it
takes to run.
portupgrade now works fine with ports overrides, at least on my machine.
the enclosed patch can be applied directly to the original make_index.
Go in /usr/ports/Tools and run patch < make_index.diff
Raphael
Raphael Marmier wrote:
hi all,
I've modified the /usr/ports/Tools/make_index script to accomodate ports
overrides.
AFAIK, this should solve portupgrade's problems on DragonFly.
Simply copy this script in place of the original. (can someone tell me
how I generate a diff that can be used with patch, like a pro?)
I would feel better if it receives some real world testing from
DragonFly users before I submit it to the FreeBSD folk ;)
Regards,
Raphael
--- make_index Tue Dec 21 00:50:16 2004
+++ make_index2 Mon Dec 20 23:22:44 2004
@@ -6,25 +6,55 @@
# *-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.
+#
+# This script is compatible DragonFlyBSD's ports overrides
require 5.002;
# Helper function to map a directory to a pkgname.
sub by_path {
my ($name, $port) = @_;
+ my ($result,$revpath,$portname) = undef;
- # If a direct mapping exists, then use it.
- return $by_path{$name} if (defined $by_path{$name});
+ # If the mapping is in our cache, use it
+ return $cache{$name} if (defined $cache{$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});
+ # Remove the $PORTSDIR part of the path
+ $path = $result[0] if @result = $name =~ m!^$pwd/(.*)$!o;
+
+ # Reverse the path so we can match from the end of a string.
+ $revpath = reverse($path);
+
+ my $portname;
+
+ # Find the key and use it to get the port's name.
+ foreach (@pathes) {
+ if ( index($_,$revpath) == 0 ) {
+ $portname = $by_path{$_};
+ $cache{$name} = $portname;
+ }
+ }
+ return $portname if (defined $portname);
# 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});
+
+ # Remove the $PORTSDIR part of the path
+ $path = $result[0] if @result = $name =~ m!^$pwd/(.*)$!o;
+
+ # Reverse the path so we can match from the end of a string.
+ $revpath = reverse($path);
+
+ # Find the key and use it to get the port's name.
+ foreach (@pathes) {
+ if ( index($_,$revpath) == 0 ) {
+ $portname = $by_path{$_};
+ $cache{$name} = $portname;
+ }
+ }
+ return $portname if (defined $portname);
print STDERR "make_index: $port: no entry for $name\n";
return undef;
@@ -99,14 +129,15 @@
chomp;
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];
+ # We store the key reversed as we need to match keys starting from the end.
+ $revpath = reverse($f[1]);
+ $by_path{$revpath} = $name = $f[0];
+
+ # Build a list of keys so we can use a regex to locate one
+ push(@pathes,$revpath);
# Create a hash table of the infomation we need about this port.
my $pkg = {
@@ -123,6 +154,9 @@
# This is a cheap way of preserving the order of the entries.
push(@names, $name);
}
+
+# We need a path resolution cache
+%cache = ();
# For each port perform the mapping between directory and pkgnames.
foreach $name (keys %index) {
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]