feat: flag added, missing abort transaction if flag set

This commit is contained in:
jg 2025-02-04 21:35:01 +01:00 committed by jgomez
parent 0f6b4f4fab
commit 649878d5d4
3 changed files with 8 additions and 1 deletions

View file

@ -2816,7 +2816,8 @@ typedef enum _alpm_transflag_t {
ALPM_TRANS_FLAG_NOSCRIPTLET = (1 << 10),
/** Ignore dependency conflicts. */
ALPM_TRANS_FLAG_NOCONFLICTS = (1 << 11),
/* (1 << 12) flag can go here */
/** Cancel removal of package if it's optdepends of another package. */
ALPM_TRANS_KEEP_OPTIONALS = (1 << 12),
/** 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. */

View file

@ -257,6 +257,7 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
/* Note packages being removed that are optdepends for installed packages */
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
/*DEV_COMMENT: This is where the check is done, use this logic to check flag ALPM_TRANS_KEEP_OPTIONALS and abort transaction if flag set */
remove_notify_needed_optdepends(handle, trans->remove);
}

View file

@ -729,6 +729,11 @@ static int parsearg_remove(int opt)
case 'u':
config->flags |= ALPM_TRANS_FLAG_UNNEEDED;
break;
case 'k':
if (config->flags & ALPM_TRANS_FLAG_RECURSE || config->flags & ALPM_TRANS_FLAG_RECURSEALL) {
config->flags |= ALPM_TRANS_KEEP_OPTIONALS;
}
break;
default:
return 1;
}