From a9c42a23880204e78eba40497fd132a496f73ec7 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Fri, 3 Sep 1993 23:01:17 +0000 Subject: [PATCH] Lots of misc tweaks, support for arbitrary separators in pkg_info, more intelligent name handling in pkg_create. Most of these files are changed because of rcsid's being different in my cvs tree and freefall's (foo). --- usr.sbin/pkg_install/add/Makefile | 2 +- usr.sbin/pkg_install/add/add.h | 2 +- usr.sbin/pkg_install/add/extract.c | 2 +- usr.sbin/pkg_install/add/futil.c | 2 +- usr.sbin/pkg_install/add/main.c | 2 +- usr.sbin/pkg_install/add/perform.c | 2 +- usr.sbin/pkg_install/create/Makefile | 2 +- usr.sbin/pkg_install/create/create.h | 2 +- usr.sbin/pkg_install/create/main.c | 2 +- usr.sbin/pkg_install/create/perform.c | 11 +++++-- usr.sbin/pkg_install/create/pkg_create.1 | 3 ++ usr.sbin/pkg_install/create/pl.c | 2 +- usr.sbin/pkg_install/delete/Makefile | 2 +- usr.sbin/pkg_install/delete/main.c | 2 +- usr.sbin/pkg_install/delete/perform.c | 2 +- usr.sbin/pkg_install/info/Makefile | 2 +- usr.sbin/pkg_install/info/info.h | 3 +- usr.sbin/pkg_install/info/main.c | 10 ++++-- usr.sbin/pkg_install/info/perform.c | 16 +++++----- usr.sbin/pkg_install/info/pkg_info.1 | 9 ++++++ usr.sbin/pkg_install/info/show.c | 6 ++-- usr.sbin/pkg_install/lib/Makefile | 1 + usr.sbin/pkg_install/lib/exec.c | 2 +- usr.sbin/pkg_install/lib/file.c | 2 +- usr.sbin/pkg_install/lib/lib.h | 6 ++-- usr.sbin/pkg_install/lib/msg.c | 2 +- usr.sbin/pkg_install/lib/pen.c | 2 +- usr.sbin/pkg_install/lib/plist.c | 40 ++++++++++++++++++++++-- 28 files changed, 101 insertions(+), 40 deletions(-) diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile index d91baba68b7b..8ac76a6d51cd 100644 --- a/usr.sbin/pkg_install/add/Makefile +++ b/usr.sbin/pkg_install/add/Makefile @@ -1,6 +1,6 @@ PROG= pkg_add -CFLAGS+= -I${.CURDIR}/../lib +CFLAGS+= ${DEBUG} -I${.CURDIR}/../lib LDADD+= -L${.CURDIR}/../lib -linstall SRCS= main.c perform.c futil.c extract.c diff --git a/usr.sbin/pkg_install/add/add.h b/usr.sbin/pkg_install/add/add.h index 8206f0fb4708..6c5d46f77327 100644 --- a/usr.sbin/pkg_install/add/add.h +++ b/usr.sbin/pkg_install/add/add.h @@ -1,4 +1,4 @@ -/* $Id: add.h,v 1.3 1993/08/24 09:23:13 jkh Exp $ */ +/* $Id: add.h,v 1.4 1993/09/04 05:06:25 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c index 62ae03e3acc9..84160f74d66b 100644 --- a/usr.sbin/pkg_install/add/extract.c +++ b/usr.sbin/pkg_install/add/extract.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: extract.c,v 1.4 1993/08/24 09:23:14 jkh Exp $"; +static const char *rcsid = "$Id: extract.c,v 1.5 1993/09/04 05:06:26 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c index 2b70f5b967fd..423f69694427 100644 --- a/usr.sbin/pkg_install/add/futil.c +++ b/usr.sbin/pkg_install/add/futil.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: futil.c,v 1.3 1993/08/26 08:12:25 jkh Exp $"; +static const char *rcsid = "$Id: futil.c,v 1.4 1993/09/04 05:06:27 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index 679dd12ca0ce..cb8cc65d2854 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -1,5 +1,5 @@ #ifndef lint -static char *rcsid = "$Id: main.c,v 1.5 1993/08/26 08:46:54 jkh Exp $"; +static char *rcsid = "$Id: main.c,v 1.6 1993/09/04 05:06:28 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index c86922b5c5e3..64203e552d4e 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: perform.c,v 1.7 1993/08/26 08:46:55 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.8 1993/09/04 05:06:29 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/create/Makefile b/usr.sbin/pkg_install/create/Makefile index 01e6b20c2c56..795ec24a7ca3 100644 --- a/usr.sbin/pkg_install/create/Makefile +++ b/usr.sbin/pkg_install/create/Makefile @@ -1,6 +1,6 @@ PROG= pkg_create -CFLAGS+= -I${.CURDIR}/../lib +CFLAGS+= ${DEBUG} -I${.CURDIR}/../lib LDADD+= -L${.CURDIR}/../lib -linstall SRCS= main.c perform.c pl.c diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h index 2e1e73c3644d..4db51dbe5d55 100644 --- a/usr.sbin/pkg_install/create/create.h +++ b/usr.sbin/pkg_install/create/create.h @@ -1,4 +1,4 @@ -/* $Id: create.h,v 1.3 1993/08/24 09:23:32 jkh Exp $ */ +/* $Id: create.h,v 1.4 1993/09/04 05:06:32 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index 63f669939678..4697c6f86f5f 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: main.c,v 1.3 1993/08/20 08:52:39 jkh Exp $"; +static const char *rcsid = "$Id: main.c,v 1.4 1993/09/04 05:06:33 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 634188b00b61..91102a0eb23c 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.4 1993/08/26 08:12:52 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.5 1993/09/04 05:06:33 jkh Exp $"; #endif /* @@ -62,14 +62,19 @@ pkg_perform(char **pkgs) else suffix = "tgz"; - /* Register the package name (base part) */ - add_plist(&plist, PLIST_NAME, pkg); if (Prefix) add_plist(&plist, PLIST_CWD, Prefix); /* Slurp in the packing list */ read_plist(&plist, pkg_in); + /* + * Run down the list and see if we've named it, if not stick in a name + * at the top. + */ + if (!in_plist(&plist, PLIST_NAME)) + add_plist_top(&plist, PLIST_NAME, pkg); + /* Make a directory to stomp around in */ home = make_playpen(); signal(SIGINT, cleanup); diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index dd0e967714a4..68220659e747 100644 --- a/usr.sbin/pkg_install/create/pkg_create.1 +++ b/usr.sbin/pkg_install/create/pkg_create.1 @@ -121,6 +121,9 @@ in the packing list. Briefly described, these sequences are: Sets the internal directory pointer to point to .I directory. All subsequent filenames will be assumed relative to this directory. +Note: +.BI @cd +is also an alias for this command. .TP .BI "@exec\ " command Execute diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c index 3b9a2d048388..e1b6e36e0971 100644 --- a/usr.sbin/pkg_install/create/pl.c +++ b/usr.sbin/pkg_install/create/pl.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: pl.c,v 1.4 1993/08/26 08:12:53 jkh Exp $"; +static const char *rcsid = "$Id: pl.c,v 1.5 1993/09/04 05:06:34 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile index 16a110f92a26..5631cdfd85e7 100644 --- a/usr.sbin/pkg_install/delete/Makefile +++ b/usr.sbin/pkg_install/delete/Makefile @@ -1,6 +1,6 @@ PROG= pkg_delete -CFLAGS+= -I${.CURDIR}/../lib +CFLAGS+= ${DEBUG} -I${.CURDIR}/../lib LDADD+= -L${.CURDIR}/../lib -linstall SRCS= main.c perform.c diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 63bc65da0128..a66edfd5967d 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -1,5 +1,5 @@ #ifndef lint -static char *rcsid = "$Id: main.c,v 1.4 1993/08/26 08:47:02 jkh Exp $"; +static char *rcsid = "$Id: main.c,v 1.5 1993/09/04 05:06:38 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 2694a0ac125f..b806e479e4ad 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: perform.c,v 1.1 1993/08/20 08:53:36 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.2 1993/09/04 05:06:39 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile index 2b4f04e0d7ac..60b543331bfb 100644 --- a/usr.sbin/pkg_install/info/Makefile +++ b/usr.sbin/pkg_install/info/Makefile @@ -1,6 +1,6 @@ PROG= pkg_info -CFLAGS+= -I${.CURDIR}/../lib +CFLAGS+= ${DEBUG} -I${.CURDIR}/../lib LDADD+= -L${.CURDIR}/../lib -linstall SRCS= main.c perform.c show.c diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 9584afb04cb2..3b9195d5bd33 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -1,4 +1,4 @@ -/* $Id: info.h,v 1.3 1993/08/26 08:47:04 jkh Exp $ */ +/* $Id: info.h,v 1.4 1993/09/04 05:06:40 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance @@ -34,6 +34,7 @@ extern int Flags; extern Boolean AllInstalled; +extern char *InfoPrefix; 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 9a5e540ae81a..90e9e70c2608 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -1,5 +1,5 @@ #ifndef lint -static char *rcsid = "$Header: /usr1/cvs/jkh/pkg_install/info/main.c,v 1.4 1993/08/26 08:47:05 jkh Exp $"; +static char *rcsid = "$Header: /usr1/cvs/jkh/pkg_install/info/main.c,v 1.5 1993/09/04 05:06:41 jkh Exp $"; #endif /* @@ -26,10 +26,11 @@ static char *rcsid = "$Header: /usr1/cvs/jkh/pkg_install/info/main.c,v 1.4 1993/ #include "lib.h" #include "info.h" -static char Options[] = "acdfikrpIvh"; +static char Options[] = "acdfikrpIvhl:"; int Flags = 0; Boolean AllInstalled = FALSE; +char *InfoPrefix = ""; int main(int argc, char **argv) @@ -84,6 +85,10 @@ main(int argc, char **argv) Flags |= SHOW_REQUIRE; break; + case 'l': + InfoPrefix = optarg; + break; + case 'h': case '?': default: @@ -132,6 +137,7 @@ usage(const char *name, const char *fmt, ...) fprintf(stderr, "-k show deinstall script\n"); fprintf(stderr, "-r show requirements script\n"); fprintf(stderr, "-p show prefix\n"); + fprintf(stderr, "-l Prefix each info catagory with \n"); fprintf(stderr, "-v show all information\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 3a3842186c0e..d3df042cbcb8 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: perform.c,v 1.3 1993/08/26 08:47:06 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.4 1993/09/04 05:06:43 jkh Exp $"; #endif /* @@ -117,19 +117,19 @@ pkg_do(char *pkg) } else { /* Start showing the package contents */ - printf(" Information for %s:\n\n", pkg); + printf("%sInformation for %s:\n\n", InfoPrefix, pkg); if (Flags & SHOW_COMMENT) - show_file(" Comment:\n", COMMENT_FNAME); + show_file("Comment:\n", COMMENT_FNAME); if (Flags & SHOW_DESC) - show_file(" Description:\n", DESC_FNAME); + show_file("Description:\n", DESC_FNAME); if (Flags & SHOW_PLIST) - show_plist(" Packing list:\n", &plist, (plist_t)-1); + show_plist("Packing list:\n", &plist, (plist_t)-1); if ((Flags & SHOW_INSTALL) && fexists(INSTALL_FNAME)) - show_file(" Install script:\n", INSTALL_FNAME); + show_file("Install script:\n", INSTALL_FNAME); if ((Flags & SHOW_DEINSTALL) && fexists(DEINSTALL_FNAME)) - show_file(" De-Install script:\n", DEINSTALL_FNAME); + show_file("De-Install script:\n", DEINSTALL_FNAME); if (Flags & SHOW_PREFIX) - show_plist(" Prefix(s):\n", &plist, PLIST_CWD); + show_plist("Prefix(s):\n", &plist, PLIST_CWD); putchar('\014'); } free_plist(&plist); diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1 index d74c1ffbca40..2746d30156ee 100644 --- a/usr.sbin/pkg_install/info/pkg_info.1 +++ b/usr.sbin/pkg_install/info/pkg_info.1 @@ -62,6 +62,15 @@ Show the de-install script (if any) for each package. .TP .B \-r Show the requirements script (if any) for each package. +.TP +.BI "\-l\ " str +Prefix each catagory of information shown with +.I str. +This is primarily of use to front-end programs who want to request a +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. .PP .SH "TECHNICAL DETAILS" Package info is either extracted from files supplied on the diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 8e73e88fe100..b18c162b6c88 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: show.c,v 1.3 1993/08/26 08:47:07 jkh Exp $"; +static const char *rcsid = "$Id: show.c,v 1.4 1993/09/04 05:06:44 jkh Exp $"; #endif /* @@ -32,7 +32,7 @@ show_file(char *title, char *fname) char line[1024]; int n; - printf(title); + printf("%s%s", InfoPrefix, title); fp = fopen(fname, "r"); if (!fp) { whinge("show_file: Can't open '%s' for reading.", fname); @@ -51,7 +51,7 @@ show_plist(char *title, Package *plist, plist_t type) PackingList p; Boolean ign = FALSE; - printf(title); + printf("%s%s", InfoPrefix, title); p = plist->head; while (p) { if (p->type != type && type != -1) { diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile index d520df542bec..1f802f60a82d 100644 --- a/usr.sbin/pkg_install/lib/Makefile +++ b/usr.sbin/pkg_install/lib/Makefile @@ -1,5 +1,6 @@ LIB= install SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c +CFLAGS+= ${DEBUG} NOPROFILE= yes install: diff --git a/usr.sbin/pkg_install/lib/exec.c b/usr.sbin/pkg_install/lib/exec.c index 6f1a67299b36..5232dd2b4dcf 100644 --- a/usr.sbin/pkg_install/lib/exec.c +++ b/usr.sbin/pkg_install/lib/exec.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: exec.c,v 1.3 1993/08/24 09:24:04 jkh Exp $"; +static const char *rcsid = "$Id: exec.c,v 1.4 1993/09/04 05:06:47 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c index ac7e4d7ac819..9c861514a0c3 100644 --- a/usr.sbin/pkg_install/lib/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: file.c,v 1.5 1993/08/26 08:13:48 jkh Exp $"; +static const char *rcsid = "$Id: file.c,v 1.6 1993/09/04 05:06:48 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 05d43e7f54ae..8c499338c2f5 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -1,4 +1,4 @@ -/* $Id: lib.h,v 1.4 1993/08/24 09:24:07 jkh Exp $ */ +/* $Id: lib.h,v 1.5 1993/09/04 05:06:49 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance @@ -123,10 +123,12 @@ Boolean y_or_n(Boolean, const char *, ...); /* Packing list */ PackingList new_plist_entry(void); PackingList last_plist(Package *); +Boolean in_plist(Package *, plist_t); void free_plist(Package *); void mark_plist(Package *); void csum_plist_entry(char *, PackingList); -void add_plist(Package *, int, char *); +void add_plist(Package *, plist_t, char *); +void add_plist_top(Package *, plist_t, char *); void write_plist(Package *, FILE *); void read_plist(Package *, FILE *); int plist_cmd(char *, char **); diff --git a/usr.sbin/pkg_install/lib/msg.c b/usr.sbin/pkg_install/lib/msg.c index 4c742907cb3a..489fc4767913 100644 --- a/usr.sbin/pkg_install/lib/msg.c +++ b/usr.sbin/pkg_install/lib/msg.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: msg.c,v 1.2 1993/08/16 14:20:18 jkh Exp $"; +static const char *rcsid = "$Id: msg.c,v 1.3 1993/09/04 05:06:50 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c index 8a3416f6b068..c5eee71eea7f 100644 --- a/usr.sbin/pkg_install/lib/pen.c +++ b/usr.sbin/pkg_install/lib/pen.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: pen.c,v 1.1 1993/08/24 09:24:08 jkh Exp $"; +static const char *rcsid = "$Id: pen.c,v 1.2 1993/09/04 05:06:51 jkh Exp $"; #endif /* diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index f2992c6963fb..cd8ae24d9bf8 100644 --- a/usr.sbin/pkg_install/lib/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: plist.c,v 1.5 1993/08/26 08:13:49 jkh Exp $"; +static const char *rcsid = "$Id: plist.c,v 1.6 1993/09/04 05:06:52 jkh Exp $"; #endif /* @@ -26,7 +26,7 @@ static const char *rcsid = "$Id: plist.c,v 1.5 1993/08/26 08:13:49 jkh Exp $"; /* Add an item to a packing list */ void -add_plist(Package *p, int type, char *arg) +add_plist(Package *p, plist_t type, char *arg) { PackingList tmp; @@ -43,6 +43,24 @@ add_plist(Package *p, int type, char *arg) } } +void +add_plist_top(Package *p, plist_t type, char *arg) +{ + PackingList tmp; + + tmp = new_plist_entry(); + tmp->name = copy_string(arg); + tmp->type = type; + + if (!p->head) + p->head = p->tail = tmp; + else { + tmp->next = p->head; + p->head->prev = tmp; + p->head = tmp; + } +} + /* Return the last (most recent) entry in a packing list */ PackingList last_plist(Package *p) @@ -62,6 +80,20 @@ mark_plist(Package *pkg) } } +/* Return whether or not there is an item of 'type' in the list */ +Boolean +in_plist(Package *pkg, plist_t type) +{ + PackingList p = pkg->head; + + while (p) { + if (p->type == type) + return TRUE; + p = p->next; + } + return FALSE; +} + /* Allocate a new packing list entry */ PackingList new_plist_entry(void) @@ -116,6 +148,8 @@ plist_cmd(char *s, char **arg) *arg = sp; if (!strcmp(cmd, "cwd")) return PLIST_CWD; + else if (!strcmp(cmd, "cd")) + return PLIST_CWD; else if (!strcmp(cmd, "exec")) return PLIST_CMD; else if (!strcmp(cmd, "mode")) @@ -226,7 +260,7 @@ delete_package(Boolean ign_err, Package *pkg) if (p->type == PLIST_CWD) { Where = p->name; if (Verbose) - printf("Delete: (CWD to %s)\n", Where); + printf("(CWD to %s)\n", Where); } else if (p->type == PLIST_IGNORE) p = p->next;