Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2018-07-19 13:54:54 +1000
committerAllan McRae <allan@archlinux.org>2018-07-27 10:24:57 +1000
commit0827aff85ee3ac9a02031cbeeb49cae2ae088529 (patch)
tree78fb8df628d8d488da984a732f87ee5e766e4b3f /lib
parent316b031b7c1c8b9a6f4194b1378c58106b2a34dd (diff)
Handle root prefix in overwrite operations
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@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/conflict.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 35946de5..716d0088 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -399,10 +399,11 @@ static alpm_pkg_t *_alpm_find_file_owner(alpm_handle_t *handle, const char *path
return NULL;
}
-static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path)
+static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path, const char *rootedpath)
{
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;
}
/**
@@ -468,7 +469,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* can skip file-file conflicts when forced *
* checking presence in p2_files detects dir-file or file-dir
* conflicts as the path from p1 is returned */
- if(_alpm_can_overwrite_file(handle, filename)
+ if(_alpm_can_overwrite_file(handle, filename, path)
&& alpm_filelist_contains(p2_files, filename)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s exists in both '%s' and '%s'\n", filename,
@@ -675,7 +676,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* skip file-file conflicts when being forced */
if(!S_ISDIR(lsbuf.st_mode)
- && _alpm_can_overwrite_file(handle, filestr)) {
+ && _alpm_can_overwrite_file(handle, filestr, path)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"conflict with file on filesystem being forced\n");
resolved_conflict = 1;