From c8f668cce58da11552a4136753024e973356f327 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 24 Nov 2006 04:11:35 +0000 Subject: [PATCH] Support extracting lzma compressed source and binary packages, and add a Suggests on package lzma. Closes: #347715 --- ChangeLog | 14 ++++++++++++++ debian/changelog | 2 ++ debian/control | 2 +- dpkg-deb/dpkg-deb.h | 2 ++ dpkg-deb/extract.c | 4 ++++ lib/compression.c | 11 +++++++++++ lib/dpkg.h | 3 ++- scripts/dpkg-source.pl | 23 +++++++++++++++++------ 8 files changed, 53 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index c309f893..e7fe0a04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-11-24 Guillem Jover + + * 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 * scripts/controllib.pl (subprocerr): Require POSIX for WIFEXITED, diff --git a/debian/changelog b/debian/changelog index a3d51bc0..149010e1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ dpkg (1.13.25~) UNRELEASED; urgency=low Thanks to Tomas Pospisek . * Require POSIX inside subprocerr in controllib.pl. Closes: #390636 Thanks to Brendan O'Dea . + * Support extracting lzma compressed source and binary packages, + and add a Suggests on package lzma. Closes: #347715 [ Updated dpkg translations ] * Chinese (Traditional, Asho Yeh) diff --git a/debian/control b/debian/control index ab825e84..6cb3f0ec 100644 --- a/debian/control +++ b/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. diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h index 585c6368..daa9c74c 100644 --- a/dpkg-deb/dpkg-deb.h +++ b/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/ " diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c index e886a7f9..4db9eb7e 100644 --- a/dpkg-deb/extract.c +++ b/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; diff --git a/lib/compression.c b/lib/compression.c index 3e6571e8..7b305e35 100644 --- a/lib/compression.c +++ b/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); diff --git a/lib/dpkg.h b/lib/dpkg.h index a12e637c..46c5e432 100644 --- a/lib/dpkg.h +++ b/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; diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 351825a0..b2ee7ff4 100755 --- a/scripts/dpkg-source.pl +++ b/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)); -- 2.39.5