From 2a62ed9ad2688a873bc7773b2c3cf818456aeabb Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck <tilman@crux.nu>
Date: Wed, 6 Dec 2006 21:17:49 +0100
Subject: [PATCH] Set ARCHIVE_EXTRACT_UNLINK when extracting archive entries.

---
 pkgutil.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pkgutil.cc b/pkgutil.cc
index f5b430d..62a9edf 100644
--- a/pkgutil.cc
+++ b/pkgutil.cc
@@ -422,8 +422,9 @@ void pkgutil::pkg_install(const string& filename, const set<string>& keep_list,
 		                           (real_filename.c_str()));
 
 		// Extract file
-		if (archive_read_extract(archive, entry, ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM) !=
-		    ARCHIVE_OK) {
+		unsigned int flags = ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_UNLINK;
+
+		if (archive_read_extract(archive, entry, flags) != ARCHIVE_OK) {
 			// If a file fails to install we just print an error message and
 			// continue trying to install the rest of the package.
 			const char* msg = archive_error_string(archive);
-- 
2.45.2