From owner-svn-src-all@FreeBSD.ORG Sun Apr 19 06:59:13 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 01708106566B; Sun, 19 Apr 2009 06:59:13 +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 E41108FC12; Sun, 19 Apr 2009 06:59:12 +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 n3J6xCBR001859; Sun, 19 Apr 2009 06:59:12 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3J6xCBl001857; Sun, 19 Apr 2009 06:59:12 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200904190659.n3J6xCBl001857@svn.freebsd.org> From: Tim Kientzle Date: Sun, 19 Apr 2009 06:59:12 +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: r191262 - head/usr.bin/cpio 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: Sun, 19 Apr 2009 06:59:13 -0000 Author: kientzle Date: Sun Apr 19 06:59:12 2009 New Revision: 191262 URL: http://svn.freebsd.org/changeset/base/191262 Log: When compiled for the release crunches, be a bit more selective about what libarchive features we pull in: * No compression support * Only cpio and ustar writing * Only cpio and tar/pax readers This reduces a statically linked, stripped binary from 900k to 680k and completely eliminates the dependency on libcrypto. Modified: head/usr.bin/cpio/Makefile head/usr.bin/cpio/cpio.c Modified: head/usr.bin/cpio/Makefile ============================================================================== --- head/usr.bin/cpio/Makefile Sun Apr 19 06:30:00 2009 (r191261) +++ head/usr.bin/cpio/Makefile Sun Apr 19 06:59:12 2009 (r191262) @@ -9,6 +9,11 @@ WARNS?= 6 DPADD= ${LIBARCHIVE} ${LIBZ} ${LIBBZ2} CFLAGS+= -DBSDCPIO_VERSION_STRING=\"${BSDCPIO_VERSION_STRING}\" CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\" +.ifdef RELEASE_CRUNCH +# FreeBSD's installer uses cpio in crunched binaries that are +# statically linked, cannot use -lcrypto, and are size sensitive. +CFLAGS+= -DSMALLER +.endif LDADD+= -larchive -lz -lbz2 -lmd .if ${MK_OPENSSL} != "no" LDADD+= -lcrypto Modified: head/usr.bin/cpio/cpio.c ============================================================================== --- head/usr.bin/cpio/cpio.c Sun Apr 19 06:30:00 2009 (r191261) +++ head/usr.bin/cpio/cpio.c Sun Apr 19 06:59:12 2009 (r191262) @@ -461,24 +461,37 @@ mode_out(struct cpio *cpio) if (cpio->archive == NULL) cpio_errc(1, 0, "Failed to allocate archive object"); switch (cpio->compress) { -#ifdef HAVE_BZLIB_H +#ifndef SMALLER case 'j': case 'y': - archive_write_set_compression_bzip2(cpio->archive); + r = archive_write_set_compression_bzip2(cpio->archive); break; -#endif -#ifdef HAVE_ZLIB_H case 'z': - archive_write_set_compression_gzip(cpio->archive); + r = archive_write_set_compression_gzip(cpio->archive); break; -#endif case 'Z': - archive_write_set_compression_compress(cpio->archive); + r = archive_write_set_compression_compress(cpio->archive); break; - default: - archive_write_set_compression_none(cpio->archive); +#endif + case '\0': + r = archive_write_set_compression_none(cpio->archive); break; + default: + cpio_errc(1, 0, "Unrecognized compression option"); } + if (r != ARCHIVE_OK) + cpio_errc(1, 0, "Unsupported compression format"); +#ifdef SMALLER + if (strcmp(cpio->format, "cpio")) + r = archive_write_set_format_cpio(cpio->archive); + else if (strcmp(cpio->format, "odc")) + r = archive_write_set_format_cpio(cpio->archive); + else if (strcmp(cpio->format, "newc")) + r = archive_write_set_format_cpio(cpio->archive); + else if (strcmp(cpio->format, "ustar")) + r = archive_write_set_format_cpio(cpio->archive); +#else r = archive_write_set_format_by_name(cpio->archive, cpio->format); +#endif if (r != ARCHIVE_OK) cpio_errc(1, 0, archive_error_string(cpio->archive)); archive_write_set_bytes_per_block(cpio->archive, cpio->bytes_per_block); @@ -815,8 +828,13 @@ mode_in(struct cpio *cpio) a = archive_read_new(); if (a == NULL) cpio_errc(1, 0, "Couldn't allocate archive object"); +#ifdef SMALLER + archive_read_support_format_cpio(a); + archive_read_support_format_tar(a); +#else archive_read_support_compression_all(a); archive_read_support_format_all(a); +#endif if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block)) cpio_errc(1, archive_errno(a), @@ -907,8 +925,13 @@ mode_list(struct cpio *cpio) a = archive_read_new(); if (a == NULL) cpio_errc(1, 0, "Couldn't allocate archive object"); +#ifdef SMALLER + archive_read_support_format_cpio(a); + archive_read_support_format_tar(a); +#else archive_read_support_compression_all(a); archive_read_support_format_all(a); +#endif if (archive_read_open_file(a, cpio->filename, cpio->bytes_per_block)) cpio_errc(1, archive_errno(a),