From 09f1e13659a307e808fd625ee6dfc8a3bb6d6bc7 Mon Sep 17 00:00:00 2001 From: jg Date: Sun, 9 Feb 2025 20:28:36 +0100 Subject: [PATCH] feat: removed keepoptdep references, changed logic to take into account RECURSEALL instead --- lib/libalpm/alpm.h | 3 +-- lib/libalpm/remove.c | 10 ++-------- src/pacman/conf.h | 1 - src/pacman/pacman.c | 7 ------- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 932959b3..41d4c029 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -2818,8 +2818,7 @@ typedef enum _alpm_transflag_t { ALPM_TRANS_FLAG_NOSCRIPTLET = (1 << 10), /** Ignore dependency conflicts. */ ALPM_TRANS_FLAG_NOCONFLICTS = (1 << 11), - /** Cancel removal of package if it's optdepends of another package. */ - ALPM_TRANS_FLAG_KEEPOPTIONALS = (1 << 12), + /* (1 << 12) flag can go here */ /** Do not install a package if it is already installed and up to date. */ ALPM_TRANS_FLAG_NEEDED = (1 << 13), /** Use ALPM_PKG_REASON_EXPLICIT when installing packages. */ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 61118a57..a6fe2193 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -268,18 +268,12 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data) removing_optdepends = remove_notify_needed_optdepends(handle, trans->remove); } - /* -Rks or Rsk == -Rs then -Rk */ - if (trans->flags & ALPM_TRANS_FLAG_RECURSE - && trans->flags & ALPM_TRANS_FLAG_KEEPOPTIONALS + if ((trans->flags & ALPM_TRANS_FLAG_RECURSE) + && !(trans->flags & ALPM_TRANS_FLAG_RECURSEALL) && removing_optdepends) { RET_ERR(handle, ALPM_ERR_REMOVING_OPTDEPENDS_DEPS, -1); } - if (!(trans->flags & ALPM_TRANS_FLAG_RECURSE) - && trans->flags & ALPM_TRANS_FLAG_KEEPOPTIONALS) { - _alpm_log(handle, ALPM_LOG_WARNING, _("-k is set without -s or --recursive, ignoring flag...\n")); - } - if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) { event.type = ALPM_EVENT_CHECKDEPS_DONE; EVENT(handle, &event); diff --git a/src/pacman/conf.h b/src/pacman/conf.h index c2975848..5bffd187 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -209,7 +209,6 @@ enum { OP_UPGRADES, OP_SYSUPGRADE, OP_UNNEEDED, - OP_KEEPOPTDEP, OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 4ac9e015..8f5fb6de 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -126,8 +126,6 @@ static void usage(int op, const char * const myname) addlist(_(" -n, --nosave remove configuration files\n")); addlist(_(" -s, --recursive remove unnecessary dependencies\n" " (-ss includes explicitly installed dependencies)\n")); - addlist(_(" -k, --keepoptdep keep the packages flagged as optdepends by other packages\n" - " (only applied when using -s or --recursive)\n")); addlist(_(" -u, --unneeded remove unneeded packages\n")); } else if(op == PM_OP_UPGRADE) { printf("%s: %s {-U --upgrade} [%s] <%s>\n", str_usg, myname, str_opt, str_file); @@ -731,10 +729,6 @@ static int parsearg_remove(int opt) case 'u': config->flags |= ALPM_TRANS_FLAG_UNNEEDED; break; - case OP_KEEPOPTDEP: - case 'k': - config->flags |= ALPM_TRANS_FLAG_KEEPOPTIONALS; - break; default: return 1; } @@ -960,7 +954,6 @@ static int parseargs(int argc, char *argv[]) {"upgrades", no_argument, 0, OP_UPGRADES}, {"sysupgrade", no_argument, 0, OP_SYSUPGRADE}, {"unneeded", no_argument, 0, OP_UNNEEDED}, - {"keepoptdep", no_argument, 0, OP_KEEPOPTDEP}, {"verbose", no_argument, 0, OP_VERBOSE}, {"downloadonly", no_argument, 0, OP_DOWNLOADONLY}, {"refresh", no_argument, 0, OP_REFRESH},