]> git.michaelhowe.org Git - packages/m/mh-sysadmin-tools.git/commitdiff
Also build from an existing DSC
authorMichael Howe <michael@michaelhowe.org>
Thu, 7 Aug 2014 17:43:49 +0000 (17:43 +0000)
committerMichael Howe <michael@michaelhowe.org>
Thu, 7 Aug 2014 17:43:49 +0000 (17:43 +0000)
bin/build-package
debian/control

index 8583729e17ffb1362f75c6cf4159b1ef2960084a..8554af33c7468aff4fbfbed47fe517a14c2d4850 100755 (executable)
@@ -7,8 +7,11 @@ use warnings;
 use Getopt::Long;
 use File::Temp qw/tempdir/;
 use Cwd;
+use Dpkg::Control;
+use File::Basename;
 
 my $svn = "/usr/bin/svn";
+my $cp = "/bin/cp";
 my $dpkgsource = "/usr/bin/dpkg-source";
 my $cowpoke = "/usr/bin/cowpoke";
 my $rsync = "/usr/bin/rsync";
@@ -19,15 +22,17 @@ my $buildhost = "wowbagger.internal.michaelhowe.org";
 
 my @archs;   # = 'amd64';
 my @dists;   # = 'squeeze';
+my $dsc;     # optional; allows use of a dsc directly
 
 GetOptions(
     "arch=s"    => \@archs,
     "dist=s"    => \@dists,
+    "dsc=s"     => \$dsc,
 );
 
 my $path = $ARGV[0];
 
-unless( $path ){
+unless( $path or $dsc ){
     die "Error - no path specified\n";
 }
 die "Error - arch not defined (use --arch)\n"
@@ -40,20 +45,46 @@ my $workingdir = getcwd();
 
 my $exportdir = tempdir( CLEANUP => 1 );
 
-my @exportcmd = ( $svn, 'export', $path, "$exportdir/export" );
+my @exportcmd;
+if( $dsc ){
+    die "Error - $dsc does not exist (or is not a readable file)\n" unless( -r $dsc );
+    my $c = Dpkg::Control->new( type => CTRL_PKG_SRC );
+    $c->load( $dsc ) or die "Could not parse $dsc\n";
+
+    my $dirname = dirname($dsc);
+
+    # split the filename out
+    my @files_to_copy = map { my ( $name ) = $_ =~ m{[0-9a-f]+ \d+ (\S+)}; $dirname . "/" . $name }
+        grep { /\S+/ }                  # only include files, not empty space
+        split( /\n/, $c->{Files} );
+
+    push @files_to_copy, $dsc;
+
+    @exportcmd = ( $cp, "-a", @files_to_copy, "$exportdir" );
+} else {
+    if ( -d ".svn" ){ 
+        @exportcmd = ( $svn, 'export', $path, "$exportdir/export" );
+    } else {
+        @exportcmd = ( $cp, "-a", $path, "$exportdir/export" );
+    }
+}
+
+
 print "Running '@exportcmd'\n";
 system( @exportcmd ) == 0
-    or die "Could not run svn export: $!";
+    or die "Could not run export command: $!";
 
 chdir( $exportdir )
     or die "Can't chdir to $exportdir: $!";
 
-my @sourcecmd = ( $dpkgsource, "-b", "$exportdir/export" );
+unless( $dsc ){
+    my @sourcecmd = ( $dpkgsource, "-b", "$exportdir/export" );
 
-system( @sourcecmd ) ==0
-    or die "Could not run dpkg-source: $!";
+    system( @sourcecmd ) ==0
+        or die "Could not run dpkg-source: $!";
 
-print "Built in $exportdir\n";
+    print "Built in $exportdir\n";
+}
 
 chdir( $workingdir );
 
index 5974bfed96616d754db3b2b59a6afefde996c5f4..8a8e5a4e058c3dc6d0b22fe41c38fd355065741f 100644 (file)
@@ -9,7 +9,7 @@ Standards-Version: 3.8.4
 
 Package: mh-sysadmin-tools
 Architecture: all
-Depends: ${misc:Depends}, krb5-user, kstart, perl
+Depends: ${misc:Depends}, krb5-user, kstart, perl, libdpkg-perl
 Recommends: rb3
 Description: General sysadmin tools as used on the michaelhowe.org systems
  This package contains simple scripts that are used for sysadmin work on