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
+1
View File
@@ -30,6 +30,7 @@ extern char *Install;
extern char *DeInstall; extern char *DeInstall;
extern char *Contents; extern char *Contents;
extern char *Require; extern char *Require;
extern char *PlayPen;
void check_list(char *, Package *); void check_list(char *, Package *);
void usage(const char *, const char *, ...); void usage(const char *, const char *, ...);
+7 -1
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 "lib.h"
#include "create.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 *Prefix = NULL;
char *Comment = NULL; char *Comment = NULL;
@@ -25,6 +25,7 @@ char *Install = NULL;
char *DeInstall = NULL; char *DeInstall = NULL;
char *Contents = NULL; char *Contents = NULL;
char *Require = NULL; char *Require = NULL;
char *PlayPen = NULL;
int int
main(int argc, char **argv) main(int argc, char **argv)
@@ -68,6 +69,10 @@ main(int argc, char **argv)
Require = optarg; Require = optarg;
break; break;
case 't':
PlayPen = optarg;
break;
case 'h': case 'h':
case '?': case '?':
default: default:
@@ -120,6 +125,7 @@ usage(const char *name, const char *fmt, ...)
fprintf(stderr, "-p arg install prefix will be arg\n"); fprintf(stderr, "-p arg install prefix will be arg\n");
fprintf(stderr, "-k script de-install script\n"); fprintf(stderr, "-k script de-install script\n");
fprintf(stderr, "-r script pre/post requirements 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"); fprintf(stderr, "-v verbose\n");
exit(1); exit(1);
} }
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
@@ -76,7 +76,7 @@ pkg_perform(char **pkgs)
add_plist_top(&plist, PLIST_NAME, pkg); add_plist_top(&plist, PLIST_NAME, pkg);
/* Make a directory to stomp around in */ /* Make a directory to stomp around in */
home = make_playpen(); home = make_playpen(PlayPen);
signal(SIGINT, cleanup); signal(SIGINT, cleanup);
signal(SIGHUP, cleanup); signal(SIGHUP, cleanup);
+14 -2
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 at installation/deinstallation time to determine whether or not
installation/deinstallation should proceed. installation/deinstallation should proceed.
.B "Optional." .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 .PP
.SH "TECHNICAL DETAILS" .SH "TECHNICAL DETAILS"
The "packing list" format (see \fB-f\fR) is fairly simple, being 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 the file it came in, and is used when keeping track of the package
for later deinstallation. Note that for later deinstallation. Note that
.B pkg_create .B pkg_create
currently derives this field from the package name and adds it will derive this field from the package name and add it automatically
automatically. if none is given.
.SH BUGS .SH BUGS
Sure to be some. Sure to be some.
+1
View File
@@ -35,6 +35,7 @@
extern int Flags; extern int Flags;
extern Boolean AllInstalled; extern Boolean AllInstalled;
extern char *InfoPrefix; extern char *InfoPrefix;
extern char *PlayPen;
extern void show_file(char *, char *); extern void show_file(char *, char *);
extern void show_plist(char *, Package *, plist_t); extern void show_plist(char *, Package *, plist_t);
+6
View File
@@ -31,6 +31,7 @@ static char Options[] = "acdfikrpIvhl:";
int Flags = 0; int Flags = 0;
Boolean AllInstalled = FALSE; Boolean AllInstalled = FALSE;
char *InfoPrefix = ""; char *InfoPrefix = "";
char *PlayPen = NULL;
int int
main(int argc, char **argv) main(int argc, char **argv)
@@ -89,6 +90,10 @@ main(int argc, char **argv)
InfoPrefix = optarg; InfoPrefix = optarg;
break; break;
case 't':
PlayPen = optarg;
break;
case 'h': case 'h':
case '?': case '?':
default: default:
@@ -139,6 +144,7 @@ usage(const char *name, const char *fmt, ...)
fprintf(stderr, "-p show prefix\n"); fprintf(stderr, "-p show prefix\n");
fprintf(stderr, "-l <str> Prefix each info catagory with <str>\n"); fprintf(stderr, "-l <str> Prefix each info catagory with <str>\n");
fprintf(stderr, "-v show all information\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"); fprintf(stderr, "\n[no args = -c -d]\n");
exit(1); exit(1);
} }
+1 -1
View File
@@ -71,7 +71,7 @@ pkg_do(char *pkg)
if (fexists(pkg)) { if (fexists(pkg)) {
char fname[FILENAME_MAX]; char fname[FILENAME_MAX];
home = make_playpen(); home = make_playpen(PlayPen);
if (pkg[0] == '/') if (pkg[0] == '/')
strcpy(fname, pkg); strcpy(fname, pkg);
else else
+14
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 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 organize it. This lets you add a special token to the start of
each field. 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 .PP
.SH "TECHNICAL DETAILS" .SH "TECHNICAL DETAILS"
Package info is either extracted from files supplied on the Package info is either extracted from files supplied on the
+3
View File
@@ -135,6 +135,9 @@ copy_hierarchy(char *dir, char *fname, Boolean to)
} }
else else
sprintf(cmd, "tar cf - %s | tar xpf - -C %s", fname, dir); 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)) if (system(cmd))
barf("copy_file: Couldn't perform '%s'", cmd); barf("copy_file: Couldn't perform '%s'", cmd);
} }
+3 -1
View File
@@ -93,8 +93,9 @@ typedef struct _pack Package;
/* Misc */ /* Misc */
int vsystem(const char *, ...); int vsystem(const char *, ...);
void cleanup(int); void cleanup(int);
char *make_playpen(void); char *make_playpen(char *);
void leave_playpen(void); void leave_playpen(void);
char *where_playpen(void);
/* String */ /* String */
char *get_dash_string(char **); char *get_dash_string(char **);
@@ -124,6 +125,7 @@ Boolean y_or_n(Boolean, const char *, ...);
PackingList new_plist_entry(void); PackingList new_plist_entry(void);
PackingList last_plist(Package *); PackingList last_plist(Package *);
Boolean in_plist(Package *, plist_t); Boolean in_plist(Package *, plist_t);
void plist_delete(Package *, Boolean, plist_t, char *);
void free_plist(Package *); void free_plist(Package *);
void mark_plist(Package *); void mark_plist(Package *);
void csum_plist_entry(char *, PackingList); void csum_plist_entry(char *, PackingList);
+13 -2
View File
@@ -34,11 +34,13 @@ static char Pen[FILENAME_MAX];
* pathname of previous working directory. * pathname of previous working directory.
*/ */
char * char *
make_playpen(void) make_playpen(char *pen)
{ {
if (!pen)
pen = "/tmp/instmp.XXXXXX";
if (!getcwd(Cwd, FILENAME_MAX)) if (!getcwd(Cwd, FILENAME_MAX))
upchuck("getcwd"); upchuck("getcwd");
strcpy(Pen, "/tmp/instmp.XXXXXX"); strcpy(Pen, pen);
if (!mktemp(Pen)) if (!mktemp(Pen))
barf("Can't mktemp '%s'.", Pen); barf("Can't mktemp '%s'.", Pen);
if (mkdir(Pen, 0755) == FAIL) 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;
}
+32
View File
@@ -94,6 +94,38 @@ in_plist(Package *pkg, plist_t type)
return FALSE; 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 */ /* Allocate a new packing list entry */
PackingList PackingList
new_plist_entry(void) new_plist_entry(void)