Introduce the notion of "preserving" an installed package.

A preserved package may not be deleted by pkg_delete(1) (unless the -f
option is given), and the preserved capability will be carried into
any binary package. pkg_add(1) will also keep the preserved capability
if it was present in the binary package.

The "preserve" capability can be given to a package by using the
PKG_PRESERVE definition in a package Makefile in pkgsrc.

Ride on the recently-bumped lib/version.h for new functionality.
This commit is contained in:
agc 2003-01-10 11:55:44 +00:00
parent a9dbc85017
commit 17a35e2e99
9 changed files with 59 additions and 16 deletions

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.76 2003/01/05 21:27:20 agc Exp $ */
/* $NetBSD: perform.c,v 1.77 2003/01/10 11:55:44 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.76 2003/01/05 21:27:20 agc Exp $");
__RCSID("$NetBSD: perform.c,v 1.77 2003/01/10 11:55:44 agc Exp $");
#endif
#endif
@ -588,6 +588,8 @@ pkg_do(const char *pkg)
move_file(".", BUILD_INFO_FNAME, LogDir);
if (fexists(DISPLAY_FNAME))
move_file(".", DISPLAY_FNAME, LogDir);
if (fexists(PRESERVE_FNAME))
move_file(".", PRESERVE_FNAME, LogDir);
/* register dependencies */
/* we could save some cycles here if we remembered what we

View File

@ -1,4 +1,4 @@
/* $NetBSD: create.h,v 1.16 2001/05/21 09:17:30 agc Exp $ */
/* $NetBSD: create.h,v 1.17 2003/01/10 11:55:45 agc Exp $ */
/* from FreeBSD Id: create.h,v 1.13 1997/10/08 07:46:19 charnier Exp */
@ -41,6 +41,7 @@ extern char *BuildVersion;
extern char *BuildInfo;
extern char *SizePkg;
extern char *SizeAll;
extern char *Preserve;
extern char *SrcDir;
extern char *realprefix;
extern char PlayPen[];

View File

@ -1,11 +1,11 @@
/* $NetBSD: main.c,v 1.22 2003/01/10 10:43:50 agc Exp $ */
/* $NetBSD: main.c,v 1.23 2003/01/10 11:55:45 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp";
#else
__RCSID("$NetBSD: main.c,v 1.22 2003/01/10 10:43:50 agc Exp $");
__RCSID("$NetBSD: main.c,v 1.23 2003/01/10 11:55:45 agc Exp $");
#endif
#endif
@ -24,7 +24,7 @@ __RCSID("$NetBSD: main.c,v 1.22 2003/01/10 10:43:50 agc Exp $");
#include "lib.h"
#include "create.h"
static const char Options[] = "B:C:D:FI:L:OP:RS:UVX:b:c:d:f:hi:k:lm:p:r:s:t:v";
static const char Options[] = "B:C:D:FI:L:OP:RS:UVX:b:c:d:f:hi:k:lm:n:p:r:s:t:v";
char *Prefix = NULL;
char *Comment = NULL;
@ -42,6 +42,7 @@ char *BuildVersion = NULL;
char *BuildInfo = NULL;
char *SizePkg = NULL;
char *SizeAll = NULL;
char *Preserve = NULL;
char *SrcDir = NULL;
char *realprefix = NULL;
char PlayPen[FILENAME_MAX];
@ -159,6 +160,10 @@ main(int argc, char **argv)
Mtree = optarg;
break;
case 'n':
Preserve = optarg;
break;
case 'P':
Pkgdeps = optarg;
break;

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.34 2002/10/17 03:31:34 christos Exp $ */
/* $NetBSD: perform.c,v 1.35 2003/01/10 11:55:45 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.34 2002/10/17 03:31:34 christos Exp $");
__RCSID("$NetBSD: perform.c,v 1.35 2003/01/10 11:55:45 agc Exp $");
#endif
#endif
@ -138,6 +138,9 @@ make_dist(const char *home, const char *pkg, const char *suffix, const package_t
if (SizeAll) {
(void) fprintf(totar, "%s\n", SIZE_ALL_FNAME);
}
if (Preserve) {
(void) fprintf(totar, "%s\n", PRESERVE_FNAME);
}
for (p = plist->head; p; p = p->next) {
if (p->type == PLIST_FILE) {
@ -382,6 +385,11 @@ pkg_perform(lpkg_head_t *pkgs)
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, SIZE_ALL_FNAME);
}
if (Preserve) {
copy_file(Home, Preserve, PRESERVE_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, PRESERVE_FNAME);
}
/* Finally, write out the packing list */
fp = fopen(CONTENTS_FNAME, "w");

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_create.1,v 1.34 2002/09/26 01:41:51 wiz Exp $
.\" $NetBSD: pkg_create.1,v 1.35 2003/01/10 11:55:45 agc Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@ -24,7 +24,7 @@
.\" [jkh] Took John's changes back and made some additional extensions for
.\" better integration with FreeBSD's new ports collection.
.\"
.Dd April 21, 1995
.Dd January 10, 2003
.Dt PKG_CREATE 1
.Os
.Sh NAME
@ -82,6 +82,9 @@
.Op Fl S Ar size-all-file
.Ek
.Bk -words
.Op Fl n Ar preserve-file
.Ek
.Bk -words
.Op Fl t Ar template
.Ek
.Bk -words
@ -253,6 +256,10 @@ flag.
The file is expected to contain the size (in bytes) of all files of
this package plus any required packages added up and stored as a
ASCII string, terminated by a newline.
.It Fl n Ar preserve-file
The file is used to denote that the package should not be deleted.
This is intended for use where the deletion of packages may present
a bootstrap problem.
.It Fl s Ar size-pkg-file
Store the given file for later querying with the
.Xr pkg_info 1

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.39 2003/01/05 21:27:24 agc Exp $ */
/* $NetBSD: perform.c,v 1.40 2003/01/10 11:55:45 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.39 2003/01/05 21:27:24 agc Exp $");
__RCSID("$NetBSD: perform.c,v 1.40 2003/01/10 11:55:45 agc Exp $");
#endif
#endif
@ -548,6 +548,12 @@ pkg_do(char *pkg)
warnx("unable to change directory to %s! deinstall failed", LogDir);
return 1;
}
if (fexists(PRESERVE_FNAME)) {
printf("Package `%s' is marked as not for deletion\n", pkg);
if (!Force) {
return 1;
}
}
if (!isemptyfile(REQUIRED_BY_FNAME)) {
/* This package is required by others. Either nuke
* them (-r), or stop. */

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_delete.1,v 1.26 2002/09/26 01:41:51 wiz Exp $
.\" $NetBSD: pkg_delete.1,v 1.27 2003/01/10 11:55:46 agc Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@ -148,6 +148,13 @@ will list those dependent packages and refuse to delete the package
.Fl f
option is given).
.Pp
If a package has been marked as a
.Cm preserved
package, it will not be able to be deleted
(unless the
.Fl f
option is given).
.Pp
If a filename is given instead of a package name, the package of which
the given file belongs to can be deleted if the
.Fl F

View File

@ -1,11 +1,11 @@
/* $NetBSD: perform.c,v 1.42 2003/01/05 21:49:57 agc Exp $ */
/* $NetBSD: perform.c,v 1.43 2003/01/10 11:55:46 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
#else
__RCSID("$NetBSD: perform.c,v 1.42 2003/01/05 21:49:57 agc Exp $");
__RCSID("$NetBSD: perform.c,v 1.43 2003/01/10 11:55:46 agc Exp $");
#endif
#endif
@ -175,6 +175,9 @@ pkg_do(char *pkg)
/* Start showing the package contents */
if (!Quiet) {
printf("%sInformation for %s:\n\n", InfoPrefix, pkg);
if (fexists(PRESERVE_FNAME)) {
printf("*** PACKAGE MAY NOT BE DELETED ***\n");
}
}
if (Flags & SHOW_COMMENT) {
show_file("Comment:\n", COMMENT_FNAME);
@ -225,6 +228,9 @@ pkg_do(char *pkg)
show_file("Size in bytes including required pkgs: ", SIZE_ALL_FNAME);
}
if (!Quiet) {
if (fexists(PRESERVE_FNAME)) {
printf("*** PACKAGE MAY NOT BE DELETED ***\n\n");
}
puts(InfoPrefix);
}
free_plist(&plist);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lib.h,v 1.47 2003/01/10 10:17:23 agc Exp $ */
/* $NetBSD: lib.h,v 1.48 2003/01/10 11:55:46 agc Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@ -102,6 +102,7 @@
#define BUILD_INFO_FNAME "+BUILD_INFO"
#define SIZE_PKG_FNAME "+SIZE_PKG"
#define SIZE_ALL_FNAME "+SIZE_ALL"
#define PRESERVE_FNAME "+PRESERVE"
#define CMD_CHAR '@' /* prefix for extended PLIST cmd */