[pacman-dev] [PATCH 1/3] alpm: add ALPM_TRANS_FLAG_NOKEEP
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. --- lib/libalpm/alpm.h | 3 ++- lib/libalpm/remove.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) 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)); } -- 2.33.0
--- doc/pacman.8.asciidoc | 3 +++ src/pacman/conf.h | 1 + src/pacman/pacman.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/doc/pacman.8.asciidoc b/doc/pacman.8.asciidoc index bb205627..fd2aa21e 100644 --- a/doc/pacman.8.asciidoc +++ b/doc/pacman.8.asciidoc @@ -269,6 +269,9 @@ Upgrade Options (apply to '-S' and '-U')[[UO]] *\--needed*:: Do not reinstall the targets that are already up-to-date. +*\--nokeep*:: + Overwrite backup files when installing packages. + *\--overwrite* <glob>:: Bypass file conflict checks and overwrite conflicting files. If the package that is about to be installed contains files that are already diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 04350d39..aa10e3a6 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -169,6 +169,7 @@ enum { OP_LOGFILE, OP_IGNOREGROUP, OP_NEEDED, + OP_NOKEEP, OP_ASEXPLICIT, OP_ARCH, OP_PRINTFORMAT, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index db64e05a..262a2ad6 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -164,6 +164,7 @@ static void usage(int op, const char * const myname) addlist(_(" -y, --refresh download fresh package databases from the server\n" " (-yy to force a refresh even if up to date)\n")); addlist(_(" --needed do not reinstall up to date packages\n")); + addlist(_(" --nokeep overwrite backup files when installing packages\n")); } else if(op == PM_OP_DATABASE) { printf("%s: %s {-D --database} <%s> <%s>\n", str_usg, myname, str_opt, str_pkg); printf("%s:\n", str_opt); @@ -731,6 +732,9 @@ static int parsearg_upgrade(int opt) case OP_NEEDED: config->flags |= ALPM_TRANS_FLAG_NEEDED; break; + case OP_NOKEEP: + config->flags |= ALPM_TRANS_FLAG_NOKEEP; + break; case OP_IGNORE: parsearg_util_addlist(&(config->ignorepkg)); break; @@ -941,6 +945,7 @@ static int parseargs(int argc, char *argv[]) {"logfile", required_argument, 0, OP_LOGFILE}, {"ignoregroup", required_argument, 0, OP_IGNOREGROUP}, {"needed", no_argument, 0, OP_NEEDED}, + {"nokeep", no_argument, 0, OP_NOKEEP}, {"asexplicit", no_argument, 0, OP_ASEXPLICIT}, {"arch", required_argument, 0, OP_ARCH}, {"print-format", required_argument, 0, OP_PRINTFORMAT}, -- 2.33.0
--nosave is now useful when installing packages as it can be combined
with --nokeep to reinstall the packages backup files without generating
a pacsave.
---
doc/pacman.8.asciidoc | 10 +++++-----
src/pacman/pacman.c | 11 ++++++-----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/doc/pacman.8.asciidoc b/doc/pacman.8.asciidoc
index fd2aa21e..e880e054 100644
--- a/doc/pacman.8.asciidoc
+++ b/doc/pacman.8.asciidoc
@@ -210,6 +210,11 @@ Transaction Options (apply to '-S', '-R' and '-U')
dependencies are installed and there are no package conflicts in the
system. Specify this option twice to skip all dependency checks.
+*-n, \--nosave*::
+ Instructs pacman to ignore file backup designations. Normally, when a
+ file is removed from the system, the database is checked to see if the
+ file should be renamed with a '.pacsave' extension.
+
*\--assume-installed*
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
participants (2)
-
Allan McRae
-
morganamilo