Removed ar(1)'s support for compressed archives. This change removes

ar(1)'s dependencies on compressor libraries -lz, -lbz2 and -llzma and
fixes building HEAD on some versions of FreeBSD[78]. Option -j and -z
is now accepted but ignored.

Compressed ar(1) archives are not useful without a ld(1) that can read
them. Also, the current ar(1) compression scheme prevents random
access of archive members and needs to be redesigned anyway.

Submitted by:	kientzle (original patch)
Reviewed by:	delphij
Discussed on:	-current mailing list
This commit is contained in:
kaiw 2010-05-17 09:37:59 +00:00
parent bd4ac448d7
commit e87f2d48bc
7 changed files with 11 additions and 40 deletions

View File

@ -3,8 +3,8 @@
PROG= ar PROG= ar
SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ} ${LIBLZMA} ${LIBELF} DPADD= ${LIBARCHIVE} ${LIBELF}
LDADD= -larchive -lbz2 -lz -llzma -lelf LDADD= -larchive -lelf
CFLAGS+=-I. -I${.CURDIR} CFLAGS+=-I. -I${.CURDIR}

View File

@ -250,7 +250,7 @@ arscp_open(char *fname)
if ((a = archive_read_new()) == NULL) if ((a = archive_read_new()) == NULL)
bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed");
archive_read_support_compression_all(a); archive_read_support_compression_none(a);
archive_read_support_format_ar(a); archive_read_support_format_ar(a);
AC(archive_read_open_file(a, fname, DEF_BLKSZ)); AC(archive_read_open_file(a, fname, DEF_BLKSZ));
if ((r = archive_read_next_header(a, &entry))) if ((r = archive_read_next_header(a, &entry)))

View File

@ -23,7 +23,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd August 31, 2007 .Dd May 17, 2010
.Dt AR 1 .Dt AR 1
.Os .Os
.Sh NAME .Sh NAME
@ -186,8 +186,7 @@ Synonymous with option
Synonymous with option Synonymous with option
.Fl b . .Fl b .
.It Fl j .It Fl j
Compress the resulting archive with This option is accepted but ignored.
.Xr bzip2 1 .
.It Fl m .It Fl m
Move archive members specified by arguments Move archive members specified by arguments
.Ar files ... .Ar files ...
@ -344,8 +343,7 @@ of extraction unless the
.Fl o .Fl o
option was specified. option was specified.
.It Fl z .It Fl z
Compress the resulting archive with This option is accepted but ignored.
.Xr gzip 1 .
.El .El
.Sh EXAMPLES .Sh EXAMPLES
To create a new archive To create a new archive

View File

@ -178,7 +178,7 @@ main(int argc, char **argv)
bsdar->options |= AR_TR; bsdar->options |= AR_TR;
break; break;
case 'j': case 'j':
bsdar->options |= AR_J; /* ignored */
break; break;
case 'l': case 'l':
/* ignored, for GNU ar comptibility */ /* ignored, for GNU ar comptibility */
@ -223,7 +223,7 @@ main(int argc, char **argv)
set_mode(bsdar, opt); set_mode(bsdar, opt);
break; break;
case 'z': case 'z':
bsdar->options |= AR_Z; /* ignored */
break; break;
case OPTION_HELP: case OPTION_HELP:
bsdar_usage(); bsdar_usage();

View File

@ -81,7 +81,6 @@ struct bsdar {
const char *addlib; /* target of ADDLIB. */ const char *addlib; /* target of ADDLIB. */
const char *posarg; /* position arg for modifiers -a, -b. */ const char *posarg; /* position arg for modifiers -a, -b. */
char mode; /* program mode */ char mode; /* program mode */
char compression; /* compression mode */
int options; /* command line options */ int options; /* command line options */
const char *progname; /* program name */ const char *progname; /* program name */

View File

@ -87,7 +87,7 @@ read_archive(struct bsdar *bsdar, char mode)
if ((a = archive_read_new()) == NULL) if ((a = archive_read_new()) == NULL)
bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed");
archive_read_support_compression_all(a); archive_read_support_compression_none(a);
archive_read_support_format_ar(a); archive_read_support_format_ar(a);
AC(archive_read_open_file(a, bsdar->filename, DEF_BLKSZ)); AC(archive_read_open_file(a, bsdar->filename, DEF_BLKSZ));

View File

@ -247,7 +247,7 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv)
if ((a = archive_read_new()) == NULL) if ((a = archive_read_new()) == NULL)
bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed"); bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_read_new failed");
archive_read_support_compression_all(a); archive_read_support_compression_none(a);
archive_read_support_format_ar(a); archive_read_support_format_ar(a);
AC(archive_read_open_filename(a, archive, DEF_BLKSZ)); AC(archive_read_open_filename(a, archive, DEF_BLKSZ));
for (;;) { for (;;) {
@ -264,13 +264,6 @@ read_objs(struct bsdar *bsdar, const char *archive, int checkargv)
continue; continue;
} }
/*
* Remember the compression mode of existing archive.
* If neither -j nor -z is specified, this mode will
* be used for resulting archive.
*/
bsdar->compression = archive_compression(a);
name = archive_entry_pathname(entry); name = archive_entry_pathname(entry);
/* /*
@ -360,9 +353,6 @@ write_archive(struct bsdar *bsdar, char mode)
pos = NULL; pos = NULL;
memset(&sb, 0, sizeof(sb)); memset(&sb, 0, sizeof(sb));
/* By default, no compression is assumed. */
bsdar->compression = ARCHIVE_COMPRESSION_NONE;
/* /*
* Test if the specified archive exists, to figure out * Test if the specified archive exists, to figure out
* whether we are creating one here. * whether we are creating one here.
@ -618,23 +608,7 @@ write_objs(struct bsdar *bsdar)
bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed"); bsdar_errc(bsdar, EX_SOFTWARE, 0, "archive_write_new failed");
archive_write_set_format_ar_svr4(a); archive_write_set_format_ar_svr4(a);
archive_write_set_compression_none(a);
/* The compression mode of the existing archive is used
* for the result archive or if creating a new archive, we
* do not compress archive by default. This default behavior can
* be overrided by compression mode specified explicitly
* through command line option `-j' or `-z'.
*/
if (bsdar->options & AR_J)
bsdar->compression = ARCHIVE_COMPRESSION_BZIP2;
if (bsdar->options & AR_Z)
bsdar->compression = ARCHIVE_COMPRESSION_GZIP;
if (bsdar->compression == ARCHIVE_COMPRESSION_BZIP2)
archive_write_set_compression_bzip2(a);
else if (bsdar->compression == ARCHIVE_COMPRESSION_GZIP)
archive_write_set_compression_gzip(a);
else
archive_write_set_compression_none(a);
AC(archive_write_open_filename(a, bsdar->filename)); AC(archive_write_open_filename(a, bsdar->filename));