summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1993-09-05 04:54:24 +0000
committerjkh <jkh@FreeBSD.org>1993-09-05 04:54:24 +0000
commite9a6985275ef309d1f9f603df83efd30018f94f8 (patch)
tree5237df764835d2c29873982e973a10aa873c31b3 /usr.sbin/pkg_install
parent443968adfa831a25c1830da2ba42acd56b84322f (diff)
downloadFreeBSD-src-e9a6985275ef309d1f9f603df83efd30018f94f8.zip
FreeBSD-src-e9a6985275ef309d1f9f603df83efd30018f94f8.tar.gz
Made staging area configurable rather than assuming /tmp (-t)
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/create/create.h1
-rw-r--r--usr.sbin/pkg_install/create/main.c8
-rw-r--r--usr.sbin/pkg_install/create/perform.c4
-rw-r--r--usr.sbin/pkg_install/create/pkg_create.116
-rw-r--r--usr.sbin/pkg_install/info/info.h1
-rw-r--r--usr.sbin/pkg_install/info/main.c6
-rw-r--r--usr.sbin/pkg_install/info/perform.c2
-rw-r--r--usr.sbin/pkg_install/info/pkg_info.114
-rw-r--r--usr.sbin/pkg_install/lib/file.c3
-rw-r--r--usr.sbin/pkg_install/lib/lib.h4
-rw-r--r--usr.sbin/pkg_install/lib/pen.c15
-rw-r--r--usr.sbin/pkg_install/lib/plist.c32
12 files changed, 97 insertions, 9 deletions
diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h
index 4db51db..aaf96a2 100644
--- a/usr.sbin/pkg_install/create/create.h
+++ b/usr.sbin/pkg_install/create/create.h
@@ -30,6 +30,7 @@ extern char *Install;
extern char *DeInstall;
extern char *Contents;
extern char *Require;
+extern char *PlayPen;
void check_list(char *, Package *);
void usage(const char *, const char *, ...);
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c
index 4697c6f..a82fb1f 100644
--- a/usr.sbin/pkg_install/create/main.c
+++ b/usr.sbin/pkg_install/create/main.c
@@ -16,7 +16,7 @@ static const char *rcsid = "$Id: main.c,v 1.4 1993/09/04 05:06:33 jkh Exp $";
#include "lib.h"
#include "create.h"
-static char Options[] = "hvf:p:c:d:i:k:r:";
+static char Options[] = "hvf:p:c:d:i:k:r:t:";
char *Prefix = NULL;
char *Comment = NULL;
@@ -25,6 +25,7 @@ char *Install = NULL;
char *DeInstall = NULL;
char *Contents = NULL;
char *Require = NULL;
+char *PlayPen = NULL;
int
main(int argc, char **argv)
@@ -68,6 +69,10 @@ main(int argc, char **argv)
Require = optarg;
break;
+ case 't':
+ PlayPen = optarg;
+ break;
+
case 'h':
case '?':
default:
@@ -120,6 +125,7 @@ usage(const char *name, const char *fmt, ...)
fprintf(stderr, "-p arg install prefix will be arg\n");
fprintf(stderr, "-k script de-install script\n");
fprintf(stderr, "-r script pre/post requirements script\n");
+ fprintf(stderr, "-t temp use temp as template for mktemp()\n");
fprintf(stderr, "-v verbose\n");
exit(1);
}
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 7697f45..747a3ef 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.2 1993/09/03 23:00:55 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.5 1993/09/04 05:06:33 jkh Exp $";
#endif
/*
@@ -76,7 +76,7 @@ pkg_perform(char **pkgs)
add_plist_top(&plist, PLIST_NAME, pkg);
/* Make a directory to stomp around in */
- home = make_playpen();
+ home = make_playpen(PlayPen);
signal(SIGINT, cleanup);
signal(SIGHUP, cleanup);
diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1
index 6822065..344ccea 100644
--- a/usr.sbin/pkg_install/create/pkg_create.1
+++ b/usr.sbin/pkg_install/create/pkg_create.1
@@ -106,6 +106,18 @@ executable program (or shell script). It will be invoked automatically
at installation/deinstallation time to determine whether or not
installation/deinstallation should proceed.
.B "Optional."
+.TP
+.BI "\-t\ " template
+Use
+.I template
+as the input to mktemp(3). By default, this is the string
+.B /tmp/instmp.XXXXXX,
+but it may be necessary to override it in the situation where
+space in your
+.B /tmp
+directory is limited. Be sure to leave some number of `X' characters
+for mktemp(3) to fill in with a unique ID.
+.B "Optional."
.PP
.SH "TECHNICAL DETAILS"
The "packing list" format (see \fB-f\fR) is fairly simple, being
@@ -174,8 +186,8 @@ put at the top. This name is potentially different than the name of
the file it came in, and is used when keeping track of the package
for later deinstallation. Note that
.B pkg_create
-currently derives this field from the package name and adds it
-automatically.
+will derive this field from the package name and add it automatically
+if none is given.
.SH BUGS
Sure to be some.
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h
index 3b9195d..272ae79 100644
--- a/usr.sbin/pkg_install/info/info.h
+++ b/usr.sbin/pkg_install/info/info.h
@@ -35,6 +35,7 @@
extern int Flags;
extern Boolean AllInstalled;
extern char *InfoPrefix;
+extern char *PlayPen;
extern void show_file(char *, char *);
extern void show_plist(char *, Package *, plist_t);
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 90e9e70..595a874 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -31,6 +31,7 @@ static char Options[] = "acdfikrpIvhl:";
int Flags = 0;
Boolean AllInstalled = FALSE;
char *InfoPrefix = "";
+char *PlayPen = NULL;
int
main(int argc, char **argv)
@@ -89,6 +90,10 @@ main(int argc, char **argv)
InfoPrefix = optarg;
break;
+ case 't':
+ PlayPen = optarg;
+ break;
+
case 'h':
case '?':
default:
@@ -139,6 +144,7 @@ usage(const char *name, const char *fmt, ...)
fprintf(stderr, "-p show prefix\n");
fprintf(stderr, "-l <str> Prefix each info catagory with <str>\n");
fprintf(stderr, "-v show all information\n");
+ fprintf(stderr, "-t temp use temp as template for mktemp()\n");
fprintf(stderr, "\n[no args = -c -d]\n");
exit(1);
}
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index d3df042..f70a604 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -71,7 +71,7 @@ pkg_do(char *pkg)
if (fexists(pkg)) {
char fname[FILENAME_MAX];
- home = make_playpen();
+ home = make_playpen(PlayPen);
if (pkg[0] == '/')
strcpy(fname, pkg);
else
diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1
index 2746d30..18434c9 100644
--- a/usr.sbin/pkg_install/info/pkg_info.1
+++ b/usr.sbin/pkg_install/info/pkg_info.1
@@ -71,6 +71,20 @@ lot of different information fields at once for a package, but don't
necessary want the output intermingled in such a way that they can't
organize it. This lets you add a special token to the start of
each field.
+.BI "\-t\ " template
+Use
+.I template
+as the input to mktemp(3). By default, this is the string
+.B /tmp/instmp.XXXXXX
+, but it may be necessary to override it in the situation where
+space in your
+.B /tmp
+directory is limited. Be sure to leave some number of `X' characters
+for mktemp(3) to fill in with a unique ID.
+Note: This should really not be necessary with pkg_info,
+since very little information is extracted from each package
+and one would have to have a very small /tmp indeed to overflow
+it.
.PP
.SH "TECHNICAL DETAILS"
Package info is either extracted from files supplied on the
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 9c86151..106a535 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -135,6 +135,9 @@ copy_hierarchy(char *dir, char *fname, Boolean to)
}
else
sprintf(cmd, "tar cf - %s | tar xpf - -C %s", fname, dir);
+#ifdef DEBUG
+ printf("Using '%s' to copy trees.\n", cmd);
+#endif
if (system(cmd))
barf("copy_file: Couldn't perform '%s'", cmd);
}
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 8c49933..682687c 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -93,8 +93,9 @@ typedef struct _pack Package;
/* Misc */
int vsystem(const char *, ...);
void cleanup(int);
-char *make_playpen(void);
+char *make_playpen(char *);
void leave_playpen(void);
+char *where_playpen(void);
/* String */
char *get_dash_string(char **);
@@ -124,6 +125,7 @@ Boolean y_or_n(Boolean, const char *, ...);
PackingList new_plist_entry(void);
PackingList last_plist(Package *);
Boolean in_plist(Package *, plist_t);
+void plist_delete(Package *, Boolean, plist_t, char *);
void free_plist(Package *);
void mark_plist(Package *);
void csum_plist_entry(char *, PackingList);
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index c5eee71..1872d82 100644
--- a/usr.sbin/pkg_install/lib/pen.c
+++ b/usr.sbin/pkg_install/lib/pen.c
@@ -34,11 +34,13 @@ static char Pen[FILENAME_MAX];
* pathname of previous working directory.
*/
char *
-make_playpen(void)
+make_playpen(char *pen)
{
+ if (!pen)
+ pen = "/tmp/instmp.XXXXXX";
if (!getcwd(Cwd, FILENAME_MAX))
upchuck("getcwd");
- strcpy(Pen, "/tmp/instmp.XXXXXX");
+ strcpy(Pen, pen);
if (!mktemp(Pen))
barf("Can't mktemp '%s'.", Pen);
if (mkdir(Pen, 0755) == FAIL)
@@ -61,3 +63,12 @@ leave_playpen(void)
}
}
+/* Accessor function for telling us where the pen is */
+char *
+where_playpen(void)
+{
+ if (Cwd[0])
+ return Pen;
+ else
+ return NULL;
+}
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
index cd8ae24..8e0d2f8 100644
--- a/usr.sbin/pkg_install/lib/plist.c
+++ b/usr.sbin/pkg_install/lib/plist.c
@@ -94,6 +94,38 @@ in_plist(Package *pkg, plist_t type)
return FALSE;
}
+/*
+ * Delete plist item 'type' in the list (if 'name' is non-null, match it
+ * too.) If 'all' is set, delete all items, not just the first occurance.
+ */
+void
+delete_plist(Package *pkg, Boolean all, plist_t type, char *name)
+{
+ PackingList p = pkg->head;
+
+ while (p) {
+ PackingList pnext = p->next;
+
+ if (p->type == type && (!name || !strcmp(name, p->name))) {
+ free(p->name);
+ if (p->prev)
+ p->prev->next = pnext;
+ else
+ pkg->head = pnext;
+ if (pnext)
+ pnext->prev = p->prev;
+ else
+ pkg->tail = p->prev;
+ free(p);
+ if (!all)
+ return;
+ p = pnext;
+ }
+ else
+ p = p->next;
+ }
+}
+
/* Allocate a new packing list entry */
PackingList
new_plist_entry(void)
OpenPOWER on IntegriCloud