]> git.michaelhowe.org Git - packages/m/mh-sysadmin-tools.git/commitdiff
Pass '-sa' to always build the sources, and copy the orig.tar.gz into the export...
authorMichael Howe <michael@michaelhowe.org>
Thu, 5 Mar 2015 22:36:22 +0000 (22:36 +0000)
committerMichael Howe <michael@michaelhowe.org>
Thu, 5 Mar 2015 22:36:22 +0000 (22:36 +0000)
bin/build-package

index 8554af33c7468aff4fbfbed47fe517a14c2d4850..b57cc0daa6514caf2c71097a6e9a9a5e74ca9aaf 100755 (executable)
@@ -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;
+}