From c4737b6bc7f5e0893609bd0fbcb7d1af6d3a4d6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20Schr=C3=B6der?= Date: Wed, 20 Jun 2007 17:14:26 +0000 Subject: [PATCH] - make debtransfrom configurable via the dsc file - print error and abort if debtransform fails - add new setdeps function to Build.pm - support macros in config files - remove cp call from init_buildsystem (cp may depend on libacl) --- Build.pm | 67 +++++++++++++++++++++++++++++++++++--------------------- Build/Rpm.pm | 14 +++++++++++- build | 5 ++++- debtransform | 41 ++++++++++++++++++++++++---------- init_buildsystem | 7 +++++- 5 files changed, 95 insertions(+), 39 deletions(-) diff --git a/Build.pm b/Build.pm index 26be125..8237880 100644 --- a/Build.pm +++ b/Build.pm @@ -35,6 +35,36 @@ sub unify { return grep(delete($h{$_}), @_); } +sub init_helper_hashes { + my ($config) = @_; + + $config->{'preferh'} = { map {$_ => 1} @{$config->{'prefer'}} }; + + my %ignore; + for (@{$config->{'ignore'}}) { + if (!/:/) { + $ignore{$_} = 1; + next; + } + my @s = split(/[,:]/, $_); + my $s = shift @s; + $ignore{"$s:$_"} = 1 for @s; + } + $config->{'ignoreh'} = \%ignore; + + my %conflicts; + for (@{$config->{'conflict'}}) { + my @s = split(/[,:]/, $_); + my $s = shift @s; + push @{$conflicts{$s}}, @s; + push @{$conflicts{$_}}, $s for @s; + } + for (keys %conflicts) { + $conflicts{$_} = [ unify(@{$conflicts{$_}}) ] + } + $config->{'conflicth'} = \%conflicts; +} + sub read_config_dist { my ($dist, $archpath, $configdir) = @_; @@ -85,7 +115,9 @@ sub read_config { } } my @spec; + $config->{'save_expanded'} = 1; Build::Rpm::parse($config, \@newconfig, \@spec); + delete $config->{'save_expanded'}; $config->{'preinstall'} = []; $config->{'vminstall'} = []; $config->{'runscripts'} = []; @@ -148,29 +180,7 @@ sub read_config { $config->{'substitute'}->{$l} = [ unify(@{$config->{'substitute'}->{$l}}) ]; s/=$// for @{$config->{'substitute'}->{$l}}; } - $config->{'preferh'} = { map {$_ => 1} @{$config->{'prefer'}} }; - my %ignore; - for (@{$config->{'ignore'}}) { - if (!/:/) { - $ignore{$_} = 1; - next; - } - my @s = split(/[,:]/, $_); - my $s = shift @s; - $ignore{"$s:$_"} = 1 for @s; - } - $config->{'ignoreh'} = \%ignore; - my %conflicts; - for (@{$config->{'conflict'}}) { - my @s = split(/[,:]/, $_); - my $s = shift @s; - push @{$conflicts{$s}}, @s; - push @{$conflicts{$_}}, $s for @s; - } - for (keys %conflicts) { - $conflicts{$_} = [ unify(@{$conflicts{$_}}) ] - } - $config->{'conflicth'} = \%conflicts; + init_helper_hashes($config); $config->{'type'} = (grep {$_ eq 'rpm'} @{$config->{'preinstall'} || []}) ? 'spec' : 'dsc'; # add rawmacros to our macro list if ($config->{'rawmacros'} ne '') { @@ -347,8 +357,15 @@ sub readdeps { $config->{'requiresh'} = \%requires; } +sub setdeps { + my ($config, $provides, $whatprovides, $requires) = @_; + $config->{'providesh'} = $provides; + $config->{'whatprovidesh'} = $whatprovides; + $config->{'requiresh'} = $requires; +} + sub forgetdeps { - my $config; + my ($config) = @_; delete $config->{'providesh'}; delete $config->{'whatprovidesh'}; delete $config->{'requiresh'}; @@ -604,7 +621,7 @@ sub order { } unshift @todo, $cycv; print STDERR "cycle: ".join(' -> ', @cyc)."\n"; - my $breakv = (sort {$needed{$a} <=> $needed{$b} || $a cmp $b} @cyc)[0]; + my $breakv = (sort {$needed{$a} <=> $needed{$b} || $a cmp $b} @cyc)[-1]; push @cyc, $cyc[0]; shift @cyc while $cyc[0] ne $breakv; $v = $cyc[1]; diff --git a/Build/Rpm.pm b/Build/Rpm.pm index fdec4ec..ee53bbe 100644 --- a/Build/Rpm.pm +++ b/Build/Rpm.pm @@ -114,6 +114,7 @@ sub parse { my @packdeps; my @prereqs; my $hasnfb; + my $nfbline; my %macros; my $ret = {}; my $ifdeps; @@ -157,8 +158,12 @@ sub parse { } push @$xspec, $line if $inspec && $xspec; if ($line =~ /^#\s*neededforbuild\s*(\S.*)$/) { - next if defined $hasnfb; + if (defined $hasnfb) { + $xspec->[-1] = [ $xspec->[-1], undef ] if $inspec && $xspec; + next; + } $hasnfb = $1; + $nfbline = \$xspec->[-1] if $inspec && $xspec; next; } if ($line =~ /^\s*#/) { @@ -389,11 +394,18 @@ sub parse { if ($line =~ /^\s*%(package|prep|build|install|check|clean|preun|postun|pretrans|posttrans|pre|post|files|changelog|description|triggerpostun|triggerun|triggerin|trigger|verifyscript)/) { $main_preamble = 0; } + + # do this always? + if ($xspec && @$xspec && $config->{'save_expanded'}) { + $xspec->[-1] = [ $xspec->[-1], $line ]; + } } close SPEC unless ref $specfile; if (defined($hasnfb)) { if (!@packdeps) { @packdeps = split(' ', $hasnfb); + } elsif ($nfbline) { + $$nfbline = [$$nfbline, undef ]; } } unshift @subpacks, $packname; diff --git a/build b/build index 1cd02df..b7eac02 100755 --- a/build +++ b/build @@ -725,7 +725,10 @@ for SPECFILE in $SPECFILES ; do if test -n "$DEB_TRANSFORM" ; then echo "running debian transformer..." mkdir -p $BUILD_ROOT$TOPDIR/SOURCES.DEB - debtransform $CHANGELOGARGS $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT$TOPDIR/SOURCES.DEB + 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 chroot $BUILD_ROOT su -c "dpkg-source -x $TOPDIR/SOURCES.DEB/*.dsc $TOPDIR/BUILD" - $BUILD_USER else chroot $BUILD_ROOT su -c "dpkg-source -x $TOPDIR/SOURCES/$SPECFILE $TOPDIR/BUILD" - $BUILD_USER diff --git a/debtransform b/debtransform index d1533cb..480661f 100755 --- a/debtransform +++ b/debtransform @@ -180,25 +180,37 @@ my $out = $ARGV[2]; die("$out: $!\n") unless -d $out; +my $tags = parsedsc($dsc); + opendir(D, $dir) || die("$dir: $!\n"); my @dir = grep {$_ ne '.' && $_ ne '..'} readdir(D); closedir(D); my %dir = map {$_ => 1} @dir; -my @tars = grep {/\.tar(?:\.gz|\.bz2)?$/} @dir; -my @debtars = grep {/^debian\.tar(?:\.gz|\.bz2)?$/} @tars; -@tars = grep {!/^debian\.tar(?:\.gz|\.bz2)?$/} @tars; -die("package contains no tar file\n") unless @tars; -die("package contains more than one tar file: @tars\n") if @tars > 1; -die("package contains more than one debian tar file\n") if @debtars > 1; -my $tarfile = $tars[0]; -my $debtarfile = $debtars[0]; +my $tarfile = $tags->{'DEBTRANSFORM-TAR'}; +my $debtarfile = $tags->{'DEBTRANSFORM-FILES-TAR'}; + +if (!$tarfile || !$debtarfile) { + my @tars = grep {/\.tar(?:\.gz|\.bz2)?$/} @dir; + my @debtars = grep {/^debian\.tar(?:\.gz|\.bz2)?$/} @tars; + if (!$tarfile) { + @tars = grep {!/^debian\.tar(?:\.gz|\.bz2)?$/} @tars; + @tars = grep {$_ ne $debtarfile} @tars if $debtarfile; + die("package contains no tar file\n") unless @tars; + die("package contains more than one tar file: @tars\n") if @tars > 1; + $tarfile = $tars[0]; + } + if (!exists($tags->{'DEBTRANSFORM-FILES-TAR'})) { + die("package contains more than one debian tar file\n") if @debtars > 1; + $debtarfile = $debtars[0]; + } +} -my $tags = parsedsc($dsc); my $name = $tags->{'SOURCE'}; die("dsc file contains no source\n") unless defined($name); my $version = $tags->{'VERSION'}; die("dsc file contains no version\n") unless defined($version); +$version =~ s/^\d+://; # no epoch in version, please my $tardir = $tarfile; $tardir =~ s/\.orig\.tar/\.tar/; @@ -230,12 +242,15 @@ if ($debtarfile) { dofile($changelog, $tardir, "debian/changelog") if defined $changelog; for my $file (grep {/^debian\./} @dir) { - next if $file =~ /^debian\.tar/; next if $file eq 'debian.series'; + next if $file =~ /\.tar$/; + next if $file =~ /\.tar\./; dofile("$dir/$file", $tardir); } -if ($dir{"debian.series"}) { +if ($tags->{'DEBTRANSFORM-SERIES'}) { + doseries("$dir/$tags->{'DEBTRANSFORM-SERIES'}", $tardir); +} elsif ($dir{"debian.series"}) { doseries("$dir/debian.series", $tardir); } elsif ($dir{"patches.series"}) { doseries("$dir/patches.series", $tardir); @@ -255,4 +270,8 @@ if (! -s "$out/${name}_$version.diff") { } $tags->{'FILES'} = "\n".join("\n", @files); +delete $tags->{'DEBTRANSFORM-SERIES'}; +delete $tags->{'DEBTRANSFORM-TAR'}; +delete $tags->{'DEBTRANSFORM-FILES-TAR'}; writedsc("$out/${name}_$version.dsc", $tags); +exit(0); diff --git a/init_buildsystem b/init_buildsystem index 7c6688b..b81ae36 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -424,7 +424,12 @@ fi # # delete all packages we don't want # -cp -a $BUILD_ROOT/.init_b_cache/alreadyinstalled $BUILD_ROOT/.init_b_cache/todelete +mkdir -p $BUILD_ROOT/.init_b_cache/todelete +for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do + PKG=${PKG##*/} + test "$PKG" = "*" && continue + touch $BUILD_ROOT/.init_b_cache/todelete/$PKG +done for PKG in $PACKAGES_TO_INSTALL_FIRST $PACKAGES_TO_INSTALL ; do rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG done -- 2.7.4