Message ID | 20210920193517.259549-1-morganamilo@archlinux.org |
---|---|
State | Under Review |
Headers | show |
Series | [pacman-dev,1/3] alpm: add ALPM_TRANS_FLAG_NOKEEP | expand |
On 21/9/21 05:35, morganamilo wrote: > this flag prevents backup files from being kept on package installation. > This is useful for resetting a package's config files back to their > original state. > > Implements FS#59908 although with it's own flag name instead of reusing > nosave. This allows nokeep to optionally create a pacnew that you can > then choose to disable by also setting nosave. > > --- > > I actually very dislike NOKEEP but it was the best I could come up with > > I would have prefered overwrite or nosave but they are taken. Better > names are welcome. Do we really need a flag for this. rm <backup file> pacman -S <package> or even pacman -Sw package tar xf <pkg> <file> Allan
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)); }