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";
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";
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: $!";
#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: $!";
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;
+}