diff options
author | jkh <jkh@FreeBSD.org> | 1995-04-19 14:02:01 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-04-19 14:02:01 +0000 |
commit | 496b8887e48a335e5e33705160dc24bae20631d5 (patch) | |
tree | 3b42c69766f04e0b864e2304219ca415145e0c76 /usr.sbin | |
parent | 0ff5903c59102c69837dc4317ea80fe6d8a12450 (diff) | |
download | FreeBSD-src-496b8887e48a335e5e33705160dc24bae20631d5.zip FreeBSD-src-496b8887e48a335e5e33705160dc24bae20631d5.tar.gz |
Add support for the ${PKG_DBDIR} environment variable. /var/db/pkg is the
default, and probably not something you'd ever change, but now it's
possible to do so for local/custom installations.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_install/add/perform.c | 18 | ||||
-rw-r--r-- | usr.sbin/pkg_install/add/pkg_add.1 | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_install/delete/perform.c | 11 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/perform.c | 15 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/lib.h | 8 |
5 files changed, 39 insertions, 18 deletions
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index b594596..415df59 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 2cabaee..5dba67c 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/<other-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 9986ee1..6449fd4 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 bde7b2e..902436b 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 abcfed7..80d69f2 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" |