Hi,

the attached patch extends the source format 3.0 handling by adding
support for .lzma and .xz compressed tarballs to svn-inject and
svn-buildpackage.
Patch is vs. SVN r15858 (where the original patch from Raphael adding
3.0 and bz2 support was already applied).


Andreas
Index: svn-buildpackage
===================================================================
--- svn-buildpackage	(revision 15861)
+++ svn-buildpackage	(working copy)
@@ -172,6 +172,13 @@
    "svn-noautodch"         => \$opt_noautodch,
 );
 
+my %tar_compress_flags = (
+    "gz" => "--gzip",
+    "bz2" => "--bzip2",
+    "lzma" => "--lzma",
+    "xz" => "--xz",
+);
+
 my $tagVersion;
 my $upVersion;
 my $upRNumber;
@@ -362,36 +369,30 @@
 
 mkdir $$c{"buildArea"} if (! -d $$c{"buildArea"});
 
-my $orig = $package."_".$upVersion.".orig.tar.gz";
-my $bzorig = $package."_".$upVersion.".orig.tar.bz2";
+# See #560391 for why we can't use dpkg-source --print-format .
+my $is_format_3_0;
+$is_format_3_0 = `grep \"3.0\" debian/source/format`
+   if (-f "debian/source/format");
 
-if ($$c{"origDir"}) {
-   my $bzorigExpect = $$c{"origDir"}."/$bzorig";
-   # See #560391 for why we can't use dpkg-source --print-format .
-   my $check;
-   $check = `grep \"3.0\" debian/source/format`
-     if (-f "debian/source/format");
-   if ((-f $bzorigExpect) and (defined $check))
-   {
-     $origExpect = $$c{"origDir"}."/$bzorig"; # just for the messages
-     $orig = $bzorig;
+my @origExtList = (".gz");
+push @origExtList, (".bz2", ".lzma", ".xz") if $is_format_3_0;
+my $origTar = $package."_".$upVersion.".orig.tar";
+my $orig = $origt...@origextlist[0];  # fallback
+$origExpect = ($$c{"origDir"} || "../tarballs") . "/$orig";  # fallback
+my $origDir = $$c{"origDir"} || "$startdir/../tarballs";
+my $ext;
+foreach $ext (@origExtList) {
+   if (-f "$origDir/$origTar$ext") {
+      $orig = "$origTar$ext";
+      $origExpect = "$origDir/$orig";  # just for the messages
+      last;
    }
-   else
-   {
-     $origExpect = $$c{"origDir"}."/$orig"; # just for the messages
-   }
-   if (-f $origExpect) {
-      $origfile = long_path($origExpect); # for the actual operation
-   }
-} else {
-    $origExpect = "../tarballs/$orig";
-    if(-f ($startdir . "/../tarballs/$orig")) {
-        $origfile = long_path($startdir . "/../tarballs/$orig");
-    }
-};
-my $origDir = $$c{"origDir"} || "$startdir/../tarballs";
-my %otherOrigFiles = map { /\.orig-([\w-]+)\.tar\.(gz|bz2|lzma)$/ ? ($1 => $_) : () } grep {
-    /(?:^|\/)\Q${package}_${upVersion}\E\.orig-[\w-]+\.tar\.(gz|bz2|lzma)$/
+}
+if (-f $origExpect) {
+   $origfile = long_path($origExpect);  # for the actual operation
+}
+my %otherOrigFiles = map { /\.orig-([\w-]+)\.tar\.(gz|bz2|lzma|xz)$/ ? ($1 => $_) : () } grep {
+    /(?:^|\/)\Q${package}_${upVersion}\E\.orig-[\w-]+\.tar\.(gz|bz2|lzma|xz)$/
 } <$origDir/*>;
 
 if(!defined($origfile)) {
@@ -574,8 +575,7 @@
       print _g("Reusing old build directory\n") if $opt_verbose;
    }
    else {
-      my $compress = "--gzip";
-      $compress = "--bzip2" if ($orig =~ /\.tar\.bz2/);
+      my $compress = $tar_compress_flags{($orig=~/\.tar\.([^.]*)$/)[0]};
       withecho "tar", "--no-same-owner", "--no-same-permissions", "--extract", $compress, "--file", $origfile, "--directory", "$ba/tmp-$mod";
       my @entries = (<$ba/tmp-$mod/*>);
       if (@entries == 1) {
Index: svn-inject
===================================================================
--- svn-inject	(revision 15861)
+++ svn-inject	(working copy)
@@ -144,6 +144,13 @@
     "3.0 (native)" => 1,
 );
 
+my %tar_compress_flags = (
+    "gz" => "--gzip",
+    "bz2" => "--bzip2",
+    "lzma" => "--lzma",
+    "xz" => "--xz",
+);
+
 #shamelessly copied and slightly modified from svn-bp
 my @CONFARGS;
 for my $file ($ENV{"HOME"}."/.svn-buildpackage.conf") {
@@ -306,17 +313,17 @@
    $dscFormat = $1 if (/^Format: (.+)\n/);
    $package=$1 if(/^Source: (.+)\n/);
    $debVersion=$1 if(/^Version: (.+)\n/ && !$debVersion);
-   if(/^(\s\w+\s\d+\s+)((.*)_(.*).orig.tar.(gz|bz2))/)
+   if(/^(\s\w+\s\d+\s+)((.*)_(.*).orig.tar.(gz|bzip2|lzma|xz))/)
    {
       $dscOrig="$fromDir/$2";
       $upsVersion=$4;
    }
-   if (/^(\s\w+\s\d+\s+)((.*)_(.*).orig(?:-([\w-]+)).tar.(gz|bz2))/)
+   if (/^(\s\w+\s\d+\s+)((.*)_(.*).orig(?:-([\w-]+)).tar.(gz|bzip2|lzma|xz))/)
    {
        $dscOtherOrig{$5}="$fromDir/$2";
    }
-   $dscDebianTar = "$fromDir/$1" if(/^\s\w+\s\d+\s(.+\.debian\.tar\.(gz|bz2))\n/);
-   $dscDiff = "$fromDir/$1" if(/^\s\w+\s\d+\s(.+\.diff.(gz|bz2))\n/);
+   $dscDebianTar = "$fromDir/$1" if(/^\s\w+\s\d+\s(.+\.debian\.tar\.(gz|bzip2|lzma|xz))\n/);
+   $dscDiff = "$fromDir/$1" if(/^\s\w+\s\d+\s(.+\.diff.(gz|bzip2|lzma|xz))\n/);
 }
 close($dsc);
 
@@ -399,7 +406,8 @@
    chdir "$subupsTags";
 
    # extract the whole package and use its Debian version as upstream version
-   withecho "tar", $opt_tarquiet, ($dscOrig=~/bz2$/i ? "-j" : "-z"), "-x", "-f", $dscOrig;
+   my $compress = $tar_compress_flags{($dscOrig=~/\.tar\.([^.]*)$/)[0]};
+   withecho "tar", $opt_tarquiet, $compress, "-x", "-f", $dscOrig;
    oldSvnDirsCheck ".";
 
    my @filesInside=(<*>);
@@ -453,7 +461,7 @@
   withecho "mkdir", "-p", $dir;
   chdir $dir;
   withecho "dpkg-source -x $opt_dsc";
-  system "rm -f *.gz *.bz2";
+  system "rm -f *.gz *.bz2 *.lzma *.xz";
   withecho "mv * $base";
 }
 chdir $tempdir;
@@ -506,7 +514,7 @@
    } else {
        withecho "dpkg-source -x $opt_dsc";
    }
-   system "rm -f *.gz *.bz2";
+   system "rm -f *.gz *.bz2 *.lzma *.xz";
    # now use svn_load_dirs to upgrade the trunk fork to Debian versions.
    # For mergeWithUpstream mode, drop all unchanged files
    my $dirname=<*>;

Reply via email to