OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-re Date: 21-Nov-2002 15:27:44
Branch: HEAD Handle: 2002112114274400
Modified files:
openpkg-re openpkg-build
Log:
now reads full index hierarchy from FTP server
added heuristics to keep file index usuable
Summary:
Revision Changes Path
1.45 +173 -64 openpkg-re/openpkg-build
____________________________________________________________________________
Index: openpkg-re/openpkg-build
============================================================
$ cvs diff -u -r1.44 -r1.45 openpkg-build
--- openpkg-re/openpkg-build 21 Nov 2002 10:36:27 -0000 1.44
+++ openpkg-re/openpkg-build 21 Nov 2002 14:27:44 -0000 1.45
@@ -246,11 +246,11 @@
if ($rel =~ /^\d+$/) {
print "# $PROG current($rel)\n";
print "# using '$RPM_NPRIV' (build) and '$RPM_PRIV' (install)\n";
- $url = "ftp://ftp.openpkg.org/current/SRC/";
+ $url = "ftp://ftp.openpkg.org/current/";
} elsif ($rel =~ /^(\d+\.\d+)/) {
$rel = $1;
print "# $PROG release($rel)\n";
- $url = "ftp://ftp.openpkg.org/release/$rel/SRC/";
+ $url = "ftp://ftp.openpkg.org/release/$rel/";
} else {
die "FATAL: don't know how to handle this release\n";
}
@@ -331,6 +331,7 @@
my($l) = @_;
$l = [ split(/\n+/, $l) ] unless ref $l;
my(%with) = map { /--define\s*'(\S+)\s+(\S+?)'/ } @$l;
+ return unless %with;
return \%with;
}
@@ -356,46 +357,69 @@
return $t->{OPTIONS};
}
+sub relurl ($$$) {
+ my($url,$fn,$suburl) = @_;
+ my($subfn,$submap);
+
+ unless ($suburl =~ /^\w+:\/\// || $suburl =~ /^\//) {
+ if (defined $fn) {
+ $subfn = $fn;
+ $subfn =~ s/\/[^\/]*$//;
+ $subfn .= '/' unless $subfn =~ /\/$/;
+ $subfn .= $suburl;
+ $suburl = $subfn;
+ } else {
+ $subfn = $url;
+ $subfn =~ s/\/[^\/]*$//;
+ $subfn .= '/' unless $subfn =~ /\/$/;
+ $suburl = "$subfn$suburl";
+ $subfn = undef;
+ }
+ }
+
+ return ($suburl, $subfn);
+}
+
sub get_index ($$$) {
my($url,$fn,$with) = @_;
my($ua,$req,$res,$rdf);
my($bzip2,$curl,$path);
- my(%map);
+ my(%map,@include);
+ my($fetch);
- $url = $fn if defined $fn;
- $url .= '00INDEX.rdf.bz2' if $url =~ /\/$/;
+ $fetch = defined $fn ? $fn : $url;
$bzip2 = $RPM;
$bzip2 =~ s/bin\/rpm$/lib\/openpkg\/bzip2/
or die "FATAL: cannot deduce bzip2 path from $RPM\n";
- $url !~ /\.bz2$/ || -x $bzip2
+ $fetch !~ /\.bz2$/ || -x $bzip2
or die "FATAL: $bzip2 not found\n";
- if ($url =~ /^\w+:/) { # looks like URL scheme
+ if ($fetch =~ /^\w+:/) { # looks like URL scheme
$curl = $RPM;
$curl =~ s/bin\/rpm$/lib\/openpkg\/curl/
or die "FATAL: cannot deduce curl path from $RPM\n";
-x $curl
or die "FATAL: $curl not found\n";
- print "# curling index $url\n";
- if ($url =~ /\.bz2$/) {
- $path = "$curl -q -s -o - \"$url\" | $bzip2 -dc |";
+ print "# curling index $fetch\n";
+ if ($fetch =~ /\.bz2$/) {
+ $path = "$curl -q -s -o - \"$fetch\" | $bzip2 -dc |";
} else {
- $path = "$curl -q -s -o - \"$url\" |";
+ $path = "$curl -q -s -o - \"$fetch\" |";
}
} else {
print "# reading index file $fn\n";
- if ($url =~ /\.bz2$/) {
- $path = "$bzip2 -dc $url |";
+ if ($fetch =~ /\.bz2$/) {
+ $path = "$bzip2 -dc $fetch |";
} else {
- $path = "< $url";
+ $path = "< $fetch";
}
}
open(RFH, $path) or
- die "FATAL: cannot open '$url' ($!)\n";
+ die "FATAL: cannot open '$fetch' ($!)\n";
eval {
require XML::Simple;
@@ -408,7 +432,9 @@
my($name,$version);
my($href,$release,$desc);
my(@prereq,@bprereq);
- my(@provides,@conflicts,$rec);
+ my(@provides,@conflicts);
+ my($platform,$prefix);
+ my($rec);
my($tag,$cond,$body);
my($useit);
@@ -417,17 +443,25 @@
s/>/>/g;
s/</</g;
- if (/<rdf:Description.*?href="([^"]*)"/) {
- $section = undef;
+ if (!(defined $href) && /<rdf:Description.*?href="([^"]*)"/) {
$href = $1;
+ $section = undef;
$name = undef;
$release = undef;
$desc = '';
+ $platform = undef;
+ $prefix = undef;
@prereq = ();
@bprereq = ();
@provides = ();
@conflicts = ();
}
+
+ if (!(defined $href) && /<Repository.*?href="([^"]*)"/) {
+ push(@include, $1);
+ next;
+ }
+
next unless defined $href;
($tag,$cond,$body) = /<(\/?[\w:]+)\s*(?:cond="([^"]+)")?>([^<]*)/;
@@ -462,6 +496,10 @@
$version = $body;
} elsif ($tag eq 'Release') {
$release = $body;
+ } elsif ($tag eq 'Platform') {
+ $platform = $body;
+ } elsif ($tag eq 'Prefix') {
+ $prefix = $body;
} elsif ($tag eq 'rdf:li') {
if ($section eq 'prereq') {
push(@prereq, $body);
@@ -474,25 +512,39 @@
}
} elsif ($tag eq '/rdf:Description') {
- if (defined $href && defined $name && defined $version) {
-
- @provides = map {{ name => $_, version => '' }} @provides;
-
- push(@provides, {
- name => $name,
- version => $version,
- release => $release
- });
+ if (defined $href &&
+ defined $name &&
+ defined $version &&
+ defined $release) {
+
+ @provides = map {
+ /(\S+)\s*(?:=(\S+?)\-(\S+))?$/;
+ {
+ name => $1,
+ version => $2,
+ release => $3
+ }
+ } @provides;
+
+ unless (grep($_->{name} eq $name, @provides)) {
+ push(@provides, {
+ name => $name,
+ version => $version,
+ release => $release
+ });
+ }
$rec = {
+ href => (relurl($url, undef, $href))[0],
name => $name,
version => $version,
release => $release,
depends => [ @bprereq ],
keeps => [ @prereq ],
conflicts => [ @conflicts ],
- href => $href,
- desc => $desc
+ desc => $desc,
+ platform => $platform,
+ prefix => $prefix
};
$rec->{OPTIONS} = parse_options($rec->{desc});
@@ -510,29 +562,55 @@
my($xml) = XML::Simple::XMLin(\*RFH, forcearray => 1);
my($desc) = $xml->{'Repository'}->[0]->{'rdf:Description'};
+ my($sub) = $xml->{'Repository'}->[0]->{'Repository'};
my($provides,@provides,$rec);
+ my($href,$name,$version,$release);
foreach (@$desc) {
+
+ $href = $_->{'href'};
+ $name = $_->{'Name'}->[0];
+ $version = $_->{'Version'}->[0];
+ $release = $_->{'Release'}->[0];
+
+ next unless defined $href &&
+ defined $name &&
+ defined $version &&
+ defined $release;
+
$provides = $_->{'Provides'}->[0]->{'rdf:bag'}->[0]->{'rdf:li'};
- if ($provides) {
- @provides = map {{ name => $_, version => '' }} @$provides;
- } else {
- @provides = ();
+
+ @provides = map {
+ /(\S+)\s*(?:=(\S+?)\-(\S+))?$/;
+ {
+ name => $1,
+ version => $2,
+ release => $3
+ }
+ } @$provides;
+
+ unless (grep($_->{name} eq $name, @provides)) {
+ push(@provides, {
+ name => $name,
+ version => $version,
+ release => $release
+ });
}
- push(@provides, {
- name => $_->{'Name'}->[0],
- version => $_->{'Version'}->[0],
- release => $_->{'Release'}->[0]
- });
$rec = {
- name => $_->{'Name'}->[0],
- version => $_->{'Version'}->[0],
- release => $_->{'Release'}->[0],
- depends => $_->{'BuildPreReq'}->[0]->{'rdf:bag'}->[0]->{'rdf:li'},
- keeps => $_->{'PreReq'}->[0]->{'rdf:bag'}->[0]->{'rdf:li'},
- href => $_->{'href'},
- desc => $_->{'Description'}->[0],
+ href => (relurl($url, undef, $href))[0],
+ name => $name,
+ version => $version,
+ release => $release,
+ platform => $_->{'Platform'}->[0],
+ prefix => $_->{'Prefix'}->[0],
+ depends =>
+ ( $_->{'BuildPreReq'}->[0]->{'rdf:bag'}->[0]->{'rdf:li'}
+ || [] ),
+ keeps =>
+ ( $_->{'PreReq'}->[0]->{'rdf:bag'}->[0]->{'rdf:li'}
+ || [] ),
+ desc => $_->{'Description'}->[0]
};
$rec->{OPTIONS} = parse_options($rec->{desc});
@@ -540,10 +618,29 @@
push(@{$map{$_->{name}}->{vs($_)}}, $rec);
}
}
+
+ if ($sub) {
+ @include = map { $_->{href} } @$sub;
+ }
}
close(RFH);
+ #
+ # cannot do real recursions on file handles, so we simply append
+ # all sub-RDFs, the result is flattend into a big hash anyway
+ #
+ foreach (@include) {
+ my($submap);
+ my($suburl,$subfn) = relurl($url,$fn,$_);
+ $submap = get_index($suburl,$subfn,$with);
+ while (my($name,$vmap) = each %$submap) {
+ while (my($vs,$recs) = each %$vmap) {
+ push @{$map{$name}->{$vs}}, @$recs;
+ }
+ }
+ }
+
return \%map;
}
@@ -562,18 +659,19 @@
#
sub chose_source ($$@) {
my($env, $name, $vmap, @vers) = @_;
- my($version,$recs,$rec);
+ my(@recs,$rec);
return unless @vers;
- $version = $vers[-1];
- $recs = $vmap->{$version};
- return unless $recs && @$recs;
+ @recs = grep { !defined $_->{'platform'} }
+ map { @{$vmap->{$_}} }
+ @vers;
+ return unless @recs;
- if (scalar(@$recs) > 1) {
+ if (scalar(@recs) > 1) {
$rec = undef;
- foreach (@$recs) {
+ foreach (@recs) {
if ($env->{built}->{$_->{name}} ||
$env->{installed}->{$_->{name}}) {
$rec = $_;
@@ -583,7 +681,7 @@
unless (defined $rec) {
print "# ambigous sources for $name\n";
my($i) = 0;
- foreach (@$recs) {
+ foreach (@recs) {
print "# $i: ".vsn($_)."\n";
$i++;
}
@@ -592,9 +690,9 @@
} else {
if ($env->{upgrade}) {
- $rec = $recs->[-1];
+ $rec = $recs[-1];
} else {
- $rec = $recs->[0];
+ $rec = $recs[0];
}
}
@@ -719,6 +817,7 @@
my($iwith) = $target->{OPTIONS};
my($k,$v);
+ return unless defined $iwith;
while (($k,$v) = each %$with) {
if (!exists $iwith->{$k}) {
print "# ATTENTION: $target->{name} ignores option '$k'\n";
@@ -732,7 +831,7 @@
sub dep2target ($$) {
my($dep, $env) = @_;
my($name,@vers);
- my($i,$r,$b,$cond);
+ my($i,$r,$b,$cond,$version);
my($t);
$dep =~ s/(\S+)\s*//;
@@ -745,9 +844,11 @@
return unless $i || $r || $b;
if ($dep =~ /^>=\s*(\S+)$/) {
- $cond = sub { vcmp($_[0],$1) >= 0; };
+ $version = $1;
+ $cond = sub { vcmp($_[0],$version) >= 0; };
} elsif ($dep =~ /^=\s*(\S+)$/) {
- $cond = sub { vcmp($_[0],$1) == 0; };
+ $version = $1;
+ $cond = sub { vcmp($_[0],$version) == 0; };
} elsif ($dep =~ /^\s*$/) {
$cond = sub { 1; };
} else {
@@ -1025,14 +1126,12 @@
return $with;
}
-sub print_list1 ($$$$@$) {
- my($list,$c,$url,$uncond,$with,$ignore) = @_;
+sub print_list1 ($$$@$) {
+ my($list,$c,$uncond,$with,$ignore) = @_;
my($spkg,$bpkg);
my($opt);
my($cmd1, $cmd2, $mark);
- $url .= '/' unless $url =~ m{/$}s;
-
$mark = '::::';
foreach (@$list) {
@@ -1052,7 +1151,7 @@
!target_suitable(binary_target($_, $bpkg),$with)) {
$opt = make_defines($_->{OPTIONS}, $with);
- $cmd1 = "$RPM_NPRIV$opt --rebuild $url$spkg";
+ $cmd1 = "$RPM_NPRIV$opt --rebuild $spkg";
}
#
@@ -1117,8 +1216,18 @@
$url = get_release();
}
+#
+# if we read the index from a file we can no longer deduce
+# repository paths from index paths. For now lets assume
+# that everything is below SRC/ to be compatible with
+# existing file indexes.
+#
+if (defined $opt_f && !defined $opt_r) {
+ $url .= 'SRC/';
+}
+
$installed = $opt_Z ? {} : get_installed();
-$repository = get_index($url,$opt_f,\%with);
+$repository = get_index($url.'00INDEX.rdf',$opt_f,\%with);
($list,$bonly) = build_list($pattern, {
installed => $installed,
@@ -1133,6 +1242,6 @@
die "FATAL: cannot find package\n" unless defined $list;
-print_list1($list,$config,$url,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
+print_list1($list,$config,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
print_list2($bonly,$config);
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]