Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge branch 'master' of github.com:pkgng/pkgng
Baptiste Daroussin committed 14 years ago
commit d31742fca1bd9ef765f797ee7c13b009eac3b6fb
parent 879b115
4 files changed +11 -14
modified libpkg/pkg.h
@@ -515,13 +515,6 @@ int pkg_delete(struct pkg *pkg, struct pkgdb *db, int force);
int pkg_repo_fetch(struct pkg *pkg, void *data, fetch_cb cb);

/**
-
 * These functions are helpers for specific parts of pkg_delete().
-
 * Generally speaking, external consumers should not use these.
-
 * @return An error code on failure, or EPKG_OK.
-
 */
-
int pkg_delete_files(struct pkg *pkg, int force);
-

-
/**
 * Get the value of a configuration key
 */
const char * pkg_config(const char *key);
modified libpkg/pkg_add.c
@@ -160,7 +160,8 @@ pkg_add(struct pkgdb *db, const char *path, struct pkg **pkg_p)
	 */
	if (extract == true && (retcode = do_extract(a, ae)) != EPKG_OK) {
		/* If the add failed, clean up */
-
		(void) pkg_delete_files(pkg, 1);
+
		pkg_delete_files(pkg, 1);
+
		pkg_delete_dirs(pkg, 1);
		goto cleanup_reg;
	}

modified libpkg/pkg_delete.c
@@ -8,10 +8,9 @@

#include "pkg.h"
#include "pkg_error.h"
+
#include "pkg_private.h"
#include "pkg_util.h"

-
static int pkg_delete_dirs(struct pkg *pkg);
-

int
pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
@@ -69,7 +68,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
	if ((ret = pkg_script_post_deinstall(pkg)) != EPKG_OK)
		return (ret);

-
	if ((ret = pkg_delete_dirs(pkg)) != EPKG_OK)
+
	if ((ret = pkg_delete_dirs(pkg, force)) != EPKG_OK)
		return (ret);

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
@@ -108,15 +107,15 @@ pkg_delete_files(struct pkg *pkg, int force)
	return (EPKG_OK);
}

-
static int
-
pkg_delete_dirs(struct pkg *pkg)
+
int
+
pkg_delete_dirs(struct pkg *pkg, int force)
{
	int i;
	const char **dirs;

	dirs = pkg_dirs(pkg);
	for (i = 0; dirs[i] != NULL; i++) {
-
		if (rmdir(dirs[i]) == -1 && errno != ENOTEMPTY) {
+
		if (rmdir(dirs[i]) == -1 && errno != ENOTEMPTY && force != 1) {
			warn("rmdir(%s)", dirs[i]);
		}
	}
modified libpkg/pkg_private.h
@@ -73,4 +73,8 @@ int packing_finish(struct packing *pack);
pkg_formats packing_format_from_string(const char *str);

void pkg_free_void(void *);
+

+
int pkg_delete_files(struct pkg *pkg, int force);
+
int pkg_delete_dirs(struct pkg *pkg, int force);
+

#endif