Subject: bin/27212: enhanced syntax for '-C cwdname' in pax file lists
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 10/10/2004 15:45:34
>Number: 27212
>Category: bin
>Synopsis: enhanced syntax for '-C cwdname' in tar file lists
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Oct 10 19:46:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Greg A. Woods
>Release: NetBSD-current
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
all
>Description:
it would be nice if pax-as-tar allowed inline use of '-C' in
file lists to follow a more natural form where the directory is
given on the same line as the option is given, e.g.:
file1
-C /tmp/newdir
file2
Note that the documentation for GNU Tar does not specify how
'-C' is supposed to be used in file lists. The documentation
says only:
When using `--files-from' (*note files::.), you can
put `-C' options in the file list. Unfortunately, you
cannot put `--directory' options in the file list.
(This interpretation can be disabled by using the
`--null' option.)
but of course GNU Tar does not actually allow the directory name
to follow on the same line, so this idea is strictly a new
invention.
However it's not my invention as far as I can remember. I'm not
sure exactly where I first found it though.... However I've
been patching it into NetBSD pax for quite a few years now,
initially to make the original "tar" support I hacked into
pkg_install work, and I still use the following patch there to
continue supporting pkgsrc on my older machines:
Index: usr.sbin/pkg_install/create/perform.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/usr.sbin/pkg_install/create/perform.c,v
retrieving revision 1.39
diff -u -r1.39 perform.c
--- create/perform.c 9 Apr 2004 18:27:48 -0000 1.39
+++ create/perform.c 28 Sep 2004 19:37:05 -0000
@@ -34,6 +34,7 @@
#include <err.h>
#include <signal.h>
+#include <sys/param.h> /* possibly for __NetBSD_Version__ */
#include <sys/wait.h>
#include <unistd.h>
@@ -153,7 +183,25 @@
continue;
}
+/*
+ * NetBSD 1.5 and lower used GNU Tar by default.
+ *
+ * We assume all the other losers do to! ;-)
+ */
+#if !defined(__NetBSD_Version__) || (__NetBSD_Version__ < 105000000)
+# undef USE_GNU_TAR
+# define USE_GNU_TAR 1
+#endif
+/*
+ * 1.6J (106100000) corresponds approximately to the time "-C\nnewdir\n"
+ * support was added to NetBSD PAX
+ */
+#if defined(USE_GNU_TAR) || (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106100000))
fprintf(totar, "-C\n%s\n", p->name);
+#else
+ /* in between my version supported the following syntax */
+ fprintf(totar, "-C %s\n", p->name);
+#endif
} else if (p->type == PLIST_IGNORE) {
p = p->next;
}
>How-To-Repeat:
>Fix:
Index: options.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/bin/pax/options.c,v
retrieving revision 1.78
diff -u -r1.78 options.c
--- options.c 26 Sep 2004 23:46:00 -0000 1.78
+++ options.c 28 Sep 2004 18:21:02 -0000
@@ -1153,6 +1153,10 @@
dirisnext = 1;
continue;
}
+ if (strncmp(str, "-C ", 3) == 0) {
+ dir = str + 3;
+ continue;
+ }
if (pat_add(str, dir) < 0)
tar_usage();
sawpat = 1;
@@ -1238,6 +1242,11 @@
}
if (strcmp(str, "-C") == 0) {
dirisnext = 1;
+ continue;
+ }
+ if (strncmp(str, "-C ", 3) == 0) {
+ if (ftree_add(str + 3, 1) < 0)
+ tar_usage();
continue;
}
if (ftree_add(str, 0) < 0)
>Release-Note:
>Audit-Trail:
>Unformatted: