Subject: [PATCH] Re: gnu tar and cpio have been replaced with pax-based versions
To: NetBSD-current Discussion List <current-users@NetBSD.ORG>
From: Eric Gillespie <epg@pretzelnet.org>
List: current-users
Date: 10/17/2002 20:45:50
Eric Gillespie <epg@pretzelnet.org> writes:

> I took a look in pkg_install/create/perform.c.  It passes -T - to
> tar and then writes a list of files to its stdin.  However, it
> apparently expects tar to interpret -C sequences in this list:

I made the following modifications to pax and i can now create
packages in pkgsrc.  I don't know for sure that this is
generally correct though...

Index: options.c
===================================================================
RCS file: /cvsroot/basesrc/bin/pax/options.c,v
retrieving revision 1.54
diff -a -u -r1.54 options.c
--- options.c	2002/10/17 00:42:02	1.54
+++ options.c	2002/10/18 01:42:42
@@ -1069,6 +1069,7 @@
 	default:
 		{
 			int sawpat = 0;
+			int dirisnext = 0;
 			char *file, *dir;
 
 			while (nincfiles || *argv != NULL) {
@@ -1102,10 +1103,22 @@
 						tar_usage();
 					}
 					while ((str = getline(fp)) != NULL) {
+						if (dirisnext) {
+							dir = str;
+							dirisnext = 0;
+							continue;
+						}
+						if (strcmp(str, "-C") == 0) {
+							dirisnext = 1;
+							continue;
+						}
 						if (pat_add(str, dir) < 0)
 							tar_usage();
 						sawpat = 1;
 					}
+					/* Bomb if given -C w/out a dir. */
+					if (dirisnext)
+						tar_usage();
 					if (strcmp(file, "-") != 0)
 						fclose(fp);
 					if (getline_error) {
@@ -1161,6 +1174,7 @@
 			if (file != NULL) {
 				FILE *fp;
 				char *str;
+				int dirisnext = 0;
 
 				/* Set directory if needed */
 				if (dir) {
@@ -1175,9 +1189,22 @@
 					tar_usage();
 				}
 				while ((str = getline(fp)) != NULL) {
+					if (dirisnext) {
+						if (ftree_add(str, 1) < 0)
+							tar_usage();
+						dirisnext = 0;
+						continue;
+					}
+					if (strcmp(str, "-C") == 0) {
+						dirisnext = 1;
+						continue;
+					}
 					if (ftree_add(str, 0) < 0)
 						tar_usage();
 				}
+				/* Bomb if given -C w/out a dir. */
+				if (dirisnext)
+					tar_usage();
 				if (strcmp(file, "-") != 0)
 					fclose(fp);
 				if (getline_error) {


--  
Eric Gillespie <*> epg@pretzelnet.org

Build a fire for a man, and he'll be warm for a day.  Set a man on
fire, and he'll be warm for the rest of his life. -Terry Pratchett