From e7cba6bfd6ad18abb193c29243e79f25cd7f97b4 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 5 Dec 2009 01:05:36 +0100 Subject: [PATCH] fix whitespace --- Build.pm | 186 +++--- Build/Deb.pm | 65 +- Build/Kiwi.pm | 27 +- Build/Rpm.pm | 243 ++++---- baselibs_global-deb.conf | 1 - baselibs_global.conf | 1 - build | 1526 +++++++++++++++++++++++----------------------- changelog2spec | 9 +- common_functions | 18 +- computeblocklists | 14 +- createrepomddeps | 457 +++++++------- createrpmdeps | 60 +- createyastdeps | 42 +- debtransform | 12 +- expanddeps | 17 +- extractbuild | 14 +- getbinaryid | 1 - getmacros | 2 +- init_buildsystem | 592 +++++++++--------- initscript_qemu_vm | 1 - mkbaselibs | 290 +++++---- spectool | 142 +++-- substitutedeps | 89 ++- test/common | 8 +- unrpm | 4 +- vc | 6 +- xen.conf | 3 +- 27 files changed, 1902 insertions(+), 1928 deletions(-) diff --git a/Build.pm b/Build.pm index 7f14a74..03be827 100644 --- a/Build.pm +++ b/Build.pm @@ -1,4 +1,3 @@ - package Build; use strict; @@ -27,7 +26,6 @@ sub import { } } - my $std_macros = q{ %define nil %define ix86 i386 i486 i586 i686 athlon @@ -44,8 +42,8 @@ sub unify { sub define($) { - my $def = shift; - $extra_macros .= '%define '.$def."\n"; + my $def = shift; + $extra_macros .= '%define '.$def."\n"; } sub init_helper_hashes { @@ -169,13 +167,13 @@ sub read_config { if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:') { my $t = substr($l0, 0, -1); for my $l (@l) { - if ($l eq '!*') { - $config->{$t} = []; - } elsif ($l =~ /^!/) { - $config->{$t} = [ grep {"!$_" ne $l} @{$config->{$t}} ]; - } else { - push @{$config->{$t}}, $l; - } + if ($l eq '!*') { + $config->{$t} = []; + } elsif ($l =~ /^!/) { + $config->{$t} = [ grep {"!$_" ne $l} @{$config->{$t}} ]; + } else { + push @{$config->{$t}}, $l; + } } } elsif ($l0 eq 'substitute:') { next unless @l; @@ -199,19 +197,19 @@ sub read_config { $config->{'optflags'}->{$ll} = join(' ', @l); } elsif ($l0 eq 'order:') { for my $l (@l) { - if ($l eq '!*') { + if ($l eq '!*') { $config->{'order'} = {}; - } elsif ($l =~ /^!(.*)$/) { + } elsif ($l =~ /^!(.*)$/) { delete $config->{'order'}->{$1}; - } else { + } else { $config->{'order'}->{$l} = 1; - } + } } } elsif ($l0 eq 'repotype:') { #type of generated repository data $config->{'repotype'} = [ @l ]; } elsif ($l0 eq 'type:') { #kind of packaging system (spec, dsc or kiwi) $config->{'type'} = $l[0]; - } elsif ($l0 eq 'patterntype:') { #kind of generated patterns in repository + } elsif ($l0 eq 'patterntype:') { #kind of generated patterns in repository $config->{'patterntype'} = [ @l ]; } elsif ($l0 eq 'release:') { $config->{'release'} = $l[0]; @@ -246,15 +244,15 @@ sub read_config { if ($config->{'rawmacros'} ne '') { for my $rm (split("\n", $config->{'rawmacros'})) { if (@macros && $macros[-1] =~ /\\$/) { - if ($rm =~ /\\$/) { - push @macros, '...\\'; - } else { - push @macros, '...'; - } + if ($rm =~ /\\$/) { + push @macros, '...\\'; + } else { + push @macros, '...'; + } } elsif ($rm !~ /^%/) { - push @macros, $rm; + push @macros, $rm; } else { - push @macros, "%define ".substr($rm, 1); + push @macros, "%define ".substr($rm, 1); } } } @@ -379,7 +377,7 @@ sub readdeps { while() { my @s = split(' ', $_); my $s = shift @s; - my @ss; + my @ss; while (@s) { if ($s[0] =~ /^\//) { shift @s; @@ -401,7 +399,7 @@ sub readdeps { } } } - my %ss; + my %ss; @ss = grep {!$ss{$_}++} @ss; if ($s =~ /^(P|R):(.*)\.(.*)-\d+\/\d+\/\d+:$/) { my $pkgid = $2; @@ -482,24 +480,24 @@ sub addproviders { for my $rp (@rp) { for my $pp (@{$provides->{$rp} || []}) { if ($pp eq $rn) { - # debian: unversioned provides do not match + # debian: unversioned provides do not match # kiwi: supports only rpm, so we need to hand it like it - next if $config->{'type'} eq 'dsc'; - push @p, $rp; - last; + next if $config->{'type'} eq 'dsc'; + push @p, $rp; + last; } next unless $pp =~ /^\Q$rn\E\s*([<=>]{1,2})\s*(.*?)$/; my $pv = $2; my $pf = $addproviders_fm{$1}; next unless $pf; if ($pf & $rf & 5) { - push @p, $rp; - last; + push @p, $rp; + last; } if ($pv eq $rv) { - next unless $pf & $rf & 2; - push @p, $rp; - last; + next unless $pf & $rf & 2; + push @p, $rp; + last; } my $rr = $rf == 2 ? $pf : ($rf ^ 5); $rr &= 5 unless $pf & 2; @@ -511,8 +509,8 @@ sub addproviders { $vv = Build::Rpm::verscmp($pv, $rv, 1); } if ($rr & (1 << ($vv + 1))) { - push @p, $rp; - last; + push @p, $rp; + last; } } } @@ -536,7 +534,7 @@ sub expand { my %p; # expanded packages my %aconflicts; # packages we are conflicting with - # add direct dependency packages. this is different from below, + # add direct dependency packages. this is different from below, # because we add packages even if to dep is already provided and # we break ambiguities if the name is an exact match. for my $p (splice @p) { @@ -564,63 +562,63 @@ sub expand { for my $p (splice @p) { for my $r (@{$requires->{$p} || [$p]}) { my $ri = (split(/[ <=>]/, $r, 2))[0]; - next if $ignore->{"$p:$ri"} || $xignore{"$p:$ri"}; - next if $ignore->{$ri} || $xignore{$ri}; - my @q = @{$whatprovides->{$r} || addproviders($config, $r)}; - next if grep {$p{$_}} @q; - next if grep {$xignore{$_}} @q; - next if grep {$ignore->{"$p:$_"} || $xignore{"$p:$_"}} @q; - @q = grep {!$aconflicts{$_}} @q; - if (!@q) { - if ($r eq $p) { - push @rerror, "nothing provides $r"; - } else { - push @rerror, "nothing provides $r needed by $p"; - } - next; - } - if (@q > 1 && !$doamb) { - push @pamb, $p unless @pamb && $pamb[-1] eq $p; - print "undecided about $p:$r: @q\n" if $expand_dbg; - next; - } - if (@q > 1) { - my @pq = grep {!$prefer->{"-$_"} && !$prefer->{"-$p:$_"}} @q; - @q = @pq if @pq; - @pq = grep {$prefer->{$_} || $prefer->{"$p:$_"}} @q; - if (@pq > 1) { - my %pq = map {$_ => 1} @pq; - @q = (grep {$pq{$_}} @{$config->{'prefer'}})[0]; - } elsif (@pq == 1) { - @q = @pq; - } - } - if (@q > 1 && $r =~ /\|/) { - # choice op, implicit prefer of first match... - my %pq = map {$_ => 1} @q; - for my $rr (split(/\s*\|\s*/, $r)) { - next unless $whatprovides->{$rr}; - my @pq = grep {$pq{$_}} @{$whatprovides->{$rr}}; - next unless @pq; - @q = @pq; - last; - } - } - if (@q > 1) { - if ($r ne $p) { - push @error, "have choice for $r needed by $p: @q"; + next if $ignore->{"$p:$ri"} || $xignore{"$p:$ri"}; + next if $ignore->{$ri} || $xignore{$ri}; + my @q = @{$whatprovides->{$r} || addproviders($config, $r)}; + next if grep {$p{$_}} @q; + next if grep {$xignore{$_}} @q; + next if grep {$ignore->{"$p:$_"} || $xignore{"$p:$_"}} @q; + @q = grep {!$aconflicts{$_}} @q; + if (!@q) { + if ($r eq $p) { + push @rerror, "nothing provides $r"; } else { - push @error, "have choice for $r: @q"; + push @rerror, "nothing provides $r needed by $p"; } - push @pamb, $p unless @pamb && $pamb[-1] eq $p; - next; - } - push @p, $q[0]; - print "added $q[0] because of $p:$r\n" if $expand_dbg; - $p{$q[0]} = 1; - $aconflicts{$_} = 1 for @{$conflicts->{$q[0]} || []}; - @error = (); - $doamb = 0; + next; + } + if (@q > 1 && !$doamb) { + push @pamb, $p unless @pamb && $pamb[-1] eq $p; + print "undecided about $p:$r: @q\n" if $expand_dbg; + next; + } + if (@q > 1) { + my @pq = grep {!$prefer->{"-$_"} && !$prefer->{"-$p:$_"}} @q; + @q = @pq if @pq; + @pq = grep {$prefer->{$_} || $prefer->{"$p:$_"}} @q; + if (@pq > 1) { + my %pq = map {$_ => 1} @pq; + @q = (grep {$pq{$_}} @{$config->{'prefer'}})[0]; + } elsif (@pq == 1) { + @q = @pq; + } + } + if (@q > 1 && $r =~ /\|/) { + # choice op, implicit prefer of first match... + my %pq = map {$_ => 1} @q; + for my $rr (split(/\s*\|\s*/, $r)) { + next unless $whatprovides->{$rr}; + my @pq = grep {$pq{$_}} @{$whatprovides->{$rr}}; + next unless @pq; + @q = @pq; + last; + } + } + if (@q > 1) { + if ($r ne $p) { + push @error, "have choice for $r needed by $p: @q"; + } else { + push @error, "have choice for $r: @q"; + } + push @pamb, $p unless @pamb && $pamb[-1] eq $p; + next; + } + push @p, $q[0]; + print "added $q[0] because of $p:$r\n" if $expand_dbg; + $p{$q[0]} = 1; + $aconflicts{$_} = 1 for @{$conflicts->{$q[0]} || []}; + @error = (); + $doamb = 0; } } return undef, @rerror if @rerror; @@ -684,7 +682,7 @@ sub order { my $v = shift @todo; if (ref($v)) { $notdone{$$v} = 0; # finished this one - next; + next; } my $s = $notdone{$v}; next unless $s; @@ -716,7 +714,7 @@ sub order { my $breakv; my @breakv = (@cyc, $cyc[0]); while (@breakv > 1) { - last if $config->{'order'}->{"$breakv[0]:$breakv[1]"}; + last if $config->{'order'}->{"$breakv[0]:$breakv[1]"}; shift @breakv; } if (@breakv > 1) { diff --git a/Build/Deb.pm b/Build/Deb.pm index afc3c10..9d4c8ed 100644 --- a/Build/Deb.pm +++ b/Build/Deb.pm @@ -1,4 +1,3 @@ - package Build::Deb; use strict; @@ -64,31 +63,31 @@ sub parse { my @d = split(/,\s*/, $data); for my $d (@d) { if ($d =~ /^(.*?)\s*\[(.*)\]$/) { - $d = $1; - my $isneg = 0; + $d = $1; + my $isneg = 0; my $bad; for my $q (split('[\s,]', $2)) { $isneg = 1 if $q =~ s/^\!//; $bad = 1 if !defined($bad) && !$isneg; if ($isneg) { if ($q eq $arch || $q eq "$os-$arch") { - $bad = 1; - last; - } - } elsif ($q eq $arch || $q eq "$os-$arch") { - $bad = 0; - } - } - next if $bad; - } - $d =~ s/ \(([^\)]*)\)/ $1/g; - $d =~ s/>>/>/g; - $d =~ s/<>/>/g; + $d =~ s/<\ndebian-binary ") { warn("$bin: not a debian package\n"); close F; - return undef; - } + return undef; + } my $len = substr($data, 8+48, 10); $len += $len & 1; if (length($data) < 8+60+$len+60) { @@ -281,24 +280,24 @@ sub queryhdrmd5 { if ((sysread(F, $data, $r < 4096 ? 4096 : $r, length($data)) || 0) < $r) { warn("$bin: unexpected EOF\n"); close F; - return undef; - } - } + return undef; + } + } $data = substr($data, 8 + 60 + $len); if (substr($data, 0, 16) ne 'control.tar.gz ') { warn("$bin: control.tar.gz is not second ar entry\n"); close F; - return undef; - } + return undef; + } $len = substr($data, 48, 10); if (length($data) < 60+$len) { my $r = 60+$len - length($data); if ((sysread(F, $data, $r, length($data)) || 0) < $r) { warn("$bin: unexpected EOF\n"); close F; - return undef; - } - } + return undef; + } + } close F; $data = substr($data, 60, $len); return Digest::MD5::md5_hex($data); diff --git a/Build/Kiwi.pm b/Build/Kiwi.pm index 14a2e7f..81f3802 100644 --- a/Build/Kiwi.pm +++ b/Build/Kiwi.pm @@ -1,4 +1,3 @@ - package Build::Kiwi; use strict; @@ -119,16 +118,16 @@ sub kiwiparse { if (defined $type->{'boot'}) { if ($type->{'boot'} =~ /^obs:\/\/\/?([^\/]+)\/([^\/]+)\/?$/) { next unless $bootcallback; - my ($bootxml, $xsrc) = $bootcallback->($1, $2); - next unless $bootxml; - push @extrasources, $xsrc if $xsrc; - my $bret = kiwiparse($bootxml, $arch, $count); - push @bootrepos, map {"$_->{'project'}/$_->{'repository'}"} @{$bret->{'path'} || []}; - push @packages, @{$bret->{'deps'} || []}; - push @extrasources, @{$bret->{'extrasource'} || []}; + my ($bootxml, $xsrc) = $bootcallback->($1, $2); + next unless $bootxml; + push @extrasources, $xsrc if $xsrc; + my $bret = kiwiparse($bootxml, $arch, $count); + push @bootrepos, map {"$_->{'project'}/$_->{'repository'}"} @{$bret->{'path'} || []}; + push @packages, @{$bret->{'deps'} || []}; + push @extrasources, @{$bret->{'extrasource'} || []}; } else { - die("bad boot reference: $type->{'boot'}\n") unless $type->{'boot'} =~ /^([^\/]+)\/([^\/]+)$/; - push @packages, "kiwi-boot:$1"; + die("bad boot reference: $type->{'boot'}\n") unless $type->{'boot'} =~ /^([^\/]+)\/([^\/]+)$/; + push @packages, "kiwi-boot:$1"; } } } @@ -142,12 +141,12 @@ sub kiwiparse { } for my $repopackages (@{$instsource->{'repopackages'} || []}) { for my $repopackage (@{$repopackages->{'repopackage'} || []}) { - push @packages, $repopackage->{'name'}; + push @packages, $repopackage->{'name'}; } } if ($instsource->{'metadata'}) { for my $repopackage (@{$instsource->{'metadata'}->[0]->{'repopackage'} || []}) { - push @packages, $repopackage->{'name'}; + push @packages, $repopackage->{'name'}; } } if ($instsource->{'productoptions'}) { @@ -159,7 +158,7 @@ sub kiwiparse { if ($instsource->{'architectures'}) { my $a = $instsource->{'architectures'}->[0] || {}; for my $ra (@{$a->{'requiredarch'} || []}) { - push @requiredarch, $ra->{'ref'} if defined($ra->{'ref'}); + push @requiredarch, $ra->{'ref'} if defined($ra->{'ref'}); } } } @@ -248,7 +247,7 @@ sub query { } sub queryhdrmd5 { - my ($bin) = @_; + my ($bin) = @_; die("Build::Kiwi::queryhdrmd5 unimplemented.\n"); } diff --git a/Build/Rpm.pm b/Build/Rpm.pm index 3d94f8d..04b5247 100644 --- a/Build/Rpm.pm +++ b/Build/Rpm.pm @@ -1,4 +1,3 @@ - package Build::Rpm; use strict; @@ -155,10 +154,10 @@ sub parse { $line = shift @$specdata; ++$lineno; if (ref $line) { - $line = $line->[0]; # verbatim line + $line = $line->[0]; # verbatim line push @$xspec, $line if $xspec; $xspec->[-1] = [ $line, undef ] if $xspec && $skip; - next; + next; } } else { $inspec = 1; @@ -171,7 +170,7 @@ sub parse { if ($line =~ /^#\s*neededforbuild\s*(\S.*)$/) { if (defined $hasnfb) { $xspec->[-1] = [ $xspec->[-1], undef ] if $inspec && $xspec; - next; + next; } $hasnfb = $1; $nfbline = \$xspec->[-1] if $inspec && $xspec; @@ -184,77 +183,77 @@ sub parse { if (!$skip) { my $tries = 0; while ($line =~ /^(.*?)%(\{([^\}]+)\}|[\?\!]*[0-9a-zA-Z_]+|%|\()(.*?)$/) { - if ($tries++ > 1000) { - print STDERR "Warning: spec file parser ",($lineno?" line $lineno":''),": macro too deeply nested\n" if $config->{'warnings'}; - $line = 'MACRO'; - last; - } - $expandedline .= $1; - $line = $4; - my $macname = defined($3) ? $3 : $2; - my $macorig = $2; - my $mactest = 0; - if ($macname =~ /^\!\?/ || $macname =~ /^\?\!/) { - $mactest = -1; - } elsif ($macname =~ /^\?/) { - $mactest = 1; - } - $macname =~ s/^[\!\?]+//; - $macname =~ s/^([^:\s]*)\s.*/$1/; - my $macalt; - ($macname, $macalt) = split(':', $macname, 2); - if ($macname eq '%') { - $expandedline .= '%'; - next; - } elsif ($macname eq '(') { - print STDERR "Warning: spec file parser",($lineno?" line $lineno":''),": can't expand %(...)\n" if $config->{'warnings'}; - $line = 'MACRO'; - last; - } elsif ($macname eq 'define' || $macname eq 'global') { - if ($line =~ /^\s*([0-9a-zA-Z_]+)(\([^\)]*\))?\s*(.*?)$/) { - my $macname = $1; - my $macargs = $2; - my $macbody = $3; - $macbody = undef if $macargs; - $macros{$macname} = $macbody; - } - $line = ''; - last; - } elsif ($macname eq 'defined' || $macname eq 'with' || $macname eq 'undefined' || $macname eq 'without' || $macname eq 'bcond_with' || $macname eq 'bcond_without') { - my @args; - if ($macorig =~ /^\{(.*)\}$/) { - @args = split(' ', $1); - shift @args; - } else { - @args = split(' ', $line); - $line = ''; - } - next unless @args; - if ($macname eq 'bcond_with') { - $macros{"with_$args[0]"} = 1 if exists $macros{"_with_$args[0]"}; - next; - } - if ($macname eq 'bcond_without') { - $macros{"with_$args[0]"} = 1 unless exists $macros{"_without_$args[0]"}; - next; - } - $args[0] = "with_$args[0]" if $macname eq 'with' || $macname eq 'without'; - $line = ((exists($macros{$args[0]}) ? 1 : 0) ^ ($macname eq 'undefined' || $macname eq 'without' ? 1 : 0)).$line; - } elsif (exists($macros{$macname})) { - if (!defined($macros{$macname})) { - print STDERR "Warning: spec file parser",($lineno?" line $lineno":''),": can't expand '$macname'\n" if $config->{'warnings'}; - $line = 'MACRO'; - last; - } - $macalt = $macros{$macname} unless defined $macalt; - $macalt = '' if $mactest == -1; - $line = "$macalt$line"; - } elsif ($mactest) { - $macalt = '' if !defined($macalt) || $mactest == 1; - $line = "$macalt$line"; - } else { - $expandedline .= "%$macorig"; - } + if ($tries++ > 1000) { + print STDERR "Warning: spec file parser ",($lineno?" line $lineno":''),": macro too deeply nested\n" if $config->{'warnings'}; + $line = 'MACRO'; + last; + } + $expandedline .= $1; + $line = $4; + my $macname = defined($3) ? $3 : $2; + my $macorig = $2; + my $mactest = 0; + if ($macname =~ /^\!\?/ || $macname =~ /^\?\!/) { + $mactest = -1; + } elsif ($macname =~ /^\?/) { + $mactest = 1; + } + $macname =~ s/^[\!\?]+//; + $macname =~ s/^([^:\s]*)\s.*/$1/; + my $macalt; + ($macname, $macalt) = split(':', $macname, 2); + if ($macname eq '%') { + $expandedline .= '%'; + next; + } elsif ($macname eq '(') { + print STDERR "Warning: spec file parser",($lineno?" line $lineno":''),": can't expand %(...)\n" if $config->{'warnings'}; + $line = 'MACRO'; + last; + } elsif ($macname eq 'define' || $macname eq 'global') { + if ($line =~ /^\s*([0-9a-zA-Z_]+)(\([^\)]*\))?\s*(.*?)$/) { + my $macname = $1; + my $macargs = $2; + my $macbody = $3; + $macbody = undef if $macargs; + $macros{$macname} = $macbody; + } + $line = ''; + last; + } elsif ($macname eq 'defined' || $macname eq 'with' || $macname eq 'undefined' || $macname eq 'without' || $macname eq 'bcond_with' || $macname eq 'bcond_without') { + my @args; + if ($macorig =~ /^\{(.*)\}$/) { + @args = split(' ', $1); + shift @args; + } else { + @args = split(' ', $line); + $line = ''; + } + next unless @args; + if ($macname eq 'bcond_with') { + $macros{"with_$args[0]"} = 1 if exists $macros{"_with_$args[0]"}; + next; + } + if ($macname eq 'bcond_without') { + $macros{"with_$args[0]"} = 1 unless exists $macros{"_without_$args[0]"}; + next; + } + $args[0] = "with_$args[0]" if $macname eq 'with' || $macname eq 'without'; + $line = ((exists($macros{$args[0]}) ? 1 : 0) ^ ($macname eq 'undefined' || $macname eq 'without' ? 1 : 0)).$line; + } elsif (exists($macros{$macname})) { + if (!defined($macros{$macname})) { + print STDERR "Warning: spec file parser",($lineno?" line $lineno":''),": can't expand '$macname'\n" if $config->{'warnings'}; + $line = 'MACRO'; + last; + } + $macalt = $macros{$macname} unless defined $macalt; + $macalt = '' if $mactest == -1; + $line = "$macalt$line"; + } elsif ($mactest) { + $macalt = '' if !defined($macalt) || $mactest == 1; + $line = "$macalt$line"; + } else { + $expandedline .= "%$macorig"; + } } } $line = $expandedline . $line; @@ -312,25 +311,25 @@ sub parse { } if ($main_preamble) { if ($line =~ /^(Name|Version|Disttag|Release)\s*:\s*(\S+)/i) { - $ret->{lc $1} = $2; - $macros{lc $1} = $2; + $ret->{lc $1} = $2; + $macros{lc $1} = $2; } elsif ($line =~ /^(Source\d*|Patch\d*|Url)\s*:\s*(\S+)/i) { - $ret->{lc $1} = $2; + $ret->{lc $1} = $2; } elsif ($line =~ /^ExclusiveArch\s*:\s*(.*)/i) { - $exclarch ||= []; - push @$exclarch, split(' ', $1); + $exclarch ||= []; + push @$exclarch, split(' ', $1); } elsif ($line =~ /^ExcludeArch\s*:\s*(.*)/i) { - $badarch ||= []; - push @$badarch, split(' ', $1); + $badarch ||= []; + push @$badarch, split(' ', $1); } } if ($line =~ /^(?:Requires\(pre\)|Requires\(post\)|PreReq)\s*:\s*(\S.*)$/i) { my $deps = $1; my @deps = $deps =~ /([^\s\[,]+)(\s+[<=>]+\s+[^\s\[,]+)?(\s+\[[^\]]+\])?[\s,]*/g; while (@deps) { - my ($pack, $vers, $qual) = splice(@deps, 0, 3); - next if $pack =~ /\//; - push @prereqs, $pack unless grep {$_ eq $pack} @prereqs; + my ($pack, $vers, $qual) = splice(@deps, 0, 3); + next if $pack =~ /\//; + push @prereqs, $pack unless grep {$_ eq $pack} @prereqs; } next; } @@ -342,64 +341,64 @@ sub parse { my $replace = 0; my @ndeps = (); while (@deps) { - my ($pack, $vers, $qual) = splice(@deps, 0, 3); - if (defined($qual)) { + my ($pack, $vers, $qual) = splice(@deps, 0, 3); + if (defined($qual)) { $replace = 1; my $arch = $macros{'_target_cpu'} || ''; my $proj = $macros{'_target_project'} || ''; - $qual =~ s/^\s*\[//; - $qual =~ s/\]$//; - my $isneg = 0; - my $bad; - for my $q (split('[\s,]', $qual)) { - $isneg = 1 if $q =~ s/^\!//; - $bad = 1 if !defined($bad) && !$isneg; - if ($isneg) { - if ($q eq $arch || $q eq $proj) { - $bad = 1; - last; - } - } elsif ($q eq $arch || $q eq $proj) { - $bad = 0; - } - } - next if $bad; - } - $vers = '' unless defined $vers; - $vers =~ s/=(>|<)/$1=/; - push @ndeps, "$pack$vers"; + $qual =~ s/^\s*\[//; + $qual =~ s/\]$//; + my $isneg = 0; + my $bad; + for my $q (split('[\s,]', $qual)) { + $isneg = 1 if $q =~ s/^\!//; + $bad = 1 if !defined($bad) && !$isneg; + if ($isneg) { + if ($q eq $arch || $q eq $proj) { + $bad = 1; + last; + } + } elsif ($q eq $arch || $q eq $proj) { + $bad = 0; + } + } + next if $bad; + } + $vers = '' unless defined $vers; + $vers =~ s/=(>|<)/$1=/; + push @ndeps, "$pack$vers"; } $replace = 1 if grep {/^-/} @ndeps; if (lc($what) ne 'buildrequires') { - push @packdeps, map {"-$_"} @ndeps; - next; + push @packdeps, map {"-$_"} @ndeps; + next; } if (defined($hasnfb)) { if ((grep {$_ eq 'glibc' || $_ eq 'rpm' || $_ eq 'gcc' || $_ eq 'bash'} @ndeps) > 2) { # ignore old generated BuildRequire lines. - $xspec->[-1] = [ $xspec->[-1], undef ] if $xspec; - next; - } + $xspec->[-1] = [ $xspec->[-1], undef ] if $xspec; + next; + } } push @packdeps, @ndeps; next unless $xspec && $inspec; if ($replace) { - my @cndeps = grep {!/^-/} @ndeps; - if (@cndeps) { + my @cndeps = grep {!/^-/} @ndeps; + if (@cndeps) { $xspec->[-1] = [ $xspec->[-1], "$what: ".join(' ', @cndeps) ]; - } else { + } else { $xspec->[-1] = [ $xspec->[-1], '']; - } + } } next; } if ($line =~ /^\s*%package\s+(-n\s+)?(\S+)/) { if ($1) { - push @subpacks, $2; + push @subpacks, $2; } else { - push @subpacks, $ret->{'name'}.'-'.$2 if defined $ret->{'name'}; + push @subpacks, $ret->{'name'}.'-'.$2 if defined $ret->{'name'}; } $preamble = 1; $main_preamble = 0; @@ -472,7 +471,7 @@ sub rpmq { push @stags, 'BASENAMES', 'DIRNAMES', 'DIRINDEXES', 'OLDFILENAMES' if $need_filenames; @stags = grep { $_ ne 'FILENAMES' } @stags if $need_filenames; - my %stags = map {0 + ($rpmstag{$_} || $_) => $_} @stags; + my %stags = map {0 + ($rpmstag{$_} || $_) => $_} @stags; my ($magic, $sigtype, $headmagic, $cnt, $cntdata, $lead, $head, $index, $data, $tag, $type, $offset, $count); @@ -769,8 +768,8 @@ sub queryhdrmd5 { local *F; open(F, '<', $bin) || die("$bin: $!\n"); my $buf = ''; - my $l; - while (length($buf) < 96 + 16) { + my $l; + while (length($buf) < 96 + 16) { $l = sysread(F, $buf, 4096, length($buf)); if (!$l) { warn("$bin: read error\n"); diff --git a/baselibs_global-deb.conf b/baselibs_global-deb.conf index ae86495..3a56a1a 100644 --- a/baselibs_global-deb.conf +++ b/baselibs_global-deb.conf @@ -37,4 +37,3 @@ requires " = " package /(.*)-debuginfo$/ +/usr/lib(64)?/debug/.*/lib(64)?/.*\.(so.*|o|a|la)\.debug$ - diff --git a/baselibs_global.conf b/baselibs_global.conf index 126e288..76fe238 100644 --- a/baselibs_global.conf +++ b/baselibs_global.conf @@ -37,4 +37,3 @@ requires "- = " package /(.*)-debuginfo$/ +/usr/lib(64)?/debug/.*/lib(64)?/.*\.(so.*|o|a|la)\.debug$ +/usr/lib(64)?/debug/.build-id/.* - diff --git a/build b/build index 338c017..f46e97a 100755 --- a/build +++ b/build @@ -205,21 +205,21 @@ cleanup_and_exit () { trap EXIT test -z "$1" && set 0 if test -n "$RUNNING_IN_VM" ; then - cd / - if test -n "$VM_SWAP" -a -e "$VM_SWAP" ; then - swapoff "$VM_SWAP" 2>/dev/null - echo -n "BUILDSTATUS$1" >"$VM_SWAP" - fi - exec >&0 2>&0 # so that the logging tee finishes - sleep 1 # wait till tee terminates - kill -9 -1 # goodbye cruel world - exec /bin/bash -c 'mount -n -o remount,ro / ; halt -f -p' - halt -f -p + cd / + if test -n "$VM_SWAP" -a -e "$VM_SWAP" ; then + swapoff "$VM_SWAP" 2>/dev/null + echo -n "BUILDSTATUS$1" >"$VM_SWAP" + fi + exec >&0 2>&0 # so that the logging tee finishes + sleep 1 # wait till tee terminates + kill -9 -1 # goodbye cruel world + exec /bin/bash -c 'mount -n -o remount,ro / ; halt -f -p' + halt -f -p else - umount -n $BUILD_ROOT/proc 2>/dev/null || true - umount -n $BUILD_ROOT/dev/pts 2>/dev/null || true - test "$VM_IMAGE" = 1 && VM_IMAGE= - [ -n "$VM_IMAGE" ] && umount $BUILD_ROOT 2>/dev/null || true + umount -n $BUILD_ROOT/proc 2>/dev/null || true + umount -n $BUILD_ROOT/dev/pts 2>/dev/null || true + test "$VM_IMAGE" = 1 && VM_IMAGE= + [ -n "$VM_IMAGE" ] && umount $BUILD_ROOT 2>/dev/null || true fi exit $1 } @@ -232,11 +232,11 @@ fail_exit() shellquote() { for arg; do - arg=${arg/\\/\\\\} - arg=${arg/\$/\\\$} - arg=${arg/\"/\\\"} - arg=${arg/\`/\\\`} - echo -n " \"$arg\"" + arg=${arg/\\/\\\\} + arg=${arg/\$/\\\$} + arg=${arg/\"/\\\"} + arg=${arg/\`/\\\`} + echo -n " \"$arg\"" done } @@ -244,58 +244,58 @@ shellquote() # through /bin/su -c toshellscript() { - echo "#!/bin/sh -x" - echo -n exec - shellquote "$@" - echo + echo "#!/bin/sh -x" + echo -n exec + shellquote "$@" + echo } setupccache() { if [ "$ccache" = 1 ]; then - if mkdir -p $BUILD_ROOT/var/lib/build/ccache/bin; then - for i in gcc g++ cc c++; do -# ln -sf /usr/bin/ccache $BUILD_ROOT/var/lib/build/ccache/bin/$i - rm -f $BUILD_ROOT/var/lib/build/ccache/bin/$i - test -e $BUILD_ROOT/usr/bin/$i || continue - echo '#! /bin/sh' > $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo "test -e /usr/bin/$i || exit 1" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo 'export PATH=/opt/icecream/bin:/usr/bin:$PATH' >> $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo "ccache $i \"\$@\"" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i - chmod 755 $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo "Installed ccache wrapper as $BUILD_ROOT/var/lib/build/ccache/bin/$i" - done - fi - mkdir -p "$BUILD_ROOT"/.ccache - chroot "$BUILD_ROOT" chown -R "$BUILD_USER" "/.ccache" - echo "export CCACHE_DIR=/.ccache" > "$BUILD_ROOT"/etc/profile.d/build_ccache.sh - echo 'export PATH=/var/lib/build/ccache/bin:$PATH' >> "$BUILD_ROOT"/etc/profile.d/build_ccache.sh + if mkdir -p $BUILD_ROOT/var/lib/build/ccache/bin; then + for i in gcc g++ cc c++; do +# ln -sf /usr/bin/ccache $BUILD_ROOT/var/lib/build/ccache/bin/$i + rm -f $BUILD_ROOT/var/lib/build/ccache/bin/$i + test -e $BUILD_ROOT/usr/bin/$i || continue + echo '#! /bin/sh' > $BUILD_ROOT/var/lib/build/ccache/bin/$i + echo "test -e /usr/bin/$i || exit 1" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i + echo 'export PATH=/opt/icecream/bin:/usr/bin:$PATH' >> $BUILD_ROOT/var/lib/build/ccache/bin/$i + echo "ccache $i \"\$@\"" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i + chmod 755 $BUILD_ROOT/var/lib/build/ccache/bin/$i + echo "Installed ccache wrapper as $BUILD_ROOT/var/lib/build/ccache/bin/$i" + done + fi + mkdir -p "$BUILD_ROOT"/.ccache + chroot "$BUILD_ROOT" chown -R "$BUILD_USER" "/.ccache" + echo "export CCACHE_DIR=/.ccache" > "$BUILD_ROOT"/etc/profile.d/build_ccache.sh + echo 'export PATH=/var/lib/build/ccache/bin:$PATH' >> "$BUILD_ROOT"/etc/profile.d/build_ccache.sh else - rm -f "$BUILD_ROOT$builduserhome"/bin/{gcc,g++,cc,c++} - rm -f "$BUILD_ROOT"/var/lib/build/ccache/bin/{gcc,g++,cc,c++} + rm -f "$BUILD_ROOT$builduserhome"/bin/{gcc,g++,cc,c++} + rm -f "$BUILD_ROOT"/var/lib/build/ccache/bin/{gcc,g++,cc,c++} fi } setupicecream() { if [ "$icecream" -eq 0 ]; then - rm -rf "$BUILD_ROOT"/var/run/icecream - rm -f "$BUILD_ROOT"/etc/profile.d/build_icecream.sh - return + rm -rf "$BUILD_ROOT"/var/run/icecream + rm -f "$BUILD_ROOT"/etc/profile.d/build_icecream.sh + return fi if ! chroot "$BUILD_ROOT" rpm -q icecream >/dev/null 2>/dev/null; then - echo "*** icecream package not installed ***" - false - return + echo "*** icecream package not installed ***" + false + return fi echo "using icecream with $icecream jobs" if [ "$ccache" -ne 1 ]; then - echo 'export PATH=/opt/icecream/bin:$PATH' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh + echo 'export PATH=/opt/icecream/bin:$PATH' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh else - echo 'export CCACHE_PATH=/opt/icecream/bin' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh + echo 'export CCACHE_PATH=/opt/icecream/bin' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh fi local icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/var/run/icecream/*.tar.{bz2,gz}`) @@ -304,30 +304,30 @@ setupicecream() # XXX use changelog like autobuild does instead? # only run create-env if compiler or glibc changed if [ -z "$icecc_vers" \ - -o ! -e "$BUILD_ROOT/$icecc_vers" \ - -o "$BUILD_ROOT/usr/bin/gcc" -nt "$BUILD_ROOT/$icecc_vers" \ - -o "$BUILD_ROOT/usr/bin/g++" -nt "$BUILD_ROOT/$icecc_vers" \ - -o "$BUILD_ROOT/usr/bin/as" -nt "$BUILD_ROOT/$icecc_vers" \ - -o "$BUILD_ROOT/lib/libc.so.6" -nt "$BUILD_ROOT/$icecc_vers" ] + -o ! -e "$BUILD_ROOT/$icecc_vers" \ + -o "$BUILD_ROOT/usr/bin/gcc" -nt "$BUILD_ROOT/$icecc_vers" \ + -o "$BUILD_ROOT/usr/bin/g++" -nt "$BUILD_ROOT/$icecc_vers" \ + -o "$BUILD_ROOT/usr/bin/as" -nt "$BUILD_ROOT/$icecc_vers" \ + -o "$BUILD_ROOT/lib/libc.so.6" -nt "$BUILD_ROOT/$icecc_vers" ] then - rm -rf $BUILD_ROOT/var/run/icecream - mkdir -p $BUILD_ROOT/var/run/icecream - if [ -e "$BUILD_ROOT"/usr/bin/create-env ]; then - createenv=/usr/bin/create-env - elif [ -e "$BUILD_ROOT"/usr/lib/icecc/icecc-create-env ]; then - createenv="/usr/lib/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX - elif [ -e "$BUILD_ROOT"/usr/lib64/icecc/icecc-create-env ]; then - createenv="/usr/lib64/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX - else - echo "create-env not found" - false - return - fi - chroot $BUILD_ROOT bash -c "cd /var/run/icecream; $createenv" || cleanup_and_exit 1 - icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/var/run/icecream/*.tar.{bz2,gz}`) - icecc_vers=${icecc_vers//$BUILD_ROOT/} + rm -rf $BUILD_ROOT/var/run/icecream + mkdir -p $BUILD_ROOT/var/run/icecream + if [ -e "$BUILD_ROOT"/usr/bin/create-env ]; then + createenv=/usr/bin/create-env + elif [ -e "$BUILD_ROOT"/usr/lib/icecc/icecc-create-env ]; then + createenv="/usr/lib/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX + elif [ -e "$BUILD_ROOT"/usr/lib64/icecc/icecc-create-env ]; then + createenv="/usr/lib64/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX + else + echo "create-env not found" + false + return + fi + chroot $BUILD_ROOT bash -c "cd /var/run/icecream; $createenv" || cleanup_and_exit 1 + icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/var/run/icecream/*.tar.{bz2,gz}`) + icecc_vers=${icecc_vers//$BUILD_ROOT/} else - echo "reusing existing icecream environment $icecc_vers" + echo "reusing existing icecream environment $icecc_vers" fi if [ -n "$icecc_vers" ]; then echo "export ICECC_VERSION=$icecc_vers" >> "$BUILD_ROOT"/etc/profile.d/build_icecream.sh @@ -337,19 +337,19 @@ setupicecream() setmemorylimit() { if [ -n "$VM_IMAGE" -o -n "$RUNNING_IN_VM" ]; then - return + return fi local mem while read mem; do - case "$mem" in - MemTotal:*) - set -- $mem + case "$mem" in + MemTotal:*) + set -- $mem eval "mem=\$(($2/3*4))" - ulimit -v $mem - echo "Memory limit set to ${mem}KB" - break; - ;; - esac + ulimit -v $mem + echo "Memory limit set to ${mem}KB" + break; + ;; + esac done < <(cat /proc/meminfo) # cat for proc stuff } @@ -367,61 +367,61 @@ function create_baselibs { ## Nb REPO is the name of the project instance ## DISTRO is the underlying (remote?) distro # if test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs_${REPO}.conf ; then -# BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs_${REPO}.conf" +# BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs_${REPO}.conf" # elif test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs_${DISTRO}.conf ; then -# BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs_${DISTRO}.conf" +# BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs_${DISTRO}.conf" # elif test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs.conf ; then if test "$BUILDTYPE" == "dsc" ; then - BPKGS=$BDEBS + BPKGS=$BDEBS else # spec and kiwi - if test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs.conf ; then - BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs.conf" - fi - if test -e $BUILD_ROOT/usr/lib/build/baselibs_global.conf; then - BASELIBS_GLOBAL="-c /usr/lib/build/baselibs_global.conf" - fi - BPKGS=$BRPMS + if test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs.conf ; then + BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs.conf" + fi + if test -e $BUILD_ROOT/usr/lib/build/baselibs_global.conf; then + BASELIBS_GLOBAL="-c /usr/lib/build/baselibs_global.conf" + fi + BPKGS=$BRPMS fi if test -f $BUILD_ROOT/usr/lib/build/mkbaselibs ; then - if test -z "$BASELIBS_CFG" -a -e $BUILD_ROOT/usr/lib/build/baselibs.conf ; then - BASELIBS_CFG="-c /usr/lib/build/baselibs.conf" - fi - chroot $BUILD_ROOT /usr/lib/build/mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $BPKGS || cleanup_and_exit 1 + if test -z "$BASELIBS_CFG" -a -e $BUILD_ROOT/usr/lib/build/baselibs.conf ; then + BASELIBS_CFG="-c /usr/lib/build/baselibs.conf" + fi + chroot $BUILD_ROOT /usr/lib/build/mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $BPKGS || cleanup_and_exit 1 else - # use external version - rm -rf $BUILD_ROOT/.mkbaselibs - mkdir -p $BUILD_ROOT/.mkbaselibs - cp -f $BUILD_DIR/mkbaselibs $BUILD_ROOT/.mkbaselibs/ - if test "$BUILDTYPE" == "dsc" ; then - cp -f $BUILD_DIR/baselibs_global-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf - cp -f $BUILD_ROOT$TOPDIR/SOURCES/baselibs-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs-deb.conf - BASELIBS_CFG="-c /.mkbaselibs/baselibs-deb.conf" - else - cp -f $BUILD_DIR/baselibs_global.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf - if test -z "$BASELIBS_CFG" -a -e $BUILD_DIR/baselibs.conf; then - cp -f $BUILD_DIR/baselibs.conf $BUILD_ROOT/.mkbaselibs/baselibs.conf - BASELIBS_CFG="-c /.mkbaselibs/baselibs.conf" - fi - fi - if test -e $BUILD_ROOT/.mkbaselibs/baselibs_g.conf; then - BASELIBS_GLOBAL="-c /.mkbaselibs/baselibs_g.conf" - fi - chroot $BUILD_ROOT /.mkbaselibs/mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $BPKGS || cleanup_and_exit 1 - rm -rf $BUILD_ROOT/.mkbaselibs + # use external version + rm -rf $BUILD_ROOT/.mkbaselibs + mkdir -p $BUILD_ROOT/.mkbaselibs + cp -f $BUILD_DIR/mkbaselibs $BUILD_ROOT/.mkbaselibs/ + if test "$BUILDTYPE" == "dsc" ; then + cp -f $BUILD_DIR/baselibs_global-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf + cp -f $BUILD_ROOT$TOPDIR/SOURCES/baselibs-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs-deb.conf + BASELIBS_CFG="-c /.mkbaselibs/baselibs-deb.conf" + else + cp -f $BUILD_DIR/baselibs_global.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf + if test -z "$BASELIBS_CFG" -a -e $BUILD_DIR/baselibs.conf; then + cp -f $BUILD_DIR/baselibs.conf $BUILD_ROOT/.mkbaselibs/baselibs.conf + BASELIBS_CFG="-c /.mkbaselibs/baselibs.conf" + fi + fi + if test -e $BUILD_ROOT/.mkbaselibs/baselibs_g.conf; then + BASELIBS_GLOBAL="-c /.mkbaselibs/baselibs_g.conf" + fi + chroot $BUILD_ROOT /.mkbaselibs/mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $BPKGS || cleanup_and_exit 1 + rm -rf $BUILD_ROOT/.mkbaselibs fi } detect_vm_2nd_stage() { if ! test "$0" = "/.build/build" ; then - return 1 + return 1 fi if test $$ -eq 1 ; then - # ignore special init signals if we're init - trap '' TERM HUP - $0 "$@" - cleanup_and_exit 1 + # ignore special init signals if we're init + trap '' TERM HUP + $0 "$@" + cleanup_and_exit 1 fi trap - TERM HUP echo "2nd stage started in virtual machine" @@ -430,10 +430,10 @@ detect_vm_2nd_stage() . $BUILD_DIR/build.data echo "machine type: `uname -m`" if test "$PERSONALITY" != 0 -a -z "$PERSONALITY_SET" ; then - export PERSONALITY_SET=true - echo "switching personality to $PERSONALITY..." - # this is 32bit perl/glibc, thus the 32bit syscall number - exec perl -e 'syscall(136, '$PERSONALITY') == -1 && warn("personality: $!\n");exec "/.build/build" || die("/.build/build: $!\n")' + export PERSONALITY_SET=true + echo "switching personality to $PERSONALITY..." + # this is 32bit perl/glibc, thus the 32bit syscall number + exec perl -e 'syscall(136, '$PERSONALITY') == -1 && warn("personality: $!\n");exec "/.build/build" || die("/.build/build: $!\n")' fi PATH=$BUILD_DIR:$PATH RUNNING_IN_VM=true @@ -445,22 +445,22 @@ detect_vm_2nd_stage() # chmod 0666 /dev/kqemu # fi if test -n "$VM_SWAP" ; then - for i in 1 2 3 4 5 6 7 8 9 10 ; do - test -e "$VM_SWAP" && break - test $i = 1 && echo "waiting for $VM_SWAP to appear" - echo -n . - sleep 1 - done - test $i = 1 || echo - # recreate the swap device manually if it didn't exist for some - # reason, hardcoded to hda2 atm - if ! test -b "$VM_SWAP" ; then - rm -f "$VM_SWAP" - umask 027 - mknod "$VM_SWAP" b 3 2 - umask 022 - fi - swapon -v "$VM_SWAP" || exit 1 + for i in 1 2 3 4 5 6 7 8 9 10 ; do + test -e "$VM_SWAP" && break + test $i = 1 && echo "waiting for $VM_SWAP to appear" + echo -n . + sleep 1 + done + test $i = 1 || echo + # recreate the swap device manually if it didn't exist for some + # reason, hardcoded to hda2 atm + if ! test -b "$VM_SWAP" ; then + rm -f "$VM_SWAP" + umask 027 + mknod "$VM_SWAP" b 3 2 + umask 022 + fi + swapon -v "$VM_SWAP" || exit 1 fi HOST="$MYHOSTNAME" @@ -471,42 +471,42 @@ find_spec_files() { local spec files if [ -z "$SPECFILES" ]; then - set -- "`pwd`" + set -- "`pwd`" else - set -- "${SPECFILES[@]}" + set -- "${SPECFILES[@]}" fi SPECFILES=() for spec in "$@"; do - if [ "$spec" = "${spec#/}" ]; then - spec="`pwd`/$spec" - fi - - if [ -d "$spec" ]; then - specs=("$spec"/*.spec) - if [ -n "$specs" ]; then - SPECFILES=("${SPECFILES[@]}" "${specs[@]}") - else - specs=("$spec"/*.spec) - if [ -n "$specs" ]; then - SPECFILES=("${SPECFILES[@]}" "${specs[@]}") - fi - fi - else - SPECFILES[${#SPECFILES[@]}]="$spec"; - fi + if [ "$spec" = "${spec#/}" ]; then + spec="`pwd`/$spec" + fi + + if [ -d "$spec" ]; then + specs=("$spec"/*.spec) + if [ -n "$specs" ]; then + SPECFILES=("${SPECFILES[@]}" "${specs[@]}") + else + specs=("$spec"/*.spec) + if [ -n "$specs" ]; then + SPECFILES=("${SPECFILES[@]}" "${specs[@]}") + fi + fi + else + SPECFILES[${#SPECFILES[@]}]="$spec"; + fi done if test -z "$SPECFILES"; then - echo no spec files or src rpms found in $@. exit... - cleanup_and_exit 1 + echo no spec files or src rpms found in $@. exit... + cleanup_and_exit 1 fi } become_root_or_fail() { if [ ! -w /root ]; then - echo "You have to be root to use $0" >&2 - exit 1 + echo "You have to be root to use $0" >&2 + exit 1 fi cleanup_and_exit 1 } @@ -514,25 +514,25 @@ become_root_or_fail() mkdir_build_root() { if [ -d "$BUILD_ROOT" ]; then - # check if it is owned by root - if [ -z "$RUNNING_IN_VM" -a \! -O "$BUILD_ROOT" -a "`stat -c %u $BUILD_ROOT`" -ne 0 ]; then - echo "BUILD_ROOT=$BUILD_ROOT must be owned by root. Exit..." - cleanup_and_exit 1 - fi + # check if it is owned by root + if [ -z "$RUNNING_IN_VM" -a \! -O "$BUILD_ROOT" -a "`stat -c %u $BUILD_ROOT`" -ne 0 ]; then + echo "BUILD_ROOT=$BUILD_ROOT must be owned by root. Exit..." + cleanup_and_exit 1 + fi else - test "$BUILD_ROOT" != "${BUILD_ROOT%/*}" && mkdir -p "${BUILD_ROOT%/*}" - if ! mkdir $BUILD_ROOT; then - echo "can not create BUILD_ROOT=$BUILD_ROOT. Exit..." - cleanup_and_exit 1 - fi + test "$BUILD_ROOT" != "${BUILD_ROOT%/*}" && mkdir -p "${BUILD_ROOT%/*}" + if ! mkdir $BUILD_ROOT; then + echo "can not create BUILD_ROOT=$BUILD_ROOT. Exit..." + cleanup_and_exit 1 + fi fi - + rm -rf "$BUILD_ROOT"/.build.packages } linux64() { - perl -e 'syscall('$PERSONALITY_SYSCALL', 0); exec(@ARGV) || die("$ARGV[0]: $!\n")' "$@" + perl -e 'syscall('$PERSONALITY_SYSCALL', 0); exec(@ARGV) || die("$ARGV[0]: $!\n")' "$@" } #### main #### @@ -583,10 +583,10 @@ while test -n "$1"; do ;; *-rpms) BUILD_RPMS="$ARG" - if [ -z "$BUILD_RPMS" ] ; then - echo_help - cleanup_and_exit - fi + if [ -z "$BUILD_RPMS" ] ; then + echo_help + cleanup_and_exit + fi shift ;; *-arch) @@ -597,12 +597,12 @@ while test -n "$1"; do export VERIFY_BUILD_SYSTEM=true ;; *-target) - ABUILD_TARGET_ARCH="$ARG" - shift + ABUILD_TARGET_ARCH="$ARG" + shift ;; - *-jobs) - BUILD_JOBS="$ARG" - shift + *-jobs) + BUILD_JOBS="$ARG" + shift ;; *-extra*packs|-X) BUILD_EXTRA_PACKS="$BUILD_EXTRA_PACKS $ARG" @@ -625,19 +625,19 @@ while test -n "$1"; do OLD_PACKAGES="$ARG" shift ;; - *-dist) - BUILD_DIST="$ARG" - export BUILD_DIST - shift + *-dist) + BUILD_DIST="$ARG" + export BUILD_DIST + shift ;; *-xen|*-kvm|--uml|--qemu) - VM_TYPE=${PARAM##*-} - if [ -n "$ARG" -a "$ARG" = "${ARG#-}" ]; then - VM_IMAGE="$ARG" - shift - else - VM_IMAGE=1 - fi + VM_TYPE=${PARAM##*-} + if [ -n "$ARG" -a "$ARG" = "${ARG#-}" ]; then + VM_IMAGE="$ARG" + shift + else + VM_IMAGE=1 + fi ;; *-xenswap|*-swap) VM_SWAP="$ARG" @@ -649,7 +649,7 @@ while test -n "$1"; do ;; *-rpmlist) RPMLIST="--rpmlist $ARG" - BUILD_RPMS= + BUILD_RPMS= shift ;; *-release) @@ -675,12 +675,12 @@ while test -n "$1"; do USEUSEDFORBUILD="--useusedforbuild" ;; *-list*state) - LIST_STATE=true + LIST_STATE=true ;; --define|--with|--without) definesnstuff[${#definesnstuff[@]}]="$PARAM"; definesnstuff[${#definesnstuff[@]}]="$ARG"; - shift + shift ;; --repository|--repo) if [ -z "$ARG" ] ; then @@ -698,9 +698,9 @@ while test -n "$1"; do cleanup_and_exit 1 fi icecream="$ARG" - if [ "$icecream" -gt 0 ]; then - BUILD_JOBS="$ARG" - fi + if [ "$icecream" -gt 0 ]; then + BUILD_JOBS="$ARG" + fi shift ;; --ccache) @@ -711,14 +711,14 @@ while test -n "$1"; do ;; --incarnation) INCARNATION=$ARG - shift + shift ;; --disturl) DISTURL=$ARG - shift + shift ;; --linksources) - LINKSOURCES=true + LINKSOURCES=true ;; ----noarg) echo "$ARG does not take an argument" @@ -753,61 +753,61 @@ done if test -n "$KILL" ; then test -z "$SRCDIR" || usage if test -z "$VM_IMAGE" ; then - if ! $BUILD_DIR/killchroot -s 9 $BUILD_ROOT ; then - echo "could not kill build in $BUILD_ROOT" - cleanup_and_exit 1 - fi + if ! $BUILD_DIR/killchroot -s 9 $BUILD_ROOT ; then + echo "could not kill build in $BUILD_ROOT" + cleanup_and_exit 1 + fi elif test "$VM_TYPE" = 'xen'; then - XENID="${VM_IMAGE%/root}" - XENID="${XENID%/tmpfs}" - XENID="${XENID##*/}" - if xm list "build:$XENID" >/dev/null 2>&1 ; then - if ! xm destroy "build:$XENID" ; then - echo "could not kill xen build $XENID" - cleanup_and_exit 1 - fi - fi + XENID="${VM_IMAGE%/root}" + XENID="${XENID%/tmpfs}" + XENID="${XENID##*/}" + if xm list "build:$XENID" >/dev/null 2>&1 ; then + if ! xm destroy "build:$XENID" ; then + echo "could not kill xen build $XENID" + cleanup_and_exit 1 + fi + fi elif test -n "$VM_TYPE"; then - if ! fuser -k -TERM "$VM_IMAGE"; then - echo "could not kill build in $VM_IMAGE" - cleanup_and_exit 1 - fi + if ! fuser -k -TERM "$VM_IMAGE"; then + echo "could not kill build in $VM_IMAGE" + cleanup_and_exit 1 + fi else - echo "don't know how to kill this build job" - cleanup_and_exit 1 + echo "don't know how to kill this build job" + cleanup_and_exit 1 fi cleanup_and_exit 0 fi if [ "$VM_TYPE" = 'kvm' ]; then if [ ! -r /dev/kvm -o ! -x "$qemu_bin"-kvm ]; then - echo "" + echo "" fi qemu_bin="$kvm_bin" qemu_kernel="$kvm_kernel" qemu_initrd="$kvm_initrd" if [ ! -e $qemu_initrd-virtio -o $qemu_kernel -nt $qemu_initrd-virtio ]; then - if [ ! -w /root ]; then - echo "No initrd that provides virtio support found. virtio accelleration disabled." - echo "Run the following command as root to enable virtio:" - shellquote "${mkinitrd_virtio_cmd[@]}" - echo - elif /sbin/modinfo virtio_pci >/dev/null 2>&1; then - echo "creating $qemu_initrd-virtio" - "${mkinitrd_virtio_cmd[@]}" || cleanup_and_exit 1 - kvm_virtio=1 - fi + if [ ! -w /root ]; then + echo "No initrd that provides virtio support found. virtio accelleration disabled." + echo "Run the following command as root to enable virtio:" + shellquote "${mkinitrd_virtio_cmd[@]}" + echo + elif /sbin/modinfo virtio_pci >/dev/null 2>&1; then + echo "creating $qemu_initrd-virtio" + "${mkinitrd_virtio_cmd[@]}" || cleanup_and_exit 1 + kvm_virtio=1 + fi else - kvm_virtio=1 + kvm_virtio=1 fi if [ "$kvm_virtio" = 1 ]; then - qemu_initrd="$qemu_initrd-virtio" - VM_SWAPDEV=/dev/vdb - qemu_rootdev=/dev/vda + qemu_initrd="$qemu_initrd-virtio" + VM_SWAPDEV=/dev/vdb + qemu_rootdev=/dev/vda else - VM_SWAPDEV=/dev/sdb - qemu_rootdev=/dev/sda + VM_SWAPDEV=/dev/sdb + qemu_rootdev=/dev/sda fi fi @@ -818,7 +818,7 @@ fi if [ -z "$RPMLIST" ]; then if [ -z "$repos" -a -z "$BUILD_RPMS" ]; then - BUILD_RPMS="/media/dvd/suse" + BUILD_RPMS="/media/dvd/suse" fi else repos=() @@ -840,9 +840,9 @@ if test -n "$LIST_STATE" ; then rm -rf $BUILD_ROOT/usr/src/packages mkdir -p $BUILD_ROOT/usr/src/packages/SOURCES $BUILD_ROOT/usr/src/packages/SPECS rpm -i --nodigest --nosignature --root $BUILD_ROOT $SPECFILE || { - echo "could not install $SPECFILE." 2>&1 - rm -rf $BUILD_ROOT - cleanup_and_exit 3 + echo "could not install $SPECFILE." 2>&1 + rm -rf $BUILD_ROOT + cleanup_and_exit 3 } for SPECFILE in $BUILD_ROOT/usr/src/packages/SPECS/*.spec ; do : ; done fi @@ -854,34 +854,34 @@ fi if test -z "$RUNNING_IN_VM" ; then if test -n "$VM_IMAGE" ; then - if test "$VM_IMAGE" = 1 ; then - VM_IMAGE="$BUILD_ROOT.img" - fi - if test ! -e "$VM_IMAGE" ; then - echo "you need to create a file system on $VM_IMAGE first" - cleanup_and_exit 3 - fi + if test "$VM_IMAGE" = 1 ; then + VM_IMAGE="$BUILD_ROOT.img" + fi + if test ! -e "$VM_IMAGE" ; then + echo "you need to create a file system on $VM_IMAGE first" + cleanup_and_exit 3 + fi fi if test -n "$VM_IMAGE" ; then - if test -n "$CLEAN_BUILD" ; then - echo "Creating filesystem on $VM_IMAGE" - $vm_img_mkfs $VM_IMAGE || cleanup_and_exit 3 - if test -n "$vm_img_tunefs" ; then - $vm_img_tunefs $VM_IMAGE || cleanup_and_exit 3 - fi - fi - mkdir_build_root - if [ -w /root ]; then - mount -o loop $VM_IMAGE $BUILD_ROOT || cleanup_and_exit 3 - else - mount $BUILD_ROOT || cleanup_and_exit 3 - fi + if test -n "$CLEAN_BUILD" ; then + echo "Creating filesystem on $VM_IMAGE" + $vm_img_mkfs $VM_IMAGE || cleanup_and_exit 3 + if test -n "$vm_img_tunefs" ; then + $vm_img_tunefs $VM_IMAGE || cleanup_and_exit 3 + fi + fi + mkdir_build_root + if [ -w /root ]; then + mount -o loop $VM_IMAGE $BUILD_ROOT || cleanup_and_exit 3 + else + mount $BUILD_ROOT || cleanup_and_exit 3 + fi else - test -w /root || become_root_or_fail + test -w /root || become_root_or_fail fi if test -n "$VM_SWAP" ; then - dd if=/dev/zero of="$VM_SWAP" bs=12 count=1 conv=notrunc 2>/dev/null - mkswap "$VM_SWAP" + dd if=/dev/zero of="$VM_SWAP" bs=12 count=1 conv=notrunc 2>/dev/null + mkswap "$VM_SWAP" fi fi @@ -905,9 +905,9 @@ if test -n "$LOGFILE" ; then rm -f $LOGFILE touch $LOGFILE if test -n "$VM_IMAGE" ; then - exec 1> >(exec -a 'build logging tee' perl -e 'open(F,">>",$ARGV[0])||die("$ARGV[0]: $!\n");$|=1;select(F);$|=1;while(){print STDOUT;s/^\r//s;s/\r\n/\n/gs;print F}' $LOGFILE) 2>&1 + exec 1> >(exec -a 'build logging tee' perl -e 'open(F,">>",$ARGV[0])||die("$ARGV[0]: $!\n");$|=1;select(F);$|=1;while(){print STDOUT;s/^\r//s;s/\r\n/\n/gs;print F}' $LOGFILE) 2>&1 else - exec 1> >(exec -a 'build logging tee' tee -a $LOGFILE) 2>&1 + exec 1> >(exec -a 'build logging tee' tee -a $LOGFILE) 2>&1 fi fi @@ -948,11 +948,11 @@ for SPECFILE in "${SPECFILES[@]}" ; do cd "$SRCDIR" if [ -z "$RUNNING_IN_VM" ]; then - echo - echo "$HOST started \"build $SPECFILE\" at `date`." - echo - test -n "$REASON" && echo "$REASON" - echo + echo + echo "$HOST started \"build $SPECFILE\" at `date`." + echo + test -n "$REASON" && echo "$REASON" + echo fi # @@ -964,18 +964,18 @@ for SPECFILE in "${SPECFILES[@]}" ; do } if test "$SPECFILE" != "${SPECFILE%.src.rpm}" ; then - echo processing src rpm $SRCDIR/$SPECFILE ... - MYSRCDIR=$BUILD_ROOT/.build-srcdir - rm -rf $MYSRCDIR - mkdir -p $MYSRCDIR - cd $MYSRCDIR || cleanup_and_exit 1 - $BUILD_DIR/unrpm -q $SRCDIR/$SPECFILE || { - echo "could not install $SPECFILE." - cleanup_and_exit 1 - } - for SPECFILE in *.spec ; do : ; done + echo processing src rpm $SRCDIR/$SPECFILE ... + MYSRCDIR=$BUILD_ROOT/.build-srcdir + rm -rf $MYSRCDIR + mkdir -p $MYSRCDIR + cd $MYSRCDIR || cleanup_and_exit 1 + $BUILD_DIR/unrpm -q $SRCDIR/$SPECFILE || { + echo "could not install $SPECFILE." + cleanup_and_exit 1 + } + for SPECFILE in *.spec ; do : ; done else - MYSRCDIR="$SRCDIR" + MYSRCDIR="$SRCDIR" # strip prefix from autogenerated files from OBS. for i in $MYSRCDIR/_service\:*; do mv "$i" "${i##*:}" @@ -985,19 +985,19 @@ for SPECFILE in "${SPECFILES[@]}" ; do # FIX to work with baselibs_$PROJ etc if test "$BUILDTYPE" == "dsc" -a -e ${SRCDIR}/baselibs-deb.conf ; then - # Set CREATE_BASELIBS if not set - echo "dsc build and baselibs-deb.conf present: forcing --baselibs to true" - CREATE_BASELIBS=true + # Set CREATE_BASELIBS if not set + echo "dsc build and baselibs-deb.conf present: forcing --baselibs to true" + CREATE_BASELIBS=true fi # Currently local osc build does not allow extra .deb packages to be # specified on the command line. Both init_buildsystem and expanddeps # need to handle .deb dependencies first # if test -n "$CREATE_BASELIBS" ; then -# case $BUILDTYPE in -# spec) ;; -# dsc) BUILD_EXTRA_PACKS="$BUILD_EXTRA_PACKS libparse-debcontrol-perl" ;; -# esac +# case $BUILDTYPE in +# spec) ;; +# dsc) BUILD_EXTRA_PACKS="$BUILD_EXTRA_PACKS libparse-debcontrol-perl" ;; +# esac # fi echo processing specfile $MYSRCDIR/$SPECFILE ... @@ -1010,172 +1010,172 @@ for SPECFILE in "${SPECFILES[@]}" ; do test -n "$DO_LINT" && ADDITIONAL_PACKS="$ADDITIONAL_PACKS rpmlint-Factory" if test -n "$CHANGELOG" -a -z "$RUNNING_IN_VM" ; then - rm -f $BUILD_ROOT/.build-changelog - case $SPECFILE in - *.dsc) CFFORMAT=debian ;; - *) CFFORMAT=rpm ;; - esac - echo "running changelog2spec --target $CFFORMAT --file $MYSRCDIR/$SPECFILE" - if ! $BUILD_DIR/changelog2spec --target $CFFORMAT --file "$MYSRCDIR/$SPECFILE" > $BUILD_ROOT/.build-changelog ; then - rm -f $BUILD_ROOT/.build-changelog - fi + rm -f $BUILD_ROOT/.build-changelog + case $SPECFILE in + *.dsc) CFFORMAT=debian ;; + *) CFFORMAT=rpm ;; + esac + echo "running changelog2spec --target $CFFORMAT --file $MYSRCDIR/$SPECFILE" + if ! $BUILD_DIR/changelog2spec --target $CFFORMAT --file "$MYSRCDIR/$SPECFILE" > $BUILD_ROOT/.build-changelog ; then + rm -f $BUILD_ROOT/.build-changelog + fi fi if test -n "$VM_TYPE"; then - rm -rf $BUILD_ROOT/.build - mkdir -p $BUILD_ROOT/.build - if test "$DO_INIT" = true ; then - # do fist stage of init_buildsystem - rm -f $BUILD_ROOT/.build.success - set -- init_buildsystem --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS - echo "$* ..." - "$@" || cleanup_and_exit 1 - if [ ! -w /root ]; then - # remove setuid bit if files belong to user to make e.g. mount work - find $BUILD_ROOT/{bin,sbin,usr/bin,usr/sbin} -type f -uid $UID -perm +4000 -print0 | xargs -0 --no-run-if-empty chmod -s - fi + rm -rf $BUILD_ROOT/.build + mkdir -p $BUILD_ROOT/.build + if test "$DO_INIT" = true ; then + # do fist stage of init_buildsystem + rm -f $BUILD_ROOT/.build.success + set -- init_buildsystem --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS + echo "$* ..." + "$@" || cleanup_and_exit 1 + if [ ! -w /root ]; then + # remove setuid bit if files belong to user to make e.g. mount work + find $BUILD_ROOT/{bin,sbin,usr/bin,usr/sbin} -type f -uid $UID -perm +4000 -print0 | xargs -0 --no-run-if-empty chmod -s + fi if [ -d "$OLD_PACKAGES" ]; then rm -rf $BUILD_ROOT/.build.oldpackages cp -a $OLD_PACKAGES $BUILD_ROOT/.build.oldpackages fi - fi - # start up xen, rerun ourself - cp -a $BUILD_DIR/. $BUILD_ROOT/.build - if ! test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then - rm -rf $BUILD_ROOT/.build-srcdir - mkdir $BUILD_ROOT/.build-srcdir - if test "$BUILDTYPE" = kiwi ; then - cp -pRL "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir - else - cp -p "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir - fi - MYSRCDIR=$BUILD_ROOT/.build-srcdir - else - # cwd is at $BUILD_ROOT/.build-srcdir which we want to - # umount later so step aside - cd "$SRCDIR" - fi - Q="'\''" - echo "SPECFILE='${SPECFILE//"'"/$Q}'" > $BUILD_ROOT/.build/build.data - echo "BUILD_JOBS='${BUILD_JOBS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "BUILD_ARCH='${BUILD_ARCH//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "BUILD_RPMS='${BUILD_RPMS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - case $BUILD_DIST in - */*) - cp $BUILD_DIST $BUILD_ROOT/.build/build.dist - BUILD_DIST=/.build/build.dist - ;; - esac - echo "BUILD_DIST='${BUILD_DIST//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "RELEASE='${RELEASE//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "BUILD_DEBUG='${BUILD_DEBUG//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "DO_LINT='${DO_LINT//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "DO_CHECKS='${DO_CHECKS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "NOROOTFORBUILD='${NOROOTFORBUILD//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "CREATE_BASELIBS='$CREATE_BASELIBS'" >> $BUILD_ROOT/.build/build.data - echo "REASON='${REASON//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "CHANGELOG='${CHANGELOG//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "INCARNATION='${INCARNATION//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - echo "DISTURL='${DISTURL//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data - # FIXME: this depends on the kernel and vm. - # could be hda2, sda2 for xen or hdb/sdb for qemu - test -n "$VM_SWAP" && echo "VM_SWAP='${VM_SWAPDEV:-/dev/hda2}'" >> $BUILD_ROOT/.build/build.data - PERSONALITY=0 - test -n "$PERSONALITY_SYSCALL" && PERSONALITY=`perl -e 'print syscall('$PERSONALITY_SYSCALL', 0)."\n"'` - echo "OLD_PACKAGES='$OLD_PACKAGES'" >> $BUILD_ROOT/.build/build.data - echo "PERSONALITY='$PERSONALITY'" >> $BUILD_ROOT/.build/build.data - echo "MYHOSTNAME='`hostname`'" >> $BUILD_ROOT/.build/build.data - echo -n "definesnstuff=(" >> $BUILD_ROOT/.build/build.data - shellquote "${definesnstuff[@]}" >> $BUILD_ROOT/.build/build.data - echo ")" >> $BUILD_ROOT/.build/build.data - echo -n "repos=(" >> $BUILD_ROOT/.build/build.data - shellquote "${repos[@]}" >> $BUILD_ROOT/.build/build.data - echo ")" >> $BUILD_ROOT/.build/build.data - umount -n $BUILD_ROOT/proc 2> /dev/null || true - umount -n $BUILD_ROOT/dev/pts 2> /dev/null || true - umount -n $BUILD_ROOT/mnt 2> /dev/null || true - - # needs to work otherwise we have a corrupted file system - umount $BUILD_ROOT || cleanup_and_exit 1 - - if [ "$VM_TYPE" = 'xen' ]; then - XMROOT=file:$VM_IMAGE - XMROOT=${XMROOT/#file:\/dev/phy:/dev} - XMROOT="disk=$XMROOT,hda1,w" - XMSWAP= - if test -n "$VM_SWAP" ; then - XMSWAP=file:$VM_SWAP - XMSWAP=${XMSWAP/#file:\/dev/phy:/dev} - XMSWAP="disk=$XMSWAP,hda2,w" - fi - XENID="${VM_IMAGE%/root}" - XENID="${XENID%/tmpfs}" - XENID="${XENID##*/}" - CROSS_INIT_SCRIPT="/.build/build" - # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell - if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc ]; then - if [ -n "$(uname -m | grep '[x3-6]86')" ]; then - if [ -e /bin/bash-static -a -e /bin/mount-static ]; then - CROSS_INIT_SCRIPT="/.build/initscript_qemu_vm" - fi - fi - fi - - echo "booting XEN kernel ..." + fi + # start up xen, rerun ourself + cp -a $BUILD_DIR/. $BUILD_ROOT/.build + if ! test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then + rm -rf $BUILD_ROOT/.build-srcdir + mkdir $BUILD_ROOT/.build-srcdir + if test "$BUILDTYPE" = kiwi ; then + cp -pRL "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir + else + cp -p "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir + fi + MYSRCDIR=$BUILD_ROOT/.build-srcdir + else + # cwd is at $BUILD_ROOT/.build-srcdir which we want to + # umount later so step aside + cd "$SRCDIR" + fi + Q="'\''" + echo "SPECFILE='${SPECFILE//"'"/$Q}'" > $BUILD_ROOT/.build/build.data + echo "BUILD_JOBS='${BUILD_JOBS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "BUILD_ARCH='${BUILD_ARCH//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "BUILD_RPMS='${BUILD_RPMS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + case $BUILD_DIST in + */*) + cp $BUILD_DIST $BUILD_ROOT/.build/build.dist + BUILD_DIST=/.build/build.dist + ;; + esac + echo "BUILD_DIST='${BUILD_DIST//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "RELEASE='${RELEASE//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "BUILD_DEBUG='${BUILD_DEBUG//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "DO_LINT='${DO_LINT//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "DO_CHECKS='${DO_CHECKS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "NOROOTFORBUILD='${NOROOTFORBUILD//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "CREATE_BASELIBS='$CREATE_BASELIBS'" >> $BUILD_ROOT/.build/build.data + echo "REASON='${REASON//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "CHANGELOG='${CHANGELOG//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "INCARNATION='${INCARNATION//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + echo "DISTURL='${DISTURL//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data + # FIXME: this depends on the kernel and vm. + # could be hda2, sda2 for xen or hdb/sdb for qemu + test -n "$VM_SWAP" && echo "VM_SWAP='${VM_SWAPDEV:-/dev/hda2}'" >> $BUILD_ROOT/.build/build.data + PERSONALITY=0 + test -n "$PERSONALITY_SYSCALL" && PERSONALITY=`perl -e 'print syscall('$PERSONALITY_SYSCALL', 0)."\n"'` + echo "OLD_PACKAGES='$OLD_PACKAGES'" >> $BUILD_ROOT/.build/build.data + echo "PERSONALITY='$PERSONALITY'" >> $BUILD_ROOT/.build/build.data + echo "MYHOSTNAME='`hostname`'" >> $BUILD_ROOT/.build/build.data + echo -n "definesnstuff=(" >> $BUILD_ROOT/.build/build.data + shellquote "${definesnstuff[@]}" >> $BUILD_ROOT/.build/build.data + echo ")" >> $BUILD_ROOT/.build/build.data + echo -n "repos=(" >> $BUILD_ROOT/.build/build.data + shellquote "${repos[@]}" >> $BUILD_ROOT/.build/build.data + echo ")" >> $BUILD_ROOT/.build/build.data + umount -n $BUILD_ROOT/proc 2> /dev/null || true + umount -n $BUILD_ROOT/dev/pts 2> /dev/null || true + umount -n $BUILD_ROOT/mnt 2> /dev/null || true + + # needs to work otherwise we have a corrupted file system + umount $BUILD_ROOT || cleanup_and_exit 1 + + if [ "$VM_TYPE" = 'xen' ]; then + XMROOT=file:$VM_IMAGE + XMROOT=${XMROOT/#file:\/dev/phy:/dev} + XMROOT="disk=$XMROOT,hda1,w" + XMSWAP= + if test -n "$VM_SWAP" ; then + XMSWAP=file:$VM_SWAP + XMSWAP=${XMSWAP/#file:\/dev/phy:/dev} + XMSWAP="disk=$XMSWAP,hda2,w" + fi + XENID="${VM_IMAGE%/root}" + XENID="${XENID%/tmpfs}" + XENID="${XENID##*/}" + CROSS_INIT_SCRIPT="/.build/build" + # to run the qemu initialization in the XEN chroot, we need to register it with a statically build shell + if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc ]; then + if [ -n "$(uname -m | grep '[x3-6]86')" ]; then + if [ -e /bin/bash-static -a -e /bin/mount-static ]; then + CROSS_INIT_SCRIPT="/.build/initscript_qemu_vm" + fi + fi + fi + + echo "booting XEN kernel ..." if xm list "build:$XENID" >/dev/null 2>&1 ; then echo "Instance already exist, something really went wrong..." echo "Please report to your server admin, there might be multiple services running for same domain" cleanup_and_exit 3 fi - set -- xm create -c $BUILD_DIR/xen.conf name="build:$XENID" ${MEMSIZE:+memory=$MEMSIZE} $XMROOT $XMSWAP extra="quiet init="$CROSS_INIT_SCRIPT" panic=1 console=ttyS0" - if test "$PERSONALITY" != 0 ; then - # have to switch back to PER_LINUX to make xm work - set -- linux64 "$@" - fi - echo "$@" - "$@" || cleanup_and_exit 3 - elif [ "$VM_TYPE" = 'uml' ]; then - echo "booting UML kernel ..." - set -- $uml_kernel initrd=$uml_initrd root=/ubda init=/.build/build panic=1 quiet ubd0=$VM_IMAGE ${MEMSIZE:+mem=$MEMSIZE} - echo "$@" - "$@" - elif [ "$VM_TYPE" = 'qemu' -o "$VM_TYPE" = 'kvm' ]; then - echo "booting $VM_TYPE ..." - if [ "$kvm_virtio" = 1 ]; then - qemu_disks=(-drive file="$VM_IMAGE",if=virtio -hda "$VM_IMAGE") - if [ -n "$VM_SWAP" ]; then - qemu_disks[${#qemu_disks[@]}]="-drive" - qemu_disks[${#qemu_disks[@]}]="file=$VM_SWAP,if=virtio" - fi - else - qemu_disks=(-hda "$VM_IMAGE") - if [ -n "$VM_SWAP" ]; then - qemu_disks[${#qemu_disks[@]}]="-hdb" - qemu_disks[${#qemu_disks[@]}]="$VM_SWAP" - fi - fi - set -- $qemu_bin -no-reboot -nographic -net none -serial stdio \ - -kernel $qemu_kernel \ - -initrd $qemu_initrd \ - -append "root=$qemu_rootdev panic=1 quiet noapic rw console=ttyS0 init=/.build/build" \ - ${MEMSIZE:+-m $MEMSIZE} \ - "${qemu_disks[@]}" - - if test "$PERSONALITY" != 0 ; then - # have to switch back to PER_LINUX to make qemu work - set -- linux64 "$@" - fi - echo "$@" - "$@" - fi - if test -n "$VM_SWAP" ; then - BUILDSTATUS=`dd if="$VM_SWAP" bs=12 count=1 2>/dev/null` - case $BUILDSTATUS in - BUILDSTATUS[02]) - mkdir -p $BUILD_ROOT/.build.packages - cd $BUILD_ROOT/.build.packages || cleanup_and_exit 1 - echo "build: extracting built packages..." - extractbuild --disk "$VM_IMAGE" --input "$VM_SWAP" --skip 512 -v || cleanup_and_exit 3 + set -- xm create -c $BUILD_DIR/xen.conf name="build:$XENID" ${MEMSIZE:+memory=$MEMSIZE} $XMROOT $XMSWAP extra="quiet init="$CROSS_INIT_SCRIPT" panic=1 console=ttyS0" + if test "$PERSONALITY" != 0 ; then + # have to switch back to PER_LINUX to make xm work + set -- linux64 "$@" + fi + echo "$@" + "$@" || cleanup_and_exit 3 + elif [ "$VM_TYPE" = 'uml' ]; then + echo "booting UML kernel ..." + set -- $uml_kernel initrd=$uml_initrd root=/ubda init=/.build/build panic=1 quiet ubd0=$VM_IMAGE ${MEMSIZE:+mem=$MEMSIZE} + echo "$@" + "$@" + elif [ "$VM_TYPE" = 'qemu' -o "$VM_TYPE" = 'kvm' ]; then + echo "booting $VM_TYPE ..." + if [ "$kvm_virtio" = 1 ]; then + qemu_disks=(-drive file="$VM_IMAGE",if=virtio -hda "$VM_IMAGE") + if [ -n "$VM_SWAP" ]; then + qemu_disks[${#qemu_disks[@]}]="-drive" + qemu_disks[${#qemu_disks[@]}]="file=$VM_SWAP,if=virtio" + fi + else + qemu_disks=(-hda "$VM_IMAGE") + if [ -n "$VM_SWAP" ]; then + qemu_disks[${#qemu_disks[@]}]="-hdb" + qemu_disks[${#qemu_disks[@]}]="$VM_SWAP" + fi + fi + set -- $qemu_bin -no-reboot -nographic -net none -serial stdio \ + -kernel $qemu_kernel \ + -initrd $qemu_initrd \ + -append "root=$qemu_rootdev panic=1 quiet noapic rw console=ttyS0 init=/.build/build" \ + ${MEMSIZE:+-m $MEMSIZE} \ + "${qemu_disks[@]}" + + if test "$PERSONALITY" != 0 ; then + # have to switch back to PER_LINUX to make qemu work + set -- linux64 "$@" + fi + echo "$@" + "$@" + fi + if test -n "$VM_SWAP" ; then + BUILDSTATUS=`dd if="$VM_SWAP" bs=12 count=1 2>/dev/null` + case $BUILDSTATUS in + BUILDSTATUS[02]) + mkdir -p $BUILD_ROOT/.build.packages + cd $BUILD_ROOT/.build.packages || cleanup_and_exit 1 + echo "build: extracting built packages..." + extractbuild --disk "$VM_IMAGE" --input "$VM_SWAP" --skip 512 -v || cleanup_and_exit 3 # create same layout as with plain chroot if test "$BUILDTYPE" = spec ; then mkdir -p SRPMS @@ -1193,47 +1193,47 @@ for SPECFILE in "${SPECFILES[@]}" ; do mkdir -p KIWI find . -type f | while read i; do mv "$i" KIWI/; done fi - cleanup_and_exit ${BUILDSTATUS#BUILDSTATUS} - ;; - BUILDSTATUS*) - cleanup_and_exit ${BUILDSTATUS#BUILDSTATUS} - ;; - *) - echo "argh, no buildstatus set, assuming bad build host..." - cleanup_and_exit 3 - ;; - esac - cleanup_and_exit 1 - fi - cleanup_and_exit 0 + cleanup_and_exit ${BUILDSTATUS#BUILDSTATUS} + ;; + BUILDSTATUS*) + cleanup_and_exit ${BUILDSTATUS#BUILDSTATUS} + ;; + *) + echo "argh, no buildstatus set, assuming bad build host..." + cleanup_and_exit 3 + ;; + esac + cleanup_and_exit 1 + fi + cleanup_and_exit 0 fi if test "$DO_INIT" = true ; then - # - # create legacy .buildenv file - # - test -z "$INCARNATION" && INCARNATION=0 - echo "BUILD_INCARNATION=$INCARNATION" > $BUILD_ROOT/.buildenv - CREATE_BUILD_BINARIES= - egrep '^#[ ]*needsbinariesforbuild[ ]*$' >/dev/null <$MYSRCDIR/$SPECFILE && CREATE_BUILD_BINARIES=--create-build-binaries + # + # create legacy .buildenv file + # + test -z "$INCARNATION" && INCARNATION=0 + echo "BUILD_INCARNATION=$INCARNATION" > $BUILD_ROOT/.buildenv + CREATE_BUILD_BINARIES= + egrep '^#[ ]*needsbinariesforbuild[ ]*$' >/dev/null <$MYSRCDIR/$SPECFILE && CREATE_BUILD_BINARIES=--create-build-binaries set -- init_buildsystem "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS - echo "$* ..." - "$@" || cleanup_and_exit 1 - if df $BUILD_ROOT 2>/dev/null | grep -q "100%"; then - df -h $BUILD_ROOT - echo "build does not work on a completely full filesystem" - cleanup_and_exit 1 - fi - mount -n -tproc none $BUILD_ROOT/proc || true - mount -n -tdevpts none $BUILD_ROOT/dev/pts + echo "$* ..." + "$@" || cleanup_and_exit 1 + if df $BUILD_ROOT 2>/dev/null | grep -q "100%"; then + df -h $BUILD_ROOT + echo "build does not work on a completely full filesystem" + cleanup_and_exit 1 + fi + mount -n -tproc none $BUILD_ROOT/proc || true + mount -n -tdevpts none $BUILD_ROOT/dev/pts if [ -d "$OLD_PACKAGES" ]; then [ -d "$BUILD_ROOT/.build.oldpackages" ] || cp -r $OLD_PACKAGES $BUILD_ROOT/.build.oldpackages fi fi if test -z "$BUILD_DIST" -a -e "$BUILD_ROOT/.guessed_dist" ; then - BUILD_DIST=`cat $BUILD_ROOT/.guessed_dist` - echo "assuming dist $BUILD_DIST" + BUILD_DIST=`cat $BUILD_ROOT/.guessed_dist` + echo "assuming dist $BUILD_DIST" fi # @@ -1241,8 +1241,8 @@ for SPECFILE in "${SPECFILES[@]}" ; do # test -f $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 && mv $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 $BUILD_ROOT/usr/lib/rpm/rpmrc if test -e $BUILD_ROOT/usr/lib/rpm/rpmrc -a "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then - mv $BUILD_ROOT/usr/lib/rpm/rpmrc $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 - sed -e 's/^buildarchtranslate: athlon.*/buildarchtranslate: athlon: i686/' -e 's/^buildarchtranslate: i686.*/buildarchtranslate: i686: i686/' < $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 > $BUILD_ROOT/usr/lib/rpm/rpmrc + mv $BUILD_ROOT/usr/lib/rpm/rpmrc $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 + sed -e 's/^buildarchtranslate: athlon.*/buildarchtranslate: athlon: i686/' -e 's/^buildarchtranslate: i686.*/buildarchtranslate: i686: i686/' < $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 > $BUILD_ROOT/usr/lib/rpm/rpmrc fi # @@ -1250,15 +1250,15 @@ for SPECFILE in "${SPECFILES[@]}" ; do # BUILD_USER=abuild if test -x $BUILD_ROOT/bin/rpm ; then - SUSE_VERSION=`chroot $BUILD_ROOT /bin/rpm --eval '%{?suse_version}' 2>/dev/null` - if test -n "$SUSE_VERSION" && test "$SUSE_VERSION" -le 1020 ; then - BUILD_USER=root - fi + SUSE_VERSION=`chroot $BUILD_ROOT /bin/rpm --eval '%{?suse_version}' 2>/dev/null` + if test -n "$SUSE_VERSION" && test "$SUSE_VERSION" -le 1020 ; then + BUILD_USER=root + fi fi if test "$BUILD_USER" = abuild ; then - egrep '^#[ ]*needsrootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=root + egrep '^#[ ]*needsrootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=root else - egrep '^#[ ]*norootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=abuild + egrep '^#[ ]*norootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=abuild fi test -n "$NOROOTFORBUILD" && BUILD_USER=abuild @@ -1266,18 +1266,18 @@ for SPECFILE in "${SPECFILES[@]}" ; do if ! egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then echo 'abuild::399:399:Autobuild:/home/abuild:/bin/bash' >>$BUILD_ROOT/etc/passwd echo 'abuild:*:::::::' >>$BUILD_ROOT/etc/shadow # This is needed on Mandriva 2009 - echo 'abuild:*::' >>$BUILD_ROOT/etc/gshadow # This is needed on Ubuntu + echo 'abuild:*::' >>$BUILD_ROOT/etc/gshadow # This is needed on Ubuntu echo 'abuild::399:' >>$BUILD_ROOT/etc/group mkdir -p $BUILD_ROOT/home/abuild chown 399:399 $BUILD_ROOT/home/abuild fi - if test -f $BUILD_ROOT/etc/shadow ; then - sed -e "s@^root::@root:*:@" < $BUILD_ROOT/etc/shadow > $BUILD_ROOT/etc/shadow.t && mv $BUILD_ROOT/etc/shadow.t $BUILD_ROOT/etc/shadow - fi - if test -f $BUILD_ROOT/etc/gshadow ; then - sed -e "s@^root::@root:*:@" < $BUILD_ROOT/etc/gshadow > $BUILD_ROOT/etc/gshadow.t && mv $BUILD_ROOT/etc/gshadow.t $BUILD_ROOT/etc/gshadow - fi - BUILD_USER_ABUILD_USED=true + if test -f $BUILD_ROOT/etc/shadow ; then + sed -e "s@^root::@root:*:@" < $BUILD_ROOT/etc/shadow > $BUILD_ROOT/etc/shadow.t && mv $BUILD_ROOT/etc/shadow.t $BUILD_ROOT/etc/shadow + fi + if test -f $BUILD_ROOT/etc/gshadow ; then + sed -e "s@^root::@root:*:@" < $BUILD_ROOT/etc/gshadow > $BUILD_ROOT/etc/gshadow.t && mv $BUILD_ROOT/etc/gshadow.t $BUILD_ROOT/etc/gshadow + fi + BUILD_USER_ABUILD_USED=true else if egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then rm -rf $BUILD_ROOT/home/abuild @@ -1297,10 +1297,10 @@ for SPECFILE in "${SPECFILES[@]}" ; do fi if test "$BUILDTYPE" = spec ; then - TOPDIR=`chroot $BUILD_ROOT su -c "rpm --eval '%_topdir'" - $BUILD_USER` + TOPDIR=`chroot $BUILD_ROOT su -c "rpm --eval '%_topdir'" - $BUILD_USER` else - TOPDIR=/usr/src/packages - mkdir -p $BUILD_ROOT$TOPDIR + TOPDIR=/usr/src/packages + mkdir -p $BUILD_ROOT$TOPDIR fi rm -f $BUILD_ROOT/.build.packages @@ -1308,7 +1308,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null mount -n -tdevpts none $BUILD_ROOT/dev/pts 2> /dev/null - + setupicecream setupccache @@ -1316,7 +1316,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do # nasty hack to prevent rpath on known paths # FIXME: do this only for suse if test -d "$BUILD_ROOT/etc/profile.d" ; then - echo "export SUSE_IGNORED_RPATHS=/etc/ld.so.conf" > "$BUILD_ROOT/etc/profile.d/buildsystem.sh" + echo "export SUSE_IGNORED_RPATHS=/etc/ld.so.conf" > "$BUILD_ROOT/etc/profile.d/buildsystem.sh" fi # @@ -1325,44 +1325,44 @@ for SPECFILE in "${SPECFILES[@]}" ; do rm -rf $BUILD_ROOT$TOPDIR for i in BUILD RPMS/`uname -m` RPMS/i386 RPMS/noarch SOURCES SPECS SRPMS BUILDROOT; do mkdir -p $BUILD_ROOT$TOPDIR/$i - test $BUILD_USER = abuild && chown 399:399 $BUILD_ROOT$TOPDIR/$i + test $BUILD_USER = abuild && chown 399:399 $BUILD_ROOT$TOPDIR/$i done test -e $BUILD_ROOT/exit && cleanup_and_exit 1 mkdir -p $BUILD_ROOT$TOPDIR/SOURCES if test "$BUILDTYPE" = kiwi ; then - mkdir -p $BUILD_ROOT$TOPDIR/KIWI - if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then - mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ - else - if test -z "$LINKSOURCES" ; then - cp -dLR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ - else - cp -lR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ - fi - if test "$?" != 0 ; then - echo "source copy failed" - cleanup_and_exit 1 - fi - fi + mkdir -p $BUILD_ROOT$TOPDIR/KIWI + if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then + mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ + else + if test -z "$LINKSOURCES" ; then + cp -dLR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ + else + cp -lR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ + fi + if test "$?" != 0 ; then + echo "source copy failed" + cleanup_and_exit 1 + fi + fi else - cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ + cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ fi test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir && rm -rf "$MYSRCDIR" CHANGELOGARGS= test -n "$CHANGELOG" -a -f "$BUILD_ROOT/.build-changelog" && CHANGELOGARGS="--changelog $BUILD_ROOT/.build-changelog" if test "$BUILDTYPE" = spec ; then - # do buildrequires/release substitution - args=() - if test -n "$RELEASE"; then - args=(--release "$RELEASE") - fi - substitutedeps "${args[@]}" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1 - # extract macros from configuration - getmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" > $BUILD_ROOT/root/.rpmmacros - if test -n "$BUILD_DEBUG" ; then - echo ' + # do buildrequires/release substitution + args=() + if test -n "$RELEASE"; then + args=(--release "$RELEASE") + fi + substitutedeps "${args[@]}" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1 + # extract macros from configuration + getmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" > $BUILD_ROOT/root/.rpmmacros + if test -n "$BUILD_DEBUG" ; then + echo ' %prep %?_suse_insert_debug_package%%prep %package %?_suse_insert_debug_package%%package %suse_insert_debug_package \ @@ -1371,55 +1371,55 @@ for SPECFILE in "${SPECFILES[@]}" ; do %%debug_package ' >> $BUILD_ROOT/root/.rpmmacros - fi - test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros - # extract optflags from configuration - getoptflags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ${BUILD_DEBUG:+--debug} > $BUILD_ROOT/root/.rpmrc - test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc - # case arm, extract changetarget - # this is restricted to arm to make sure it doesn't interfere with x86 - buildarchtest=$( echo $BUILD_ARCH | grep -i arm ) - if [ x"$buildarchtest" != x"" ]; then - echo "changing targetarch" - CHANGETARGET=$(getchangetarget --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ) - echo "NEW TARGET: $CHANGETARGET" - fi + fi + test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros + # extract optflags from configuration + getoptflags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ${BUILD_DEBUG:+--debug} > $BUILD_ROOT/root/.rpmrc + test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc + # case arm, extract changetarget + # this is restricted to arm to make sure it doesn't interfere with x86 + buildarchtest=$( echo $BUILD_ARCH | grep -i arm ) + if [ x"$buildarchtest" != x"" ]; then + echo "changing targetarch" + CHANGETARGET=$(getchangetarget --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ) + echo "NEW TARGET: $CHANGETARGET" + fi fi if test -f $BUILD_ROOT/.spec.new ; then - if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT/.spec.new ; then - echo ----------------------------------------------------------------- - echo I have the following modifications for $SPECFILE: - sed -e "/^%changelog/q" $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE > $BUILD_ROOT/.spec.t1 - sed -e "/^%changelog/q" $BUILD_ROOT/.spec.new > $BUILD_ROOT/.spec.t2 - diff $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2 - rm -f $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2 - mv $BUILD_ROOT/.spec.new $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE - else - rm -f $BUILD_ROOT/.spec.new - fi + if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT/.spec.new ; then + echo ----------------------------------------------------------------- + echo I have the following modifications for $SPECFILE: + sed -e "/^%changelog/q" $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE > $BUILD_ROOT/.spec.t1 + sed -e "/^%changelog/q" $BUILD_ROOT/.spec.new > $BUILD_ROOT/.spec.t2 + diff $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2 + rm -f $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2 + mv $BUILD_ROOT/.spec.new $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE + else + rm -f $BUILD_ROOT/.spec.new + fi fi if test "$BUILDTYPE" = dsc ; then - rm -rf $BUILD_ROOT$TOPDIR/BUILD - mkdir -p $BUILD_ROOT$TOPDIR/SOURCES.DEB - test $BUILD_USER = abuild && chown 399:399 $BUILD_ROOT$TOPDIR - DEB_TRANSFORM= - DEB_SOURCEDIR=$TOPDIR/SOURCES - DEB_DSCFILE=$SPECFILE - for f in $BUILD_ROOT$TOPDIR/SOURCES/debian.* ; do - test -f $f && DEB_TRANSFORM=true - done - if test -n "$DEB_TRANSFORM" ; then - echo "running debian transformer..." + rm -rf $BUILD_ROOT$TOPDIR/BUILD + mkdir -p $BUILD_ROOT$TOPDIR/SOURCES.DEB + test $BUILD_USER = abuild && chown 399:399 $BUILD_ROOT$TOPDIR + DEB_TRANSFORM= + DEB_SOURCEDIR=$TOPDIR/SOURCES + DEB_DSCFILE=$SPECFILE + for f in $BUILD_ROOT$TOPDIR/SOURCES/debian.* ; do + test -f $f && DEB_TRANSFORM=true + done + if test -n "$DEB_TRANSFORM" ; then + echo "running debian transformer..." if ! debtransform $CHANGELOGARGS $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT$TOPDIR/SOURCES.DEB ; then - echo "debian transforming failed." - cleanup_and_exit 1 - fi - DEB_SOURCEDIR=$TOPDIR/SOURCES.DEB - for DEB_DSCFILE in $BUILD_ROOT/$DEB_SOURCEDIR/*.dsc ; do : ; done - DEB_DSCFILE="${DEB_DSCFILE##*/}" + echo "debian transforming failed." + cleanup_and_exit 1 + fi + DEB_SOURCEDIR=$TOPDIR/SOURCES.DEB + for DEB_DSCFILE in $BUILD_ROOT/$DEB_SOURCEDIR/*.dsc ; do : ; done + DEB_DSCFILE="${DEB_DSCFILE##*/}" fi - chroot $BUILD_ROOT su -c "dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD" - $BUILD_USER + chroot $BUILD_ROOT su -c "dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD" - $BUILD_USER fi if test $BUILD_USER = abuild ; then @@ -1474,190 +1474,190 @@ for SPECFILE in "${SPECFILES[@]}" ; do fi if test "$BUILDTYPE" = spec ; then - test -z "$BUILD_RPM_BUILD_STAGE" && BUILD_RPM_BUILD_STAGE=-ba - - # XXX: move _srcdefattr to macro file? - rpmbopts=("$BUILD_RPM_BUILD_STAGE" "--define" "_srcdefattr (-,root,root)") - if [ -n "$ABUILD_TARGET_ARCH" ]; then - rpmbopts[${#rpmbopts[@]}]="--target=$ABUILD_TARGET_ARCH" - fi - if [ -n "$BUILD_JOBS" ]; then - rpmbopts[${#rpmbopts[@]}]='--define' - rpmbopts[${#rpmbopts[@]}]="jobs $BUILD_JOBS" - fi - if [ -n "$DISTURL" ]; then - rpmbopts[${#rpmbopts[@]}]='--define' - rpmbopts[${#rpmbopts[@]}]="disturl $DISTURL" - fi - if test -s "$BUILD_ROOT/usr/lib/rpm/mandriva/macros" ; then - rpmbopts[${#rpmbopts[@]}]='--eval' - rpmbopts[${#rpmbopts[@]}]="%undefine _enable_debug_packages" - fi - if [ -n "$BUILD_DEBUG" ]; then - rpmbopts[${#rpmbopts[@]}]='--eval' - rpmbopts[${#rpmbopts[@]}]="%suse_insert_debug_package" - fi - if [ -n "$CHANGETARGET" ]; then - rpmbopts[${#rpmbopts[@]}]='--target' - rpmbopts[${#rpmbopts[@]}]="$CHANGETARGET" - fi - if [ -n "$RSYNCDONE" ] ; then - rpmbopts[${#rpmbopts[@]}]='--define' - rpmbopts[${#rpmbopts[@]}]="RSYNCDONE 1" - fi - - rpmbuild=rpmbuild - - test -x $BUILD_ROOT/usr/bin/rpmbuild || rpmbuild=rpm - # su involves a shell which would require even more - # complicated quoting to bypass than this - toshellscript $rpmbuild \ - "${definesnstuff[@]}" \ - "${rpmbopts[@]}" \ - "$TOPDIR/SOURCES/$SPECFILE" \ - > $BUILD_ROOT/.build.command - chmod 755 $BUILD_ROOT/.build.command - chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true + test -z "$BUILD_RPM_BUILD_STAGE" && BUILD_RPM_BUILD_STAGE=-ba + + # XXX: move _srcdefattr to macro file? + rpmbopts=("$BUILD_RPM_BUILD_STAGE" "--define" "_srcdefattr (-,root,root)") + if [ -n "$ABUILD_TARGET_ARCH" ]; then + rpmbopts[${#rpmbopts[@]}]="--target=$ABUILD_TARGET_ARCH" + fi + if [ -n "$BUILD_JOBS" ]; then + rpmbopts[${#rpmbopts[@]}]='--define' + rpmbopts[${#rpmbopts[@]}]="jobs $BUILD_JOBS" + fi + if [ -n "$DISTURL" ]; then + rpmbopts[${#rpmbopts[@]}]='--define' + rpmbopts[${#rpmbopts[@]}]="disturl $DISTURL" + fi + if test -s "$BUILD_ROOT/usr/lib/rpm/mandriva/macros" ; then + rpmbopts[${#rpmbopts[@]}]='--eval' + rpmbopts[${#rpmbopts[@]}]="%undefine _enable_debug_packages" + fi + if [ -n "$BUILD_DEBUG" ]; then + rpmbopts[${#rpmbopts[@]}]='--eval' + rpmbopts[${#rpmbopts[@]}]="%suse_insert_debug_package" + fi + if [ -n "$CHANGETARGET" ]; then + rpmbopts[${#rpmbopts[@]}]='--target' + rpmbopts[${#rpmbopts[@]}]="$CHANGETARGET" + fi + if [ -n "$RSYNCDONE" ] ; then + rpmbopts[${#rpmbopts[@]}]='--define' + rpmbopts[${#rpmbopts[@]}]="RSYNCDONE 1" + fi + + rpmbuild=rpmbuild + + test -x $BUILD_ROOT/usr/bin/rpmbuild || rpmbuild=rpm + # su involves a shell which would require even more + # complicated quoting to bypass than this + toshellscript $rpmbuild \ + "${definesnstuff[@]}" \ + "${rpmbopts[@]}" \ + "$TOPDIR/SOURCES/$SPECFILE" \ + > $BUILD_ROOT/.build.command + chmod 755 $BUILD_ROOT/.build.command + chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true fi if test "$BUILDTYPE" = dsc ; then - # Checks to see if a build script should be used - # this allows the build environment to be manipulated - # and alternate build commands can be used - DSC_BUILD_CMD="dpkg-buildpackage -us -uc -rfakeroot-tcp" - if test -e $BUILD_ROOT/$TOPDIR/SOURCES/build.script ; then - echo "Sourcing build.script to build - it should normally run 'dpkg-buildpackage -us -uc -rfakeroot-tcp'" - DSC_BUILD_CMD="source $TOPDIR/SOURCES/build.script" - chmod +x $BUILD_ROOT/$TOPDIR/SOURCES/build.script - fi - chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && $DSC_BUILD_CMD" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true - - mkdir -p $BUILD_ROOT/$TOPDIR/DEBS - for DEB in $BUILD_ROOT/$TOPDIR/*.deb ; do - test -e "$DEB" && mv "$DEB" "$BUILD_ROOT/$TOPDIR/DEBS" - done - # link sources over - ln $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE $BUILD_ROOT/$TOPDIR/DEBS/ - while read f ; do - ln $BUILD_ROOT/$DEB_SOURCEDIR/$f $BUILD_ROOT/$TOPDIR/DEBS/ - done < <(sed -ne '/^Files:/,$s/^ ................................ [0-9][0-9]* //p' < $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE) + # Checks to see if a build script should be used + # this allows the build environment to be manipulated + # and alternate build commands can be used + DSC_BUILD_CMD="dpkg-buildpackage -us -uc -rfakeroot-tcp" + if test -e $BUILD_ROOT/$TOPDIR/SOURCES/build.script ; then + echo "Sourcing build.script to build - it should normally run 'dpkg-buildpackage -us -uc -rfakeroot-tcp'" + DSC_BUILD_CMD="source $TOPDIR/SOURCES/build.script" + chmod +x $BUILD_ROOT/$TOPDIR/SOURCES/build.script + fi + chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && $DSC_BUILD_CMD" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true + + mkdir -p $BUILD_ROOT/$TOPDIR/DEBS + for DEB in $BUILD_ROOT/$TOPDIR/*.deb ; do + test -e "$DEB" && mv "$DEB" "$BUILD_ROOT/$TOPDIR/DEBS" + done + # link sources over + ln $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE $BUILD_ROOT/$TOPDIR/DEBS/ + while read f ; do + ln $BUILD_ROOT/$DEB_SOURCEDIR/$f $BUILD_ROOT/$TOPDIR/DEBS/ + done < <(sed -ne '/^Files:/,$s/^ ................................ [0-9][0-9]* //p' < $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE) fi if test "$BUILDTYPE" = kiwi ; then - # run createrepo on the repositories - if test -d $BUILD_ROOT/$TOPDIR/SOURCES/repos ; then - ( - ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos - cd $BUILD_ROOT/$TOPDIR/SOURCES/repos - for r in */* ; do - test -L $r && continue - test -d $r || continue - repo="$TOPDIR/SOURCES/repos/$r/" - # create compatibility link for old kiwi versions - rc="${r//:/:/}" - if test "$rc" != "$r" ; then - rl="${rc//[^\/]}" - rl="${rl//?/../}" - mkdir -p "${rc%/*}" - ln -s $rl$r "${rc%/*}/${rc##*/}" - repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/" - fi - echo "creating repodata for $repo" - chroot $BUILD_ROOT createrepo "$repo" - done - ) - fi + # run createrepo on the repositories + if test -d $BUILD_ROOT/$TOPDIR/SOURCES/repos ; then + ( + ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos + cd $BUILD_ROOT/$TOPDIR/SOURCES/repos + for r in */* ; do + test -L $r && continue + test -d $r || continue + repo="$TOPDIR/SOURCES/repos/$r/" + # create compatibility link for old kiwi versions + rc="${r//:/:/}" + if test "$rc" != "$r" ; then + rl="${rc//[^\/]}" + rl="${rl//?/../}" + mkdir -p "${rc%/*}" + ln -s $rl$r "${rc%/*}/${rc##*/}" + repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/" + fi + echo "creating repodata for $repo" + chroot $BUILD_ROOT createrepo "$repo" + done + ) + fi # unpack root tar - for t in $BUILD_ROOT/$TOPDIR/SOURCES/root.tar* ; do - test -f $t || continue - mkdir -p $BUILD_ROOT/$TOPDIR/SOURCES/root - chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/root -xf "$TOPDIR/SOURCES/${t##*/}" - done + for t in $BUILD_ROOT/$TOPDIR/SOURCES/root.tar* ; do + test -f $t || continue + mkdir -p $BUILD_ROOT/$TOPDIR/SOURCES/root + chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/root -xf "$TOPDIR/SOURCES/${t##*/}" + done # fix script permissions chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/*.sh 2>/dev/null - # unpack tar files in image directories - if test -d $BUILD_ROOT/$TOPDIR/SOURCES/images ; then - ( - cd $BUILD_ROOT/$TOPDIR/SOURCES/images - for r in */* ; do - test -L $r && continue - test -d $r || continue - for t in $r/root.tar* ; do - test -f $t || continue - mkdir -p $r/root - chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/images/$r/root -xf "$TOPDIR/SOURCES/images/$r/${t##*/}" - done + # unpack tar files in image directories + if test -d $BUILD_ROOT/$TOPDIR/SOURCES/images ; then + ( + cd $BUILD_ROOT/$TOPDIR/SOURCES/images + for r in */* ; do + test -L $r && continue + test -d $r || continue + for t in $r/root.tar* ; do + test -f $t || continue + mkdir -p $r/root + chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/images/$r/root -xf "$TOPDIR/SOURCES/images/$r/${t##*/}" + done # fix script permissions chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/images/$r/*.sh 2>/dev/null - # create compatibility link for old kiwi versions - rc="${r//:/:/}" - if test "$rc" != "$r" ; then - rl="${rc//[^\/]}" - rl="${rl//?/../}" - mkdir -p "${rc%/*}" - ln -s $rl$r "${rc%/*}/${rc##*/}" - fi - done - ) - fi - rm -f $BUILD_ROOT/$TOPDIR/SOURCES/config.xml - ln -s $SPECFILE $BUILD_ROOT/$TOPDIR/SOURCES/config.xml - imagetype=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE imagetype) - imagename=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE filename) - imageversion=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE version) - chroot $BUILD_ROOT su -c "kiwi --version" - - if test "$imagetype" = product ; then - echo "running kiwi --create-instsource..." - chroot $BUILD_ROOT su -c "APPID=- KIWI_COLLECT_TERMINAL_LOG=1 LANG=POSIX kiwi --root $TOPDIR/KIWIROOT -v -v --instsource-local --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true + # create compatibility link for old kiwi versions + rc="${r//:/:/}" + if test "$rc" != "$r" ; then + rl="${rc//[^\/]}" + rl="${rl//?/../}" + mkdir -p "${rc%/*}" + ln -s $rl$r "${rc%/*}/${rc##*/}" + fi + done + ) + fi + rm -f $BUILD_ROOT/$TOPDIR/SOURCES/config.xml + ln -s $SPECFILE $BUILD_ROOT/$TOPDIR/SOURCES/config.xml + imagetype=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE imagetype) + imagename=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE filename) + imageversion=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE version) + chroot $BUILD_ROOT su -c "kiwi --version" - + if test "$imagetype" = product ; then + echo "running kiwi --create-instsource..." + chroot $BUILD_ROOT su -c "APPID=- KIWI_COLLECT_TERMINAL_LOG=1 LANG=POSIX kiwi --root $TOPDIR/KIWIROOT -v -v --instsource-local --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true ### This block is obsolete with current kiwi versions, only needed for kiwi 3.01 version -# for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do -# test -d "$i" || continue -# n="${i##*/}" -# test "$n" = scripts && continue -# test "$n" != "${n%0}" && continue -# chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER -# done - - # move created product to correct destination - for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do - test -e "$i" || continue - f=${i##*/} - case $f in - *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;; - scripts) ;; - *0) ;; - *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;; - esac - done - else - BUILD_SUCCEEDED=true +# for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do +# test -d "$i" || continue +# n="${i##*/}" +# test "$n" = scripts && continue +# test "$n" != "${n%0}" && continue +# chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER +# done + + # move created product to correct destination + for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do + test -e "$i" || continue + f=${i##*/} + case $f in + *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;; + scripts) ;; + *0) ;; + *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;; + esac + done + else + BUILD_SUCCEEDED=true if [ -z "$RUNNING_IN_VM" ]; then # NOTE: this must be done with the outer system, because it loads the dm-mod kernel modules, which needs to fit to the kernel. echo "starting device mapper for kiwi..." [ -x /etc/init.d/boot.device-mapper ] && /etc/init.d/boot.device-mapper start fi - for imgtype in $imagetype ; do - echo "running kiwi --prepare for $imgtype..." + for imgtype in $imagetype ; do + echo "running kiwi --prepare for $imgtype..." # Do not use $BUILD_USER here, since we always need root permissions - if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then - echo "running kiwi --create for $imgtype..." - mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype - chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --create $TOPDIR/KIWIROOT-$imgtype --logfile terminal --type $imgtype -d $TOPDIR/KIWI-$imgtype" - root < /dev/null || cleanup_and_exit 1 - else + if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then + echo "running kiwi --create for $imgtype..." + mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype + chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --create $TOPDIR/KIWIROOT-$imgtype --logfile terminal --type $imgtype -d $TOPDIR/KIWI-$imgtype" - root < /dev/null || cleanup_and_exit 1 + else cleanup_and_exit 1 - fi - done + fi + done - # create tar.gz of images, in case it makes sense + # create tar.gz of images, in case it makes sense imagearch=`uname -m` buildnum="" - if test -n "$RELEASE"; then - buildnum="-Build$RELEASE" - fi + if test -n "$RELEASE"; then + buildnum="-Build$RELEASE" + fi for imgtype in $imagetype ; do case "$imgtype" in oem) - pushd $BUILD_ROOT/$TOPDIR/KIWI-oem > /dev/null + pushd $BUILD_ROOT/$TOPDIR/KIWI-oem > /dev/null echo "compressing images... " tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-raw.tar.bz2 \ --exclude=$imagename.$imagearch-$imageversion.iso \ @@ -1667,7 +1667,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do echo "Copy iso file and create md5..." mv $imagename.$imagearch-$imageversion.iso \ $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum.iso || cleanup_and_exit 1 - pushd $BUILD_ROOT/$TOPDIR/KIWI > /dev/null + pushd $BUILD_ROOT/$TOPDIR/KIWI > /dev/null md5sum $imagename.$imagearch-$imageversion$buildnum.iso \ > "$imagename.$imagearch-$imageversion$buildnum.iso.md5" || cleanup_and_exit 1 popd > /dev/null @@ -1676,7 +1676,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do echo "Copy raw file and create md5..." mv $imagename.$imagearch-$imageversion.raw \ $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum.raw || cleanup_and_exit 1 - pushd $BUILD_ROOT/$TOPDIR/KIWI > /dev/null + pushd $BUILD_ROOT/$TOPDIR/KIWI > /dev/null bzip2 $imagename.$imagearch-$imageversion$buildnum.raw && \ md5sum $imagename.$imagearch-$imageversion$buildnum.raw.bz2 \ > "$imagename.$imagearch-$imageversion$buildnum.raw.bz2.md5" || cleanup_and_exit 1 @@ -1687,21 +1687,21 @@ for SPECFILE in "${SPECFILES[@]}" ; do vmx) pushd $BUILD_ROOT/$TOPDIR/KIWI-vmx > /dev/null echo "compressing images... " - if [ -e $imagename.$imagearch-$imageversion.xenconfig ] ; then + if [ -e $imagename.$imagearch-$imageversion.xenconfig ] ; then tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-xenvmx.tar.bz2 \ $imagename.$imagearch-$imageversion.raw \ $imagename.$imagearch-$imageversion.xenconfig || cleanup_and_exit 1 - else + else tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-vmx.tar.bz2 \ $imagename.$imagearch-$imageversion.vmx \ $imagename.$imagearch-$imageversion.vmdk || cleanup_and_exit 1 - if [ -e $imagename.$imagearch-$imageversion.ovf ] ; then + if [ -e $imagename.$imagearch-$imageversion.ovf ] ; then tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-ovf.tar.bz2 \ $imagename.$imagearch-$imageversion.ovf \ $imagename.$imagearch-$imageversion-disk*.vmdk || cleanup_and_exit 1 - fi - fi - popd > /dev/null + fi + fi + popd > /dev/null ;; xen) pushd $BUILD_ROOT/$TOPDIR/KIWI-xen > /dev/null @@ -1711,7 +1711,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do `grep ^ramdisk $imagename.$imagearch-$imageversion.xenconfig | cut -d'"' -f2` \ $imagename.$imagearch-$imageversion.xenconfig \ $imagename.$imagearch-$imageversion || cleanup_and_exit 1 - popd > /dev/null + popd > /dev/null ;; pxe) pushd $BUILD_ROOT/$TOPDIR/KIWI-pxe > /dev/null @@ -1719,29 +1719,29 @@ for SPECFILE in "${SPECFILES[@]}" ; do tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-pxe.tar.bz2 \ $imagename.$imagearch-$imageversion* \ initrd-* || cleanup_and_exit 1 - popd > /dev/null + popd > /dev/null ;; iso) pushd $BUILD_ROOT/$TOPDIR/KIWI-iso > /dev/null echo "creating md5 sum for iso images... " - for i in *.iso; do + for i in *.iso; do pushd $BUILD_ROOT/$TOPDIR/KIWI/ > /dev/null - mv $BUILD_ROOT/$TOPDIR/KIWI-iso/$i ${i%.iso}$buildnum.iso || cleanup_and_exit 1 - md5sum ${i%.iso}$buildnum.iso > ${i%.iso}$buildnum.iso.md5 || cleanup_and_exit 1 - popd > /dev/null + mv $BUILD_ROOT/$TOPDIR/KIWI-iso/$i ${i%.iso}$buildnum.iso || cleanup_and_exit 1 + md5sum ${i%.iso}$buildnum.iso > ${i%.iso}$buildnum.iso.md5 || cleanup_and_exit 1 + popd > /dev/null done - popd > /dev/null + popd > /dev/null ;; *) pushd $BUILD_ROOT/$TOPDIR/KIWI-$imgtype > /dev/null echo "compressing unkown images... " tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-$imgtype.tar.bz2 \ * || cleanup_and_exit 1 - popd > /dev/null + popd > /dev/null ;; esac done - fi + fi fi test "$BUILD_SUCCEEDED" = true || cleanup_and_exit 1 @@ -1755,14 +1755,14 @@ if test -n "$RPMS" -a -n "$BUILD_USER_ABUILD_USED" ; then echo "... checking for files with abuild user/group" BADFILE= while read un gn fn ; do - if test "$un" = abuild -o "$gn" = abuild -o "$un" = 399 -o "$gn" = 399 ; then - echo " $un $gn $fn" - BADFILE=true - fi + if test "$un" = abuild -o "$gn" = abuild -o "$un" = 399 -o "$gn" = 399 ; then + echo " $un $gn $fn" + BADFILE=true + fi done < <(rpm -qp --qf '[%{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]' $RPMS) if test -n "$BADFILE" ; then - echo "please fix your filelist (e.g. add defattr)" - cleanup_and_exit 1 + echo "please fix your filelist (e.g. add defattr)" + cleanup_and_exit 1 fi fi @@ -1771,11 +1771,11 @@ if test -n "$RPMS" -a -d "$BUILD_ROOT/usr/lib/build/checks" ; then export PNAME="" export DO_RPM_REMOVE=true for SRPM in $BUILD_ROOT/$TOPDIR/SRPMS/*src.rpm ; do - test -f "$SRPM" && PNAME=`rpm --nodigest --nosignature -qp --qf "%{NAME}" $SRPM` + test -f "$SRPM" && PNAME=`rpm --nodigest --nosignature -qp --qf "%{NAME}" $SRPM` done for CHECKSCRIPT in $BUILD_ROOT/usr/lib/build/checks/* ; do - echo "... running `basename $CHECKSCRIPT`" - $CHECKSCRIPT || cleanup_and_exit 1 + echo "... running `basename $CHECKSCRIPT`" + $CHECKSCRIPT || cleanup_and_exit 1 done umount -n $BUILD_ROOT/proc 2> /dev/null fi @@ -1795,9 +1795,9 @@ fi if test \( -n "$RPMS" -o -n "$DEBS" \) -a -n "$CREATE_BASELIBS" -a \( -d "$BUILD_ROOT/$TOPDIR/RPMS" -o -d "$BUILD_ROOT/$TOPDIR/DEBS" \) ; then if test -f $BUILD_ROOT/usr/lib/build/mkbaselibs -o "$CREATE_BASELIBS" != internal ; then - mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null - create_baselibs - umount -n $BUILD_ROOT/proc 2> /dev/null + mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null + create_baselibs + umount -n $BUILD_ROOT/proc 2> /dev/null fi fi @@ -1808,15 +1808,15 @@ if test -n "$RUNNING_IN_VM" -a -n "$VM_SWAP"; then swapoff "$VM_SWAP" args="--padstart 512 --padend 512 -v" case "$BUILDTYPE" in - spec) - computeblocklists $args $TOPDIR/RPMS/*/*.rpm $TOPDIR/SRPMS/* > "$VM_SWAP" - ;; - dsc) - computeblocklists $args $TOPDIR/DEBS/*.deb $TOPDIR/SOURCES.DEB/* > "$VM_SWAP" - ;; - kiwi) - computeblocklists $args $TOPDIR/KIWI/* > "$VM_SWAP" - ;; + spec) + computeblocklists $args $TOPDIR/RPMS/*/*.rpm $TOPDIR/SRPMS/* > "$VM_SWAP" + ;; + dsc) + computeblocklists $args $TOPDIR/DEBS/*.deb $TOPDIR/SOURCES.DEB/* > "$VM_SWAP" + ;; + kiwi) + computeblocklists $args $TOPDIR/KIWI/* > "$VM_SWAP" + ;; esac || cleanup_and_exit 1 fi diff --git a/changelog2spec b/changelog2spec index 9160e75..2a8771a 100755 --- a/changelog2spec +++ b/changelog2spec @@ -16,7 +16,6 @@ use strict; my @wday = qw{Sun Mon Tue Wed Thu Fri Sat}; my @mon = qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec}; - my $ok; my $zone; my $test; @@ -56,8 +55,8 @@ if (@ARGV == 2 && $ARGV[0] eq '--file') { while ($file ne '') { my @c = grep {/\Q$file\E/} @changes; if (@c) { - @changes = @c; - last; + @changes = @c; + last; } last unless $file =~ s/[-.][^-.]*$//; } @@ -124,7 +123,7 @@ sub parse_suse { sub parse_debian { $_ = $_[0]; - + die("bad line: $_\n") unless /^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)((\s+[-+0-9a-z.]+)+)\;.*$/; my $package = $1; my $version = $2; @@ -166,7 +165,7 @@ while (<>) { next if (/^========================/); if (/^(?:\* )?([A-Za-z]+\s+[A-Za-z]+\s+[0-9].*[0-9][0-9][0-9][0-9])(.*\@.*$)/) { $format = 'suse'; - + } elsif (/^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)((\s+[-+0-9a-z.]+)+)\;.*$/) { $format = 'debian'; } else { diff --git a/common_functions b/common_functions index 41584db..cea3aa0 100644 --- a/common_functions +++ b/common_functions @@ -5,8 +5,8 @@ set_build_arch() : ${BUILD_HOST_ARCH:=`uname -m`} if [ -z "$BUILD_ARCH" ]; then - BUILD_ARCH="$BUILD_HOST_ARCH" - test i686 != "$BUILD_ARCH" || BUILD_ARCH=i586 # XXX: why? + BUILD_ARCH="$BUILD_HOST_ARCH" + test i686 != "$BUILD_ARCH" || BUILD_ARCH=i586 # XXX: why? fi case $BUILD_ARCH in @@ -16,13 +16,11 @@ set_build_arch() x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;; esac if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then - cpuflags=`grep ^flags /proc/cpuinfo` - cpuflags="$cpuflags " - test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}" && { - echo "Your cpu doesn't support i686 rpms. Exit." - exit 1 - } + cpuflags=`grep ^flags /proc/cpuinfo` + cpuflags="$cpuflags " + test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}" && { + echo "Your cpu doesn't support i686 rpms. Exit." + exit 1 + } fi } - -# vim:sw=4 diff --git a/computeblocklists b/computeblocklists index ff8cebf..c93b3cb 100755 --- a/computeblocklists +++ b/computeblocklists @@ -75,16 +75,16 @@ for my $file (@ARGV) { } else { # blocks are non-contiguous if($lastblock+1 != $block) { - # check if we skipped some that form a range - if($firstblock != $lastblock) { - printf "-$lastblock"; - } - print " $block"; - $firstblock = $block; + # check if we skipped some that form a range + if($firstblock != $lastblock) { + printf "-$lastblock"; + } + print " $block"; + $firstblock = $block; } # last block, check if contiguous if($b+1==$blocks && $lastblock+1 == $block) { - print "-$block"; + print "-$block"; } } $lastblock = $block; diff --git a/createrepomddeps b/createrepomddeps index 3068036..a1fec28 100755 --- a/createrepomddeps +++ b/createrepomddeps @@ -25,41 +25,41 @@ my $opt_bc; my $old_seen = (); my $repomdparser = { - repomd => { - data => { - _start => \&repomd_handle_data_start, - location => { - _start => \&repomd_handle_location, - }, - }, - }, + repomd => { + data => { + _start => \&repomd_handle_data_start, + location => { + _start => \&repomd_handle_location, + }, + }, + }, }; my $primaryparser = { - metadata => { - 'package' => { - _start => \&primary_handle_package_start, - _end => \&primary_handle_package_end, - name => { _text => \&primary_collect_text, _end => \&primary_store_text }, - arch => { _text => \&primary_collect_text, _end => \&primary_store_text }, - version => { _start => \&primary_handle_version }, - 'time' => { _start => \&primary_handle_time }, - format => { - 'rpm:provides' => { 'rpm:entry' => { _start => \&primary_handle_package_provides }, }, - 'rpm:requires' => { 'rpm:entry' => { _start => \&primary_handle_package_requires }, }, - 'rpm:conflicts' => { 'rpm:entry' => { _start => \&primary_handle_package_conflicts }, }, - 'rpm:obsoletes' => { 'rpm:entry' => { _start => \&primary_handle_package_obsoletes }, }, - 'rpm:buildhost' => { _text => \&primary_collect_text, _end => \&primary_store_text }, - 'rpm:sourcerpm' => { _text => \&primary_collect_text, _end => \&primary_store_text }, - file => { - _start => \&primary_handle_file_start, - _text => \&primary_collect_text, - _end => \&primary_handle_file_end - }, - }, - location => { _start => \&primary_handle_package_location }, - }, - }, + metadata => { + 'package' => { + _start => \&primary_handle_package_start, + _end => \&primary_handle_package_end, + name => { _text => \&primary_collect_text, _end => \&primary_store_text }, + arch => { _text => \&primary_collect_text, _end => \&primary_store_text }, + version => { _start => \&primary_handle_version }, + 'time' => { _start => \&primary_handle_time }, + format => { + 'rpm:provides' => { 'rpm:entry' => { _start => \&primary_handle_package_provides }, }, + 'rpm:requires' => { 'rpm:entry' => { _start => \&primary_handle_package_requires }, }, + 'rpm:conflicts' => { 'rpm:entry' => { _start => \&primary_handle_package_conflicts }, }, + 'rpm:obsoletes' => { 'rpm:entry' => { _start => \&primary_handle_package_obsoletes }, }, + 'rpm:buildhost' => { _text => \&primary_collect_text, _end => \&primary_store_text }, + 'rpm:sourcerpm' => { _text => \&primary_collect_text, _end => \&primary_store_text }, + file => { + _start => \&primary_handle_file_start, + _text => \&primary_collect_text, + _end => \&primary_handle_file_end + }, + }, + location => { _start => \&primary_handle_package_location }, + }, + }, }; # [ [tag, \%], ... ] @@ -67,79 +67,79 @@ my @cursor = (); sub repomd_handle_data_start { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); - if($attr->{'type'} ne 'primary') { - pop @cursor; - } + my $attr = map_attrs(@_); + if($attr->{'type'} ne 'primary') { + pop @cursor; + } } sub repomd_handle_location { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); - if(exists $attr->{'href'}) { - push @primaryfiles, { location => $attr->{'href'} }; - } + my $attr = map_attrs(@_); + if(exists $attr->{'href'}) { + push @primaryfiles, { location => $attr->{'href'} }; + } } sub generic_handle_start { - my $p = shift; - my $el = shift; - - if(exists $cursor[-1]->[1]->{$el}) - { - my $h = $cursor[-1]->[1]->{$el}; - push @cursor, [$el, $h]; - if(exists $h->{'_start'}) { - &{$h->{'_start'}}($p, $el, @_); - } - } + my $p = shift; + my $el = shift; + + if(exists $cursor[-1]->[1]->{$el}) + { + my $h = $cursor[-1]->[1]->{$el}; + push @cursor, [$el, $h]; + if(exists $h->{'_start'}) { + &{$h->{'_start'}}($p, $el, @_); + } + } } sub generic_handle_char { - my $p = shift; - my $text = shift; + my $p = shift; + my $text = shift; - my $h = $cursor[-1]->[1]; + my $h = $cursor[-1]->[1]; - if(exists $h->{'_text'}) { - &{$h->{'_text'}}($p, $text); - } + if(exists $h->{'_text'}) { + &{$h->{'_text'}}($p, $text); + } } sub generic_handle_end { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - if(!defined $cursor[-1]->[0] || $cursor[-1]->[0] eq $el) - { - my $h = $cursor[-1]->[1]; + if(!defined $cursor[-1]->[0] || $cursor[-1]->[0] eq $el) + { + my $h = $cursor[-1]->[1]; - if(exists $h->{'_end'}) { - &{$h->{'_end'}}($p, $el); - } + if(exists $h->{'_end'}) { + &{$h->{'_end'}}($p, $el); + } - pop @cursor; - } + pop @cursor; + } } sub map_attrs { - my %h; - while(@_) { - my $k = shift; - $h{$k} = shift; - } + my %h; + while(@_) { + my $k = shift; + $h{$k} = shift; + } - return \%h; + return \%h; } # expat does not guarantee that character data doesn't get split up @@ -147,10 +147,10 @@ sub map_attrs my $textbuf = ''; sub primary_collect_text { - my $p = shift; - my $text = shift; + my $p = shift; + my $text = shift; - $textbuf .= $text; + $textbuf .= $text; } sub primary_store_text @@ -164,185 +164,184 @@ sub primary_store_text sub primary_handle_package_start { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); + my $attr = map_attrs(@_); - push @packages, { type => $attr->{'type'}, baseurl => $baseurl }; + push @packages, { type => $attr->{'type'}, baseurl => $baseurl }; } sub primary_handle_package_end { - my $p = shift; - my $el = shift; - - if($opt_bc) { - printasbuildcachefile(@packages); - shift @packages; - } elsif ($opt_old) { - foreach my $pkg (@packages) { - my $arch = $pkg->{'arch'}; - $arch = 'src' if $pkg->{'arch'} eq 'nosrc'; - next if ($arch eq 'src' && $opt_nosrc); - if(exists($old_seen->{$pkg->{'name'}}->{$arch})) { - my $pv = $old_seen->{$pkg->{'name'}}->{$arch}->{'ver'}; - my $rv = $pkg->{'ver'}.'-'.$pkg->{'rel'}; - my $vv = Build::Rpm::verscmp($pv, $rv, 0); - if($vv < 0) - { - print $old_seen->{$pkg->{'name'}}->{$arch}->{'loc'}."\n"; - $old_seen->{$pkg->{'name'}}->{$arch}->{'ver'} = $pkg->{'ver'}.'-'.$pkg->{'rel'}; - $old_seen->{$pkg->{'name'}}->{$arch}->{'loc'} = $pkg->{'baseurl'} . $pkg->{'location'}; - } else { - print $pkg->{'baseurl'} . $pkg->{'location'}."\n"; - } - } else { - $old_seen->{$pkg->{'name'}}->{$arch}->{'ver'} = $pkg->{'ver'}.'-'.$pkg->{'rel'}; - $old_seen->{$pkg->{'name'}}->{$arch}->{'loc'} = $pkg->{'baseurl'} . $pkg->{'location'}; - } - } - shift @packages; - } + my $p = shift; + my $el = shift; + + if($opt_bc) { + printasbuildcachefile(@packages); + shift @packages; + } elsif ($opt_old) { + foreach my $pkg (@packages) { + my $arch = $pkg->{'arch'}; + $arch = 'src' if $pkg->{'arch'} eq 'nosrc'; + next if ($arch eq 'src' && $opt_nosrc); + if(exists($old_seen->{$pkg->{'name'}}->{$arch})) { + my $pv = $old_seen->{$pkg->{'name'}}->{$arch}->{'ver'}; + my $rv = $pkg->{'ver'}.'-'.$pkg->{'rel'}; + my $vv = Build::Rpm::verscmp($pv, $rv, 0); + if($vv < 0) + { + print $old_seen->{$pkg->{'name'}}->{$arch}->{'loc'}."\n"; + $old_seen->{$pkg->{'name'}}->{$arch}->{'ver'} = $pkg->{'ver'}.'-'.$pkg->{'rel'}; + $old_seen->{$pkg->{'name'}}->{$arch}->{'loc'} = $pkg->{'baseurl'} . $pkg->{'location'}; + } else { + print $pkg->{'baseurl'} . $pkg->{'location'}."\n"; + } + } else { + $old_seen->{$pkg->{'name'}}->{$arch}->{'ver'} = $pkg->{'ver'}.'-'.$pkg->{'rel'}; + $old_seen->{$pkg->{'name'}}->{$arch}->{'loc'} = $pkg->{'baseurl'} . $pkg->{'location'}; + } + } + shift @packages; + } } sub primary_handle_version { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); - $packages[-1]->{'ver'} = $attr->{'ver'}; - $packages[-1]->{'rel'} = $attr->{'rel'}; + my $attr = map_attrs(@_); + $packages[-1]->{'ver'} = $attr->{'ver'}; + $packages[-1]->{'rel'} = $attr->{'rel'}; } sub primary_handle_time { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); - $packages[-1]->{'filetime'} = $attr->{'file'}; - $packages[-1]->{'buildtime'} = $attr->{'build'}; + my $attr = map_attrs(@_); + $packages[-1]->{'filetime'} = $attr->{'file'}; + $packages[-1]->{'buildtime'} = $attr->{'build'}; } sub primary_handle_package_location { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); - $packages[-1]->{'location'} = $attr->{'href'}; + my $attr = map_attrs(@_); + $packages[-1]->{'location'} = $attr->{'href'}; } sub primary_handle_file_start { - my $p = shift; - my $el = shift; + my $p = shift; + my $el = shift; - my $attr = map_attrs(@_); - if(exists $attr->{'type'}) { - pop @cursor; - } + my $attr = map_attrs(@_); + if(exists $attr->{'type'}) { + pop @cursor; + } } sub primary_handle_file_end { - my $p = shift; - my $text = shift; + my $p = shift; + my $text = shift; - primary_handle_package_deps('provides', 'name', $textbuf); - $textbuf = ''; + primary_handle_package_deps('provides', 'name', $textbuf); + $textbuf = ''; } my %flagmap = ( - EQ => '=', - LE => '<=', - GE => '>=', - GT => '>', - LT => '<', - NE => '!=', + EQ => '=', + LE => '<=', + GE => '>=', + GT => '>', + LT => '<', + NE => '!=', ); sub primary_handle_package_deps { - my $dep = shift; - my $attr = map_attrs(@_); - - if(exists $attr->{'flags'}) { - if(!exists($flagmap{$attr->{'flags'}})) { - print STDERR "bogus relation: ", $attr->{'flags'}, "\n"; - return; - } - $attr->{'flags'} = $flagmap{$attr->{'flags'}}; - } - return if($attr->{'name'} =~ /^rpmlib\(/); - push @{$packages[-1]->{$dep}}, $attr; + my $dep = shift; + my $attr = map_attrs(@_); + + if(exists $attr->{'flags'}) { + if(!exists($flagmap{$attr->{'flags'}})) { + print STDERR "bogus relation: ", $attr->{'flags'}, "\n"; + return; + } + $attr->{'flags'} = $flagmap{$attr->{'flags'}}; + } + return if($attr->{'name'} =~ /^rpmlib\(/); + push @{$packages[-1]->{$dep}}, $attr; } sub primary_handle_package_conflicts { - shift;shift; primary_handle_package_deps('conflicts', @_); + shift;shift; primary_handle_package_deps('conflicts', @_); } sub primary_handle_package_obsoletes { - shift;shift; primary_handle_package_deps('obsoletes', @_); + shift;shift; primary_handle_package_deps('obsoletes', @_); } sub primary_handle_package_requires { - shift;shift; primary_handle_package_deps('requires', @_); + shift;shift; primary_handle_package_deps('requires', @_); } sub primary_handle_package_provides { - shift;shift; primary_handle_package_deps('provides', @_); + shift;shift; primary_handle_package_deps('provides', @_); } sub deps2string { - return join(' ', map { - my $s = $_->{'name'}; - if(exists $_->{'flags'}) { - $s .= ' '.$_->{'flags'}.' '; - $s .= $_->{'epoch'}.':' if(exists $_->{'epoch'} && $_->{'epoch'} != 0); - $s .= $_->{'ver'}; - $s .= '-'.$_->{'rel'} if exists $_->{'rel'}; - } - $s - } @_); + return join(' ', map { + my $s = $_->{'name'}; + if(exists $_->{'flags'}) { + $s .= ' '.$_->{'flags'}.' '; + $s .= $_->{'epoch'}.':' if(exists $_->{'epoch'} && $_->{'epoch'} != 0); + $s .= $_->{'ver'}; + $s .= '-'.$_->{'rel'} if exists $_->{'rel'}; + } + $s + } @_); } sub printasbuildcachefile(@) { - foreach my $pkg (@_) { - next if $pkg->{'arch'} eq 'src' || $pkg->{'arch'} eq 'nosrc'; - my $id = sprintf("%s.%s-%d/%d/%d: ", - $pkg->{'name'}, - $pkg->{'arch'}, - $pkg->{'buildtime'}, - $pkg->{'filetime'}, - 0); - print "F:".$id. $pkg->{'baseurl'} . $pkg->{'location'} . "\n"; - - my $deps = deps2string(@{$pkg->{'provides'}}); - print "P:$id$deps\n"; - - $deps = deps2string(@{$pkg->{'requires'}}); - print "R:$id$deps\n"; - - my $tag = sprintf("%s-%s-%s %s", - $pkg->{'name'}, - $pkg->{'ver'}, - $pkg->{'rel'}, -# $pkg->{'rpm:buildhost'}, - $pkg->{'buildtime'}); - print "I:$id$tag\n"; - } + foreach my $pkg (@_) { + next if $pkg->{'arch'} eq 'src' || $pkg->{'arch'} eq 'nosrc'; + my $id = sprintf("%s.%s-%d/%d/%d: ", + $pkg->{'name'}, + $pkg->{'arch'}, + $pkg->{'buildtime'}, + $pkg->{'filetime'}, + 0); + print "F:".$id. $pkg->{'baseurl'} . $pkg->{'location'} . "\n"; + + my $deps = deps2string(@{$pkg->{'provides'}}); + print "P:$id$deps\n"; + + $deps = deps2string(@{$pkg->{'requires'}}); + print "R:$id$deps\n"; + + my $tag = sprintf("%s-%s-%s %s", + $pkg->{'name'}, + $pkg->{'ver'}, + $pkg->{'rel'}, +# $pkg->{'rpm:buildhost'}, + $pkg->{'buildtime'}); + print "I:$id$tag\n"; + } } - ### main GetOptions ( @@ -354,35 +353,35 @@ GetOptions ( $opt_bc = 1 unless ($opt_dump || $opt_old); my $p = new XML::Parser( - Handlers => { - Start => \&generic_handle_start, - End => \&generic_handle_end, - Char => \&generic_handle_char - }); + Handlers => { + Start => \&generic_handle_start, + End => \&generic_handle_end, + Char => \&generic_handle_char + }); #my $url = '/mounts/mirror/SuSE/ftp.suse.com/pub/suse/update/10.1/'; foreach my $url (@ARGV) { - $url .= '/' unless $url =~ /\/$/; + $url .= '/' unless $url =~ /\/$/; - $baseurl = $url; - @primaryfiles = (); - @cursor = ([undef, $repomdparser]); + $baseurl = $url; + @primaryfiles = (); + @cursor = ([undef, $repomdparser]); - $p->parsefile($url . 'repodata/repomd.xml'); + $p->parsefile($url . 'repodata/repomd.xml'); -# print Dumper(\@primaryfiles); +# print Dumper(\@primaryfiles); - foreach my $f (@primaryfiles) { - @cursor = ([undef, $primaryparser]); + foreach my $f (@primaryfiles) { + @cursor = ([undef, $primaryparser]); - my $u = $url . $f->{'location'}; - $u = 'gzip -cd ' . $u . '|' if ($u =~ /\.gz$/); # XXX + my $u = $url . $f->{'location'}; + $u = 'gzip -cd ' . $u . '|' if ($u =~ /\.gz$/); # XXX - my $fh; - open($fh, $u) or next; - $p->parse($fh); - close($fh); - } + my $fh; + open($fh, $u) or next; + $p->parse($fh); + close($fh); + } } if ($opt_dump) { @@ -394,20 +393,20 @@ if ($opt_dump) { # my $packages = do $rpmdepdump or die $!; # # foreach my $pkg (@$packages) { -# next if exists $packs{$pkg->{'name'}}; -# next unless exists $amap{$pkg->{'arch'}}; -# next if $pkg->{'arch'} eq 'src' || $pkg->{'arch'} eq 'nosrc'; -# next if $pkg->{'location'} =~ /\.(?:patch|delta)\.rpm$/; +# next if exists $packs{$pkg->{'name'}}; +# next unless exists $amap{$pkg->{'arch'}}; +# next if $pkg->{'arch'} eq 'src' || $pkg->{'arch'} eq 'nosrc'; +# next if $pkg->{'location'} =~ /\.(?:patch|delta)\.rpm$/; # -# my $pa = $pkg->{'name'}.'.'.$pkg->{'arch'}; -# $packs{$pkg->{'name'}} = $pa; -# $fn{$pa} = $pkg->{'baseurl'}.$pkg->{'location'}; -# my $r = {}; -# # flags and version ignored -# my @pr = map { $_->{'name'} } @{$pkg->{'provides'}}; -# my @re = map { $_->{'name'} } @{$pkg->{'requires'}}; -# $r->{'provides'} = \@pr; -# $r->{'requires'} = \@re; -# $repo{$pkg->{'name'}} = $r; +# my $pa = $pkg->{'name'}.'.'.$pkg->{'arch'}; +# $packs{$pkg->{'name'}} = $pa; +# $fn{$pa} = $pkg->{'baseurl'}.$pkg->{'location'}; +# my $r = {}; +# # flags and version ignored +# my @pr = map { $_->{'name'} } @{$pkg->{'provides'}}; +# my @re = map { $_->{'name'} } @{$pkg->{'requires'}}; +# $r->{'provides'} = \@pr; +# $r->{'requires'} = \@re; +# $repo{$pkg->{'name'}} = $r; # } #} diff --git a/createrpmdeps b/createrpmdeps index 0240e94..e41de15 100755 --- a/createrpmdeps +++ b/createrpmdeps @@ -91,46 +91,46 @@ foreach my $dir (@ARGV) { my $id = $known; $id =~ s/.*-//; if ($known ne "$res{1000}->[0].$res{1022}->[0]-$id") { - $known = "$res{1000}->[0].$res{1022}->[0]-$id"; - if (!$known2path{$known}) { - push @known, $known; - $known2path{$known} = $path; - } + $known = "$res{1000}->[0].$res{1022}->[0]-$id"; + if (!$known2path{$known}) { + push @known, $known; + $known2path{$known} = $path; + } + } + # rpm3 compatibility: retrofit missing self provides + my $name = $res{1000}->[0]; + if (!@{$res{1047} || []} || $res{1047}->[-1] !~ /^\Q$name\E =/) { + my $evr = "$res{1001}->[0]-$res{1002}->[0]"; + $evr = "$res{1003}->[0]:$evr" if $res{1003} && $res{1003}->[0]; + push @{$res{1047}}, "$name = $evr"; } - # rpm3 compatibility: retrofit missing self provides - my $name = $res{1000}->[0]; - if (!@{$res{1047} || []} || $res{1047}->[-1] !~ /^\Q$name\E =/) { - my $evr = "$res{1001}->[0]-$res{1002}->[0]"; - $evr = "$res{1003}->[0]:$evr" if $res{1003} && $res{1003}->[0]; - push @{$res{1047}}, "$name = $evr"; - } $newp{$known} = "P:$known: ".join(' ', @{$res{1047} || []}); $newr{$known} = "R:$known: ".join(' ', @{$res{1049} || []}); - #$tag{$known} = $res{1000}->[0]."-".$res{1001}->[0]."-".$res{1002}->[0]." ".$res{1007}->[0]."-".$res{1006}->[0]; - $tag{$known} = $res{1000}->[0]."-".$res{1001}->[0]."-".$res{1002}->[0]." ".$res{1006}->[0]; + #$tag{$known} = $res{1000}->[0]."-".$res{1001}->[0]."-".$res{1002}->[0]." ".$res{1007}->[0]."-".$res{1006}->[0]; + $tag{$known} = $res{1000}->[0]."-".$res{1001}->[0]."-".$res{1002}->[0]." ".$res{1006}->[0]; } else { my %res = Build::Deb::debq($path); next unless %res; - my ($dn, $da) = ($res{'PACKAGE'}, $res{'ARCHITECTURE'}); - $da = 'noarch' if $da eq 'all'; + my ($dn, $da) = ($res{'PACKAGE'}, $res{'ARCHITECTURE'}); + $da = 'noarch' if $da eq 'all'; my $id = $known; $id =~ s/.*-//; if ($known ne "$dn.$da-$id") { - $known = "$dn.$da-$id"; - if (!$known2path{$known}) { - push @known, $known; - $known2path{$known} = $path; - } - } - my @provides = split(',\s*', $res{'PROVIDES'} || ''); - my @depends = split(',\s*', $res{'DEPENDS'} || ''); - my @predepends = split(',\s*', $res{'PRE-DEPENDS'} || ''); - s/\s.*// for @provides; #for now - s/\s.*// for @depends; #for now - s/\s.*// for @predepends; #for now - push @depends, @predepends; - push @provides, $res{'PACKAGE'}; + $known = "$dn.$da-$id"; + if (!$known2path{$known}) { + push @known, $known; + $known2path{$known} = $path; + } + } + my @provides = split(',\s*', $res{'PROVIDES'} || ''); + my @depends = split(',\s*', $res{'DEPENDS'} || ''); + my @predepends = split(',\s*', $res{'PRE-DEPENDS'} || ''); + s/\s.*// for @provides; #for now + s/\s.*// for @depends; #for now + s/\s.*// for @predepends; #for now + push @depends, @predepends; + push @provides, $res{'PACKAGE'}; $newp{$known} = "P:$known: ".join(' ', @provides); $newr{$known} = "R:$known: ".join(' ', @depends); } diff --git a/createyastdeps b/createyastdeps index f0adfad..9208024 100755 --- a/createyastdeps +++ b/createyastdeps @@ -14,23 +14,23 @@ sub print_pkg($) return if $pkg->{'arch'} eq 'src' || $pkg->{'arch'} eq 'nosrc'; my $id = sprintf("%s.%s-%d/%d/%d: ", - $pkg->{'name'}, - $pkg->{'arch'}, - $pkg->{'buildtime'}, - 0, - 0); + $pkg->{'name'}, + $pkg->{'arch'}, + $pkg->{'buildtime'}, + 0, + 0); print sprintf('F:%s%ssuse/%s/%s',$id,$pkg->{'baseurl'}, $pkg->{'arch'}, $pkg->{'location'}), "\n"; - + print "P:$id".$pkg->{'provides'}."\n"; print "R:$id".$pkg->{'requires'}."\n"; my $tag = sprintf("%s-%s-%s %s", - $pkg->{'name'}, - $pkg->{'version'}, - $pkg->{'release'}, -# $pkg->{'rpm:buildhost'}, - $pkg->{'buildtime'}); + $pkg->{'name'}, + $pkg->{'version'}, + $pkg->{'release'}, +# $pkg->{'rpm:buildhost'}, + $pkg->{'buildtime'}); print "I:$id$tag\n"; } @@ -70,15 +70,15 @@ while (@ARGV) # if(open(F, '<', $url."/yast/order")) { # my $found_products; # while() { -# chomp; -# my ($a, $b) = split(/ /); -# $a =~ s/^\///; -# if(-e $url.$a) -# { -# push @ARGV, $url.$a; -# $found_products = 1; -# print STDERR "$url -> $url$a\n"; -# } +# chomp; +# my ($a, $b) = split(/ /); +# $a =~ s/^\///; +# if(-e $url.$a) +# { +# push @ARGV, $url.$a; +# $found_products = 1; +# print STDERR "$url -> $url$a\n"; +# } # } # close(F); # next if $found_products; @@ -92,5 +92,3 @@ while (@ARGV) { 'Loc' => 'location', 'Prv' => 'provides', 'Req' => 'requires', 'Tim' => 'buildtime' }, { cb => \&callback, data => $url }); } - -# vim: sw=2 diff --git a/debtransform b/debtransform index 93c0326..bf86618 100755 --- a/debtransform +++ b/debtransform @@ -132,15 +132,15 @@ sub doseries { $_ = substr($_, 4); my $l = $level; while ($l > 0) { - last unless s/.*?\///; - $l--; - } + last unless s/.*?\///; + $l--; + } if ($start eq '--- ') { print DIFF "$start$tardir.orig/$_\n"; - } else { + } else { print DIFF "$start$tardir/$_\n"; - } - next; + } + next; } print DIFF "$_\n"; } diff --git a/expanddeps b/expanddeps index b7d5db9..73b977b 100755 --- a/expanddeps +++ b/expanddeps @@ -171,15 +171,14 @@ $cf->{'warnings'} = 1; sub print_rpmlist { - for (@_) { - print "$_ $fn{$packs{$_}}\n"; - print "rpmid: $_:$ids{$packs{$_}}\n" if exists $ids{$packs{$_}}; - } - print "preinstall: @{$cf->{'preinstall'} || []}\n"; - print "vminstall: @{$cf->{'vminstall'} || []}\n"; - print "runscripts: @{$cf->{'runscripts'} || []}\n"; - print "dist: $dist\n" if defined $dist; - + for (@_) { + print "$_ $fn{$packs{$_}}\n"; + print "rpmid: $_:$ids{$packs{$_}}\n" if exists $ids{$packs{$_}}; + } + print "preinstall: @{$cf->{'preinstall'} || []}\n"; + print "vminstall: @{$cf->{'vminstall'} || []}\n"; + print "runscripts: @{$cf->{'runscripts'} || []}\n"; + print "dist: $dist\n" if defined $dist; } if ($useusedforbuild) { diff --git a/extractbuild b/extractbuild index 5b5da86..6996b0a 100755 --- a/extractbuild +++ b/extractbuild @@ -77,19 +77,19 @@ while() { while($block <= $end && $filesize) { my $size; if($end == $block) { - $size = $blksize; - ++$block; + $size = $blksize; + ++$block; } elsif($maxblocks >= $end-$block) { - $size = ($end-$block)*$blksize; - $block += $end-$block; + $size = ($end-$block)*$blksize; + $block += $end-$block; } else { - $size = $maxblocks*$blksize; - $block += $maxblocks; + $size = $maxblocks*$blksize; + $block += $maxblocks; } $size = $filesize if $size > $filesize; my $buf; if((sysread(F, $buf, $size) || 0) != $size) { - die "$file: read: $!\n"; + die "$file: read: $!\n"; } $filesize -= $size; print O $buf; diff --git a/getbinaryid b/getbinaryid index 2d899a0..55c57f6 100755 --- a/getbinaryid +++ b/getbinaryid @@ -55,4 +55,3 @@ for my $file (@files) { print "$sig\n"; } } - diff --git a/getmacros b/getmacros index 4df5625..d15af57 100755 --- a/getmacros +++ b/getmacros @@ -18,7 +18,7 @@ while (@ARGV) { if ($ARGV[0] eq '--archpath') { shift @ARGV; $archs = shift @ARGV; - next; + next; } if ($ARGV[0] eq '--configdir') { shift @ARGV; diff --git a/init_buildsystem b/init_buildsystem index 2675d60..d9d9144 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -42,43 +42,43 @@ CREATE_BUILD_BINARIES= while test -n "$1" ; do case "$1" in - --prepare) - shift - PREPARE_VM=true - ;; - --create-build-binaries) - shift - CREATE_BUILD_BINARIES=true - ;; - --useusedforbuild) - shift - USEUSEDFORBUILD=--useusedforbuild - ;; - --list-state) - shift - LIST_STATE=true - ;; - --rpmlist) - shift - RPMLIST=$1 - shift - ;; - --define|--with|--without) - definesnstuff[${#definesnstuff[@]}]="$1"; - definesnstuff[${#definesnstuff[@]}]="$2"; - shift 2 - ;; - --repository|--repo) - repos[${#repos[@]}]="$2"; - shift 2; - ;; - --clean) - CLEAN_BUILD="$1" - shift - ;; - *) - break - ;; + --prepare) + shift + PREPARE_VM=true + ;; + --create-build-binaries) + shift + CREATE_BUILD_BINARIES=true + ;; + --useusedforbuild) + shift + USEUSEDFORBUILD=--useusedforbuild + ;; + --list-state) + shift + LIST_STATE=true + ;; + --rpmlist) + shift + RPMLIST=$1 + shift + ;; + --define|--with|--without) + definesnstuff[${#definesnstuff[@]}]="$1"; + definesnstuff[${#definesnstuff[@]}]="$2"; + shift 2 + ;; + --repository|--repo) + repos[${#repos[@]}]="$2"; + shift 2; + ;; + --clean) + CLEAN_BUILD="$1" + shift + ;; + *) + break + ;; esac done PKGS=("$@") @@ -106,13 +106,13 @@ function clean_build_root () { rm -rf -- $BUILD_ROOT/* rm -rf -- $BUILD_ROOT/.build rm -rf -- $BUILD_ROOT/.root - rm -rf -- $BUILD_ROOT/.init_b_cache - mkdir -p $BUILD_ROOT/proc - mkdir -p $BUILD_ROOT/dev/pts - if [ "$UID" = '0' ]; then - mount -n -tproc none $BUILD_ROOT/proc - mount -n -tdevpts none $BUILD_ROOT/dev/pts - fi + rm -rf -- $BUILD_ROOT/.init_b_cache + mkdir -p $BUILD_ROOT/proc + mkdir -p $BUILD_ROOT/dev/pts + if [ "$UID" = '0' ]; then + mount -n -tproc none $BUILD_ROOT/proc + mount -n -tdevpts none $BUILD_ROOT/dev/pts + fi } } @@ -120,64 +120,64 @@ function preinstall { if test -n "$1" ; then echo "preinstalling $1..." cd $BUILD_ROOT || cleanup_and_exit 1 - CPIO="cpio --extract --unconditional --preserve-modification-time --make-directories --no-absolute-filenames --quiet" - if test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" ; then - PAYLOADDECOMPRESS=cat - case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm"` in - lzma) rpm --showrc | grep PayloadIsLzma > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;; - xz) rpm --showrc | grep PayloadIsXz > /dev/null || PAYLOADDECOMPRESS="xz -d" ;; - esac - if test "$PAYLOADDECOMPRESS" = "lzma -d" ; then - if ! lzma /dev/null 2>&1 ; then - test -f "$BUILD_DIR/lzmadec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/lzmadec.sh" - fi - fi - if test "$PAYLOADDECOMPRESS" = cat ; then - rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $CPIO - else - rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $PAYLOADDECOMPRESS | $CPIO - fi - if test -e .init_b_cache/scripts/$1.run ; then - rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > .init_b_cache/scripts/$1.pre - rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > .init_b_cache/scripts/$1.post - echo -n '(none)' > .init_b_cache/scripts/.none - cmp -s .init_b_cache/scripts/$1.pre .init_b_cache/scripts/.none && rm -f .init_b_cache/scripts/$1.pre - cmp -s .init_b_cache/scripts/$1.post .init_b_cache/scripts/.none && rm -f .init_b_cache/scripts/$1.post - rm -f .init_b_cache/scripts/.none - fi - elif test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" ; then - ar x "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" control.tar.gz data.tar.gz - mkdir -p .init_b_cache/scripts/control - tar -C .init_b_cache/scripts/control -xzf control.tar.gz - tar xzf data.tar.gz - if test -e .init_b_cache/scripts/$1.run ; then - test -e .init_b_cache/scripts/control/preinst && mv .init_b_cache/scripts/control/preinst .init_b_cache/scripts/$1.pre - test -e .init_b_cache/scripts/control/postinst && mv .init_b_cache/scripts/control/postinst .init_b_cache/scripts/$1.post - fi - rm -rf .init_b_cache/scripts/control control.tar.gz data.tar.gz - else - echo "warning: package $1 does not exist" - fi + CPIO="cpio --extract --unconditional --preserve-modification-time --make-directories --no-absolute-filenames --quiet" + if test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" ; then + PAYLOADDECOMPRESS=cat + case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm"` in + lzma) rpm --showrc | grep PayloadIsLzma > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;; + xz) rpm --showrc | grep PayloadIsXz > /dev/null || PAYLOADDECOMPRESS="xz -d" ;; + esac + if test "$PAYLOADDECOMPRESS" = "lzma -d" ; then + if ! lzma /dev/null 2>&1 ; then + test -f "$BUILD_DIR/lzmadec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/lzmadec.sh" + fi + fi + if test "$PAYLOADDECOMPRESS" = cat ; then + rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $CPIO + else + rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $PAYLOADDECOMPRESS | $CPIO + fi + if test -e .init_b_cache/scripts/$1.run ; then + rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > .init_b_cache/scripts/$1.pre + rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > .init_b_cache/scripts/$1.post + echo -n '(none)' > .init_b_cache/scripts/.none + cmp -s .init_b_cache/scripts/$1.pre .init_b_cache/scripts/.none && rm -f .init_b_cache/scripts/$1.pre + cmp -s .init_b_cache/scripts/$1.post .init_b_cache/scripts/.none && rm -f .init_b_cache/scripts/$1.post + rm -f .init_b_cache/scripts/.none + fi + elif test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" ; then + ar x "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" control.tar.gz data.tar.gz + mkdir -p .init_b_cache/scripts/control + tar -C .init_b_cache/scripts/control -xzf control.tar.gz + tar xzf data.tar.gz + if test -e .init_b_cache/scripts/$1.run ; then + test -e .init_b_cache/scripts/control/preinst && mv .init_b_cache/scripts/control/preinst .init_b_cache/scripts/$1.pre + test -e .init_b_cache/scripts/control/postinst && mv .init_b_cache/scripts/control/postinst .init_b_cache/scripts/$1.post + fi + rm -rf .init_b_cache/scripts/control control.tar.gz data.tar.gz + else + echo "warning: package $1 does not exist" + fi fi if test -n "$2" ; then - chroot $BUILD_ROOT /sbin/ldconfig 2>/dev/null + chroot $BUILD_ROOT /sbin/ldconfig 2>/dev/null for PKG in $PACKAGES_TO_RUNSCRIPTS ; do if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then echo "running $PKG preinstall script" - if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then - chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0 - else - chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install < /dev/null - fi + if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then + chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0 + else + chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install < /dev/null + fi rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" fi if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then echo "running $PKG postinstall script" - if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then - chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1 - else - chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' < /dev/null - fi + if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then + chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1 + else + chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' < /dev/null + fi rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" fi done @@ -186,19 +186,19 @@ function preinstall { function init_db { if test $PSUF = rpm ; then - echo initializing rpm db... - chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1 - # hack: add nofsync to db config to speed up install - mkdir -p $BUILD_ROOT/root - echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/.rpmmacros - echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/root/.rpmmacros + echo initializing rpm db... + chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1 + # hack: add nofsync to db config to speed up install + mkdir -p $BUILD_ROOT/root + echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/.rpmmacros + echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/root/.rpmmacros else - # force dpkg into database to make epoch test work - if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then - rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb - cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1 - fi - chroot $BUILD_ROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1 + # force dpkg into database to make epoch test work + if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then + rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb + cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1 + fi + chroot $BUILD_ROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1 fi } @@ -206,7 +206,7 @@ function reorder { test -z "$*" && return rm -f $BUILD_ROOT/.init_b_cache/order.manifest for PKG in "$@" ; do - echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest + echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest done $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms rm -f $BUILD_ROOT/.init_b_cache/order.manifest @@ -219,28 +219,28 @@ function create_devs { test -f $BUILD_ROOT/dev/shm && rm -f $BUILD_ROOT/dev/shm mkdir -m 755 -p $BUILD_ROOT/dev/shm while read com file mode arg ; do - rm -f $BUILD_ROOT/dev/$file - if test $com = ln ; then - ln -s $arg $BUILD_ROOT/dev/$file - continue - fi - $com -m $mode $BUILD_ROOT/dev/$file $arg + rm -f $BUILD_ROOT/dev/$file + if test $com = ln ; then + ln -s $arg $BUILD_ROOT/dev/$file + continue + fi + $com -m $mode $BUILD_ROOT/dev/$file $arg done << DEVLIST - mknod null 666 c 1 3 - mknod zero 666 c 1 5 - mknod full 622 c 1 7 - mknod random 666 c 1 8 - mknod urandom 644 c 1 9 - mknod tty 666 c 5 0 - mknod ptmx 666 c 5 2 - mknod loop0 640 b 7 0 - mknod loop1 640 b 7 1 - mknod loop2 640 b 7 2 - mknod loop3 640 b 7 3 - ln fd 777 /proc/self/fd - ln stdin 777 fd/0 - ln stdout 777 fd/1 - ln stderr 777 fd/2 + mknod null 666 c 1 3 + mknod zero 666 c 1 5 + mknod full 622 c 1 7 + mknod random 666 c 1 8 + mknod urandom 644 c 1 9 + mknod tty 666 c 5 0 + mknod ptmx 666 c 5 2 + mknod loop0 640 b 7 0 + mknod loop1 640 b 7 1 + mknod loop2 640 b 7 2 + mknod loop3 640 b 7 3 + ln fd 777 /proc/self/fd + ln stdin 777 fd/0 + ln stdout 777 fd/1 + ln stderr 777 fd/2 DEVLIST } @@ -249,33 +249,33 @@ function validate_cache_file { test "${repos[*]} ${BUILD_RPMS//:/ /}" != "$(cat $CACHE_FILE.id 2>/dev/null)" && rm -f $CACHE_FILE.id test -f $CACHE_FILE || rm -f $CACHE_FILE.id for SRC in "${repos[@]}" ${BUILD_RPMS//:/ /}; do - test -z "$SRC" && SRC=. - test "$SRC" -nt $CACHE_FILE && rm -f $CACHE_FILE.id + test -z "$SRC" && SRC=. + test "$SRC" -nt $CACHE_FILE && rm -f $CACHE_FILE.id done if ! test -f $CACHE_FILE.id ; then - test -z "$LIST_STATE" && echo initializing $CACHE_FILE ... - for SRC in "${repos[@]}" -- ${BUILD_RPMS//:/ /}; do - if test "$SRC" = '--' ; then - findonly=1 - continue - fi - test -z "$SRC" && SRC=`pwd` - if [ ! -e "$SRC" ]; then - echo "*** $SRC does not exist" >&2 - cleanup_and_exit 1 - elif [ -z "$findonly" -a -e "$SRC"/suse/setup/descr/packages -o -e "$SRC"/suse/setup/descr/packages.gz ]; then - set -- $BUILD_DIR/createyastdeps "$SRC" - elif [ -z "$findonly" -a -e "$SRC"/repodata/repomd.xml ]; then - set -- $BUILD_DIR/createrepomddeps "$SRC" - else - set -- $BUILD_DIR/createrpmdeps "$SRC" - fi - echo "$@" >&2 - "$@" || cleanup_and_exit 1 - done > $CACHE_FILE.new - - mv $CACHE_FILE.new $CACHE_FILE - echo "${repos[*]} ${BUILD_RPMS//:/ /}" > $CACHE_FILE.id + test -z "$LIST_STATE" && echo initializing $CACHE_FILE ... + for SRC in "${repos[@]}" -- ${BUILD_RPMS//:/ /}; do + if test "$SRC" = '--' ; then + findonly=1 + continue + fi + test -z "$SRC" && SRC=`pwd` + if [ ! -e "$SRC" ]; then + echo "*** $SRC does not exist" >&2 + cleanup_and_exit 1 + elif [ -z "$findonly" -a -e "$SRC"/suse/setup/descr/packages -o -e "$SRC"/suse/setup/descr/packages.gz ]; then + set -- $BUILD_DIR/createyastdeps "$SRC" + elif [ -z "$findonly" -a -e "$SRC"/repodata/repomd.xml ]; then + set -- $BUILD_DIR/createrepomddeps "$SRC" + else + set -- $BUILD_DIR/createrpmdeps "$SRC" + fi + echo "$@" >&2 + "$@" || cleanup_and_exit 1 + done > $CACHE_FILE.new + + mv $CACHE_FILE.new $CACHE_FILE + echo "${repos[*]} ${BUILD_RPMS//:/ /}" > $CACHE_FILE.id fi } @@ -286,20 +286,20 @@ function register_qemu_user { # if [ x"$BUILD_ARCH" == xarmv4l -o x"$BUILD_ARCH" == xarmv5el -o x"$BUILD_ARCH" == xarmv7el -o x"$BUILD_ARCH" == xsh4 -o x"$BUILD_ARCH" == xppc ]; then if [ -n "$(uname -m | grep '[x3-6]86')" ]; then - if [ -e /usr/sbin/qemu-binfmt-conf.sh ]; then + if [ -e /usr/sbin/qemu-binfmt-conf.sh ]; then (mkdir -p $BUILD_ROOT/usr/bin $BUILD_ROOT/usr/sbin && set -x && cp /usr/bin/qemu-* $BUILD_ROOT/usr/bin && cp /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin) fi # To initially run the init script, there needs to be also a static bash to register qemu in this chroot and though to start up /.build/build - if [ -e /bin/bash-static -a -e /bin/mount-static ]; then + if [ -e /bin/bash-static -a -e /bin/mount-static ]; then (mkdir -p $BUILD_ROOT/bin && set -x && cp /bin/bash-static $BUILD_ROOT/bin && cp /bin/mount-static $BUILD_ROOT/bin) fi if [ -e /proc/sys/fs/binfmt_misc/arm -o -e /proc/sys/fs/binfmt_misc/armeb -o -e /proc/sys/fs/binfmt_misc/sh4 ]; then echo "qemu-* already registered" else - if [ -e /usr/sbin/qemu-binfmt-conf.sh ]; then - echo "qemu-* will be registered" - (set -x && /usr/sbin/qemu-binfmt-conf.sh) - fi + if [ -e /usr/sbin/qemu-binfmt-conf.sh ]; then + echo "qemu-* will be registered" + (set -x && /usr/sbin/qemu-binfmt-conf.sh) + fi fi fi fi @@ -341,9 +341,9 @@ if test -e $BUILD_IS_RUNNING ; then echo -n "[y/N/c] " read ANSWER case "$ANSWER" in - c|C) rm -f $BUILD_IS_RUNNING ;; - y|Y) clean_build_root ;; - *) cleanup_and_exit 1 ;; + c|C) rm -f $BUILD_IS_RUNNING ;; + y|Y) clean_build_root ;; + *) cleanup_and_exit 1 ;; esac fi @@ -366,10 +366,10 @@ if test -e $BUILD_ROOT/.build/init_buildsystem.data ; then # vm continuation . $BUILD_ROOT/.build/init_buildsystem.data if ! test -e $BUILD_ROOT/.init_b_cache/preinstall_finished ; then - # finish preinstall - preinstall '' true - init_db - touch $BUILD_ROOT/.init_b_cache/preinstall_finished + # finish preinstall + preinstall '' true + init_db + touch $BUILD_ROOT/.init_b_cache/preinstall_finished fi else # @@ -379,35 +379,35 @@ else mkdir -p $BUILD_ROOT/.init_b_cache/scripts if test -z "$RPMLIST" ; then - # - # create rpmdeps file - # - CACHE_FILE=$BUILD_ROOT/.srcfiles.cache - validate_cache_file - - # - # select and expand packages - # - RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist - test -z "$LIST_STATE" && echo "expanding package dependencies..." - if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs "${PKGS[@]}" > $RPMLIST ; then - rm -f $BUILD_IS_RUNNING - cleanup_and_exit 1 - fi + # + # create rpmdeps file + # + CACHE_FILE=$BUILD_ROOT/.srcfiles.cache + validate_cache_file + + # + # select and expand packages + # + RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist + test -z "$LIST_STATE" && echo "expanding package dependencies..." + if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs "${PKGS[@]}" > $RPMLIST ; then + rm -f $BUILD_IS_RUNNING + cleanup_and_exit 1 + fi fi if test -n "$LIST_STATE" ; then - rm -f $BUILD_IS_RUNNING - while read PKG SRC ; do - test "$PKG" = "preinstall:" && continue - test "$PKG" = "runscripts:" && continue - test "$PKG" = "vminstall:" && continue - test "$PKG" = "dist:" && continue - test "$PKG" = "rpmid:" && continue - echo "${SRC##*/}" - done < $BUILD_ROOT/.init_b_cache/rpmlist - rm -rf $BUILD_ROOT/.init_b_cache - cleanup_and_exit 0 + rm -f $BUILD_IS_RUNNING + while read PKG SRC ; do + test "$PKG" = "preinstall:" && continue + test "$PKG" = "runscripts:" && continue + test "$PKG" = "vminstall:" && continue + test "$PKG" = "dist:" && continue + test "$PKG" = "rpmid:" && continue + echo "${SRC##*/}" + done < $BUILD_ROOT/.init_b_cache/rpmlist + rm -rf $BUILD_ROOT/.init_b_cache + cleanup_and_exit 0 fi PACKAGES_TO_INSTALL= @@ -418,29 +418,29 @@ else GUESSED_DIST=unknown mkdir -p $BUILD_ROOT/.init_b_cache/rpms while read PKG SRC ; do - if test "$PKG" = "preinstall:" ; then - PACKAGES_TO_PREINSTALL=$SRC - continue - fi - if test "$PKG" = "vminstall:" ; then - PACKAGES_TO_VMINSTALL=$SRC - continue - fi - if test "$PKG" = "runscripts:" ; then - RUNSCRIPTS_SEEN=true - PACKAGES_TO_RUNSCRIPTS=$SRC - continue - fi - if test "$PKG" = "dist:" ; then - GUESSED_DIST=$SRC - continue - fi - if test "$PKG" = "rpmid:" ; then - echo "${SRC#*:}" > $BUILD_ROOT/.init_b_cache/rpms/${SRC%%:*}.id - continue - fi - ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRC##*.}" - PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG" + if test "$PKG" = "preinstall:" ; then + PACKAGES_TO_PREINSTALL=$SRC + continue + fi + if test "$PKG" = "vminstall:" ; then + PACKAGES_TO_VMINSTALL=$SRC + continue + fi + if test "$PKG" = "runscripts:" ; then + RUNSCRIPTS_SEEN=true + PACKAGES_TO_RUNSCRIPTS=$SRC + continue + fi + if test "$PKG" = "dist:" ; then + GUESSED_DIST=$SRC + continue + fi + if test "$PKG" = "rpmid:" ; then + echo "${SRC#*:}" > $BUILD_ROOT/.init_b_cache/rpms/${SRC%%:*}.id + continue + fi + ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRC##*.}" + PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG" done < $RPMLIST # compatibility... @@ -461,35 +461,35 @@ if test ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rp mkdir -p $BUILD_ROOT/proc || cleanup_and_exit 1 test -f $BUILD_ROOT/etc/HOSTNAME || hostname -f > $BUILD_ROOT/etc/HOSTNAME if test $PSUF = deb ; then - mkdir -p $BUILD_ROOT/var/lib/dpkg - mkdir -p $BUILD_ROOT/var/log - mkdir -p $BUILD_ROOT/etc/default - :> $BUILD_ROOT/var/lib/dpkg/status - :> $BUILD_ROOT/var/lib/dpkg/available - :> $BUILD_ROOT/var/log/dpkg.log - :> $BUILD_ROOT/etc/ld.so.conf - :> $BUILD_ROOT/etc/default/rcS + mkdir -p $BUILD_ROOT/var/lib/dpkg + mkdir -p $BUILD_ROOT/var/log + mkdir -p $BUILD_ROOT/etc/default + :> $BUILD_ROOT/var/lib/dpkg/status + :> $BUILD_ROOT/var/lib/dpkg/available + :> $BUILD_ROOT/var/log/dpkg.log + :> $BUILD_ROOT/etc/ld.so.conf + :> $BUILD_ROOT/etc/default/rcS fi for PKG in $PACKAGES_TO_RUNSCRIPTS ; do - : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run + : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run done for PKG in $PACKAGES_TO_PREINSTALL ; do - preinstall ${PKG##*/} + preinstall ${PKG##*/} done if test -n "$PREPARE_VM" ; then - for PKG in $PACKAGES_TO_VMINSTALL ; do - preinstall ${PKG##*/} - done + for PKG in $PACKAGES_TO_VMINSTALL ; do + preinstall ${PKG##*/} + done fi if [ -w /root ]; then - test -c $BUILD_ROOT/dev/null || create_devs + test -c $BUILD_ROOT/dev/null || create_devs fi test -e $BUILD_ROOT/etc/fstab || touch $BUILD_ROOT/etc/fstab test -e $BUILD_ROOT/etc/ld.so.conf || cp $BUILD_ROOT/etc/ld.so.conf.in $BUILD_ROOT/etc/ld.so.conf if test -z "$PREPARE_VM" ; then - preinstall '' true - init_db - touch $BUILD_ROOT/.init_b_cache/preinstall_finished + preinstall '' true + init_db + touch $BUILD_ROOT/.init_b_cache/preinstall_finished fi fi @@ -497,9 +497,9 @@ if test -n "$PREPARE_VM" ; then mkdir -p $BUILD_ROOT/.build echo "copying packages..." for PKG in $PACKAGES_TO_INSTALL ; do - rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF - cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1 - ln -s -f ../$PKG.$PSUF $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF + rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF + cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1 + ln -s -f ../$PKG.$PSUF $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF done # alreadyinstalled check will not work, but we have to live with # that... @@ -527,11 +527,11 @@ if test -n "$CREATE_BUILD_BINARIES" ; then echo "creating .build.binaries directory..." mkdir -p "$BUILD_ROOT/.build.binaries" for PKG in $PACKAGES_TO_INSTALL ; do - test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue - LPKG=`readlink -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"` - ln "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" 2>/dev/null - test -f "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" && continue - cp "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" + test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue + LPKG=`readlink -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"` + ln "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" 2>/dev/null + test -f "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" && continue + cp "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" done fi @@ -541,9 +541,9 @@ fi mkdir -p $BUILD_ROOT/.init_b_cache/alreadyinstalled if test -f $BUILD_ROOT/var/lib/rpm/packages.rpm -o -f $BUILD_ROOT/var/lib/rpm/Packages ; then chroot $BUILD_ROOT rpm -qa --qf "%{NAME} $RPMIDFMT" | ( - while read pp ii; do - echo "$ii" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$pp" - done + while read pp ii; do + echo "$ii" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$pp" + done ) fi @@ -574,7 +574,7 @@ for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do test "$PKG" = "*" && continue echo deleting `sed -e 's/ .*//' < $BUILD_ROOT/.init_b_cache/todelete/$PKG` chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \ - grep -v -e "^r.*failed: No such file or directory" -e "^error: failed to stat .*: No such file or directory" + grep -v -e "^r.*failed: No such file or directory" -e "^error: failed to stat .*: No such file or directory" done rm -rf $BUILD_ROOT/.init_b_cache/todelete @@ -606,63 +606,63 @@ for PKG in $PACKAGES_TO_INSTALL_FIRST RUN_LDCONFIG $PACKAGES_TO_INSTALL ; do test -f $BUILD_ROOT/installed-pkg/$PKG && continue if test $PSUF = deb ; then - # debian world, install deb files - test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb || continue - if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb" -ef "$BUILD_ROOT/.init_b_cache/$PKG.deb" ; then - rm -f $BUILD_ROOT/.init_b_cache/$PKG.deb - cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb $BUILD_ROOT/.init_b_cache/$PKG.deb || cleanup_and_exit 1 - fi - PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb` - PKGID="${PKGID##*/}" - PKGID="${PKGID%.deb}" - echo "installing ${PKGID%_*}" - ( chroot $BUILD_ROOT dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \ - perl -ne '$|=1;/^(Configuration file|Installing new config file|Selecting previously deselected|\(Reading database|Unpacking |Setting up|Creating config file|Preparing to replace dpkg)/||/^$/||print' - test -e $BUILD_ROOT/exit && cleanup_and_exit 1 - echo "$PKGID debian" > $BUILD_ROOT/installed-pkg/$PKG - continue + # debian world, install deb files + test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb || continue + if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb" -ef "$BUILD_ROOT/.init_b_cache/$PKG.deb" ; then + rm -f $BUILD_ROOT/.init_b_cache/$PKG.deb + cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb $BUILD_ROOT/.init_b_cache/$PKG.deb || cleanup_and_exit 1 + fi + PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb` + PKGID="${PKGID##*/}" + PKGID="${PKGID%.deb}" + echo "installing ${PKGID%_*}" + ( chroot $BUILD_ROOT dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \ + perl -ne '$|=1;/^(Configuration file|Installing new config file|Selecting previously deselected|\(Reading database|Unpacking |Setting up|Creating config file|Preparing to replace dpkg)/||/^$/||print' + test -e $BUILD_ROOT/exit && cleanup_and_exit 1 + echo "$PKGID debian" > $BUILD_ROOT/installed-pkg/$PKG + continue fi test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm || continue if test -f $BUILD_ROOT/.init_b_cache/rpms/$PKG.id -a -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then read PKGID < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id - read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG - if test "$PKGID" = "$OLDPKGID" ; then - #echo "keeping ${PKGID%% *}" - echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG - continue - fi + read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG + if test "$PKGID" = "$OLDPKGID" ; then + #echo "keeping ${PKGID%% *}" + echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG + continue + fi fi PKGID=`rpm -qp --qf "$RPMIDFMT" $RPMCHECKOPTS_HOST $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm` if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then - read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG - if test "$PKGID" != "$OLDPKGID" ; then - echo deleting unwanted ${OLDPKGID%% *} - chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \ - grep -v -e "^r.*failed: No such file or directory" -e "^error: failed to stat .*: No such file or directory" - elif test "$VERIFY_BUILD_SYSTEM" = true ; then - chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE - if grep ^missing $TMPFILE > /dev/null ; then - echo deleting incomplete ${PKGID%% *} - chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \ - grep -v -e "^r.*failed: No such file or directory" -e "^error: failed to stat .*: No such file or directory" - else - #echo "keeping ${PKGID%% *}" - echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG - continue - fi - else - #echo "keeping ${PKGID%% *}" - echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG - continue - fi - if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then - preinstall "$PKG" - test rpm = "$PKG" && chroot $BUILD_ROOT rpm --rebuilddb - fi + read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG + if test "$PKGID" != "$OLDPKGID" ; then + echo deleting unwanted ${OLDPKGID%% *} + chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \ + grep -v -e "^r.*failed: No such file or directory" -e "^error: failed to stat .*: No such file or directory" + elif test "$VERIFY_BUILD_SYSTEM" = true ; then + chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE + if grep ^missing $TMPFILE > /dev/null ; then + echo deleting incomplete ${PKGID%% *} + chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \ + grep -v -e "^r.*failed: No such file or directory" -e "^error: failed to stat .*: No such file or directory" + else + #echo "keeping ${PKGID%% *}" + echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG + continue + fi + else + #echo "keeping ${PKGID%% *}" + echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG + continue + fi + if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then + preinstall "$PKG" + test rpm = "$PKG" && chroot $BUILD_ROOT rpm --rebuilddb + fi fi export ADDITIONAL_PARAMS= if test "$USE_FORCE" = true ; then @@ -670,13 +670,13 @@ for PKG in $PACKAGES_TO_INSTALL_FIRST RUN_LDCONFIG $PACKAGES_TO_INSTALL ; do fi echo "installing ${PKGID%% *}" if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" -ef "$BUILD_ROOT/.init_b_cache/$PKG.rpm" ; then - rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm - cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm $BUILD_ROOT/.init_b_cache/$PKG.rpm || cleanup_and_exit 1 + rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm + cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm $BUILD_ROOT/.init_b_cache/$PKG.rpm || cleanup_and_exit 1 fi ( chroot $BUILD_ROOT rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \ - $ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \ - touch $BUILD_ROOT/exit ) | \ - grep -v "^warning:.*saved as.*rpmorig$" + $ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \ + touch $BUILD_ROOT/exit ) | \ + grep -v "^warning:.*saved as.*rpmorig$" # delete link so package is only installed once rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm test -e $BUILD_ROOT/exit && cleanup_and_exit 1 @@ -800,9 +800,9 @@ mkdir -p $BUILD_ROOT/var/adm/packages touch $BUILD_ROOT/var/adm/packages if test -x $BUILD_ROOT/sbin/SuSEconfig ; then if grep norestarts $BUILD_ROOT/sbin/SuSEconfig > /dev/null ; then - chroot $BUILD_ROOT /sbin/SuSEconfig --norestarts --force + chroot $BUILD_ROOT /sbin/SuSEconfig --norestarts --force else - chroot $BUILD_ROOT /sbin/SuSEconfig --force + chroot $BUILD_ROOT /sbin/SuSEconfig --force fi fi diff --git a/initscript_qemu_vm b/initscript_qemu_vm index 857c767..01d5227 100755 --- a/initscript_qemu_vm +++ b/initscript_qemu_vm @@ -12,4 +12,3 @@ echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\ echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register exec /.build/build - diff --git a/mkbaselibs b/mkbaselibs index 3dac3bb..30f6010 100755 --- a/mkbaselibs +++ b/mkbaselibs @@ -245,37 +245,37 @@ sub rpmq_many { if ($stags{$tag}) { eval { my $otag = $stags{$tag}; - if ($type == 0) { - $res{$otag} = [ '' ]; - } elsif ($type == 1) { - $res{$otag} = [ unpack("\@${offset}c$count", $data) ]; - } elsif ($type == 2) { - $res{$otag} = [ unpack("\@${offset}c$count", $data) ]; - } elsif ($type == 3) { - $res{$otag} = [ unpack("\@${offset}n$count", $data) ]; - } elsif ($type == 4) { - $res{$otag} = [ unpack("\@${offset}N$count", $data) ]; - } elsif ($type == 5) { - $res{$otag} = [ undef ]; - } elsif ($type == 6) { - $res{$otag} = [ unpack("\@${offset}Z*", $data) ]; - } elsif ($type == 7) { - $res{$otag} = [ unpack("\@${offset}a$count", $data) ]; - } elsif ($type == 8 || $type == 9) { - my $d = unpack("\@${offset}a*", $data); - my @res = split("\0", $d, $count + 1); - $res{$otag} = [ splice @res, 0, $count ]; - } else { - $res{$otag} = [ undef ]; - } + if ($type == 0) { + $res{$otag} = [ '' ]; + } elsif ($type == 1) { + $res{$otag} = [ unpack("\@${offset}c$count", $data) ]; + } elsif ($type == 2) { + $res{$otag} = [ unpack("\@${offset}c$count", $data) ]; + } elsif ($type == 3) { + $res{$otag} = [ unpack("\@${offset}n$count", $data) ]; + } elsif ($type == 4) { + $res{$otag} = [ unpack("\@${offset}N$count", $data) ]; + } elsif ($type == 5) { + $res{$otag} = [ undef ]; + } elsif ($type == 6) { + $res{$otag} = [ unpack("\@${offset}Z*", $data) ]; + } elsif ($type == 7) { + $res{$otag} = [ unpack("\@${offset}a$count", $data) ]; + } elsif ($type == 8 || $type == 9) { + my $d = unpack("\@${offset}a*", $data); + my @res = split("\0", $d, $count + 1); + $res{$otag} = [ splice @res, 0, $count ]; + } else { + $res{$otag} = [ undef ]; + } }; if ($@) { - warn("Bad rpm $rpm: $@\n"); + warn("Bad rpm $rpm: $@\n"); return (); } } } - + if ($need_filenames) { if ($res{'OLDFILENAMES'}) { $res{'FILENAMES'} = [ @{$res{'OLDFILENAMES'}} ]; @@ -311,7 +311,7 @@ sub rpmq_add_flagsvers { my @preamble = qw{ Name Version Release Epoch Summary Copyright License Distribution - Disturl Vendor Group Packager Url Icon Prefixes + Disturl Vendor Group Packager Url Icon Prefixes }; my $rpm; @@ -349,7 +349,7 @@ my $verbose; my %target_matched; my @filesystem; -# Used for each package by +# Used for each package by sub parse_config { my $target = shift; my $pkgname = shift; @@ -551,40 +551,40 @@ sub handle_rpms { for my $r (@baselib) { my $rr = substr($r, 1); if (substr($r, 0, 1) eq '+') { - if ($rr =~ /^(.*?)\s*->\s*(.*?)$/) { - if (grep {$_ eq $1} @rpmfiles) { - $files{$1} = 1; - $moves{$1} = $2; - } - } else { - for (grep {/$rr/} @rpmfiles) { - $files{$_} = 1; - delete $moves{$_}; - } - } + if ($rr =~ /^(.*?)\s*->\s*(.*?)$/) { + if (grep {$_ eq $1} @rpmfiles) { + $files{$1} = 1; + $moves{$1} = $2; + } + } else { + for (grep {/$rr/} @rpmfiles) { + $files{$_} = 1; + delete $moves{$_}; + } + } } elsif (substr($r, 0, 1) eq '-') { - delete $files{$_} for grep {/$rr/} keys %files; + delete $files{$_} for grep {/$rr/} keys %files; } elsif (substr($r, 0, 1) eq '"') { $rr =~ s/\"$//; - if ($rr =~ /^(.*?)\s*->\s*(.*?)$/) { - $symlinks{$1} = $2; - } else { - die("bad baselib string rule: $r\n"); - } + if ($rr =~ /^(.*?)\s*->\s*(.*?)$/) { + $symlinks{$1} = $2; + } else { + die("bad baselib string rule: $r\n"); + } } else { - die("bad baselib rule: $r\n"); + die("bad baselib rule: $r\n"); } } if ($configdir) { for my $r (@config) { - my $rr = substr($r, 1); - if (substr($r, 0, 1) eq '+') { - $cfiles{$_} = 1 for grep {/$rr/} grep {!$ghosts{$_}} @rpmfiles; - } elsif (substr($r, 0, 1) eq '-') { - delete $cfiles{$_} for grep {/$rr/} keys %cfiles; - } else { - die("bad config rule: $r\n"); - } + my $rr = substr($r, 1); + if (substr($r, 0, 1) eq '+') { + $cfiles{$_} = 1 for grep {/$rr/} grep {!$ghosts{$_}} @rpmfiles; + } elsif (substr($r, 0, 1) eq '-') { + delete $cfiles{$_} for grep {/$rr/} keys %cfiles; + } else { + die("bad config rule: $r\n"); + } } } $files{$_} = 1 for keys %cfiles; @@ -613,7 +613,7 @@ sub handle_rpms { next if $cfiles{$_}; my $fn = $_; if ($moves{$fn}) { - $fn = $moves{$fn}; + $fn = $moves{$fn}; next unless $fn =~ s/\/[^\/]+$//; $alldirs{$fn} = 1; } else { @@ -651,20 +651,20 @@ sub handle_rpms { my $d = $res{$pt}->[0]; $d =~ s/%/%%/g; if ($p eq 'Name') { - print SPEC "Name: $sname\n"; - next; + print SPEC "Name: $sname\n"; + next; } if ($p eq 'Version') { - print SPEC "Version: $sversion\n"; - next; + print SPEC "Version: $sversion\n"; + next; } if ($p eq 'Release') { - print SPEC "Release: $srelease\n"; - next; + print SPEC "Release: $srelease\n"; + next; } if ($p eq 'Disturl') { - print SPEC "%define disturl $d\n"; - next; + print SPEC "%define disturl $d\n"; + next; } print SPEC "$p: $d\n"; } @@ -682,12 +682,12 @@ sub handle_rpms { my $d = $res{$pt}->[0]; $d =~ s/%/%%/g; if ($pt eq 'VERSION' && $legacyversion) { - $d = $legacyversion; + $d = $legacyversion; } elsif ($pt eq 'RELEASE' && $legacyversion) { - my @bt = localtime($res{'BUILDTIME'}->[0]); - $bt[5] += 1900; - $bt[4] += 1; - $d = sprintf("%04d%02d%02d%02d%02d\n", @bt[5,4,3,2,1]); + my @bt = localtime($res{'BUILDTIME'}->[0]); + $bt[5] += 1900; + $bt[4] += 1; + $d = sprintf("%04d%02d%02d%02d%02d\n", @bt[5,4,3,2,1]); } print SPEC "$p: $d\n"; } @@ -700,19 +700,19 @@ sub handle_rpms { [\@supplements, 'supplements'], [\@obsoletes, 'obsoletes'], [\@conflicts, 'conflicts']) { - my @a = @{$ar->[0]}; + my @a = @{$ar->[0]}; my @na = (); for (@a) { - if (substr($_, 0, 1) eq '"') { - die("bad $ar->[1] rule: $_\n") unless /^\"(.*)\"$/; - push @na, $1; - } elsif (substr($_, 0, 1) eq '-') { - my $ra = substr($_, 1); - @na = grep {!/$ra/} @na; - } else { - die("bad $ar->[1] rule: $_\n"); - } - } + if (substr($_, 0, 1) eq '"') { + die("bad $ar->[1] rule: $_\n") unless /^\"(.*)\"$/; + push @na, $1; + } elsif (substr($_, 0, 1) eq '-') { + my $ra = substr($_, 1); + @na = grep {!/$ra/} @na; + } else { + die("bad $ar->[1] rule: $_\n"); + } + } print SPEC ucfirst($ar->[1]).": $_\n" for @na; } my $cpiopre = ''; @@ -733,8 +733,8 @@ sub handle_rpms { my @cfl = grep {!$cfiles{$_} && !$moves{$_}} sort keys %files; if (@cfl) { if ($prefix ne '') { - print SPEC "mkdir -p \$RPM_BUILD_ROOT$prefix\n"; - print SPEC "pushd \$RPM_BUILD_ROOT$prefix\n"; + print SPEC "mkdir -p \$RPM_BUILD_ROOT$prefix\n"; + print SPEC "pushd \$RPM_BUILD_ROOT$prefix\n"; } print SPEC "cat <.filelist\n"; print SPEC "$_\n" for map {$cpiopre.substr($_, 1)} @cfl; @@ -743,15 +743,15 @@ sub handle_rpms { print SPEC "rpm2cpio $rpm | cpio -i -d -v -E .filelist\n"; print SPEC "rm .filelist\n"; if (%ghosts) { - for my $fn (grep {$ghosts{$_}} @cfl) { + for my $fn (grep {$ghosts{$_}} @cfl) { my $fnm = $fn; - $fnm = '.' unless $fnm =~ s/\/[^\/]+$//; - print SPEC "mkdir -p \$RPM_BUILD_ROOT$prefix$fnm\n"; - print SPEC "touch \$RPM_BUILD_ROOT$prefix$fn\n"; - } + $fnm = '.' unless $fnm =~ s/\/[^\/]+$//; + print SPEC "mkdir -p \$RPM_BUILD_ROOT$prefix$fnm\n"; + print SPEC "touch \$RPM_BUILD_ROOT$prefix$fn\n"; + } } if ($prefix ne '') { - print SPEC "popd\n"; + print SPEC "popd\n"; } } if (%cfiles || %moves) { @@ -767,10 +767,10 @@ sub handle_rpms { print SPEC "mv .cfiles$_ \$RPM_BUILD_ROOT$configdir\n" for sort keys %cfiles; } for my $fn (sort keys %moves) { - my $fnm = $moves{$fn}; - $fnm = '.' unless $fnm =~ s/\/[^\/]+$//; - print SPEC "mkdir -p \$RPM_BUILD_ROOT$fnm\n"; - print SPEC "mv .cfiles$fn \$RPM_BUILD_ROOT$moves{$fn}\n"; + my $fnm = $moves{$fn}; + $fnm = '.' unless $fnm =~ s/\/[^\/]+$//; + print SPEC "mkdir -p \$RPM_BUILD_ROOT$fnm\n"; + print SPEC "mv .cfiles$fn \$RPM_BUILD_ROOT$moves{$fn}\n"; } print SPEC "rm -rf .cfiles\n"; } @@ -830,53 +830,53 @@ sub handle_rpms { my $fv = $res{'FILEVERIFYFLAGS'}->[$fi]; my $ff = $res{'FILEFLAGS'}->[$fi]; if (POSIX::S_ISDIR($fm)) { - print SPEC "%dir "; + print SPEC "%dir "; } if ($ff & ((1 << 3) | (1 << 4))) { - print SPEC "%config(missingok noreplace) "; + print SPEC "%config(missingok noreplace) "; } elsif ($ff & (1 << 3)) { - print SPEC "%config(missingok) "; + print SPEC "%config(missingok) "; } elsif ($ff & (1 << 4)) { - print SPEC "%config(noreplace) "; + print SPEC "%config(noreplace) "; } elsif ($ff & (1 << 0)) { - print SPEC "%config "; + print SPEC "%config "; } print SPEC "%doc " if $ff & (1 << 1); print SPEC "%ghost " if $ff & (1 << 6); print SPEC "%license " if $ff & (1 << 7); print SPEC "%readme " if $ff & (1 << 8); if ($fv != 4294967295) { - print SPEC "%verify("; - if ($fv & 2147483648) { - print SPEC "not "; - $fv ^= 4294967295; - } - print SPEC "md5 " if $fv & (1 << 0); - print SPEC "size " if $fv & (1 << 1); - print SPEC "link " if $fv & (1 << 2); - print SPEC "user " if $fv & (1 << 3); - print SPEC "group " if $fv & (1 << 4); - print SPEC "mtime " if $fv & (1 << 5); - print SPEC "mode " if $fv & (1 << 6); - print SPEC "rdev " if $fv & (1 << 7); - print SPEC ") "; + print SPEC "%verify("; + if ($fv & 2147483648) { + print SPEC "not "; + $fv ^= 4294967295; + } + print SPEC "md5 " if $fv & (1 << 0); + print SPEC "size " if $fv & (1 << 1); + print SPEC "link " if $fv & (1 << 2); + print SPEC "user " if $fv & (1 << 3); + print SPEC "group " if $fv & (1 << 4); + print SPEC "mtime " if $fv & (1 << 5); + print SPEC "mode " if $fv & (1 << 6); + print SPEC "rdev " if $fv & (1 << 7); + print SPEC ") "; } #sigh, no POSIX::S_ISLNK ... if (($fm & 0170000) == 0120000) { - printf SPEC "%%attr(-,%s,%s) ", $res{'FILEUSERNAME'}->[$fi], $res{'FILEGROUPNAME'}->[$fi]; + printf SPEC "%%attr(-,%s,%s) ", $res{'FILEUSERNAME'}->[$fi], $res{'FILEGROUPNAME'}->[$fi]; } else { - printf SPEC "%%attr(%03o,%s,%s) ", $fm & 07777, $res{'FILEUSERNAME'}->[$fi], $res{'FILEGROUPNAME'}->[$fi]; + printf SPEC "%%attr(%03o,%s,%s) ", $fm & 07777, $res{'FILEUSERNAME'}->[$fi], $res{'FILEGROUPNAME'}->[$fi]; } if ($cfiles{$file}) { - my $fn = $file; - $fn =~ s/.*\///; - print SPEC "$configdir/$fn\n"; + my $fn = $file; + $fn =~ s/.*\///; + print SPEC "$configdir/$fn\n"; } else { - if ($moves{$file}) { - print SPEC "$moves{$file}\n"; - } else { - print SPEC "$prefix$file\n"; - } + if ($moves{$file}) { + print SPEC "$moves{$file}\n"; + } else { + print SPEC "$prefix$file\n"; + } } } for (keys %symlinks) { @@ -915,8 +915,6 @@ sub handle_rpms { } ################################################################ -################################################################ -################################################################ sub handle_debs { @@ -926,8 +924,8 @@ sub handle_debs { if ($@){ print "mkbaselibs needs the perl module Parse::DebControl\n". "Error. baselibs-deb.conf specified but mkbaselibs can't run\n". - "Please ensure that 'osc meta prjconf' contains the following line:\n". - " Support: libparse-debcontrol-perl\n"; + "Please ensure that 'osc meta prjconf' contains the following line:\n". + " Support: libparse-debcontrol-perl\n"; return; }; @@ -1033,43 +1031,42 @@ sub handle_debs { # Tidy up the various control files. # the md5sums are regenerated by dpkg-deb when building foreach my $c_file qw(conffiles postinst postrm preinst prerm) { - unlink "${baseTarget}/DEBIAN/$c_file"; + unlink "${baseTarget}/DEBIAN/$c_file"; } # Create them if needed if (@prein) { - map s/^"(.*)"$/$1/, @prein; # remove leading/trailing "s - open(my $SCRIPT, ">${baseTarget}/DEBIAN/preinst"); - print $SCRIPT join("\n", @prein) ; - chmod(0755, $SCRIPT); - close($SCRIPT); + map s/^"(.*)"$/$1/, @prein; # remove leading/trailing "s + open(my $SCRIPT, ">${baseTarget}/DEBIAN/preinst"); + print $SCRIPT join("\n", @prein) ; + chmod(0755, $SCRIPT); + close($SCRIPT); } if (@postin) { - map s/^"(.*)"$/$1/, @postin; - open(my $SCRIPT, ">${baseTarget}/DEBIAN/postinst"); - print $SCRIPT join("\n", @postin) ; - chmod(0755, $SCRIPT); - close($SCRIPT); + map s/^"(.*)"$/$1/, @postin; + open(my $SCRIPT, ">${baseTarget}/DEBIAN/postinst"); + print $SCRIPT join("\n", @postin) ; + chmod(0755, $SCRIPT); + close($SCRIPT); } if (@preun) { - map s/^"(.*)"$/$1/, @preun; - open(my $SCRIPT, ">${baseTarget}/DEBIAN/prerm"); - print $SCRIPT join("\n", @preun) ; - chmod(0755, $SCRIPT); - close($SCRIPT); + map s/^"(.*)"$/$1/, @preun; + open(my $SCRIPT, ">${baseTarget}/DEBIAN/prerm"); + print $SCRIPT join("\n", @preun) ; + chmod(0755, $SCRIPT); + close($SCRIPT); } if (@postun) { - map s/^"(.*)"$/$1/, @postun; - open(my $SCRIPT, ">${baseTarget}/DEBIAN/postrm"); - print $SCRIPT join("\n", @postun) ; - chmod(0755, $SCRIPT); - close($SCRIPT); + map s/^"(.*)"$/$1/, @postun; + open(my $SCRIPT, ">${baseTarget}/DEBIAN/postrm"); + print $SCRIPT join("\n", @postun) ; + chmod(0755, $SCRIPT); + close($SCRIPT); } # Don't forget to rename the package - or it will replace/uninstall the /-based one $control{"Package"} = "${d_name}-${targettype}"; - $controlParser->write_file("${baseTarget}/DEBIAN/control", \%control, - {clobberFile => 1, addNewline=>1 } ); + $controlParser->write_file("${baseTarget}/DEBIAN/control", \%control, {clobberFile => 1, addNewline=>1 } ); system "dpkg -b ${baseTarget} /usr/src/packages/DEBS/${d_name}-${targettype}_${d_version}_${targetarch}.deb" || die "dpkg -b failed on $deb"; system "rm -rf ${baseTarget}"; } @@ -1136,4 +1133,3 @@ if (@rpms) { if (@debs) { handle_debs(@debs); } - diff --git a/spectool b/spectool index 0d9136c..8c24086 100755 --- a/spectool +++ b/spectool @@ -251,18 +251,18 @@ for my $spec (@specs) { if($tag =~ /^\/(.+)\/$/) { my $expr = $1; for my $t (keys %$parsed) { - if ($t =~ $expr) { - push @opt_showtag, $t; - } + if ($t =~ $expr) { + push @opt_showtag, $t; + } } } else { if(exists $parsed->{lc $tag}) { - print $tag, ": "; - my $v = $parsed->{lc $tag}; - $v = join(' ', @$v) if (ref $v eq 'ARRAY'); - print $v, "\n"; + print $tag, ": "; + my $v = $parsed->{lc $tag}; + $v = join(' ', @$v) if (ref $v eq 'ARRAY'); + print $v, "\n"; } else { - print STDERR "$tag does not exist\n"; + print STDERR "$tag does not exist\n"; } } } @@ -272,83 +272,81 @@ for my $spec (@specs) { my $srcfile = read_sources_digests($files, $spec); if ($opt_download) { for my $t (keys %$parsed) { - next unless ($t =~ /^(?:source|patch)\d*/); - my $url = $parsed->{$t}; - next unless $url =~ /^(?:http|ftp):\/\//; - my $file = $url; - $file =~ s/.*\///; - next if -e $file; - print "Downloading $file...\n"; - if(system('curl', '-f', '-L', '-#', '-o', $file, $url) != 0) { - # let's see if the file was recompressed - if($url =~ s/\.bz2$/.gz/ && $file =~ s/\.bz2$/.gz/ - && system('curl', '-f', '-L', '-#', '-o', $file, $url) == 0) { - if(system('bznew', $file) == 0) { - print STDERR "Used $file and recompressed to bz2 instead\n"; - } else { - unlink $file; - } - } else { - print STDERR "Downloading $file failed\n"; - } - } + next unless ($t =~ /^(?:source|patch)\d*/); + my $url = $parsed->{$t}; + next unless $url =~ /^(?:http|ftp):\/\//; + my $file = $url; + $file =~ s/.*\///; + next if -e $file; + print "Downloading $file...\n"; + if(system('curl', '-f', '-L', '-#', '-o', $file, $url) != 0) { + # let's see if the file was recompressed + if($url =~ s/\.bz2$/.gz/ && $file =~ s/\.bz2$/.gz/ + && system('curl', '-f', '-L', '-#', '-o', $file, $url) == 0) { + if(system('bznew', $file) == 0) { + print STDERR "Used $file and recompressed to bz2 instead\n"; + } else { + unlink $file; + } + } else { + print STDERR "Downloading $file failed\n"; + } + } } } if ($opt_update) { my $changed; for my $t (keys %$parsed) { - next unless ($t =~ /^(?:source|patch)\d*/); - my $file = $parsed->{$t}; - $file =~ s/.*\///; - next unless -B $file; - my $sum = check_sum($file, ($files->{$file} || ($srcfile eq 'sources'?'md5:':'sha1:'))); - if($sum) { - print STDERR "update $file\n"; - $files->{$file} = $sum; - $changed = 1; - } + next unless ($t =~ /^(?:source|patch)\d*/); + my $file = $parsed->{$t}; + $file =~ s/.*\///; + next unless -B $file; + my $sum = check_sum($file, ($files->{$file} || ($srcfile eq 'sources'?'md5:':'sha1:'))); + if($sum) { + print STDERR "update $file\n"; + $files->{$file} = $sum; + $changed = 1; + } } if($changed) { - if(open(F, '>', $srcfile)) { - for my $file (keys %$files) { - $files->{$file} =~ s/^md5:// if $srcfile eq 'sources'; - print F $files->{$file}, ' ', $file, "\n"; - } - close F; - } + if(open(F, '>', $srcfile)) { + for my $file (keys %$files) { + $files->{$file} =~ s/^md5:// if $srcfile eq 'sources'; + print F $files->{$file}, ' ', $file, "\n"; + } + close F; + } } } else { for my $t (keys %$parsed) { - next unless ($t =~ /^(?:source|patch)\d*/); - my $file = $parsed->{$t}; - $file =~ s/.*\///; - if (!exists $files->{$file}) { - if (! -e $file) { - print '- '; - } elsif (-B $file) { - print '_ '; - } else { - print 't '; - } - } elsif (! -e $file) { - print 'd '; - delete $files->{$file}; - } else { - my $sum = check_sum($file, $files->{$file}); - if($sum) { - print '! '; - } else { - print '. '; - } - delete $files->{$file}; - } - print $parsed->{$t}, "\n"; + next unless ($t =~ /^(?:source|patch)\d*/); + my $file = $parsed->{$t}; + $file =~ s/.*\///; + if (!exists $files->{$file}) { + if (! -e $file) { + print '- '; + } elsif (-B $file) { + print '_ '; + } else { + print 't '; + } + } elsif (! -e $file) { + print 'd '; + delete $files->{$file}; + } else { + my $sum = check_sum($file, $files->{$file}); + if($sum) { + print '! '; + } else { + print '. '; + } + delete $files->{$file}; + } + print $parsed->{$t}, "\n"; } for my $file (keys %$files) { - print "? $file\n"; + print "? $file\n"; } } } } - -# vim: sw=2 diff --git a/substitutedeps b/substitutedeps index 97ba712..e81654b 100755 --- a/substitutedeps +++ b/substitutedeps @@ -8,7 +8,6 @@ use strict; use Build; - sub expand { my ($config, $str) = @_; my @xspec; @@ -118,19 +117,19 @@ for my $l (@$xspec) { my $oldl = $l; if (defined $release) { if (!($l =~ s//$release/g)) { - if ($l =~ /<(?:CI_CNT|B_CNT)>/) { - # XXX: should pass ci_cnt/b_cnt instead - if ($release =~ /(\d+)\.(\d+)$/) { - my ($ci, $b) = ($1, $2); - $l =~ s//$ci/; - $l =~ s//$b/; - } elsif ($release =~ /(\d+)$/) { - my $b = $1; - $l =~ s//$b/ unless $l =~ s//$b/; - } - } else { - $l =~ s/^(Release:\s*).*/$1$release/i; - } + if ($l =~ /<(?:CI_CNT|B_CNT)>/) { + # XXX: should pass ci_cnt/b_cnt instead + if ($release =~ /(\d+)\.(\d+)$/) { + my ($ci, $b) = ($1, $2); + $l =~ s//$ci/; + $l =~ s//$b/; + } elsif ($release =~ /(\d+)$/) { + my $b = $1; + $l =~ s//$b/ unless $l =~ s//$b/; + } + } else { + $l =~ s/^(Release:\s*).*/$1$release/i; + } } } # this is to be compatible to legacy autobuild. @@ -148,56 +147,56 @@ for my $l (@$xspec) { my @nl; my $interpreter = "/bin/bash"; if (open(RP, '<', "$specdir$cf->{'releaseprg'}")) { - @nl = ; + @nl = ; close RP; - if (@nl && $nl[0] =~ /^#!\s*(\S*)/) { - $interpreter = $1; - } + if (@nl && $nl[0] =~ /^#!\s*(\S*)/) { + $interpreter = $1; + } } if ($buildroot) { - my $sd = $specdir; - $sd =~ s/^\Q$buildroot\E//; + my $sd = $specdir; + $sd =~ s/^\Q$buildroot\E//; open(RP, "-|", 'chroot', $buildroot, $interpreter, "$sd$cf->{'releaseprg'}", $project, $newl, $pkg, $arch) || die("$cf->{'releaseprg'}: $!\n"); } else { open(RP, "-|", $interpreter, "$specdir$cf->{'releaseprg'}", $project, $newl, $pkg, $arch) || die("$cf->{'releaseprg'}: $!\n"); } @nl = grep {$_ ne ''} ; if (!close(RP)) { - warn("$cf->{'releaseprg'} failed: $?\n"); + warn("$cf->{'releaseprg'} failed: $?\n"); } # and another compatibility hack: if the prg returns pkg:, # the release of the package will be used. yuck... if (@nl && $nl[0] =~ s/^pkg://) { - my $relpkg = $nl[0]; - chomp $relpkg; - if ($buildroot) { - open(RP, "-|", 'chroot', $buildroot, 'rpm', '-q', '--qf', '%{RELEASE}', $relpkg) || die("rpm: $!\n"); - } else { - open(RP, "-|", 'rpm', '-q', '--qf', '%{RELEASE}', $relpkg) || die("rpm: $!\n"); - } + my $relpkg = $nl[0]; + chomp $relpkg; + if ($buildroot) { + open(RP, "-|", 'chroot', $buildroot, 'rpm', '-q', '--qf', '%{RELEASE}', $relpkg) || die("rpm: $!\n"); + } else { + open(RP, "-|", 'rpm', '-q', '--qf', '%{RELEASE}', $relpkg) || die("rpm: $!\n"); + } @nl = grep {$_ ne ''} ; if (!close(RP)) { - warn("rpm package query of '$relpkg' failed: $?\n"); + warn("rpm package query of '$relpkg' failed: $?\n"); } } if ($nl[0]) { - chomp $nl[0]; - $l =~ s/^(Release:\s*).*/$1$nl[0]/i; + chomp $nl[0]; + $l =~ s/^(Release:\s*).*/$1$nl[0]/i; if (defined $release) { - if (!($l =~ s//$release/g)) { - if ($l =~ /<(?:CI_CNT|B_CNT)>/) { - # XXX: should pass ci_cnt/b_cnt instead - if ($release =~ /(\d+)\.(\d+)$/) { - my ($ci, $b) = ($1, $2); - $l =~ s//$ci/; - $l =~ s//$b/; - } elsif ($release =~ /(\d+)$/) { - my $b = $1; - $l =~ s//$b/ unless $l =~ s//$b/; - } - } - } - } + if (!($l =~ s//$release/g)) { + if ($l =~ /<(?:CI_CNT|B_CNT)>/) { + # XXX: should pass ci_cnt/b_cnt instead + if ($release =~ /(\d+)\.(\d+)$/) { + my ($ci, $b) = ($1, $2); + $l =~ s//$ci/; + $l =~ s//$b/; + } elsif ($release =~ /(\d+)$/) { + my $b = $1; + $l =~ s//$b/ unless $l =~ s//$b/; + } + } + } + } } } # all compat stuff done. we return to your scheduled program diff --git a/test/common b/test/common index 35968fb..cd41825 100644 --- a/test/common +++ b/test/common @@ -5,16 +5,16 @@ # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # version 2 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; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# set -e . ${0%/*}/config @@ -65,7 +65,7 @@ linux32= arch32bit() { local hostarch=`uname -m` - case "$hostarch" in + case "$hostarch" in x86_64) linux32=linux32 ;; *) skip ;; esac diff --git a/unrpm b/unrpm index 6b51b56..43cf73f 100755 --- a/unrpm +++ b/unrpm @@ -1,5 +1,4 @@ -#! /bin/bash -# +#!/bin/bash function Usage () { echo "Usage: $(basename $0) [-vq] rpm-files..."; @@ -27,7 +26,6 @@ for i in $* ; do esac done - test "$VERBOSE" = "true" && CPIO_OPTS="$CPIO_OPTS --verbose" test "$QUIET" = "true" && CPIO_OPTS="$CPIO_OPTS --quiet" diff --git a/vc b/vc index 8c4c823..7209d75 100755 --- a/vc +++ b/vc @@ -120,9 +120,9 @@ set +e { if [ ! $just_edit ]; then - echo "-------------------------------------------------------------------" - echo "$date - $mailaddr" - echo + echo "-------------------------------------------------------------------" + echo "$date - $mailaddr" + echo fi if [ -n "$message" ]; then echo "- $message" diff --git a/xen.conf b/xen.conf index 62f3dd1..d40ac93 100644 --- a/xen.conf +++ b/xen.conf @@ -2,7 +2,7 @@ #============================================================================ # Python configuration setup for 'xm create'. # This script sets the parameters used when a domain is created using 'xm create'. -# You use a separate script for each domain you want to create, or +# You use a separate script for each domain you want to create, or # you can set the parameters for the domain on the xm command line. #============================================================================ @@ -32,4 +32,3 @@ extra = "init=/bin/bash console=ttyS0 panic=1 udev_timeout=360" on_poweroff = 'destroy' on_reboot = 'destroy' on_crash = 'destroy' - -- 2.7.4