diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index b59459605ea..415df5901bf 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.14 1995/04/09 15:04:52 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.15 1995/04/10 08:01:44 jkh Exp $"; #endif /* @@ -58,6 +58,7 @@ pkg_do(char *pkg) { char pkg_fullname[FILENAME_MAX]; char home[FILENAME_MAX]; + char *tmp; FILE *cfile; int code = 0; PackingList p; @@ -131,9 +132,10 @@ pkg_do(char *pkg) } setenv(PKG_PREFIX_VNAME, (p = find_plist(&Plist, PLIST_CWD)) ? p->name : NULL, 1); - PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous"; /* Protect against old packages with bogus @name fields */ - sprintf(LogDir, "%s/%s", LOG_DIR, basename_of(PkgName)); + PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous"; + sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, + basename_of(PkgName)); if (isdir(LogDir)) { whinge("Package `%s' already recorded as installed.\n", PkgName); code = 1; @@ -269,8 +271,9 @@ pkg_do(char *pkg) code = 1; goto success; /* well, partial anyway */ } - /* Protect against old packages with bogus @name fields */ - sprintf(LogDir, "%s/%s", LOG_DIR, basename_of(PkgName)); + sprintf(LogDir, "%s/%s", + (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, + basename_of(PkgName)); if (Verbose) printf("Attempting to record package into %s..\n", LogDir); if (make_hierarchy(LogDir)) { @@ -305,8 +308,9 @@ pkg_do(char *pkg) if (Verbose) printf("Attempting to record dependency on package `%s'\n", p->name); - sprintf(contents, "%s/%s/%s", LOG_DIR, basename_of(p->name), - REQUIRED_BY_FNAME); + sprintf(contents, "%s/%s/%s", + (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, + basename_of(p->name), REQUIRED_BY_FNAME); cfile = fopen(contents, "a"); if (!cfile) { whinge("Can't open dependency file '%s'!\n\tDependency registration incomplete.", diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1 index 2cabaee119b..5dba67c2035 100644 --- a/usr.sbin/pkg_install/add/pkg_add.1 +++ b/usr.sbin/pkg_install/add/pkg_add.1 @@ -262,7 +262,10 @@ for subsequent possible use by .Xr pkg_delete 8 . Any package dependencies are recorded in the other packages' .Pa /var/db/pkg//+REQUIRED_BY -file. +file +(if the environment variable PKG_DBDIR is set, this overrides the +.Pa /var/db/pkg/ +path shown above). .It Finally, the staging area is deleted and the program terminates. .El diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 9986ee15d49..6449fd49b8f 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.5 1994/09/29 13:19:39 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.6 1994/12/06 00:51:40 jkh Exp $"; #endif /* @@ -50,12 +50,14 @@ pkg_do(char *pkg) FILE *cfile; char home[FILENAME_MAX]; PackingList p; + char *tmp; /* Reset some state */ if (Plist.head) free_plist(&Plist); - sprintf(LogDir, "%s/%s", LOG_DIR, pkg); + sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, + pkg); if (!fexists(LogDir)) { whinge("No such package '%s' installed.", pkg); return 1; @@ -154,9 +156,12 @@ undepend(PackingList p, char *pkgname) char fname[FILENAME_MAX], ftmp[FILENAME_MAX]; char fbuf[FILENAME_MAX]; FILE *fp, *fpwr; + char *tmp; int s; - sprintf(fname, "%s/%s/%s", LOG_DIR, p->name, REQUIRED_BY_FNAME); + sprintf(fname, "%s/%s/%s", + (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, + p->name, REQUIRED_BY_FNAME); fp = fopen(fname, "r"); if (fp == NULL) { whinge("Couldn't open dependency file `%s'", fname); diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index bde7b2e49e7..902436b9296 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.10 1994/12/06 00:51:45 jkh Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.11 1995/01/05 01:10:12 swallace Exp $"; #endif /* @@ -33,16 +33,20 @@ int pkg_perform(char **pkgs) { int i, err_cnt = 0; + char *tmp; signal(SIGINT, cleanup); + tmp = getenv(PKG_DBDIR); + if (!tmp) + tmp = DEF_LOG_DIR; /* Overriding action? */ if (AllInstalled || CheckPkg) { - if (isdir(LOG_DIR)) { + if (isdir(tmp)) { DIR *dirp; struct dirent *dp; - dirp = opendir(LOG_DIR); + dirp = opendir(tmp); if (dirp) { for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) { @@ -106,7 +110,10 @@ pkg_do(char *pkg) } } else { - sprintf(log_dir, "%s/%s", LOG_DIR, pkg); + char *tmp; + + sprintf(log_dir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, + pkg); if (!fexists(log_dir)) { whinge("Can't find package '%s' installed or in a file!", pkg); return 1; diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index abcfed74116..80d69f26732 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.11 1994/11/17 10:51:46 jkh Exp $ */ +/* $Id: lib.h,v 1.12 1994/12/06 00:51:49 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance @@ -56,8 +56,10 @@ /* Usually "rm", but often "echo" during debugging! */ #define RMDIR_CMD "rmdir" -/* Where we put logging information */ -#define LOG_DIR "/var/db/pkg" +/* Where we put logging information by default, else ${PKG_DBDIR} if set */ +#define DEF_LOG_DIR "/var/db/pkg" +/* just in case we change the environment variable name */ +#define PKG_DBDIR "PKG_DBDIR" /* The names of our "special" files */ #define CONTENTS_FNAME "+CONTENTS"