diff options
Diffstat (limited to 'expanddeps')
-rwxr-xr-x | expanddeps | 171 |
1 files changed, 125 insertions, 46 deletions
@@ -28,7 +28,8 @@ use strict; use Build; -my ($dist, $rpmdeps, $archs, $configdir, $useusedforbuild, $installonly, $noinstall); +my ($dist, $rpmdeps, $archs, $configdir, $useusedforbuild, $installonly, $noinstall, $isvm); +my ($obspackage, $buildflavor); $configdir = ($::ENV{'BUILD_DIR'} || '/usr/lib/build') . '/configs'; @@ -76,6 +77,21 @@ while (@ARGV) { Build::define("_without_$def --without-$def"); next; } + if ($ARGV[0] eq '--vm') { + shift @ARGV; + $isvm = 1; + next; + } + if ($ARGV[0] eq '--buildflavor') { + shift @ARGV; + $buildflavor = shift @ARGV; + next; + } + if ($ARGV[0] eq '--obspackage') { + shift @ARGV; + $obspackage = shift @ARGV; + next; + } last; } @@ -97,10 +113,10 @@ for my $arg (@ARGV) { my $binarytype; my @archs = split(':', $archs); -if ($recipe =~ /(^|\/)PKGBUILD$/) { +if ($recipe && $recipe =~ /(^|\/)PKGBUILD$/) { push @archs, 'any' unless grep {$_ eq 'any'} @archs; $binarytype = 'arch'; -} elsif ($recipe =~ /\.dsc$/) { +} elsif ($recipe && $recipe =~ /\.dsc$/) { push @archs, 'all' unless grep {$_ eq 'noarch'} @archs; $binarytype = 'deb'; } else { @@ -115,7 +131,7 @@ if (defined($dist) && $dist ne '') { $binarytype = $cf->{'binarytype'} if $cf->{'binarytype'} && $cf->{'binarytype'} ne 'UNDEFINED'; } -my (%fn, %prov, %req, %con, %obs); +my (%fn, %prov, %req, %con, %obs, %rec, %sup); my %packs; my %repo; @@ -123,9 +139,10 @@ my %ids; 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, $pkgC, $pkgO); +my ($pkgF, $pkgP, $pkgR, $pkgC, $pkgO, $pkgr, $pkgs); my $verscmp = \&Build::Rpm::verscmp; @@ -148,29 +165,41 @@ while(<F>) { $pkgC = $2; } elsif (/^O:(.*?)-\d+\/\d+\/\d+: (.*)$/) { $pkgO = $2; + } elsif (/^r:(.*?)-\d+\/\d+\/\d+: (.*)$/) { + $pkgr = $2; + } elsif (/^s:(.*?)-\d+\/\d+\/\d+: (.*)$/) { + $pkgs = $2; } elsif (/^I:(.*?)-\d+\/\d+\/\d+: (.*)$/) { - 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; + 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 $rec{$i}; + delete $con{$i}; + delete $obs{$i}; + delete $rec{$i}; + delete $sup{$i}; + $req{$i} = $pkgR; + $con{$i} = $pkgC if defined $pkgC; + $obs{$i} = $pkgO if defined $pkgO; + $rec{$i} = $pkgr if defined $pkgr; + $sup{$i} = $pkgs if defined $pkgs; + } } undef $pkgF; undef $pkgP; undef $pkgR; undef $pkgC; undef $pkgO; + undef $pkgr; + undef $pkgs; } elsif ($_ eq 'D:') { %packs_done = %ids; } @@ -210,13 +239,15 @@ if (!defined($dist) || $dist eq '') { $cf ||= Build::read_config_dist($dist, $archs[0], $configdir); $cf->{'warnings'} = 1; +$cf->{'buildflavor'} = $buildflavor if defined $buildflavor; +$cf->{'obspackage'} = $obspackage if defined $obspackage; my $dofileprovides = %{$cf->{'fileprovides'}}; $dofileprovides = 1 if ($binarytype || 'rpm') ne 'rpm'; for my $pack (keys %packs) { my $r = {}; - my (@s, $s, @pr, @re, @co, @ob); + my (@s, $s, @pr, @re, @co, @ob, @rc, @su); @s = split(' ', $prov{$packs{$pack}} || ''); while (@s) { $s = shift @s; @@ -273,10 +304,44 @@ for my $pack (keys %packs) { splice(@s, 0, 2); } } + @s = split(' ', $rec{$packs{$pack}} || ''); + while (@s) { + $s = shift @s; + next if !$dofileprovides && $s =~ /^\//; + if ($s =~ /^rpmlib\(/) { + splice(@s, 0, 2); + next; + } + push @rc, $s; + while (@s && $s[0] =~ /^[\(<=>|]/) { + $rc[-1] .= " $s[0] $s[1]"; + $rc[-1] =~ s/ \((.*)\)/ $1/; + $rc[-1] =~ s/(<|>){2}/$1/; + splice(@s, 0, 2); + } + } + @s = split(' ', $sup{$packs{$pack}} || ''); + while (@s) { + $s = shift @s; + next if !$dofileprovides && $s =~ /^\//; + if ($s =~ /^rpmlib\(/) { + splice(@s, 0, 2); + next; + } + push @su, $s; + while (@s && $s[0] =~ /^[\(<=>|]/) { + $su[-1] .= " $s[0] $s[1]"; + $su[-1] =~ s/ \((.*)\)/ $1/; + $su[-1] =~ s/(<|>){2}/$1/; + splice(@s, 0, 2); + } + } $r->{'provides'} = \@pr; $r->{'requires'} = \@re; $r->{'conflicts'} = \@co; $r->{'obsoletes'} = \@ob; + $r->{'recommends'} = \@rc; + $r->{'supplements'} = \@su; $repo{$pack} = $r; } @@ -329,34 +394,25 @@ if ($useusedforbuild) { ####################################################################### -my ($packname, $packvers, $subpacks, @packdeps); -$subpacks = []; +my $subpacks = []; + +my $buildtype = ''; +my $extrasysdeps; if ($recipe) { my $d = Build::parse($cf, $recipe) || {}; - my $buildtype = Build::recipe2buildtype($recipe) || ''; + $buildtype = Build::recipe2buildtype($recipe) || ''; $cf->{'type'} = $buildtype if $buildtype; if ($buildtype eq 'kiwi') { # lets see if this is a product or image build - my $type = $d->{'imagetype'} && $d->{'imagetype'}->[0] eq 'product' ? 'product' : 'image'; - my @kdeps; - if ($type eq 'image') { - @kdeps = @{$cf->{'substitute'}->{'kiwi-setup:image'} || []}; - @kdeps = ('kiwi', 'createrepo', 'tar') unless @kdeps; - } else { - @kdeps = @{$cf->{'substitute'}->{'kiwi-setup:product'} || []}; - @kdeps = ('kiwi') unless @kdeps; - } - push @kdeps, grep {/^kiwi-.*:/} @{$d->{'deps'} || []}; - $d = { 'deps' => \@kdeps, 'subpacks' => [] }; + $buildtype = $d->{'imagetype'} && $d->{'imagetype'}->[0] eq 'product' ? 'kiwi-product' : 'kiwi-image'; + $extrasysdeps = [ grep {/^kiwi-.*:/} @{$d->{'deps'} || []} ]; } - $packname = $d->{'name'}; - $packvers = $d->{'version'}; $subpacks = $d->{'subpacks'}; - @packdeps = @{$d->{'deps'} || []}; + unshift @extradeps, @{$d->{'deps'} || []}; if ($d->{'prereqs'}) { - my %deps = map {$_ => 1} (@packdeps, @{$d->{'subpacks'} || []}); - push @packdeps, '--directdepsend--', grep {!$deps{$_} && !/^%/} @{$d->{'prereqs'}}; + my %deps = map {$_ => 1} (@extradeps, @{$d->{'subpacks'} || []}); + push @extradeps, '--directdepsend--', grep {!$deps{$_} && !/^%/} @{$d->{'prereqs'}}; } } @@ -364,7 +420,21 @@ Build::readdeps($cf, undef, \%repo); ####################################################################### -my @bdeps = Build::get_build($cf, $subpacks, @packdeps, @extradeps); +my @sysdeps = Build::get_sysbuild($cf, $buildtype, $extrasysdeps); + +if ($buildtype eq 'kiwi-image' || $buildtype eq 'kiwi-product') { + if (!shift @sysdeps) { + print STDERR "expansion error\n"; + print STDERR " $_\n" for @sysdeps; + exit(1); + } + # just use the sysdeps for now, ignore real deps + print_rpmlist(@sysdeps); + exit(0); +} + +push @extradeps, '--ignoreignore--' if @sysdeps; +my @bdeps = Build::get_build($cf, $subpacks, @extradeps); if (!shift @bdeps) { print STDERR "expansion error\n"; @@ -372,7 +442,6 @@ if (!shift @bdeps) { exit(1); } -my @sysdeps = Build::get_sysbuild($cf); if (@sysdeps) { if (!shift @sysdeps) { print STDERR "expansion error\n"; @@ -386,8 +455,18 @@ if (@sysdeps) { @bdeps = Build::unify(@sysdeps, @bdeps); } -# make sure all preinstalls are in bdeps; -# XXX: also add vmdeps? -@bdeps = Build::unify(@bdeps, Build::get_preinstalls($cf)); +# get preinstalls/vminstalls and check if the packages exist +my @xdeps = Build::get_preinstalls($cf); +push @xdeps, Build::get_vminstalls($cf) if $isvm; +my @missing = grep {!$packs{$_}} @xdeps; +if (@missing) { + @missing = sort(Build::unify(@missing)); + print STDERR "expansion error\n"; + print STDERR " missing pre/vminstalls: ".join(', ', @missing)."\n"; + exit(1); +} + +# make sure all preinstalls/vminstalls are in bdeps +@bdeps = Build::unify(@bdeps, @xdeps); print_rpmlist(@bdeps); |