summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>1999-07-28 12:35:01 +0000
committerMarc Espie <espie@cvs.openbsd.org>1999-07-28 12:35:01 +0000
commit4ba389467a778ed9562e3d53a1a67ec17977658f (patch)
treea0be693533ded80ae923822aa2f5f30aa1f23d8b
parent94736b728ec2d7801ae915b6c338153bde974527 (diff)
Use new tar -T option.
Removes an annoying limit on PLIST lengths.
-rw-r--r--usr.sbin/pkg_install/create/perform.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 6f6c94c2282..02e6fc84b1d 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: perform.c,v 1.8 1999/02/26 16:13:31 espie Exp $ */
+/* $OpenBSD: perform.c,v 1.9 1999/07/28 12:35:00 espie Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: perform.c,v 1.8 1999/02/26 16:13:31 espie Exp $";
+static const char *rcsid = "$OpenBSD: perform.c,v 1.9 1999/07/28 12:35:00 espie Exp $";
#endif
/*
@@ -219,9 +219,13 @@ make_dist(char *home, char *pkg, char *suffix, package_t *plist)
plist_t *p;
int ret;
#define DIST_MAX_ARGS 4096
- char *args[DIST_MAX_ARGS]; /* Much more than enough. */
+ char *args[DIST_MAX_ARGS];
+ char *tempfile[DIST_MAX_ARGS/2];
+ int current = 0;
+ FILE *flist = 0;
int nargs = 0;
int pipefds[2];
+ int i;
FILE *totar;
pid_t pid;
@@ -270,15 +274,31 @@ make_dist(char *home, char *pkg, char *suffix, package_t *plist)
for (p = plist->head; p; p = p->next) {
if (nargs > (DIST_MAX_ARGS - 2))
errx(2, "too many args for tar command");
- if (p->type == PLIST_FILE)
- args[nargs++] = p->name;
+ if (p->type == PLIST_FILE) {
+ if (!flist) {
+ int fd;
+ tempfile[current] = strdup("/tmp/tpkg.XXXXXXXXXX");
+ if ((fd = mkstemp(tempfile[current])) == -1)
+ errx(2, "can't make temp file");
+ if (! (flist = fdopen(fd, "w")))
+ errx(2, "can't write to temp file");
+ args[nargs++] = "-T";
+ args[nargs++] = tempfile[current++];
+ }
+ fprintf(flist, "%s\n", p->name);
+ }
else if (p->type == PLIST_CWD || p->type == PLIST_SRC) {
+ if (flist)
+ fclose(flist);
+ flist = 0;
args[nargs++] = "-C";
args[nargs++] = p->name;
}
else if (p->type == PLIST_IGNORE)
p = p->next;
}
+ if (flist)
+ fclose(flist);
args[nargs] = NULL;
/* fork/exec tar to create the package */
@@ -288,9 +308,13 @@ make_dist(char *home, char *pkg, char *suffix, package_t *plist)
err(2, "failed to fork");
else if ( pid == 0 ) {
execv("/bin/tar", args);
+ for (i = 0; i < current; i++)
+ unlink(tempfile[i]);
err(2, "failed to execute tar command");
}
wait(&ret);
+ for (i = 0; i < current; i++)
+ unlink(tempfile[i]);
/* assume either signal or bad exit is enough for us */
if (ret) {
cleanup(0);