From 288cff37f8da02d29f054c736896432a4addfc5c Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 21 Jun 2019 11:06:45 +0200 Subject: [PATCH] xbps-install: return 0 if pkg is already installed or uptodate. Before this change xbps-install could return EEXIST when the package is already installed, or already up-to-date. Return 0 if such condition happens, and only return EEXIST if there's a file conflict. Close #51 --- bin/xbps-install/main.c | 12 ++++++------ bin/xbps-install/transaction.c | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 30033218..bba6337d 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -239,11 +239,11 @@ main(int argc, char **argv) rv = dist_upgrade(&xh, maxcols, yes, drun); } else if (update) { /* Update target packages */ - int npkgs = argc - optind; for (i = optind; i < argc; i++) { rv = update_pkg(&xh, argv[i]); - if (npkgs >= 2 && rv == EEXIST) { - ; + if (rv == EEXIST) { + /* pkg already updated, ignore */ + rv = 0; } else if (rv != 0) { xbps_end(&xh); exit(rv); @@ -252,11 +252,11 @@ main(int argc, char **argv) rv = exec_transaction(&xh, maxcols, yes, drun); } else if (!update) { /* Install target packages */ - int npkgs = argc - optind; for (i = optind; i < argc; i++) { rv = install_new_pkg(&xh, argv[i], reinstall); - if (npkgs >= 2 && rv == EEXIST) { - ; + if (rv == EEXIST) { + /* pkg already installed, ignore */ + rv = 0; } else if (rv != 0) { xbps_end(&xh); exit(rv); diff --git a/bin/xbps-install/transaction.c b/bin/xbps-install/transaction.c index 2601b845..a397f59d 100644 --- a/bin/xbps-install/transaction.c +++ b/bin/xbps-install/transaction.c @@ -389,6 +389,8 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun) trans->dl_pkgcnt, trans->inst_pkgcnt, trans->up_pkgcnt, trans->cf_pkgcnt + trans->inst_pkgcnt, trans->rm_pkgcnt); + } else { + fprintf(stderr, "Transaction failed! see above for errors.\n"); } out: if (trans->iter)