summaryrefslogtreecommitdiff
path: root/usr/src/cmd/svr4pkg/installf
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/svr4pkg/installf')
-rw-r--r--usr/src/cmd/svr4pkg/installf/dofinal.c197
-rw-r--r--usr/src/cmd/svr4pkg/installf/installf.h4
-rw-r--r--usr/src/cmd/svr4pkg/installf/main.c74
3 files changed, 117 insertions, 158 deletions
diff --git a/usr/src/cmd/svr4pkg/installf/dofinal.c b/usr/src/cmd/svr4pkg/installf/dofinal.c
index 331ea43810..144bcf3217 100644
--- a/usr/src/cmd/svr4pkg/installf/dofinal.c
+++ b/usr/src/cmd/svr4pkg/installf/dofinal.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -54,7 +54,7 @@ static char *check_db_entry(VFP_T *, struct cfextra *, int, char *, int *);
/*ARGSUSED*/
int
-dofinal(VFP_T *vfp, VFP_T *vfpo, int rmflag, char *myclass, char *prog)
+dofinal(PKGserver server, VFP_T *vfpo, int rmflag, char *myclass, char *prog)
{
struct cfextra entry;
int n, indx, dbchg;
@@ -70,22 +70,22 @@ dofinal(VFP_T *vfp, VFP_T *vfpo, int rmflag, char *myclass, char *prog)
dbchg = 0;
- while (n = srchcfile(&(entry.cf_ent), "*", vfp, vfpo)) {
+ if (pkgopenfilter(server, pkginst) != 0)
+ quit(99);
+
+ while (n = srchcfile(&(entry.cf_ent), "*", server)) {
if (n < 0) {
char *errstr = getErrstr();
- progerr(gettext
- ("bad entry read in contents file"));
- logerr(gettext("pathname=%s"),
- (entry.cf_ent.path &&
- *(entry.cf_ent.path)) ?
- entry.cf_ent.path : "Unknown");
+ progerr(gettext("bad entry read in contents file"));
+ logerr(gettext("pathname=%s"),
+ (entry.cf_ent.path && *(entry.cf_ent.path)) ?
+ entry.cf_ent.path : "Unknown");
logerr(gettext("problem=%s"),
- (errstr && *errstr) ? errstr :
- "Unknown");
+ (errstr && *errstr) ? errstr : "Unknown");
quit(99);
}
- save_path = check_db_entry(
- vfpo, &entry, rmflag, myclass, &dbchg);
+ save_path = check_db_entry(vfpo, &entry, rmflag, myclass,
+ &dbchg);
/* Restore original server-relative path, if needed */
if (save_path != NULL) {
@@ -94,6 +94,8 @@ dofinal(VFP_T *vfp, VFP_T *vfpo, int rmflag, char *myclass, char *prog)
}
}
+ pkgclosefilter(server);
+
return (dbchg);
}
@@ -106,13 +108,11 @@ check_db_entry(VFP_T *vfpo, struct cfextra *entry, int rmflag, char *myclass,
char *save_path = NULL;
char *tp;
- /* write this entry to the contents file */
-
if (myclass && strcmp(myclass, entry->cf_ent.pkg_class)) {
- if (putcvfpfile(&entry->cf_ent, vfpo)) {
- progerr(gettext(ERR_WRITE));
- quit(99);
- }
+ /*
+ * We already have it in the database we don't want
+ * to modify it.
+ */
return (NULL);
}
@@ -131,98 +131,101 @@ check_db_entry(VFP_T *vfpo, struct cfextra *entry, int rmflag, char *myclass,
/*
* If pinfo == NULL at this point, then this file or
* directory isn't part of the package of interest.
- * So the loop below executes only on files in the package
+ * So the code below executes only on files in the package
* of interest.
*/
- save_path = NULL;
+ if (pinfo == NULL)
+ return (NULL);
- if (pinfo) {
- if (rmflag && (pinfo->status == RM_RDY)) {
- *dbchg = 1;
+ if (rmflag && (pinfo->status == RM_RDY)) {
+ *dbchg = 1;
- (void) eptstat(&(entry->cf_ent), pkginst, '@');
+ (void) eptstat(&(entry->cf_ent), pkginst, '@');
- if (entry->cf_ent.npkgs) {
- if (putcvfpfile(&(entry->cf_ent), vfpo)) {
- progerr(gettext(ERR_WRITE));
- quit(99);
- }
+ if (entry->cf_ent.npkgs) {
+ if (putcvfpfile(&(entry->cf_ent), vfpo)) {
+ progerr(gettext(ERR_WRITE));
+ quit(99);
}
- return (NULL);
-
- } else if (!rmflag && (pinfo->status == INST_RDY)) {
- *dbchg = 1;
+ } else if (entry->cf_ent.path != NULL) {
+ (void) vfpSetModified(vfpo);
+ /* add "-<path>" to the file */
+ vfpPutc(vfpo, '-');
+ vfpPuts(vfpo, entry->cf_ent.path);
+ vfpPutc(vfpo, '\n');
+ }
+ return (NULL);
- /* tp is the server-relative path */
- tp = fixpath(entry->cf_ent.path);
- /* save_path is the cmd line path */
- save_path = entry->cf_ent.path;
- /* entry has the server-relative path */
- entry->cf_ent.path = tp;
+ } else if (!rmflag && (pinfo->status == INST_RDY)) {
+ *dbchg = 1;
+
+ /* tp is the server-relative path */
+ tp = fixpath(entry->cf_ent.path);
+ /* save_path is the cmd line path */
+ save_path = entry->cf_ent.path;
+ /* entry has the server-relative path */
+ entry->cf_ent.path = tp;
+
+ /*
+ * The next if statement figures out how
+ * the contents file entry should be
+ * annotated.
+ *
+ * Don't install or verify objects for
+ * remote, read-only filesystems. We
+ * need only verify their presence and
+ * flag them appropriately from some
+ * server. Otherwise, ok to do final
+ * check.
+ */
+ fs_entry = fsys(entry->cf_ent.path);
+
+ if (is_remote_fs_n(fs_entry) && !is_fs_writeable_n(fs_entry)) {
+ /*
+ * Mark it shared whether it's present
+ * or not. life's too funny for me
+ * to explain.
+ */
+ pinfo->status = SERVED_FILE;
/*
- * The next if statement figures out how
- * the contents file entry should be
- * annotated.
- *
- * Don't install or verify objects for
- * remote, read-only filesystems. We
- * need only verify their presence and
- * flag them appropriately from some
- * server. Otherwise, ok to do final
- * check.
+ * restore for now. This may
+ * chg soon.
*/
- fs_entry = fsys(entry->cf_ent.path);
-
- if (is_remote_fs_n(fs_entry) &&
- !is_fs_writeable_n(fs_entry)) {
- /*
- * Mark it shared whether it's present
- * or not. life's too funny for me
- * to explain.
- */
- pinfo->status = SERVED_FILE;
+ entry->cf_ent.path = save_path;
+ } else {
+ /*
+ * If the object is accessible, check
+ * the new entry for existence and
+ * attributes. If there's a problem,
+ * mark it NOT_FND; otherwise,
+ * ENTRY_OK.
+ */
+ if (is_mounted_n(fs_entry)) {
+ int n;
- /*
- * restore for now. This may
- * chg soon.
- */
- entry->cf_ent.path = save_path;
- } else {
- /*
- * If the object is accessible, check
- * the new entry for existence and
- * attributes. If there's a problem,
- * mark it NOT_FND; otherwise,
- * ENTRY_OK.
- */
- if (is_mounted_n(fs_entry)) {
- int n;
-
- n = finalck((&entry->cf_ent), 1, 1,
- B_FALSE);
-
- pinfo->status = ENTRY_OK;
- if (n != 0) {
- pinfo->status = NOT_FND;
- }
- }
+ n = finalck((&entry->cf_ent), 1, 1, B_FALSE);
- /*
- * It's not remote, read-only but it
- * may look that way to the client.
- * If it does, overwrite the above
- * result - mark it shared.
- */
- if (is_served_n(fs_entry))
- pinfo->status = SERVED_FILE;
-
- /* restore original path */
- entry->cf_ent.path = save_path;
- /* and clear save_path */
- save_path = NULL;
+ pinfo->status = ENTRY_OK;
+ if (n != 0) {
+ pinfo->status = NOT_FND;
+ }
}
+
+ /*
+ * It's not remote, read-only but it
+ * may look that way to the client.
+ * If it does, overwrite the above
+ * result - mark it shared.
+ */
+ if (is_served_n(fs_entry))
+ pinfo->status = SERVED_FILE;
+
+ /* restore original path */
+ entry->cf_ent.path = save_path;
+ /* and clear save_path */
+ save_path = NULL;
}
}
diff --git a/usr/src/cmd/svr4pkg/installf/installf.h b/usr/src/cmd/svr4pkg/installf/installf.h
index 6d473aa3af..b553c61425 100644
--- a/usr/src/cmd/svr4pkg/installf/installf.h
+++ b/usr/src/cmd/svr4pkg/installf/installf.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -48,7 +48,7 @@ extern void quit(int);
extern void usage(void);
extern void removef(int, char *[]);
extern int installf(int, char *[]);
-extern int dofinal(VFP_T *, VFP_T *, int, char *, char *);
+extern int dofinal(PKGserver, VFP_T *, int, char *, char *);
#ifdef __cplusplus
}
diff --git a/usr/src/cmd/svr4pkg/installf/main.c b/usr/src/cmd/svr4pkg/installf/main.c
index 8c70add8ed..2e1bfed717 100644
--- a/usr/src/cmd/svr4pkg/installf/main.c
+++ b/usr/src/cmd/svr4pkg/installf/main.c
@@ -116,7 +116,6 @@ char *ulim;
char *script;
int eptnum;
-int sortflag;
int nosetuid;
int nocnflct;
int warnflag = 0;
@@ -130,15 +129,12 @@ extern void set_limit(void);
int
main(int argc, char **argv)
{
- FILE *pp;
VFP_T *cfTmpVfp;
- VFP_T *cfVfp;
- char *cmd;
+ PKGserver pkgserver = NULL;
char *tp;
char *prog;
char *pt;
char *vfstab_file = NULL;
- char line[1024];
char outbuf[PATH_MAX];
int c;
int dbchg;
@@ -299,8 +295,6 @@ main(int argc, char **argv)
set_PKGADM(server_map(get_PKGADM(), fsys_value));
}
- sortflag = 0;
-
/*
* get the package name and verify length is not too long
*/
@@ -382,12 +376,12 @@ main(int argc, char **argv)
/* open the package database (contents) file */
- if (!ocfile(&cfVfp, &cfTmpVfp, 0L)) {
+ if (!ocfile(&pkgserver, &cfTmpVfp, 0L)) {
quit(1);
}
if (fflag) {
- dbchg = dofinal(cfVfp, cfTmpVfp, REMOVEF, classname, prog);
+ dbchg = dofinal(pkgserver, cfTmpVfp, REMOVEF, classname, prog);
} else {
if (INSTALF) {
dbst = INST_RDY;
@@ -398,7 +392,7 @@ main(int argc, char **argv)
removef(argc-optind, &argv[optind]);
}
- dbchg = pkgdbmerg(cfVfp, cfTmpVfp, extlist, 0);
+ dbchg = pkgdbmerg(pkgserver, cfTmpVfp, extlist);
if (dbchg < 0) {
progerr(gettext(ERR_MERG));
quit(99);
@@ -406,11 +400,11 @@ main(int argc, char **argv)
}
if (dbchg) {
- if ((n = swapcfile(&cfVfp, &cfTmpVfp, pkginst, 1))
- == RESULT_WRN) {
- warnflag++;
+ if ((n = swapcfile(pkgserver, &cfTmpVfp, pkginst, 1))
+ == RESULT_WRN) {
+ warnflag++;
} else if (n == RESULT_ERR) {
- quit(99);
+ quit(99);
}
}
@@ -442,15 +436,15 @@ main(int argc, char **argv)
if (is_a_cl_basedir() && !is_an_inst_root()) {
c = strlen(get_client_basedir());
(void) snprintf(outbuf, sizeof (outbuf),
- "%s/%s\n", get_basedir(),
- &(ept->path[c]));
+ "%s/%s\n", get_basedir(),
+ &(ept->path[c]));
} else if (is_an_inst_root()) {
(void) snprintf(outbuf, sizeof (outbuf),
- "%s/%s\n", get_inst_root(),
- &(ept->path[c]));
+ "%s/%s\n", get_inst_root(),
+ &(ept->path[c]));
} else {
(void) snprintf(outbuf, sizeof (outbuf),
- "%s\n", &(ept->path[c]));
+ "%s\n", &(ept->path[c]));
}
canonize(outbuf);
(void) printf("%s", outbuf);
@@ -462,50 +456,12 @@ main(int argc, char **argv)
if (strchr("dxcbp", ept->ftype)) {
tp = fixpath(ept->path);
- (void) averify(1, &ept->ftype,
- tp, &ept->ainfo);
+ (void) averify(1, &ept->ftype, tp, &ept->ainfo);
}
}
}
- /* Sort the contents files if needed */
- if (sortflag) {
- int n;
-
- warnflag += (ocfile(&cfVfp, &cfTmpVfp, 0L)) ? 0 : 1;
- if (!warnflag) {
- size_t len;
-
- len = strlen(CMD_SORT) + strlen(get_PKGADM()) +
- strlen("/contents") + 5;
- cmd = (char *)malloc(len);
- (void) snprintf(cmd, len, "%s %s/contents",
- CMD_SORT, get_PKGADM());
- pp = popen(cmd, "r");
- if (pp == NULL) {
- (void) vfpClose(&cfVfp);
- (void) vfpClose(&cfTmpVfp);
- free(cmd);
- progerr(gettext(ERR_SORT));
- quit(1);
- }
- while (fgets(line, 1024, pp) != NULL) {
- if (line[0] != DUP_ENTRY) {
- vfpPuts(cfTmpVfp, line);
- }
- }
- free(cmd);
- (void) pclose(pp);
- n = swapcfile(&cfVfp, &cfTmpVfp, pkginst, 1);
- if (n == RESULT_WRN) {
- warnflag++;
- } else if (n == RESULT_ERR) {
- quit(99);
- }
-
- relslock(); /* Unlock the database. */
- }
- }
+ pkgcloseserver(pkgserver);
z_destroyMountTable();