Author: guillem
Date: 2006-11-24 05:11:35 +0100 (Fri, 24 Nov 2006)
New Revision: 602

Modified:
   trunk/ChangeLog
   trunk/debian/changelog
   trunk/debian/control
   trunk/dpkg-deb/dpkg-deb.h
   trunk/dpkg-deb/extract.c
   trunk/lib/compression.c
   trunk/lib/dpkg.h
   trunk/scripts/dpkg-source.pl
Log:
Support extracting lzma compressed source and binary packages,
and add a Suggests on package lzma. Closes: #347715


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/ChangeLog     2006-11-24 04:11:35 UTC (rev 602)
@@ -1,3 +1,17 @@
+2006-11-24  Guillem Jover  <[EMAIL PROTECTED]>
+
+       * scripts/dpkg-source.pl: Add lzma extracting support.
+       (checkdiff): Likewise.
+       (forkgzipread): Likewise.
+       * lib/dpkg.h (LZMA): New macro.
+       (compression_type): Add compress_type_lzma.
+       * lib/compression.c (decompress_cat): Handle compress_type_lzma
+       decompression.
+       * dpkg-deb/dpkg-deb.h (DATAMEMBER_LZMA): New macro.
+       (DATAMEMBER_COMPAT_LZMA): Likewise.
+       * dpkg-deb/extract.c (extracthalf): Handle DATAMEMBER_LZMA and
+       DATAMEMBER_COMPAT_LZMA members.
+
 2006-11-24  Brendan O'Dea  <[EMAIL PROTECTED]>
 
        * scripts/controllib.pl (subprocerr): Require POSIX for WIFEXITED,

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/debian/changelog      2006-11-24 04:11:35 UTC (rev 602)
@@ -8,6 +8,8 @@
     Thanks to Tomas Pospisek <[EMAIL PROTECTED]>.
   * Require POSIX inside subprocerr in controllib.pl. Closes: #390636
     Thanks to Brendan O'Dea <[EMAIL PROTECTED]>.
+  * Support extracting lzma compressed source and binary packages,
+    and add a Suggests on package lzma. Closes: #347715
 
   [ Updated dpkg translations ]
   * Chinese (Traditional, Asho Yeh)

Modified: trunk/debian/control
===================================================================
--- trunk/debian/control        2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/debian/control        2006-11-24 04:11:35 UTC (rev 602)
@@ -18,7 +18,7 @@
  dpkg-dev (<< 1.10)
 Replaces: dpkg-doc-ja, dpkg-static, manpages-de (<= 0.4-3),
  manpages-pl (<= 20051117-1)
-Suggests: apt
+Suggests: apt, lzma
 Description: package maintenance system for Debian
  This package contains the low-level commands for handling the installation
  and removal of packages on your system.

Modified: trunk/dpkg-deb/dpkg-deb.h
===================================================================
--- trunk/dpkg-deb/dpkg-deb.h   2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/dpkg-deb/dpkg-deb.h   2006-11-24 04:11:35 UTC (rev 602)
@@ -45,6 +45,8 @@
 #define DATAMEMBER_COMPAT_GZ   "data.tar.gz/    "
 #define DATAMEMBER_BZ2         "data.tar.bz2    "
 #define DATAMEMBER_COMPAT_BZ2          "data.tar.bz2/   "
+#define DATAMEMBER_LZMA                "data.tar.lzma   "
+#define DATAMEMBER_COMPAT_LZMA "data.tar.lzma/  "
 #define DATAMEMBER_CAT         "data.tar        "
 #define DATAMEMBER_COMPAT_CAT          "data.tar/       "
 

Modified: trunk/dpkg-deb/extract.c
===================================================================
--- trunk/dpkg-deb/extract.c    2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/dpkg-deb/extract.c    2006-11-24 04:11:35 UTC (rev 602)
@@ -157,6 +157,10 @@
                     
!memcmp(arh.ar_name,DATAMEMBER_COMPAT_BZ2,sizeof(arh.ar_name))) {
            adminmember= 0;
            compress_type= BZ2;
+         } else if (!memcmp(arh.ar_name, DATAMEMBER_LZMA, sizeof(arh.ar_name)) 
||
+                    !memcmp(arh.ar_name, DATAMEMBER_COMPAT_LZMA, 
sizeof(arh.ar_name))) {
+           adminmember = 0;
+           compress_type = compress_type_lzma;
          } else if (!memcmp(arh.ar_name,DATAMEMBER_CAT,sizeof(arh.ar_name)) ||
                     
!memcmp(arh.ar_name,DATAMEMBER_COMPAT_CAT,sizeof(arh.ar_name))) {
            adminmember= 0;

Modified: trunk/lib/compression.c
===================================================================
--- trunk/lib/compression.c     2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/lib/compression.c     2006-11-24 04:11:35 UTC (rev 602)
@@ -90,6 +90,17 @@
       }
       execlp(BZIP2,"bzip2","-dc",(char*)0); ohshite(_("%s: failed to exec 
bzip2 -dc"), v.buf);
 #endif
+    case compress_type_lzma:
+      if (fd_in != 0) {
+        m_dup2(fd_in, 0);
+        close(fd_in);
+      }
+      if (fd_out != 1) {
+        m_dup2(fd_out, 1);
+        close(fd_out);
+      }
+      execlp(LZMA, "lzma", "-dc", (char *)0);
+      ohshite(_("%s: failed to exec %s"), v.buf, "lzma -dc");
     case CAT:
       fd_fd_copy(fd_in, fd_out, -1, _("%s: decompression"), v.buf);
       exit(0);

Modified: trunk/lib/dpkg.h
===================================================================
--- trunk/lib/dpkg.h    2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/lib/dpkg.h    2006-11-24 04:11:35 UTC (rev 602)
@@ -139,6 +139,7 @@
 #define TAR            "tar"
 #define GZIP           "gzip"
 #define BZIP2          "bzip2"
+#define LZMA           "lzma"
 #define RM             "rm"
 #define FIND           "find"
 #define SHELL          "sh"
@@ -373,7 +374,7 @@
 
 /*** from compression.c ***/
 
-enum compression_type { CAT, GZ, BZ2 };
+enum compression_type { CAT, GZ, BZ2, compress_type_lzma };
 
 void decompress_cat(enum compression_type type, int fd_in, int fd_out, char 
*desc, ...) NONRETURNING;
 void compress_cat(enum compression_type type, int fd_in, int fd_out, const 
char *compression, char *desc, ...) NONRETURNING;

Modified: trunk/scripts/dpkg-source.pl
===================================================================
--- trunk/scripts/dpkg-source.pl        2006-11-24 04:08:00 UTC (rev 601)
+++ trunk/scripts/dpkg-source.pl        2006-11-24 04:11:35 UTC (rev 602)
@@ -680,7 +680,7 @@
 
        &error(sprintf(_g("Files field contains invalid filename `%s'"), $file))
            unless s/^\Q$sourcepackage\E_\Q$baseversion\E(?=[.-])// and
-                  s/\.(gz|bz2)$//;
+                  s/\.(gz|bz2|lzma)$//;
        s/^-\Q$revision\E(?=\.)// if length $revision;
 
        &error(sprintf(_g("repeated file type - files `%s' and `%s'"), 
$seen{$_}, $file)) if $seen{$_};
@@ -835,7 +835,7 @@
 
     for my $patch (@patches) {
        printf(_g("%s: applying %s")."\n", $progname, $patch);
-       if ($patch =~ /\.(gz|bz2)$/) {
+       if ($patch =~ /\.(gz|bz2|lzma)$/) {
            &forkgzipread($patch);
            *DIFF = *GZIP;
        } else {
@@ -855,7 +855,7 @@
         $c2 == waitpid($c2,0) || &syserr(_g("wait for patch"));
         $? && subprocerr("patch");
 
-       &reapgzip if $patch =~ /\.(gz|bz2)$/;
+       &reapgzip if $patch =~ /\.(gz|bz2|lzma)$/;
     }
 
     my $now = time;
@@ -1138,7 +1138,7 @@
 sub checkdiff
 {
     my $diff = shift;
-    if ($diff =~ /\.(gz|bz2)$/) {
+    if ($diff =~ /\.(gz|bz2|lzma)$/) {
        &forkgzipread($diff);
        *DIFF = *GZIP;
     } else {
@@ -1212,7 +1212,7 @@
     }
     close(DIFF);
     
-    &reapgzip if $diff =~ /\.(gz|bz2)$/;
+    &reapgzip if $diff =~ /\.(gz|bz2|lzma)$/;
 }
 
 sub extracttar {
@@ -1307,7 +1307,18 @@
 
 sub forkgzipread {
     local $SIG{PIPE} = 'DEFAULT';
-    my $prog = $_[0] =~ /\.gz$/ ? 'gunzip' : 'bunzip2';
+    my $prog;
+
+    if ($_[0] =~ /\.gz$/) {
+      $prog = 'gunzip';
+    } elsif ($_[0] =~ /\.bz2$/) {
+      $prog = 'bunzip2';
+    } elsif ($_[0] =~ /\.lzma$/) {
+      $prog = 'unlzma';
+    } else {
+      &error(sprintf(_g("unknown compression type on file %s"), $_[0]));
+    }
+
     open(GZIPFILE,"< $_[0]") || &syserr(sprintf(_g("read file %s"), $_[0]));
     pipe(GZIP,GZIPWRITE) || &syserr(sprintf(_g("pipe for %s"), $prog));
     defined($cgz= fork) || &syserr(sprintf(_g("fork for %s"), $prog));


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to