Made staging area configurable rather than assuming /tmp (-t)

This commit is contained in:
Jordan K. Hubbard 1993-09-05 04:54:24 +00:00
parent 368b3399cd
commit e0ab6cb9c7
12 changed files with 97 additions and 9 deletions

View File

@ -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 *, ...);

View File

@ -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);
}

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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)