summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2009-02-13 01:31:42 +0000
committerjoerg <joerg@pkgsrc.org>2009-02-13 01:31:42 +0000
commit643788189cca834b532a66802e2dc6b79124220c (patch)
treedb27ca7a9ffa013644548b283305adccd82ebf58 /pkgtools
parentf649c1da8be72bd1760b9fbea32bc102010bb2c0 (diff)
downloadpkgsrc-643788189cca834b532a66802e2dc6b79124220c.tar.gz
pkg_install-20090213:
Fix pkg_delete -d: - ignore @dirrm commands, directories are removed already on demand - use local copy of dir before changing it, the caller expects it unmodified for the call to pkgdb_remove
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/lib/lib.h4
-rw-r--r--pkgtools/pkg_install/files/lib/plist.c30
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
3 files changed, 21 insertions, 17 deletions
diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h
index 2098752e7d0..dd8f8096ef4 100644
--- a/pkgtools/pkg_install/files/lib/lib.h
+++ b/pkgtools/pkg_install/files/lib/lib.h
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.46 2009/02/02 12:35:01 joerg Exp $ */
+/* $NetBSD: lib.h,v 1.47 2009/02/13 01:31:42 joerg Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -308,7 +308,7 @@ Boolean isempty(const char *);
int URLlength(const char *);
Boolean make_preserve_name(char *, size_t, char *, char *);
void remove_files(const char *, const char *);
-int delete_hierarchy(char *, Boolean, Boolean);
+int delete_hierarchy(const char *, Boolean, Boolean);
int format_cmd(char *, size_t, const char *, const char *, const char *);
int recursive_remove(const char *, int);
diff --git a/pkgtools/pkg_install/files/lib/plist.c b/pkgtools/pkg_install/files/lib/plist.c
index b55cd3f6239..8d236149460 100644
--- a/pkgtools/pkg_install/files/lib/plist.c
+++ b/pkgtools/pkg_install/files/lib/plist.c
@@ -1,4 +1,4 @@
-/* $NetBSD: plist.c,v 1.22 2009/02/02 12:35:01 joerg Exp $ */
+/* $NetBSD: plist.c,v 1.23 2009/02/13 01:31:42 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,7 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: plist.c,v 1.22 2009/02/02 12:35:01 joerg Exp $");
+__RCSID("$NetBSD: plist.c,v 1.23 2009/02/13 01:31:42 joerg Exp $");
/*
* FreeBSD install - a package for the installation and maintainance
@@ -638,7 +638,7 @@ pkgdb_cleanup:
break;
case PLIST_DIR_RM:
- if (NoDeleteFiles)
+ if (NoDeleteFiles || nukedirs)
break;
(void) snprintf(tmp, sizeof(tmp), "%s%s%s/%s",
@@ -675,11 +675,10 @@ pkgdb_cleanup:
* Returns 1 on error, 0 else.
*/
int
-delete_hierarchy(char *dir, Boolean ign_err, Boolean nukedirs)
+delete_hierarchy(const char *dir, Boolean ign_err, Boolean nukedirs)
{
- char *cp1, *cp2;
+ char *cp1, *cp2, *tmp_dir;
- cp1 = cp2 = dir;
if (!fexists(dir)) {
if (!ign_err)
warnx("%s `%s' doesn't really exist",
@@ -700,21 +699,26 @@ delete_hierarchy(char *dir, Boolean ign_err, Boolean nukedirs)
if (!nukedirs)
return 0;
+
+ cp1 = cp2 = tmp_dir = xstrdup(dir);;
+
while (cp2) {
if ((cp2 = strrchr(cp1, '/')) != NULL)
*cp2 = '\0';
- if (!isemptydir(dir))
- return 0;
- if (rmdir(dir) && !ign_err) {
- if (!fexists(dir))
- warnx("directory `%s' doesn't really exist", dir);
- else
+ if (!isemptydir(tmp_dir))
+ break;
+ if (rmdir(tmp_dir) && !ign_err) {
+ if (fexists(tmp_dir)) {
+ free(tmp_dir);
return 1;
+ }
+ warnx("directory `%s' doesn't really exist", tmp_dir);
}
/* back up the pathname one component */
if (cp2) {
- cp1 = dir;
+ cp1 = tmp_dir;
}
}
+ free(tmp_dir);
return 0;
}
diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index 27be18a3aa2..0a44841a77c 100644
--- a/pkgtools/pkg_install/files/lib/version.h
+++ b/pkgtools/pkg_install/files/lib/version.h
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.110 2009/02/11 23:42:42 joerg Exp $ */
+/* $NetBSD: version.h,v 1.111 2009/02/13 01:31:42 joerg Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@@ -27,6 +27,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
-#define PKGTOOLS_VERSION "20090212"
+#define PKGTOOLS_VERSION "20090213"
#endif /* _INST_LIB_VERSION_H_ */