summaryrefslogtreecommitdiff
path: root/expanddeps
diff options
context:
space:
mode:
Diffstat (limited to 'expanddeps')
-rwxr-xr-xexpanddeps137
1 files changed, 109 insertions, 28 deletions
diff --git a/expanddeps b/expanddeps
index 48116d8..48272b7 100755
--- a/expanddeps
+++ b/expanddeps
@@ -1,5 +1,25 @@
#!/usr/bin/perl -w
+################################################################
+#
+# Copyright (c) 1995-2014 SUSE Linux Products GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or 3 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program (see the file COPYING); if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+################################################################
+
BEGIN {
unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
}
@@ -74,14 +94,28 @@ for my $arg (@ARGV) {
push @extradeps, $arg;
}
}
+
+my $binarytype;
my @archs = split(':', $archs);
if ($recipe =~ /(^|\/)PKGBUILD$/) {
push @archs, 'any' unless grep {$_ eq 'any'} @archs;
+ $binarytype = 'arch';
+} elsif ($recipe =~ /\.dsc$/) {
+ push @archs, 'all' unless grep {$_ eq 'noarch'} @archs;
+ $binarytype = 'deb';
} else {
push @archs, 'noarch' unless grep {$_ eq 'noarch'} @archs;
+ $binarytype = 'rpm';
+}
+
+# read dist if we can
+my $cf;
+if (defined($dist) && $dist ne '') {
+ $cf = Build::read_config_dist($dist, $archs[0], $configdir);
+ $binarytype = $cf->{'binarytype'} if $cf->{'binarytype'} && $cf->{'binarytype'} ne 'UNDEFINED';
}
-my (%fn, %prov, %req);
+my (%fn, %prov, %req, %con, %obs);
my %packs;
my %repo;
@@ -91,42 +125,52 @@ my %packs_arch;
my %packs_done;
open(F, '<', $rpmdeps) || die("$rpmdeps: $!\n");
# WARNING: the following code assumes that the 'I' tag comes last
-my ($pkgF, $pkgP, $pkgR);
+my ($pkgF, $pkgP, $pkgR, $pkgC, $pkgO);
+
+my $verscmp = \&Build::Rpm::verscmp;
+
+if ($binarytype && $binarytype eq 'deb') {
+ $verscmp = \&Build::Deb::verscmp;
+ for my $arch (@archs) {
+ $arch = Build::Deb::basearch($arch) unless $arch =~ /^i[456]86$/;
+ }
+}
+
while(<F>) {
chomp;
if (/^F:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
$pkgF = $2;
- next if $fn{$1};
- $fn{$1} = $2;
- my $pack = $1;
- $pack =~ /^(.*)\.([^\.]+)$/ or die;
- push @{$packs_arch{$2}}, $1;
} elsif (/^P:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
$pkgP = $2;
- next if $prov{$1};
- $prov{$1} = $2;
} elsif (/^R:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
$pkgR = $2;
- next if $req{$1};
- $req{$1} = $2;
+ } elsif (/^C:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
+ $pkgC = $2;
+ } elsif (/^O:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
+ $pkgO = $2;
} elsif (/^I:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
- if ($ids{$1} && !$packs_done{$1} && defined($pkgF) && defined($pkgP) && defined($pkgR)) {
- my $i = $1;
- my $oldid = $ids{$1};
- my $newid = $2;
- if (Build::Rpm::verscmp($oldid, $newid) < 0) {
- $ids{$i} = $newid;
- $fn{$i} = $pkgF;
- $prov{$i} = $pkgP;
- $req{$i} = $pkgR;
- }
- } else {
- next if $ids{$1};
- $ids{$1} = $2;
+ next if $packs_done{$1};
+ my ($i, $newid) = ($1, $2);
+ undef $i unless !$ids{$i} || $verscmp->($ids{$i}, $newid) < 0;
+ undef $i unless defined($pkgF) && defined($pkgP);
+ if (defined $i) {
+ $i =~ /^(.*)\.([^\.]+)$/ or die;
+ push @{$packs_arch{$2}}, $1;
+ $ids{$i} = $newid;
+ $fn{$i} = $pkgF;
+ $prov{$i} = $pkgP;
+ delete $req{$i};
+ delete $con{$i};
+ delete $obs{$i};
+ $req{$i} = $pkgR;
+ $con{$i} = $pkgC if defined $pkgC;
+ $obs{$i} = $pkgO if defined $pkgO;
}
undef $pkgF;
undef $pkgP;
undef $pkgR;
+ undef $pkgC;
+ undef $pkgO;
} elsif ($_ eq 'D:') {
%packs_done = %ids;
}
@@ -164,14 +208,15 @@ if (!defined($dist) || $dist eq '') {
print STDERR "Warning: distribution not specified, assuming '$dist' (see $configdir).\n";
}
-my $cf = Build::read_config_dist($dist, $archs[0], $configdir);
+$cf ||= Build::read_config_dist($dist, $archs[0], $configdir);
$cf->{'warnings'} = 1;
my $dofileprovides = %{$cf->{'fileprovides'}};
+$dofileprovides = 1 if ($binarytype || 'rpm') ne 'rpm';
for my $pack (keys %packs) {
my $r = {};
- my (@s, $s, @pr, @re);
+ my (@s, $s, @pr, @re, @co, @ob);
@s = split(' ', $prov{$packs{$pack}} || '');
while (@s) {
$s = shift @s;
@@ -181,7 +226,12 @@ for my $pack (keys %packs) {
next;
}
push @pr, $s;
- splice(@s, 0, 2) if @s && $s[0] =~ /^[<=>]/;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $pr[-1] .= " $s[0] $s[1]";
+ $pr[-1] =~ s/ \((.*)\)/ $1/;
+ $pr[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
}
@s = split(' ', $req{$packs{$pack}} || '');
while (@s) {
@@ -192,10 +242,41 @@ for my $pack (keys %packs) {
next;
}
push @re, $s;
- splice(@s, 0, 2) if @s && $s[0] =~ /^[<=>]/;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $re[-1] .= " $s[0] $s[1]";
+ $re[-1] =~ s/ \((.*)\)/ $1/;
+ $re[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
+ }
+ @s = split(' ', $con{$packs{$pack}} || '');
+ while (@s) {
+ $s = shift @s;
+ next if !$dofileprovides && $s =~ /^\//;
+ push @co, $s;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $co[-1] .= " $s[0] $s[1]";
+ $co[-1] =~ s/ \((.*)\)/ $1/;
+ $co[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
+ }
+ @s = split(' ', $obs{$packs{$pack}} || '');
+ while (@s) {
+ $s = shift @s;
+ next if !$dofileprovides && $s =~ /^\//;
+ push @ob, $s;
+ while (@s && $s[0] =~ /^[\(<=>|]/) {
+ $ob[-1] .= " $s[0] $s[1]";
+ $ob[-1] =~ s/ \((.*)\)/ $1/;
+ $ob[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ }
}
$r->{'provides'} = \@pr;
$r->{'requires'} = \@re;
+ $r->{'conflicts'} = \@co;
+ $r->{'obsoletes'} = \@ob;
$repo{$pack} = $r;
}