Package: svn-buildpackage
Version: 0.6.23
Tags: patch

It would be useful if svn-buildpackage would allow the use of an
external script to handle downloading/generating an orig tarball. I
think it would benefit people who maintain packages with very large
orig tarballs from the requirement of having to upload the orig
tarball to some external site, especially people with slow upload
connections. There's also the added bonus of writing checks for
MD5/SHA-* checksums directly in the script, the ability to check
multiple mirrors, downloads from svn, and probably some other benefits
that I can't think of yet.

The patch introduces another property (svn-bp:debOrigScript) and works
similar to svn-bp:origUrl. Set the property under the top level
directory of the package. For example:
'svn propset svn-bp:debOrigScript "debian/generate-tarball-script" debian'
It can be any type of script, and this assumes the script generates
the tarball in the current working directory. It will change to
whatever directory is set for origDir first and then run the script.
It will expect an exit status of 0 from the script.

Another change I introduced in this patch is for handling downloading
from origUrl. It will expect an exit status of 0 for wget as well.
It's not related to this bug but I thought svn-buildpackage would
improve with this as well.

-- 
Regards,
Andres Mejia
--- svn-buildpackage.bak	2008-01-01 04:45:51.000000000 -0500
+++ svn-buildpackage	2008-01-01 04:47:40.000000000 -0500
@@ -6,6 +6,7 @@
 use Getopt::Long qw(:config no_ignore_case bundling pass_through);
 use File::Basename;
 use Cwd;
+use POSIX; # WEXITSTATUS
 
 use strict;
 #use diagnostics;
@@ -326,11 +327,30 @@
       $origfile = long_path($origExpect); # for the actual operation
    }
    else {
-      if ($$c{"origUrl"}) {
+      if ($$c{"debOrigScript"}) { # use an external script to acquire debian orig tarball
+         my $top_dir = getcwd();
+         my $tar_dir = $$c{"origDir"};
+         my $debScript = $$c{"debOrigScript"};
+         my $debScript_abs_path = long_path($debScript); # use absolute path to script
+         print "Orig tarball not found (expected $origExpect), fetching using script $debScript...\n";
+         print "Running script from $tar_dir\n";
+         chdir($tar_dir);
+         my $sysret = WEXITSTATUS(system($debScript_abs_path)); # assume a non-interactive script
+         if (0 != $sysret) { # script failed
+            die "Fetching of orig tarball using $debScript failed...\n";
+         }
+         $origfile = long_path($origExpect); # now the file should exist
+         chdir($top_dir);
+      } elsif ($$c{"origUrl"}) {
          my $oUrl = $$c{"origUrl"};
          print "Orig tarball not found (expected $origExpect), fetching from $oUrl...\n";
          mkdir -p $$c{"origDir"} if (! -d $$c{"origDir"});
-         system "wget -O $origExpect $oUrl" ;
+         my $wget_bin = '/usr/bin/wget';
+         my @args = ('-O', $origExpect, $oUrl);
+         my $sysret = WEXITSTATUS(system($wget_bin, @args));
+         if (0 != $sysret) { # downloading orig tarball failed
+            die "Fetching of tarball from $oUrl failed\n";
+         }
          $origfile = long_path($origExpect); # now the file should exist
       };
    }

Reply via email to