Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pkgviews]: src/usr.sbin/pkg_install Enhance pkg_delete(1) to do a differ...
details: https://anonhg.NetBSD.org/src/rev/c5b984c61a92
branches: pkgviews
changeset: 534247:c5b984c61a92
user: jlam <jlam%NetBSD.org@localhost>
date: Wed Jul 30 11:04:33 2003 +0000
description:
Enhance pkg_delete(1) to do a different cleanup step if it's deleting a
depoted package: remove all of the +* metadata files and try removing the
depot directory. The package is considered deleted if the metadata files
are successfully removed, so make pkg_delete(1) return success in that
case. This allows us to preserve modified config files that live in the
depot directory. Bump version to 20030730.
diffstat:
usr.sbin/pkg_install/delete/perform.c | 30 ++++++++++++++++++++++++------
usr.sbin/pkg_install/lib/version.h | 4 ++--
2 files changed, 26 insertions(+), 8 deletions(-)
diffs (87 lines):
diff -r 4beb75399b7b -r c5b984c61a92 usr.sbin/pkg_install/delete/perform.c
--- a/usr.sbin/pkg_install/delete/perform.c Tue Jul 29 07:00:36 2003 +0000
+++ b/usr.sbin/pkg_install/delete/perform.c Wed Jul 30 11:04:33 2003 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: perform.c,v 1.36.2.5 2003/07/24 23:14:51 jlam Exp $ */
+/* $NetBSD: perform.c,v 1.36.2.6 2003/07/30 11:04:33 jlam 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.36.2.5 2003/07/24 23:14:51 jlam Exp $");
+__RCSID("$NetBSD: perform.c,v 1.36.2.6 2003/07/30 11:04:33 jlam Exp $");
#endif
#endif
@@ -607,6 +607,7 @@
char view[FILENAME_MAX];
char *tmp;
int cc;
+ Boolean is_depoted_pkg = FALSE;
/* Reset some state */
if (Plist.head)
@@ -639,6 +640,11 @@
warnx("unable to change directory to %s! deinstall failed", LogDir);
return 1;
}
+ if (!fexists(CONTENTS_FNAME)) {
+ warnx("package '%s' is not installed, %s missing", pkg, CONTENTS_FNAME);
+ if (!Force)
+ return 1;
+ }
if (fexists(PRESERVE_FNAME)) {
printf("Package `%s' is marked as not for deletion\n", pkg);
if (Force <= 1) {
@@ -786,16 +792,28 @@
}
}
}
+ if (fexists(VIEWS_FNAME))
+ is_depoted_pkg = TRUE;
+
/* Change out of LogDir before we remove it.
* Do not fail here, as the package is not yet completely deleted! */
if (chdir(home) == FAIL)
warnx("Oops - removed current working directory. Oh, well.");
if (!Fake) {
/* Finally nuke the +-files and the pkgdb-dir (/var/db/pkg/foo) */
- if (vsystem("%s -r %s", REMOVE_CMD, LogDir)) {
- warnx("couldn't remove log entry in %s, deinstall failed", LogDir);
- if (!Force)
- return 1;
+ if (is_depoted_pkg) {
+ (void) vsystem("%s %s/+*", REMOVE_CMD, LogDir);
+ if (isemptydir(LogDir))
+ (void) vsystem("%s %s", RMDIR_CMD, LogDir);
+ else
+ warnx("%s is not empty", LogDir);
+ return 0;
+ } else {
+ if (vsystem("%s -r %s", REMOVE_CMD, LogDir)) {
+ warnx("couldn't remove log entry in %s, deinstall failed", LogDir);
+ if (!Force)
+ return 1;
+ }
}
}
return 0;
diff -r 4beb75399b7b -r c5b984c61a92 usr.sbin/pkg_install/lib/version.h
--- a/usr.sbin/pkg_install/lib/version.h Tue Jul 29 07:00:36 2003 +0000
+++ b/usr.sbin/pkg_install/lib/version.h Wed Jul 30 11:04:33 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.13.4.6 2003/07/29 07:00:36 jlam Exp $ */
+/* $NetBSD: version.h,v 1.13.4.7 2003/07/30 11:04:34 jlam Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@@ -33,6 +33,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
-#define PKGTOOLS_VERSION "20030729"
+#define PKGTOOLS_VERSION "20030730"
#endif /* _INST_LIB_VERSION_H_ */
Home |
Main Index |
Thread Index |
Old Index