summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorasami <asami@FreeBSD.org>1994-05-25 18:00:04 +0000
committerasami <asami@FreeBSD.org>1994-05-25 18:00:04 +0000
commit93b71d3919adb93943ea63bf72e610078b6d3270 (patch)
tree623ac33447f4f82558dea7d7cb6bab8078024ec5 /usr.sbin
parent2469c867a164210ce96143517059f21db7f1fd17 (diff)
downloadFreeBSD-src-93b71d3919adb93943ea63bf72e610078b6d3270.zip
FreeBSD-src-93b71d3919adb93943ea63bf72e610078b6d3270.tar.gz
The environment variable PKG_PREFIX is set to the first @cwd command
in the packing list, or the argument to -p if it is specified, before the requirements/installation/deinstallation scripts are called. This enables the scripts to be written to work on the final installation destination, even if the user uses -p to override the package's default.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/add/perform.c7
-rw-r--r--usr.sbin/pkg_install/add/pkg_add.114
-rw-r--r--usr.sbin/pkg_install/delete/perform.c23
-rw-r--r--usr.sbin/pkg_install/delete/pkg_delete.114
-rw-r--r--usr.sbin/pkg_install/lib/lib.h4
5 files changed, 46 insertions, 16 deletions
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 34f3da0..88719cd 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.6 1993/10/10 20:25:31 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.7 1994/05/25 06:24:18 jkh Exp $";
#endif
/*
@@ -108,9 +108,6 @@ pkg_do(char *pkg)
delete_plist(&Plist, FALSE, PLIST_CWD, NULL);
add_plist_top(&Plist, PLIST_CWD, Prefix);
}
- /* Just to be safe - overridden if package has made a choice */
- else
- add_plist_top(&Plist, PLIST_CWD, home);
/* If we're running in MASTER mode, just output the plist and return */
if (AddMode == MASTER) {
printf("%s\n", where_playpen());
@@ -118,6 +115,8 @@ pkg_do(char *pkg)
return 0;
}
}
+ setenv(PKG_PREFIX_VNAME,
+ (p = find_plist(&Plist, PLIST_CWD)) ? p->name : NULL, 1);
PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous";
if (fexists(REQUIRE_FNAME)) {
vsystem("chmod +x %s", REQUIRE_FNAME); /* be sure */
diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1
index a587491..1863144 100644
--- a/usr.sbin/pkg_install/add/pkg_add.1
+++ b/usr.sbin/pkg_install/add/pkg_add.1
@@ -172,10 +172,22 @@ This all allows you to write an
.B install
script that does "before and after" actions.
.PP
+All the scripts are called with the environment variable
+.B PKG_PREFIX
+set to the installation prefix (see the
+.B -p
+option above). This allows a package author to write a script
+that reliably performs some action on the directory where the package
+is installed, even if the user might change it by
+.B -p
+when
+.B pkg_add
+is run.
+.PP
After installation is complete, a copy of the packing list, in addition
to any
.B deinstall
-script the package might have, is copied into /var/pkg/<pkg-name>
+script the package might have, is copied into /var/db/pkg/<pkg-name>
for subsequent possible use by
.B pkg-delete.
Finally, the staging area is deleted and the program terminates.
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c
index 76e92ee..6fce7db 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.2 1993/09/03 23:01:02 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.3 1993/10/08 01:19:35 jkh Exp $";
#endif
/*
@@ -48,6 +48,7 @@ pkg_do(char *pkg)
{
FILE *cfile;
char home[FILENAME_MAX];
+ PackingList p;
/* Reset some state */
if (Plist.head)
@@ -65,15 +66,6 @@ pkg_do(char *pkg)
return 1;
}
sanity_check(LogDir);
- if (fexists(REQUIRE_FNAME)) {
- if (Verbose)
- printf("Executing 'require' script.\n");
- vsystem("chmod +x %s", REQUIRE_FNAME); /* be sure */
- if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) {
- whinge("Package %s fails requirements - not deleted.", pkg);
- return 1;
- }
- }
cfile = fopen(CONTENTS_FNAME, "r");
if (!cfile) {
whinge("Unable to open '%s' file.", CONTENTS_FNAME);
@@ -84,6 +76,17 @@ pkg_do(char *pkg)
add_plist(&Plist, PLIST_CWD, Prefix);
read_plist(&Plist, cfile);
fclose(cfile);
+ setenv(PKG_PREFIX_VNAME,
+ (p = find_plist(&Plist, PLIST_CWD)) ? p->name : NULL, 1);
+ if (fexists(REQUIRE_FNAME)) {
+ if (Verbose)
+ printf("Executing 'require' script.\n");
+ vsystem("chmod +x %s", REQUIRE_FNAME); /* be sure */
+ if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) {
+ whinge("Package %s fails requirements - not deleted.", pkg);
+ return 1;
+ }
+ }
if (!NoDeInstall && fexists(DEINSTALL_FNAME)) {
if (Fake)
printf("Would execute de-install script at this point.\n");
diff --git a/usr.sbin/pkg_install/delete/pkg_delete.1 b/usr.sbin/pkg_install/delete/pkg_delete.1
index e5a9454..cde1ba6 100644
--- a/usr.sbin/pkg_install/delete/pkg_delete.1
+++ b/usr.sbin/pkg_install/delete/pkg_delete.1
@@ -99,6 +99,20 @@ is a keyword denoting that this is a deinstallation. Passing the keyword
lets you potentially write only one program/script that handles all
aspects of installation and deletion.
.PP
+All scripts are called with the environment variable
+.B PKG_PREFIX
+set to the installation prefix (see the
+.B -p
+option above). This allows a package author to write a script
+that reliably performs some action on the directory where the package
+is installed, even if the user might have changed it by
+.B -p
+when
+.B pkg_add
+or
+.B pkg_delete
+is run.
+.PP
.SH BUGS
Sure to be some.
.SH "SEE ALSO"
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 7acf8ed..54e8251 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.5 1994/04/05 14:08:46 jkh Exp $ */
+/* $Id: lib.h,v 1.6 1994/05/25 06:27:23 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -69,6 +69,8 @@
#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
+/* The name of the "prefix" environment variable given to scripts */
+#define PKG_PREFIX_VNAME "PKG_PREFIX"
enum _plist_t {
PLIST_FILE, PLIST_CWD, PLIST_CMD, PLIST_CHMOD,
OpenPOWER on IntegriCloud