Add -O option to only delete things from the pkgdb, and do not touch

anything else of the package or it's files. To be used on "make reinstall"
by the buildsystem (quite exclusively).
This commit is contained in:
hubertf 1999-03-03 17:29:58 +00:00
parent 3f2f7307b5
commit fe7b9b969f
2 changed files with 52 additions and 8 deletions

View File

@ -1,11 +1,11 @@
/* $NetBSD: main.c,v 1.8 1999/02/26 10:49:30 chopps Exp $ */ /* $NetBSD: main.c,v 1.9 1999/03/03 17:29:58 hubertf Exp $ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp"; static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp";
#else #else
__RCSID("$NetBSD: main.c,v 1.8 1999/02/26 10:49:30 chopps Exp $"); __RCSID("$NetBSD: main.c,v 1.9 1999/03/03 17:29:58 hubertf Exp $");
#endif #endif
#endif #endif
@ -31,10 +31,11 @@ __RCSID("$NetBSD: main.c,v 1.8 1999/02/26 10:49:30 chopps Exp $");
*/ */
#include <err.h> #include <err.h>
#include <errno.h>
#include "lib.h" #include "lib.h"
#include "delete.h" #include "delete.h"
static char Options[] = "hvDdnfFrp:"; static char Options[] = "hvDdnfFrOp:";
char *Prefix = NULL; char *Prefix = NULL;
char *ProgramPath = NULL; char *ProgramPath = NULL;
@ -42,11 +43,12 @@ Boolean NoDeInstall = FALSE;
Boolean CleanDirs = FALSE; Boolean CleanDirs = FALSE;
Boolean File2Pkg = FALSE; Boolean File2Pkg = FALSE;
Boolean Recurse = FALSE; Boolean Recurse = FALSE;
Boolean OnlyDeleteFromPkgDB = FALSE;
static void static void
usage(void) usage(void)
{ {
fprintf(stderr, "usage: pkg_delete [-vDdnFfr] [-p prefix] pkg-name ...\n"); fprintf(stderr, "usage: pkg_delete [-vDdnFfrO] [-p prefix] pkg-name ...\n");
exit(1); exit(1);
} }
@ -94,6 +96,10 @@ main(int argc, char **argv)
Recurse = TRUE; Recurse = TRUE;
break; break;
case 'O':
OnlyDeleteFromPkgDB = TRUE;
break;
case 'h': case 'h':
case '?': case '?':
default: default:
@ -139,7 +145,42 @@ main(int argc, char **argv)
*pkgs = NULL; *pkgs = NULL;
if (!Fake && getuid() != 0) if (!Fake && getuid() != 0)
errx(1, "you must be root to delete packages"); errx(1, "you must be root to delete packages");
if ((error = pkg_perform(start)) != 0) { if (OnlyDeleteFromPkgDB) {
/* Only delete the given packages' files from pkgdb, do not touch
* the pkg itself. Used by "make reinstall" in bsd.pkg.mk
*/
char *key, *val;
char **s;
if (pkgdb_open(0)==-1) {
err(1, "cannot open %s", _pkgdb_getPKGDB_FILE());
}
error = 0;
while ((key=pkgdb_iter())) {
val=pkgdb_retrieve(key);
for (s=start; *s; s++) {
if (strcmp(val, *s) == 0) {
if (Verbose)
printf("Removing file %s from pkgdb\n", key);
errno=0;
if (pkgdb_remove(key)) {
if (errno)
printf("Error removing %s from pkgdb: %s\n", key, strerror(errno));
else
printf("Key %s not present in pkgdb?!\n", key);
error = 1;
}
}
}
}
pkgdb_close();
return error;
} else if ((error = pkg_perform(start)) != 0) {
if (Verbose) if (Verbose)
warnx("%d package deletion(s) failed", error); warnx("%d package deletion(s) failed", error);
return error; return error;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_delete.1,v 1.7 1999/02/26 10:49:30 chopps Exp $ .\" $NetBSD: pkg_delete.1,v 1.8 1999/03/03 17:29:58 hubertf Exp $
.\" .\"
.\" FreeBSD install - a package for the installation and maintainance .\" FreeBSD install - a package for the installation and maintainance
.\" of non-core utilities. .\" of non-core utilities.
@ -17,7 +17,7 @@
.\" .\"
.\" from FreeBSD: @(#)pkg_delete.1 .\" from FreeBSD: @(#)pkg_delete.1
.\" .\"
.Dd January 12, 1999 .Dd March 3rd, 1999
.Dt pkg_delete 1 .Dt pkg_delete 1
.Os FreeBSD 2.0 .Os FreeBSD 2.0
.Sh NAME .Sh NAME
@ -25,7 +25,7 @@
.Nd a utility for deleting previously installed software package distributions .Nd a utility for deleting previously installed software package distributions
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl vDdnFf .Op Fl vDdnFfO
.Op Fl p Ar prefix .Op Fl p Ar prefix
.Ar pkg-name ... .Ar pkg-name ...
.Sh DESCRIPTION .Sh DESCRIPTION
@ -79,6 +79,9 @@ If a deinstallation script exists for a given package, do not execute it.
.It Fl n .It Fl n
Don't actually deinstall a package, just report the steps that Don't actually deinstall a package, just report the steps that
would be taken if it were. would be taken if it were.
.It Fl O
Only delete the package's entries from the package database, do not
touch the package or it's files itself.
.It Fl p Ar prefix .It Fl p Ar prefix
Set Set
.Ar prefix .Ar prefix