Преглед изворни кода

Support extracting lzma compressed source and binary packages,
and add a Suggests on package lzma. Closes: #347715

Guillem Jover пре 19 година
родитељ
комит
c8f668cce5
8 измењених фајлова са 53 додато и 8 уклоњено
  1. 14 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 1 1
      debian/control
  4. 2 0
      dpkg-deb/dpkg-deb.h
  5. 4 0
      dpkg-deb/extract.c
  6. 11 0
      lib/compression.c
  7. 2 1
      lib/dpkg.h
  8. 17 6
      scripts/dpkg-source.pl

+ 14 - 0
ChangeLog

@@ -1,3 +1,17 @@
+2006-11-24  Guillem Jover  <guillem@debian.org>
+
+	* 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  <bod@debian.org>
 
 	* scripts/controllib.pl (subprocerr): Require POSIX for WIFEXITED,

+ 2 - 0
debian/changelog

@@ -8,6 +8,8 @@ dpkg (1.13.25~) UNRELEASED; urgency=low
     Thanks to Tomas Pospisek <tpo_deb@sourcepole.ch>.
   * Require POSIX inside subprocerr in controllib.pl. Closes: #390636
     Thanks to Brendan O'Dea <bod@debian.org>.
+  * Support extracting lzma compressed source and binary packages,
+    and add a Suggests on package lzma. Closes: #347715
 
   [ Updated dpkg translations ]
   * Chinese (Traditional, Asho Yeh)

+ 1 - 1
debian/control

@@ -18,7 +18,7 @@ Conflicts: sysvinit (<< 2.82-1), dpkg-iasearch (<< 0.11), dpkg-static,
  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.

+ 2 - 0
dpkg-deb/dpkg-deb.h

@@ -45,6 +45,8 @@ extern enum compression_type compress_type;
 #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/       "
 

+ 4 - 0
dpkg-deb/extract.c

@@ -157,6 +157,10 @@ void extracthalf(const char *debar, const char *directory,
 		     !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;

+ 11 - 0
lib/compression.c

@@ -90,6 +90,17 @@ void decompress_cat(enum compression_type type, int fd_in, int fd_out, char *des
       }
       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);

+ 2 - 1
lib/dpkg.h

@@ -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 @@ int cisalpha(int c);
 
 /*** 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;

+ 17 - 6
scripts/dpkg-source.pl

@@ -680,7 +680,7 @@ if ($opmode eq 'build') {
 
 	&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 @@ if ($opmode eq 'build') {
 
     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 @@ if ($opmode eq 'build') {
         $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 @@ no strict 'vars';
 sub checkdiff
 {
     my $diff = shift;
-    if ($diff =~ /\.(gz|bz2)$/) {
+    if ($diff =~ /\.(gz|bz2|lzma)$/) {
 	&forkgzipread($diff);
 	*DIFF = *GZIP;
     } else {
@@ -1212,7 +1212,7 @@ sub checkdiff
     }
     close(DIFF);
     
-    &reapgzip if $diff =~ /\.(gz|bz2)$/;
+    &reapgzip if $diff =~ /\.(gz|bz2|lzma)$/;
 }
 
 sub extracttar {
@@ -1307,7 +1307,18 @@ sub forkgzipwrite {
 
 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));