diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2008-06-11 00:49:09 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2008-06-11 00:49:09 +0000 |
commit | aca026a36001bd6ccecb84c44ceac1bda62a0147 (patch) | |
tree | b0a27ba27b712622cfffc6f615b3eb3665404bb2 | |
parent | d8660a73c1ac2d9df61c5e2103ed7d788541d702 (diff) |
Add tar -j option that calls bzip2 for compress/decompress. Requires
you to install the bzip2 pkg (or add bzip2 in another way).
ok millert@ otto@ deraadt@ and 'many others'@
man page tweak from jmc@
-rw-r--r-- | bin/pax/ar_io.c | 6 | ||||
-rw-r--r-- | bin/pax/cpio.1 | 13 | ||||
-rw-r--r-- | bin/pax/options.c | 43 | ||||
-rw-r--r-- | bin/pax/pax.1 | 18 | ||||
-rw-r--r-- | bin/pax/tar.1 | 19 |
5 files changed, 66 insertions, 33 deletions
diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index 2b52bd6d738..2a833bb2f65 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar_io.c,v 1.37 2005/08/04 10:02:44 mpf Exp $ */ +/* $OpenBSD: ar_io.c,v 1.38 2008/06/11 00:49:08 pvalchev Exp $ */ /* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94"; #else -static const char rcsid[] = "$OpenBSD: ar_io.c,v 1.37 2005/08/04 10:02:44 mpf Exp $"; +static const char rcsid[] = "$OpenBSD: ar_io.c,v 1.38 2008/06/11 00:49:08 pvalchev Exp $"; #endif #endif /* not lint */ @@ -1284,7 +1284,7 @@ ar_start_gzip(int fd, const char *gzip_program, int wr) close(fds[0]); close(fds[1]); if (execlp(gzip_program, gzip_program, gzip_flags, (char *)NULL) < 0) - err(1, "could not exec"); + err(1, "could not exec %s", gzip_program); /* NOTREACHED */ } } diff --git a/bin/pax/cpio.1 b/bin/pax/cpio.1 index 4d9600cb367..cfe407c4fac 100644 --- a/bin/pax/cpio.1 +++ b/bin/pax/cpio.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cpio.1,v 1.26 2007/05/31 19:19:15 jmc Exp $ +.\" $OpenBSD: cpio.1,v 1.27 2008/06/11 00:49:08 pvalchev Exp $ .\" .\" Copyright (c) 1997 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -23,9 +23,9 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: cpio.1,v 1.26 2007/05/31 19:19:15 jmc Exp $ +.\" $OpenBSD: cpio.1,v 1.27 2008/06/11 00:49:08 pvalchev Exp $ .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 11 2008 $ .Dt CPIO 1 .Os .Sh NAME @@ -34,7 +34,7 @@ .Sh SYNOPSIS .Nm cpio .Fl o -.Op Fl AaBcLvZz +.Op Fl AaBcjLvZz .Op Fl C Ar bytes .Op Fl F Ar archive .Op Fl H Ar format @@ -43,7 +43,7 @@ .Op Ar \*(Gt archive .Nm cpio .Fl i -.Op Fl 6BbcdfmrSstuvZz +.Op Fl 6BbcdfjmrSstuvZz .Op Fl C Ar bytes .Op Fl E Ar file .Op Fl F Ar archive @@ -109,6 +109,9 @@ Old tar format. .It Ar ustar POSIX ustar format. .El +.It Fl j +Compress archive using the bzip2 format. +The bzip2 utility must be installed separately. .It Fl L Follow symbolic links. .It Fl O Ar archive diff --git a/bin/pax/options.c b/bin/pax/options.c index 24d7f5ad744..fa198891e54 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.69 2008/05/28 20:04:59 sobrado Exp $ */ +/* $OpenBSD: options.c,v 1.70 2008/06/11 00:49:08 pvalchev Exp $ */ /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; #else -static const char rcsid[] = "$OpenBSD: options.c,v 1.69 2008/05/28 20:04:59 sobrado Exp $"; +static const char rcsid[] = "$OpenBSD: options.c,v 1.70 2008/06/11 00:49:08 pvalchev Exp $"; #endif #endif /* not lint */ @@ -88,6 +88,7 @@ static int getline_error; #define GZIP_CMD "gzip" /* command to run as gzip */ #define COMPRESS_CMD "compress" /* command to run as compress */ +#define BZIP2_CMD "bzip2" /* command to run as bzip2 */ /* * Format specific routine table - MUST BE IN SORTED ORDER BY NAME @@ -199,7 +200,7 @@ pax_options(int argc, char **argv) /* * process option flags */ - while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0")) + while ((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0")) != -1) { switch (c) { case 'a': @@ -246,6 +247,12 @@ pax_options(int argc, char **argv) iflag = 1; flg |= IF; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + gzip_program = BZIP2_CMD; + break; case 'k': /* * do not clobber files that exist @@ -621,7 +628,7 @@ tar_options(int argc, char **argv) * process option flags */ while ((c = getoldopt(argc, argv, - "b:cef:hmopqruts:vwxzBC:HI:LOPXZ014578")) != -1) { + "b:cef:hjmopqruts:vwxzBC:HI:LOPXZ014578")) != -1) { switch (c) { case 'b': /* @@ -666,6 +673,12 @@ tar_options(int argc, char **argv) */ Lflag = 1; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + gzip_program = BZIP2_CMD; + break; case 'm': /* * do not preserve modification time @@ -1038,7 +1051,7 @@ cpio_options(int argc, char **argv) dflag = 1; act = -1; nodirs = 1; - while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) + while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) switch (c) { case 'a': /* @@ -1075,6 +1088,12 @@ cpio_options(int argc, char **argv) */ act = EXTRACT; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + gzip_program = BZIP2_CMD; + break; case 'k': break; case 'l': @@ -1536,11 +1555,11 @@ void pax_usage(void) { (void)fputs( - "usage: pax [-0cdnOvz] [-E limit] [-f archive] [-G group] [-s replstr]\n" + "usage: pax [-0cdjnOvz] [-E limit] [-f archive] [-G group] [-s replstr]\n" " [-T range] [-U user] [pattern ...]\n" - " pax -r [-0cDdiknOuvYZz] [-E limit] [-f archive] [-G group] [-o options]\n" + " pax -r [-0cDdijknOuvYZz] [-E limit] [-f archive] [-G group] [-o options]\n" " [-p string] [-s replstr] [-T range] [-U user] [pattern ...]\n" - " pax -w [-0adHiLOPtuvXz] [-B bytes] [-b blocksize] [-f archive]\n" + " pax -w [-0adHijLOPtuvXz] [-B bytes] [-b blocksize] [-f archive]\n" " [-G group] [-o options] [-s replstr] [-T range] [-U user]\n" " [-x format] [file ...]\n" " pax -rw [-0DdHikLlnOPtuvXYZ] [-G group] [-p string] [-s replstr]\n" @@ -1558,10 +1577,10 @@ void tar_usage(void) { (void)fputs( - "usage: tar {crtux}[014578befHhLmOoPpqsvwXZz]\n" + "usage: tar {crtux}[014578befHhjLmOoPpqsvwXZz]\n" " [blocking-factor | archive | replstr] [-C directory] [-I file]\n" " [file ...]\n" - " tar {-crtux} [-014578eHhLmOoPpqvwXZz] [-b blocking-factor]\n" + " tar {-crtux} [-014578eHhjLmOoPpqvwXZz] [-b blocking-factor]\n" " [-C directory] [-f archive] [-I file] [-s replstr] [file ...]\n", stderr); exit(1); @@ -1576,9 +1595,9 @@ void cpio_usage(void) { (void)fputs( - "usage: cpio -o [-AaBcLvZz] [-C bytes] [-F archive] [-H format]\n" + "usage: cpio -o [-AaBcjLvZz] [-C bytes] [-F archive] [-H format]\n" " [-O archive] < name-list [> archive]\n" - " cpio -i [-6BbcdfmrSstuvZz] [-C bytes] [-E file] [-F archive] [-H format]\n" + " cpio -i [-6BbcdfjmrSstuvZz] [-C bytes] [-E file] [-F archive] [-H format]\n" " [-I archive] [pattern ...] [< archive]\n" " cpio -p [-adLlmuv] destination-directory < name-list\n", stderr); diff --git a/bin/pax/pax.1 b/bin/pax/pax.1 index 0fb89ca430b..888e9acb5de 100644 --- a/bin/pax/pax.1 +++ b/bin/pax/pax.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pax.1,v 1.52 2007/05/31 19:19:15 jmc Exp $ +.\" $OpenBSD: pax.1,v 1.53 2008/06/11 00:49:08 pvalchev Exp $ .\" $NetBSD: pax.1,v 1.3 1995/03/21 09:07:37 cgd Exp $ .\" .\" Copyright (c) 1992 Keith Muller. @@ -34,7 +34,7 @@ .\" .\" @(#)pax.1 8.4 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: June 11 2008 $ .Dt PAX 1 .Os .Sh NAME @@ -43,7 +43,7 @@ .Sh SYNOPSIS .Bk -words .Nm pax -.Op Fl 0cdnOvz +.Op Fl 0cdjnOvz .Op Fl E Ar limit .Op Fl f Ar archive .Op Fl G Ar group @@ -53,7 +53,7 @@ .Op Ar pattern ... .Nm pax .Fl r -.Op Fl 0cDdiknOuvYZz +.Op Fl 0cDdijknOuvYZz .Op Fl E Ar limit .Op Fl f Ar archive .Op Fl G Ar group @@ -65,7 +65,7 @@ .Op Ar pattern ... .Nm pax .Fl w -.Op Fl 0adHiLOPtuvXz +.Op Fl 0adHijLOPtuvXz .Op Fl B Ar bytes .Op Fl b Ar blocksize .Op Fl f Ar archive @@ -78,7 +78,7 @@ .Op Ar file ... .Nm pax .Fl rw -.Op Fl 0DdHikLlnOPtuvXYZ +.Op Fl 0DdHijkLlnOPtuvXYZ .Op Fl G Ar group .Op Fl p Ar string .Op Fl s Ar replstr @@ -442,6 +442,11 @@ will immediately exit with a non-zero exit status if is encountered when reading a response or if .Pa /dev/tty cannot be opened for reading and writing. +.It Fl j +Use bzip2 to compress (decompress) the archive while writing (reading). +The bzip2 utility must be installed separately. +Incompatible with +.Fl a . .It Fl k Do not overwrite existing files. .It Fl L @@ -945,6 +950,7 @@ Incompatible with The options that operate on the names of files or archive members .Po Fl c , .Fl i , +.Fl j , .Fl n , .Fl s , .Fl u , diff --git a/bin/pax/tar.1 b/bin/pax/tar.1 index a439066ee1a..a411bc0c15a 100644 --- a/bin/pax/tar.1 +++ b/bin/pax/tar.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tar.1,v 1.49 2008/05/28 20:04:59 sobrado Exp $ +.\" $OpenBSD: tar.1,v 1.50 2008/06/11 00:49:08 pvalchev Exp $ .\" .\" Copyright (c) 1996 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -23,9 +23,9 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: tar.1,v 1.49 2008/05/28 20:04:59 sobrado Exp $ +.\" $OpenBSD: tar.1,v 1.50 2008/06/11 00:49:08 pvalchev Exp $ .\" -.Dd $Mdocdate: May 28 2008 $ +.Dd $Mdocdate: June 11 2008 $ .Dt TAR 1 .Os .Sh NAME @@ -34,7 +34,7 @@ .Sh SYNOPSIS .Nm tar .Sm off -.No { Cm crtux No } Op Cm 014578befHhLmOoPpqsvwXZz +.No { Cm crtux No } Op Cm 014578befHhjLmOoPpqsvwXZz .Sm on .Bk -words .Op Ar blocking-factor | archive | replstr @@ -44,7 +44,7 @@ .Ek .Nm tar .No { Ns Fl crtux Ns } -.Op Fl 014578eHhLmOoPpqvwXZz +.Op Fl 014578eHhjLmOoPpqvwXZz .Op Fl b Ar blocking-factor .Op Fl C Ar directory .Op Fl f Ar archive @@ -157,6 +157,9 @@ link ultimately points to. .It Fl I Ar file This is a positional argument which reads the names of files to archive or extract from the given file, one per line. +.It Fl j +Compress archive using bzip2. +The bzip2 utility must be installed separately. .It Fl L Synonym for the .Fl h @@ -376,7 +379,9 @@ command first appeared in Keith Muller at the University of California, San Diego. .Sh CAVEATS The +.Fl j +and .Fl L -flag is not portable to other versions of +flags are not portable to other versions of .Nm -where it may have a different meaning. +where they may have a different meaning. |