[pacman-dev] [PATCH] Handle root prefix in overwrite operations

Allan McRae allan at archlinux.org
Thu Jul 19 03:57:21 UTC 2018


The pacman --overwrite operation currently expects a path without
the root prefix specified.  This is unexpected, particularly
given our conflict error message reports the path with the root
prefix included.

This patch allows libalpm to overwrite files with the root prefix
specified.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/conflict.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 35946de5..2e87cfa1 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -401,8 +401,12 @@ static alpm_pkg_t *_alpm_find_file_owner(alpm_handle_t *handle, const char *path
 
 static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path)
 {
+	char rootedpath[PATH_MAX];
+	snprintf(rootedpath, PATH_MAX, "%s%s", handle->root, path);
+
 	return handle->trans->flags & ALPM_TRANS_FLAG_FORCE
-		|| _alpm_fnmatch_patterns(handle->overwrite_files, path) == 0;
+		|| _alpm_fnmatch_patterns(handle->overwrite_files, path) == 0
+		|| _alpm_fnmatch_patterns(handle->overwrite_files, rootedpath) == 0;
 }
 
 /**
-- 
2.18.0


More information about the pacman-dev mailing list