diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-06-29 10:41:49 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-06-29 10:41:49 +0000 |
| commit | 94d1d55871d871076be3e3c80b95ac602f460f94 (patch) | |
| tree | ee1c47d0f8445bf8cef82e383867e18c91e8b4a0 /usr.sbin/pkg_install/lib | |
| parent | 5f88d2b8b4fa898cf7c280f84fefa4b2c6ce4ae5 (diff) | |
Notes
Diffstat (limited to 'usr.sbin/pkg_install/lib')
| -rw-r--r-- | usr.sbin/pkg_install/lib/plist.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index 72db68e76c21..53801877845f 100644 --- a/usr.sbin/pkg_install/lib/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id$"; +static const char *rcsid = "$Id: plist.c,v 1.19 1997/02/22 16:09:51 peter Exp $"; #endif /* @@ -23,6 +23,7 @@ static const char *rcsid = "$Id$"; */ #include "lib.h" +#include <errno.h> #include <md5.h> /* Add an item to a packing list */ @@ -352,10 +353,16 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) PackingList p; char *Where = ".", *last_file = ""; Boolean fail = SUCCESS; - char tmp[FILENAME_MAX]; + Boolean preserve; + char tmp[FILENAME_MAX], *name = NULL; + preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE; for (p = pkg->head; p; p = p->next) { switch (p->type) { + case PLIST_NAME: + name = p->name; + break; + case PLIST_IGNORE: p = p->next; break; @@ -401,8 +408,22 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) } if (Verbose) printf("Delete file %s\n", tmp); + if (!Fake && preserve) { + if (!name) + whinge("preserve set but no package name supplied!"); + else { + char tmp2[FILENAME_MAX]; - if (!Fake && delete_hierarchy(tmp, ign_err, nukedirs)) { + snprintf(tmp2, FILENAME_MAX, "%s.%s", tmp, name); + if (fexists(tmp2)) { + (void)chflags(tmp, 0); + delete_hierarchy(tmp, TRUE, TRUE); + if (rename(tmp2, tmp)) + whinge("preserve: Unable to restore %s as %s, errno = %d", tmp2, tmp, errno); + } + } + } + else if (!Fake && delete_hierarchy(tmp, ign_err, nukedirs)) { whinge("Unable to completely remove file '%s'", tmp); fail = FAIL; } |
