diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 8d8fe243..c6048b63 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -2704,7 +2704,8 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); typedef enum _alpm_transflag_t { /** Ignore dependency checks. */ ALPM_TRANS_FLAG_NODEPS = 1, - /* (1 << 1) flag can go here */ + /** Don't keep backup files when installing packages. */ + ALPM_TRANS_FLAG_NOKEEP = (1 << 1), /** Delete files even if they are tagged as backup. */ ALPM_TRANS_FLAG_NOSAVE = (1 << 2), /** Ignore version numbers when checking dependencies. */ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index de39724a..233fff0c 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -575,7 +575,9 @@ static int should_skip_file(alpm_handle_t *handle, { return _alpm_fnmatch_patterns(handle->noupgrade, path) == 0 || alpm_list_find_str(handle->trans->skip_remove, path) - || (newpkg && _alpm_needbackup(path, newpkg) + || (!(handle->trans->flags & ALPM_TRANS_FLAG_NOKEEP) + && newpkg + && _alpm_needbackup(path, newpkg) && alpm_filelist_contains(alpm_pkg_get_files(newpkg), path)); }