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.
This commit is contained in:
parent
26f9a76710
commit
5edd12d270
@ -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 */
|
||||
|
@ -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.
|
||||
|
@ -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");
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user