From owner-svn-src-all@FreeBSD.ORG Fri Apr 17 00:55:53 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 084421065672; Fri, 17 Apr 2009 00:55:53 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E98CA8FC16; Fri, 17 Apr 2009 00:55:52 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3H0tqPV099281; Fri, 17 Apr 2009 00:55:52 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3H0tqmA099278; Fri, 17 Apr 2009 00:55:52 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200904170055.n3H0tqmA099278@svn.freebsd.org> From: Tim Kientzle Date: Fri, 17 Apr 2009 00:55:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191173 - head/lib/libarchive X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Apr 2009 00:55:53 -0000 Author: kientzle Date: Fri Apr 17 00:55:52 2009 New Revision: 191173 URL: http://svn.freebsd.org/changeset/base/191173 Log: Implement command-line fallbacks for gzip and bzip2 decompression as well. Not an issue for FreeBSD, since the base system has the necessary libraries. Since all decompressors are always available now, we can unconditionally enable them in archive_read_support_compression_all(). Modified: head/lib/libarchive/archive_read_support_compression_all.c head/lib/libarchive/archive_read_support_compression_bzip2.c head/lib/libarchive/archive_read_support_compression_gzip.c Modified: head/lib/libarchive/archive_read_support_compression_all.c ============================================================================== --- head/lib/libarchive/archive_read_support_compression_all.c Fri Apr 17 00:54:35 2009 (r191172) +++ head/lib/libarchive/archive_read_support_compression_all.c Fri Apr 17 00:55:52 2009 (r191173) @@ -31,18 +31,24 @@ __FBSDID("$FreeBSD$"); int archive_read_support_compression_all(struct archive *a) { -#if HAVE_BZLIB_H + /* Bzip falls back to "bunzip2" command-line */ archive_read_support_compression_bzip2(a); -#endif /* The decompress code doesn't use an outside library. */ archive_read_support_compression_compress(a); /* Gzip decompress falls back to "gunzip" command-line. */ archive_read_support_compression_gzip(a); -#if HAVE_LZMADEC_H - /* LZMA bidding is subject to false positives because - * the LZMA file format has a very weak signature. It - * may not be feasible to include LZMA detection here. */ - /* archive_read_support_compression_lzma(a); */ -#endif + /* The LZMA file format has a very weak signature, so it + * may not be feasible to keep this here, but we'll try. + * This will come back out if there are problems. */ + /* Lzma falls back to "unlzma" command-line program. */ + archive_read_support_compression_lzma(a); + /* Xz falls back to "unxz" command-line program. */ + archive_read_support_compression_xz(a); + + /* Note: We always return ARCHIVE_OK here, even if some of the + * above return ARCHIVE_WARN. The intent here is to enable + * "as much as possible." Clients who need specific + * compression should enable those individually so they can + * verify the level of support. */ return (ARCHIVE_OK); } Modified: head/lib/libarchive/archive_read_support_compression_bzip2.c ============================================================================== --- head/lib/libarchive/archive_read_support_compression_bzip2.c Fri Apr 17 00:54:35 2009 (r191172) +++ head/lib/libarchive/archive_read_support_compression_bzip2.c Fri Apr 17 00:55:52 2009 (r191173) @@ -86,7 +86,13 @@ archive_read_support_compression_bzip2(s reader->init = bzip2_reader_init; reader->options = NULL; reader->free = bzip2_reader_free; +#if HAVE_BZLIB_H return (ARCHIVE_OK); +#else + archive_set_error(_a, ARCHIVE_ERRNO_MISC, + "Using external bunzip2 program"); + return (ARCHIVE_WARN); +#endif } static int @@ -150,10 +156,15 @@ bzip2_reader_bid(struct archive_read_fil static int bzip2_reader_init(struct archive_read_filter *self) { + int r; - archive_set_error(&self->archive->archive, -1, - "This version of libarchive was compiled without bzip2 support"); - return (ARCHIVE_FATAL); + r = __archive_read_program(self, "bunzip2"); + /* Note: We set the format here even if __archive_read_program() + * above fails. We do, after all, know what the format is + * even if we weren't able to read it. */ + self->code = ARCHIVE_COMPRESSION_BZIP2; + self->name = "bzip2"; + return (r); } Modified: head/lib/libarchive/archive_read_support_compression_gzip.c ============================================================================== --- head/lib/libarchive/archive_read_support_compression_gzip.c Fri Apr 17 00:54:35 2009 (r191172) +++ head/lib/libarchive/archive_read_support_compression_gzip.c Fri Apr 17 00:55:52 2009 (r191173) @@ -92,7 +92,14 @@ archive_read_support_compression_gzip(st bidder->init = gzip_bidder_init; bidder->options = NULL; bidder->free = NULL; /* No data, so no cleanup necessary. */ + /* Signal the extent of gzip support with the return value here. */ +#if HAVE_ZLIB_H return (ARCHIVE_OK); +#else + archive_set_error(_a, ARCHIVE_ERRNO_MISC, + "Using external gunzip program"); + return (ARCHIVE_WARN); +#endif } /* @@ -207,9 +214,9 @@ gzip_bidder_bid(struct archive_read_filt #ifndef HAVE_ZLIB_H /* - * If we don't have the library on this system, we can't actually do the - * decompression. We can, however, still detect compressed archives - * and emit a useful message. + * If we don't have the library on this system, we can't do the + * decompression directly. We can, however, try to run gunzip + * in case that's available. */ static int gzip_bidder_init(struct archive_read_filter *self) @@ -217,6 +224,9 @@ gzip_bidder_init(struct archive_read_fil int r; r = __archive_read_program(self, "gunzip"); + /* Note: We set the format here even if __archive_read_program() + * above fails. We do, after all, know what the format is + * even if we weren't able to read it. */ self->code = ARCHIVE_COMPRESSION_GZIP; self->name = "gzip"; return (r);