|
|
@@ -231,6 +231,9 @@ sub release_cmp ($$) {
|
|
|
|
|
|
sub vcmp ($$) {
|
|
|
my($a,$b) = @_;
|
|
|
+
|
|
|
+ return 0 if $a eq $b;
|
|
|
+
|
|
|
my($av,$ar) = $a =~ /^(.*?)(?:\-([\d\.]+))?$/;
|
|
|
my($bv,$br) = $b =~ /^(.*?)(?:\-([\d\.]+))?$/;
|
|
|
my($c);
|
|
|
@@ -302,18 +305,67 @@ sub get_release () {
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
+sub parse_provides ($) {
|
|
|
+ my($s) = @_;
|
|
|
+ my($nam,$val,$pre,$with,$pxy,$ver,$rel);
|
|
|
+
|
|
|
+ ($nam,$val) = $s =~ /^(\S+)\s*(?:=\s*(\S*?))?$/;
|
|
|
+
|
|
|
+ #
|
|
|
+ # build options are encoded as a Requirement
|
|
|
+ # <packagename>::<buildoption> = <value>
|
|
|
+ #
|
|
|
+ # since the value is interpreted as a version number
|
|
|
+ # you can only do equality tests
|
|
|
+ #
|
|
|
+ if (($pre,$with) = $nam =~ /^(\S+?)::(\S*)$/) {
|
|
|
+ $val =~ s/(?:\%([0-9a-fA-F][0-9a-fA-F]))/chr(hex($1))/eg;
|
|
|
+ ($ver,$rel,$pxy) = ($val, '', undef);
|
|
|
+ } else {
|
|
|
+ ($ver,$rel,$pxy) = $val =~ /^([^\s\-]+)-([^\s\+]+)(\+PROXY)?$/;
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ name => $nam,
|
|
|
+ version => $ver,
|
|
|
+ release => $rel,
|
|
|
+ proxy => $pxy,
|
|
|
+ prefix => $pre,
|
|
|
+ with => $with
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
sub get_installed () {
|
|
|
my(%map);
|
|
|
my(@l) = `$RPM_NPRIV --provides -qa`;
|
|
|
+ my($p);
|
|
|
+ my($nam,$val,%options);
|
|
|
|
|
|
foreach (@l) {
|
|
|
- /^(\S+)\s*(?:=\s*([^\s\-]+)-([^\s\+]+)(\+PROXY)?)?$/;
|
|
|
- push(@{$map{$1}->{"$2-$3"}}, {
|
|
|
- name => $1,
|
|
|
- version => (defined $2 ? $2 : '*'),
|
|
|
- release => (defined $3 ? $3 : '*'),
|
|
|
- PROXY => $4
|
|
|
- });
|
|
|
+ $p = parse_provides($_);
|
|
|
+
|
|
|
+ if (defined $p->{with}) {
|
|
|
+ $options{$p->{prefix}}->{$p->{with}} = $p->{version}
|
|
|
+ }
|
|
|
+
|
|
|
+ push @{$map{$p->{name}}->{"$p->{version}-$p->{release}"}}, {
|
|
|
+ name => $p->{name},
|
|
|
+ version => (defined $p->{version} ? $p->{version} : '*'),
|
|
|
+ release => (defined $p->{release} ? $p->{release} : '*'),
|
|
|
+ PROXY => $p->{proxy}
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ #
|
|
|
+ # options are provided for a package
|
|
|
+ # apply them to all instances of the package
|
|
|
+ #
|
|
|
+ foreach $nam (keys %options) {
|
|
|
+ foreach $val (keys %{$map{$nam}}) {
|
|
|
+ foreach (@{$map{$nam}->{$val}}) {
|
|
|
+ $_->{OPTIONS} = $options{$nam};
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return \%map;
|
|
|
@@ -378,10 +430,10 @@ sub get_revdep ($) {
|
|
|
sub parse_options ($) {
|
|
|
my($l) = @_;
|
|
|
$l = join("\n", @$l) if ref $l;
|
|
|
- return if ($l !~ m/(--define|%option\s+)/s);
|
|
|
+ return if ($l !~ m/(--define|\%option\s+)/s);
|
|
|
my $with = {};
|
|
|
$l =~ s/--define\s*'(\S+)\s+(\S+?)'/$with->{$1} = $2, ''/sge; # before openpkg-20021230
|
|
|
- $l =~ s/%option\s+(\S+)\s+(\S+)/$with->{$1} = $2, ''/sge; # after openpkg-20021230
|
|
|
+ $l =~ s/\%option\s+(\S+)\s+(\S+)/$with->{$1} = $2, ''/sge; # after openpkg-20021230
|
|
|
return $with;
|
|
|
}
|
|
|
|
|
|
@@ -514,7 +566,6 @@ sub get_index ($$$) {
|
|
|
@bprereq = ();
|
|
|
@provides = ();
|
|
|
@conflicts = ();
|
|
|
- %options = ();
|
|
|
}
|
|
|
|
|
|
if (!(defined $href) && /<Repository.*?href="([^"]*)"/) {
|
|
|
@@ -543,10 +594,6 @@ sub get_index ($$$) {
|
|
|
$section = undef;
|
|
|
} elsif ($section eq 'description') {
|
|
|
$desc .= $_;
|
|
|
- } elsif ($tag eq 'Options') {
|
|
|
- $section = 'options' if $useit;
|
|
|
- } elsif ($tag eq '/Options') {
|
|
|
- $section = undef;
|
|
|
} elsif ($tag eq 'PreReq') {
|
|
|
$section = 'prereq' if $useit;
|
|
|
} elsif ($tag eq '/PreReq') {
|
|
|
@@ -574,11 +621,7 @@ sub get_index ($$$) {
|
|
|
} elsif ($tag eq 'Prefixes') {
|
|
|
$prefix = $body;
|
|
|
} elsif ($tag eq 'rdf:li') {
|
|
|
- if ($section eq 'options') {
|
|
|
- if ($body =~ /<.*?ID="([^"]+)".*?>\s*([^<]+?)\s*</) {
|
|
|
- $options{$1} = $2;
|
|
|
- }
|
|
|
- } elsif ($section eq 'prereq') {
|
|
|
+ if ($section eq 'prereq') {
|
|
|
push(@prereq, $body);
|
|
|
} elsif ($section eq 'bprereq') {
|
|
|
push(@bprereq, $body);
|
|
|
@@ -594,13 +637,12 @@ sub get_index ($$$) {
|
|
|
defined $version &&
|
|
|
defined $release) {
|
|
|
|
|
|
- @provides = map {
|
|
|
- /(\S+)\s*(?:=\s*(\S+?)\-(\S+))?$/;
|
|
|
- {
|
|
|
- name => $1,
|
|
|
- version => $2,
|
|
|
- release => $3
|
|
|
- }
|
|
|
+ @provides = map { parse_provides($_) } @provides;
|
|
|
+
|
|
|
+ %options = map {
|
|
|
+ ( $_->{with} => $_->{version} )
|
|
|
+ } grep {
|
|
|
+ defined $_->{with}
|
|
|
} @provides;
|
|
|
|
|
|
unless (grep($_->{name} eq $name, @provides)) {
|
|
|
@@ -644,7 +686,7 @@ sub get_index ($$$) {
|
|
|
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($provides,@provides,%options,$rec);
|
|
|
my($href,$name,$version,$release);
|
|
|
|
|
|
foreach (@$desc) {
|
|
|
@@ -661,14 +703,13 @@ sub get_index ($$$) {
|
|
|
|
|
|
$provides = $_->{'Provides'}->[0]->{'rdf:bag'}->[0]->{'rdf:li'};
|
|
|
|
|
|
- @provides = map {
|
|
|
- /(\S+)\s*(?:=\s*(\S+?)\-(\S+))?$/;
|
|
|
- {
|
|
|
- name => $1,
|
|
|
- version => $2,
|
|
|
- release => $3
|
|
|
- }
|
|
|
- } @$provides;
|
|
|
+ @provides = map { parse_provides($_) } @$provides;
|
|
|
+
|
|
|
+ %options = map {
|
|
|
+ ( $_->{with} => $_->{version} )
|
|
|
+ } grep {
|
|
|
+ defined $_->{with}
|
|
|
+ } @provides;
|
|
|
|
|
|
unless (grep($_->{name} eq $name, @provides)) {
|
|
|
push(@provides, {
|
|
|
@@ -692,8 +733,8 @@ sub get_index ($$$) {
|
|
|
};
|
|
|
|
|
|
$rec->{OPTIONS} =
|
|
|
- exists $_->{'Options'}
|
|
|
- ? make_hash($_->{'Options'}, 'Option', $with)
|
|
|
+ %options
|
|
|
+ ? { %options }
|
|
|
: parse_options($rec->{desc});
|
|
|
|
|
|
foreach (@provides) {
|
|
|
@@ -951,10 +992,19 @@ sub dep2target ($$) {
|
|
|
|
|
|
return unless $i || $r || $b;
|
|
|
|
|
|
- if ($dep =~ /^>=\s*(\S+)$/) {
|
|
|
+ if ($dep =~ /^(?:>=|=>)\s*(\S+)$/) {
|
|
|
$version = $1;
|
|
|
$cond = sub { vcmp($_[0],$version) >= 0; };
|
|
|
- } elsif ($dep =~ /^=\s*(\S+)$/) {
|
|
|
+ } elsif ($dep =~ /^(?:<=|=<)\s*(\S+)$/) {
|
|
|
+ $version = $1;
|
|
|
+ $cond = sub { vcmp($_[0],$version) <= 0; };
|
|
|
+ } elsif ($dep =~ /^>\s*(\S+)$/) {
|
|
|
+ $version = $1;
|
|
|
+ $cond = sub { vcmp($_[0],$version) > 0; };
|
|
|
+ } elsif ($dep =~ /^<\s*(\S+)$/) {
|
|
|
+ $version = $1;
|
|
|
+ $cond = sub { vcmp($_[0],$version) < 0; };
|
|
|
+ } elsif ($dep =~ /^==?\s*(\S+)$/) {
|
|
|
$version = $1;
|
|
|
$cond = sub { vcmp($_[0],$version) == 0; };
|
|
|
} elsif ($dep =~ /^\s*$/) {
|