From: Michael Howe Date: Thu, 5 Mar 2015 22:36:22 +0000 (+0000) Subject: Pass '-sa' to always build the sources, and copy the orig.tar.gz into the export... X-Git-Tag: 1.6~9 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c794d2cef698b794b04a4c160b4a22be727ca3d2;p=packages%2Fm%2Fmh-sysadmin-tools.git Pass '-sa' to always build the sources, and copy the orig.tar.gz into the export dir if required --- diff --git a/bin/build-package b/bin/build-package index 8554af3..b57cc0d 100755 --- a/bin/build-package +++ b/bin/build-package @@ -8,8 +8,11 @@ use Getopt::Long; use File::Temp qw/tempdir/; use Cwd; use Dpkg::Control; +use Dpkg::Changelog; use File::Basename; +use Data::Dumper; + my $svn = "/usr/bin/svn"; my $cp = "/bin/cp"; my $dpkgsource = "/usr/bin/dpkg-source"; @@ -17,6 +20,8 @@ my $cowpoke = "/usr/bin/cowpoke"; my $rsync = "/usr/bin/rsync"; my $debsign = "/usr/bin/debsign"; my @debsign_opts = (); +my @cowpoke_opts = qw(--dpkg-opts='-sa'); +my @orig_compression_types = qw(bz2 gz lzma xz); my $buildhost = "wowbagger.internal.michaelhowe.org"; @@ -74,6 +79,23 @@ print "Running '@exportcmd'\n"; system( @exportcmd ) == 0 or die "Could not run export command: $!"; +my $format = get_source_format(); +if( $format =~ m{quilt} ){ + my ( $packagename, $version ) = parse_changelog_details(); + my $orig_glob = "../${packagename}_$version.orig.tar.{" . join(',', @orig_compression_types) . "}"; + my @origfiles = grep { -f $_ } glob( $orig_glob ); + unless( @origfiles ){ + die "Error - this is a quilt package, but cannot find an orig.tar.ext file matching $orig_glob\n"; + } + foreach my $file ( @origfiles ){ + # should only copy one? + my @cpcmd = ( $cp, "-a", $file, $exportdir ); + print "Running `@cpcmd`\n"; + system( @cpcmd ) == 0 + or die "Could not run copy command: $!"; + } +} + chdir( $exportdir ) or die "Can't chdir to $exportdir: $!"; @@ -107,7 +129,7 @@ my $distcmds = "--dist=" . join( " ", @dists ); #my @archcmds = map { "--arch=" . $_ } @archs; #my @distcmds = map { "--dist=" . $_ } @dists; -my @cowpokecmd = ( $cowpoke, $archcmds, $distcmds, $dscfile ); +my @cowpokecmd = ( $cowpoke, $archcmds, $distcmds, @cowpoke_opts, $dscfile ); print "Running @cowpokecmd"; system( @cowpokecmd ) == 0 or die "Could not run cowpoke: $!"; @@ -130,3 +152,26 @@ foreach my $changefile ( @changefiles ){ system( @debsigncmd ) == 0 or warn "Could not sign changes file $changefile: $!"; } + +sub get_source_format { + unless( -f "debian/source/format" ){ + return ""; + } + open( my $formatfh, "<", "debian/source/format" ) + or die "Cannot open debian/source/format: $!"; + chomp( my $line = <$formatfh> ); + close( $formatfh ); + return $line; +} + +sub parse_changelog_details { + unless( -f "debian/changelog" ){ + die "Cannot find debian/changelog\n"; + } + open( my $changelogfh, "<", "debian/changelog" ) + or die "Cannot open debian/changelog: $!"; + chomp( my $line = <$changelogfh> ); + close( $changelogfh ); + my ( $package, $ver ) = $line =~ m{(\S+)\s+\(([\d.]+).*\)}; + return $package, $ver; +}