From 95397dc7b6b72fc698fcab6f7d4ac07fc5afc3aa Mon Sep 17 00:00:00 2001 From: jschauma Date: Tue, 8 Jul 2003 18:40:28 +0000 Subject: Synch with latest changes by simonb@ in basesrc and as a result, bump the version to todays date: Add support for gnutar's -O "extract to stdout" option. --- archivers/pax/Makefile | 4 ++-- archivers/pax/files/ar_subs.c | 33 ++++++++++++++++++++------------- archivers/pax/files/extern.h | 3 ++- archivers/pax/files/options.c | 15 ++++++++++----- archivers/pax/files/pax.c | 5 +++-- archivers/pax/files/tar.1 | 5 +++-- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/archivers/pax/Makefile b/archivers/pax/Makefile index 7e65ab7239e..7c9154a5d24 100644 --- a/archivers/pax/Makefile +++ b/archivers/pax/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.3 2003/06/30 11:47:27 grant Exp $ +# $NetBSD: Makefile,v 1.4 2003/07/08 18:40:28 jschauma Exp $ # -DISTNAME= pax-20030630 +DISTNAME= pax-20030708 CATEGORIES= archivers pkgtools MASTER_SITES= # empty DISTFILES= # empty diff --git a/archivers/pax/files/ar_subs.c b/archivers/pax/files/ar_subs.c index 3de91d01804..c5798fc5d02 100644 --- a/archivers/pax/files/ar_subs.c +++ b/archivers/pax/files/ar_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: ar_subs.c,v 1.2 2003/06/23 13:45:07 grant Exp $ */ +/* $NetBSD: ar_subs.c,v 1.3 2003/07/08 18:40:29 jschauma Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -47,7 +47,7 @@ #if 0 static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ar_subs.c,v 1.2 2003/06/23 13:45:07 grant Exp $"); +__RCSID("$NetBSD: ar_subs.c,v 1.3 2003/07/08 18:40:29 jschauma Exp $"); #endif #endif /* not lint */ @@ -313,7 +313,8 @@ extract(void) /* * if required, chdir around. */ - if ((arcn->pat != NULL) && (arcn->pat->chdname != NULL)) + if ((arcn->pat != NULL) && (arcn->pat->chdname != NULL) && + !to_stdout) if (chdir(arcn->pat->chdname) != 0) syswarn(1, errno, "Cannot chdir to %s", arcn->pat->chdname); @@ -341,22 +342,28 @@ extract(void) } continue; } - /* - * we have a file with data here. If we cannot create it, skip - * over the data and purge the name from hard link table - */ - if ((fd = file_creat(arcn)) < 0) { - (void)fflush(listf); - (void)rd_skip(arcn->skip + arcn->pad); - purg_lnk(arcn); - continue; + if (to_stdout) + fd = STDOUT_FILENO; + else { + /* + * we have a file with data here. If we cannot create, + * it, skip over the data and purge the name from hard + * link table. + */ + if ((fd = file_creat(arcn)) < 0) { + (void)fflush(listf); + (void)rd_skip(arcn->skip + arcn->pad); + purg_lnk(arcn); + continue; + } } /* * extract the file from the archive and skip over padding and * any unprocessed data */ res = (*frmt->rd_data)(arcn, fd, &cnt); - file_close(arcn, fd); + if (!to_stdout) + file_close(arcn, fd); if (vflag && vfpart) { (void)putc('\n', listf); vfpart = 0; diff --git a/archivers/pax/files/extern.h b/archivers/pax/files/extern.h index b464e288872..9deec1ebddd 100644 --- a/archivers/pax/files/extern.h +++ b/archivers/pax/files/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.1.1.1 2003/06/23 11:46:17 grant Exp $ */ +/* $NetBSD: extern.h,v 1.2 2003/07/08 18:40:29 jschauma Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -258,6 +258,7 @@ extern int pids; extern int rmleadslash; extern int exit_val; extern int docrc; +extern int to_stdout; extern char *dirptr; extern char *ltmfrmt; extern char *argv0; diff --git a/archivers/pax/files/options.c b/archivers/pax/files/options.c index 9600b2ccf18..88726440ffe 100644 --- a/archivers/pax/files/options.c +++ b/archivers/pax/files/options.c @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.1.1.1 2003/06/23 11:46:25 grant Exp $ */ +/* $NetBSD: options.c,v 1.2 2003/07/08 18:40:30 jschauma Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -47,7 +47,7 @@ #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: options.c,v 1.1.1.1 2003/06/23 11:46:25 grant Exp $"); +__RCSID("$NetBSD: options.c,v 1.2 2003/07/08 18:40:30 jschauma Exp $"); #endif #endif /* not lint */ @@ -725,6 +725,7 @@ struct option tar_longopts[] = { { "gunzip", no_argument, 0, 'z' }, { "read-full-blocks", no_argument, 0, 'B' }, { "directory", required_argument, 0, 'C' }, + { "to-stdout", no_argument, 0, 'O' }, { "absolute-paths", no_argument, 0, 'P' }, { "files-from", required_argument, 0, 'T' }, { "exclude-from", required_argument, 0, 'X' }, @@ -765,7 +766,6 @@ struct option tar_longopts[] = { { "multi-volume", no_argument, 0, 'M' }, { "after-date", required_argument, 0, 'N' }, { "newer", required_argument, 0, 'N' }, - { "to-stdout", no_argument, 0, 'O' }, { "record-number", no_argument, 0, 'R' }, { "remove-files", no_argument, 0, OPT_REMOVE_FILES }, @@ -1092,8 +1092,13 @@ tar_options(int argc, char **argv) if (act == ARCHIVE || act == APPND) frmt = &(fsub[Oflag ? F_TAR : F_USTAR]); else if (Oflag) { - tty_warn(1, "The -O/-o options are only valid when writing an archive"); - tar_usage(); /* only valid when writing */ + if (act == EXTRACT) + to_stdout = 1; + else { + tty_warn(1, "The -O/-o options are only valid when " + "writing or extracting an archive"); + tar_usage(); + } } /* diff --git a/archivers/pax/files/pax.c b/archivers/pax/files/pax.c index d320d3cc035..becbda4c7d8 100644 --- a/archivers/pax/files/pax.c +++ b/archivers/pax/files/pax.c @@ -1,4 +1,4 @@ -/* $NetBSD: pax.c,v 1.2 2003/06/23 13:45:07 grant Exp $ */ +/* $NetBSD: pax.c,v 1.3 2003/07/08 18:40:30 jschauma Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -52,7 +52,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ #if 0 static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pax.c,v 1.2 2003/06/23 13:45:07 grant Exp $"); +__RCSID("$NetBSD: pax.c,v 1.3 2003/07/08 18:40:30 jschauma Exp $"); #endif #endif /* not lint */ @@ -114,6 +114,7 @@ int pids; /* preserve file uid/gid */ int rmleadslash = 0; /* remove leading '/' from pathnames */ int exit_val; /* exit value */ int docrc; /* check/create file crc */ +int to_stdout; /* extract to stdout */ char *dirptr; /* destination dir in a copy */ char *ltmfrmt; /* -v locale time format (if any) */ char *argv0; /* root of argv[0] */ diff --git a/archivers/pax/files/tar.1 b/archivers/pax/files/tar.1 index 86f285608f6..189ebcf88b3 100644 --- a/archivers/pax/files/tar.1 +++ b/archivers/pax/files/tar.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: tar.1,v 1.1.1.1 2003/06/23 11:46:39 grant Exp $ +.\" $NetBSD: tar.1,v 1.2 2003/07/08 18:40:30 jschauma Exp $ .\" .\" Copyright (c) 1996 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -124,7 +124,8 @@ Do not cross filesystems. .It Fl m , -modification-time Do not preserve modification time. .It Fl O -Write old-style (non-POSIX) archives. +When creating and appending to an archive, write old-style (non-POSIX) archives. +When extracting from an archive, extract to standard output. .It Fl o , -portability , -old-archive Don't write directory information that the older (V7) style .Nm -- cgit v1.2.3