I get bit by this fairly often when I build AUR packages. From my perspective as a user, the distinction between -U and -S seems irrelevant: I just want to install this package. So let's just have pacman offer to Do What I Mean and install the files if I use -S when I should have used -U. Signed-off-by: Andrew Eikum <coldpie@fastmail.com> --- RFC because this lacks tests and maybe UI polish, but I thought I'd see if there's interest in this change before I put more effort into it. --- src/pacman/sync.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 8b30603..faad728 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -619,6 +619,9 @@ static int process_targname(alpm_list_t *dblist, const char *targname, return process_group(dblist, targname, error); } +#define TGT_FAIL 1 +#define TGT_FAIL_IS_FILE 2 + static int process_target(const char *target, int error) { /* process targets */ @@ -639,7 +642,7 @@ static int process_target(const char *target, int error) if(!db) { pm_printf(ALPM_LOG_ERROR, _("database not found: %s\n"), dbname); - ret = 1; + ret = TGT_FAIL; goto cleanup; } @@ -667,6 +670,7 @@ cleanup: pm_printf(ALPM_LOG_WARNING, _("'%s' is a file, did you mean %s instead of %s?\n"), target, "-U/--upgrade", "-S/--sync"); + ret = TGT_FAIL_IS_FILE; } return ret; } @@ -682,14 +686,29 @@ static int sync_trans(alpm_list_t *targets) } /* process targets */ + if(targets) { + retval = -1; + } for(i = targets; i; i = alpm_list_next(i)) { const char *targ = i->data; - if(process_target(targ, retval) == 1) { - retval = 1; + int ret = process_target(targ, retval); + if(retval < 0) { + retval = ret; + }else if(retval != ret) { + retval = TGT_FAIL; + } + } + + if(retval == TGT_FAIL_IS_FILE) { + int confirm = noyes(_("Proceed with install from file(s)?")); + if(confirm) { + trans_release(); + return pacman_upgrade(targets); } + retval = TGT_FAIL; } - if(retval) { + if(retval == TGT_FAIL) { trans_release(); return retval; } -- 2.8.3