[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#246918: dpkg-source may have an option to get .diff.gz from a custom source



tags 246918 + patch
thanks

> this is a very simple and non-intrusive change that I wish to see in
> dpkg-source. I would like to make it read the contents of the future
> .diff.gz file from a user-specified location and not run diff (and other

The attached patch implements the requested functionality. One has to
set $DIFFSRC to the diff source filename when running dpkg-source.

Regards,
Eduard.
--- /usr/bin/dpkg-source	2004-06-01 23:23:39.000000000 +0200
+++ dpkg-source	2004-07-02 14:30:56.000000000 +0200
@@ -125,6 +125,8 @@
     }
 }
 
+$diffsrc=$ENV{"DIFFSRC"};
+
 defined($opmode) || &usageerr("need -x or -b");
 
 $SIG{'PIPE'} = 'DEFAULT';
@@ -334,7 +336,7 @@
     
     addfile("$tarname");
 
-    if ($sourcestyle =~ m/[kpKP]/) {
+    if ($sourcestyle =~ m/[kpKP]/ && !$diffsrc) {
 
         if (stat($origdir)) {
             $sourcestyle =~ m/[KP]/ ||
@@ -354,16 +356,28 @@
         mkdir("$origtargz.tmp-nest",0755) ||
             &syserr("unable to create \`$origtargz.tmp-nest'");
 	push @exit_handlers, sub { erasedir("$origtargz.tmp-nest") };
-        extracttar($origtargz,"$origtargz.tmp-nest",$expectprefix);
-        rename("$origtargz.tmp-nest/$expectprefix",$expectprefix) ||
-            &syserr("unable to rename \`$origtargz.tmp-nest/$expectprefix' to ".
-                    "\`$expectprefix'");
-        rmdir("$origtargz.tmp-nest") ||
-            &syserr("unable to remove \`$origtargz.tmp-nest'");
-	    pop @exit_handlers;
+        if($diffsrc) {
+           print("\$DIFFSRC found, not touching $origtargz\n");
+        }
+        else {
+           extracttar($origtargz,"$origtargz.tmp-nest",$expectprefix);
+           rename("$origtargz.tmp-nest/$expectprefix",$expectprefix) ||
+           &syserr("unable to rename \`$origtargz.tmp-nest/$expectprefix' to ".
+           "\`$expectprefix'");
+           rmdir("$origtargz.tmp-nest") ||
+           &syserr("unable to remove \`$origtargz.tmp-nest'");
+           pop @exit_handlers;
+        }
     }
         
-    if ($sourcestyle =~ m/[kpursKPUR]/) {
+    if($diffsrc) {
+       print("\$DIFFSRC found, using it to build $basenamerev.diff.gz\n");
+       if(system "gzip < \"$diffsrc\" > \"$basenamerev.diff.gz\"" ) {
+          &syserr("unable to compress $diffsrc to $basenamerev.diff.gz");
+       }
+        &addfile("$basenamerev.diff.gz");
+    }
+    elsif ($sourcestyle =~ m/[kpursKPUR]/) {
         
         print("$progname: building $sourcepackage in $basenamerev.diff.gz\n")
             || &syserr("write building diff message");
@@ -530,8 +544,8 @@
     $sourcepackage= $fi{'S Source'};
     $sourcepackage =~ m/[^-+.0-9a-z]/ &&
         &error("source package name contains illegal character \`$&'");
-    $sourcepackage =~ m/^[0-9a-z]/ ||
-        &error("source package name starts with non-alphanum");
+    $sourcepackage =~ m/^[0-9a-z]./ ||
+        &error("source package name is too short or starts with non-alphanum");
 
     $version= $fi{'S Version'};
     $version =~ m/[^-+:.0-9a-zA-Z~]/ &&

Reply to: