summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/lib
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-04-22 07:41:02 +0000
committerjkh <jkh@FreeBSD.org>1995-04-22 07:41:02 +0000
commitde203839fac828d56d3d8d330e53a5365b37aa35 (patch)
treed22e0cbc69e23b3540c90724d35317e88c10bbad /usr.sbin/pkg_install/lib
parenta1afd3bc97947971bf64e151359fb2e8e592aa45 (diff)
downloadFreeBSD-src-de203839fac828d56d3d8d330e53a5365b37aa35.zip
FreeBSD-src-de203839fac828d56d3d8d330e53a5365b37aa35.tar.gz
1. Add an new @option directive. You'll understand it better in a moment.
2. Fix a long-standing bug in pkg_add where the failure of one package in a multipackage installation (pkg_add *.tgz) would blow you right out of the water. Ick.
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-rw-r--r--usr.sbin/pkg_install/lib/lib.h6
-rw-r--r--usr.sbin/pkg_install/lib/plist.c41
2 files changed, 37 insertions, 10 deletions
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 80d69f2..c1614fa 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.12 1994/12/06 00:51:49 jkh Exp $ */
+/* $Id: lib.h,v 1.13 1995/04/19 14:02:01 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -81,7 +81,8 @@ enum _plist_t {
PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT,
PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
- PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST
+ PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST,
+ PLIST_OPTION
};
typedef enum _plist_t plist_t;
@@ -139,6 +140,7 @@ Boolean y_or_n(Boolean, const char *, ...);
PackingList new_plist_entry(void);
PackingList last_plist(Package *);
PackingList find_plist(Package *, plist_t);
+char *find_plist_option(Package *, char *name);
void plist_delete(Package *, Boolean, plist_t, char *);
void free_plist(Package *);
void mark_plist(Package *);
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
index d8ea00e..bb2dd5d 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.10 1994/12/06 00:51:50 jkh Exp $";
+static const char *rcsid = "$Id: plist.c,v 1.11 1995/04/22 00:14:20 jkh Exp $";
#endif
/*
@@ -94,6 +94,20 @@ find_plist(Package *pkg, plist_t type)
return NULL;
}
+/* Look for a specific boolean option argument in the list */
+char *
+find_plist_option(Package *pkg, char *name)
+{
+ PackingList p = pkg->head;
+
+ while (p) {
+ if (p->type == PLIST_OPTION && !strcmp(p->name, name))
+ return p->name;
+ p = p->next;
+ }
+ return NULL;
+}
+
/*
* 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.
@@ -210,6 +224,8 @@ plist_cmd(char *s, char **arg)
return PLIST_MTREE;
else if (!strcmp(cmd, "dirrm"))
return PLIST_DIR_RM;
+ else if (!strcmp(cmd, "option"))
+ return PLIST_OPTION;
else
return FAIL;
}
@@ -314,6 +330,10 @@ write_plist(Package *pkg, FILE *fp)
fprintf(fp, "%cdirrm %s\n", CMD_CHAR, plist->name);
break;
+ case PLIST_OPTION:
+ fprintf(fp, "%coption %s\n", CMD_CHAR, plist->name);
+ break;
+
default:
barf("Unknown command type %d (%s)\n", plist->type, plist->name);
break;
@@ -322,7 +342,12 @@ write_plist(Package *pkg, FILE *fp)
}
}
-/* Delete the results of a package installation, not the packaging itself */
+/*
+ * Delete the results of a package installation.
+ *
+ * This is here rather than in the pkg_delete code because pkg_add needs to
+ * run it too in cases of failure.
+ */
int
delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
{
@@ -334,16 +359,16 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
if (p->type == PLIST_CWD) {
Where = p->name;
if (Verbose)
- printf("(CWD to %s)\n", Where);
+ printf("Change working directory to %s\n", CMD_CHAR, Where);
}
else if (p->type == PLIST_UNEXEC) {
char cmd[FILENAME_MAX];
format_cmd(cmd, p->name, Where, last_file);
if (Verbose)
- printf("unexec command: %s\n", cmd);
+ printf("Execute `%s'\n", cmd);
if (!Fake && system(cmd)) {
- whinge("unexec '%s' failed.", cmd);
+ whinge("unexec command for `%s' failed.", cmd);
fail = FAIL;
}
}
@@ -354,7 +379,7 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
sprintf(full_name, "%s/%s", Where, p->name);
if (Verbose)
- printf("Delete%s: %s\n",
+ printf("Delete%s %s\n",
p->type == PLIST_FILE ? "" : " directory", full_name);
if (!Fake && delete_hierarchy(full_name, ign_err,
@@ -386,7 +411,7 @@ delete_hierarchy(char *dir, Boolean ign_err, Boolean nukedirs)
cp1 = cp2 = dir;
if (!fexists(dir)) {
if (!ign_err)
- whinge("%s '%s' doesn't really exist.",
+ whinge("%s `%s' doesn't really exist.",
isdir(dir) ? "Directory" : "File", dir);
} else if (nukedirs) {
if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), dir))
@@ -408,7 +433,7 @@ delete_hierarchy(char *dir, Boolean ign_err, Boolean nukedirs)
return 0;
if (RMDIR(dir) && !ign_err)
if (!fexists(dir))
- whinge("Directory '%s' doesn't really exist.", dir);
+ whinge("Directory `%s' doesn't really exist.", dir);
else
return 1;
/* back up the pathname one component */
OpenPOWER on IntegriCloud