Here's a revised patch for using a debOrigScript property to acquire
an orig tarball. This adds an option to force the use of downloading a
tarball using origUrl. I think this is useful when a package does get
accepted into Debian and there's no longer a need to generate the
tarball.
--- svn-buildpackage.bak	2008-01-01 04:45:51.000000000 -0500
+++ svn-buildpackage	2008-01-01 13:59:32.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;
@@ -47,6 +48,7 @@
 Miscelaneous:
   --svn-pkg PACKAGE    Specifies the package name
   --svn-override a=b   Override some config variable (comma separated list)
+  --svn-use-origurl    Download tarball using origUrl instead of debOrigScript
   --svn-verbose        More verbose program output
   --svn-noninteractive Turn off interactive mode
   -h, --help           Show this help message
@@ -84,6 +86,7 @@
 my $package;
 my $opt_savecfg;
 my $opt_dbgsdcommon;
+my $opt_use_origurl;
 
 my %options = (
 #   "h|help"                => \&help,
@@ -108,6 +111,7 @@
    "svn-postbuild=s"       => \$opt_postbuild,
    "svn-pretag=s"          => \$opt_pretag,
    "svn-posttag=s"         => \$opt_posttag,
+   "svn-use-origurl"       => \$opt_use_origurl,
    # and for compatibility with old config directives
    "pre-tag-action=s"      => \$opt_pretag,
    "post-tag-action=s"     => \$opt_posttag,
@@ -326,11 +330,30 @@
       $origfile = long_path($origExpect); # for the actual operation
    }
    else {
-      if ($$c{"origUrl"}) {
+      if (($$c{"debOrigScript"}) && (!$opt_use_origurl)) { # 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