Fix 'pkg_add -R' handling - not registering really means not touching

the pkgdb too - useful for pkg_add as non-root!
This commit is contained in:
hubertf 2005-06-29 01:39:37 +00:00
parent 316b5f711e
commit 9a9bdaa985

View File

@ -1,11 +1,11 @@
/* $NetBSD: extract.c,v 1.34 2005/01/06 11:59:35 agc Exp $ */ /* $NetBSD: extract.c,v 1.35 2005/06/29 01:39:37 hubertf Exp $ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static const char *rcsid = "FreeBSD - Id: extract.c,v 1.17 1997/10/08 07:45:35 charnier Exp"; static const char *rcsid = "FreeBSD - Id: extract.c,v 1.17 1997/10/08 07:45:35 charnier Exp";
#else #else
__RCSID("$NetBSD: extract.c,v 1.34 2005/01/06 11:59:35 agc Exp $"); __RCSID("$NetBSD: extract.c,v 1.35 2005/06/29 01:39:37 hubertf Exp $");
#endif #endif
#endif #endif
@ -142,11 +142,13 @@ extract_plist(char *home, package_t *pkg)
last_file = NULL; last_file = NULL;
Directory = home; Directory = home;
if (!NoRecord) {
/* Open Package Database for writing */ /* Open Package Database for writing */
if (!pkgdb_open(ReadWrite)) { if (!pkgdb_open(ReadWrite)) {
cleanup(0); cleanup(0);
err(EXIT_FAILURE, "can't open pkgdb"); err(EXIT_FAILURE, "can't open pkgdb");
} }
}
/* Do it */ /* Do it */
while (p) { while (p) {
char cmd[MaxPathSize]; char cmd[MaxPathSize];
@ -191,8 +193,8 @@ extract_plist(char *home, package_t *pkg)
} }
} }
if (rename(p->name, try) == 0) { if (rename(p->name, try) == 0) {
if (!NoRecord) {
/* note in pkgdb */ /* note in pkgdb */
{
char *s, t[MaxPathSize]; char *s, t[MaxPathSize];
int rc; int rc;
@ -249,11 +251,12 @@ extract_plist(char *home, package_t *pkg)
} }
perm_count += add_count; perm_count += add_count;
if (!NoRecord) {
/* note in pkgdb */ /* note in pkgdb */
/* XXX would be better to store in PUSHOUT, but /* XXX would be better to store in PUSHOUT, but
* that would probably affect too much code I prefer * that would probably affect too much code I prefer
* not to touch - HF */ * not to touch - HF */
{
char *s, t[MaxPathSize], *u; char *s, t[MaxPathSize], *u;
int rc; int rc;
@ -331,6 +334,7 @@ extract_plist(char *home, package_t *pkg)
p = p->next; p = p->next;
} }
PUSHOUT(Directory); PUSHOUT(Directory);
if (!NoRecord)
pkgdb_close(); pkgdb_close();
free(perm_args); free(perm_args);
free(where_args); free(where_args);