Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/conflict.c
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2017-04-09 20:42:01 -0400
committerAllan McRae <allan@archlinux.org>2017-04-12 11:47:33 +1000
commit04d211effa8d65020887112ee30c7b3b0fc28ad3 (patch)
tree9939b65851a6fc5bb6a0863d286b8da0d4876e74 /lib/libalpm/conflict.c
parent86f5c74694cb0403eaf11fa4734f307a0df345cb (diff)
add --overwrite option to ignore file conflicts
Allows for safer, more fine-grained control for overwriting files than --force's all-or-nothing approach. Implements FS#31549. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/conflict.c')
-rw-r--r--lib/libalpm/conflict.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index b1666dfe..0e37419f 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -385,6 +385,12 @@ static alpm_list_t *alpm_db_find_file_owners(alpm_db_t* db, const char *path)
return owners;
}
+static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path)
+{
+ return handle->trans->flags & ALPM_TRANS_FLAG_FORCE
+ || _alpm_fnmatch_patterns(handle->overwrite_files, path) == 0;
+}
+
/**
* @brief Find file conflicts that may occur during the transaction.
*
@@ -448,8 +454,8 @@ 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((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
- alpm_filelist_contains(p2_files, filename)) {
+ if(_alpm_can_overwrite_file(handle, filename)
+ && alpm_filelist_contains(p2_files, filename)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s exists in both '%s' and '%s'\n", filename,
p1->name, p2->name);
@@ -654,8 +660,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
}
/* skip file-file conflicts when being forced */
- if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
- !S_ISDIR(lsbuf.st_mode)) {
+ if(!S_ISDIR(lsbuf.st_mode)
+ && _alpm_can_overwrite_file(handle, filestr)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"conflict with file on filesystem being forced\n");
resolved_conflict = 1;