From 249b37251ee9339d2b2f5aa3b5b48b2ad722e490 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 2 Apr 2016 14:04:11 +0200 Subject: [PATCH] Do not skip the proceed action when the size or the action is below the limit set in pkg.conf. Only skip printing it --- src/autoremove.c | 2 +- src/check.c | 2 +- src/delete.c | 2 +- src/fetch.c | 19 +++++-------------- src/install.c | 17 ++++------------- src/pkgcli.h | 5 +---- src/upgrade.c | 17 ++++------------- src/utils.c | 35 ++++++++++++++++------------------- 8 files changed, 33 insertions(+), 66 deletions(-) diff --git a/src/autoremove.c b/src/autoremove.c index fef6f1a..e7e490d 100644 --- a/src/autoremove.c +++ b/src/autoremove.c @@ -133,7 +133,7 @@ exec_autoremove(int argc, char **argv) } if (!quiet || dry_run) { - print_jobs_summary(jobs, NULL, NULL, + print_jobs_summary(jobs, "Deinstallation has been requested for the following %d packages:\n\n", nbactions); if (!dry_run) rc = query_yesno(false, diff --git a/src/check.c b/src/check.c index 08f34b2..67ce037 100644 --- a/src/check.c +++ b/src/check.c @@ -199,7 +199,7 @@ fix_deps(struct pkgdb *db, struct deps_entry *dh, int nbpkgs) } /* print a summary before applying the jobs */ - print_jobs_summary(jobs, NULL, NULL, + print_jobs_summary(jobs, "The following packages will be installed:\n\n"); rc = query_yesno(false, "\n>>> Try to fix the missing dependencies? "); diff --git a/src/delete.c b/src/delete.c index 767ea33..718c8cf 100644 --- a/src/delete.c +++ b/src/delete.c @@ -205,7 +205,7 @@ exec_delete(int argc, char **argv) if (!quiet || dry_run) { if (!quiet) { - print_jobs_summary(jobs, NULL, NULL, + print_jobs_summary(jobs, "Deinstallation has been requested for the following %d packages " "(of %d packages in the universe):\n\n", nbactions, pkg_jobs_total(jobs)); diff --git a/src/fetch.c b/src/fetch.c index 29755d3..2225422 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -65,9 +65,6 @@ exec_fetch(int argc, char **argv) unsigned mode; match_t match = MATCH_EXACT; pkg_flags f = PKG_FLAG_NONE; - size_t dlbytes, diffbytes, limbytes; - - limbytes = pkg_object_int(pkg_config_get("WARN_SIZE_LIMIT")); struct option longopts[] = { { "all", no_argument, NULL, 'a' }, @@ -204,19 +201,13 @@ exec_fetch(int argc, char **argv) if (!quiet) { - rc = print_jobs_summary(jobs, &diffbytes, &dlbytes, - "The following packages will be fetched:\n\n"); + rc = print_jobs_summary(jobs, + "The following packages will be fetched:\n\n"); if (rc != 0) { - if (limbytes && (diffbytes > limbytes || dlbytes > limbytes)) { - rc = query_yesno(false, "\nProceed with fetching " - "packages? "); - } - else { - rc = true; - } - } - else { + rc = query_yesno(false, "\nProceed with fetching " + "packages? "); + } else { printf("No packages are required to be fetched.\n"); rc = query_yesno(false, "Check the integrity of packages " "downloaded? "); diff --git a/src/install.c b/src/install.c index 51703d1..15e504b 100644 --- a/src/install.c +++ b/src/install.c @@ -68,9 +68,6 @@ exec_install(int argc, char **argv) bool local_only = false; match_t match = MATCH_EXACT; pkg_flags f = PKG_FLAG_NONE | PKG_FLAG_PKG_VERSION_TEST; - size_t dlbytes, diffbytes, limbytes; - - limbytes = pkg_object_int(pkg_config_get("WARN_SIZE_LIMIT")); struct option longopts[] = { { "automatic", no_argument, NULL, 'A' }, @@ -230,20 +227,14 @@ exec_install(int argc, char **argv) rc = yes; /* print a summary before applying the jobs */ if (!quiet || dry_run) { - print_jobs_summary(jobs, &diffbytes, &dlbytes, + print_jobs_summary(jobs, "The following %d package(s) will be affected (of %d checked):\n\n", nbactions, pkg_jobs_total(jobs)); if (!dry_run) { - if (limbytes && (diffbytes > limbytes || dlbytes > limbytes)) { - rc = query_yesno(false, - "\nProceed with this action? "); - } - else { - rc = true; - } - } - else { + rc = query_yesno(false, + "\nProceed with this action? "); + } else { rc = false; } } diff --git a/src/pkgcli.h b/src/pkgcli.h index 87cbc2d..ec4a056 100644 --- a/src/pkgcli.h +++ b/src/pkgcli.h @@ -266,10 +266,7 @@ int query_select(const char *msg, const char **opts, int ncnt, int deft); bool query_tty_yesno(bool deft, const char *msg, ...); int info_flags(uint64_t opt, bool remote); void print_info(struct pkg * const pkg, uint64_t opt); -int print_jobs_summary(struct pkg_jobs *j, - size_t *bytes_change, - size_t *bytes_download, - const char *msg, ...); +int print_jobs_summary(struct pkg_jobs *j, const char *msg, ...); void job_status_begin(struct sbuf *); void job_status_end(struct sbuf *); diff --git a/src/upgrade.c b/src/upgrade.c index 38fda3f..d2789ff 100644 --- a/src/upgrade.c +++ b/src/upgrade.c @@ -58,9 +58,6 @@ exec_upgrade(int argc, char **argv) int done = 0; bool rc = true; pkg_flags f = PKG_FLAG_NONE | PKG_FLAG_PKG_VERSION_TEST; - size_t dlbytes, diffbytes, limbytes; - - limbytes = pkg_object_int(pkg_config_get("WARN_SIZE_LIMIT")); struct option longopts[] = { { "case-sensitive", no_argument, NULL, 'C' }, @@ -185,20 +182,14 @@ exec_upgrade(int argc, char **argv) /* print a summary before applying the jobs */ rc = yes; if (!quiet || dry_run) { - print_jobs_summary(jobs, &diffbytes, &dlbytes, + print_jobs_summary(jobs, "The following %d package(s) will be affected (of %d checked):\n\n", nbactions, pkg_jobs_total(jobs)); if (!dry_run) { - if (limbytes && (diffbytes > limbytes || dlbytes > limbytes)) { - rc = query_yesno(false, "\nProceed with this " - "action? "); - } - else { - rc = true; - } - } - else { + rc = query_yesno(false, "\nProceed with this " + "action? "); + } else { rc = false; } } diff --git a/src/utils.c b/src/utils.c index 480fdb3..ac5527e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -886,8 +886,7 @@ static const char* pkg_display_messages[PKG_DISPLAY_MAX + 1] = { }; int -print_jobs_summary(struct pkg_jobs *jobs, size_t *bytes_change, size_t *bytes_download, - const char *msg, ...) +print_jobs_summary(struct pkg_jobs *jobs, const char *msg, ...) { struct pkg *new_pkg, *old_pkg; void *iter = NULL; @@ -897,6 +896,7 @@ print_jobs_summary(struct pkg_jobs *jobs, size_t *bytes_change, size_t *bytes_do int64_t dlsize, oldsize, newsize; struct pkg_solved_display_item *disp[PKG_DISPLAY_MAX], *cur, *tmp; bool first = true; + size_t bytes_change, limbytes; dlsize = oldsize = newsize = 0; type = pkg_jobs_type(jobs); @@ -929,18 +929,23 @@ print_jobs_summary(struct pkg_jobs *jobs, size_t *bytes_change, size_t *bytes_do } } + limbytes = pkg_object_int(pkg_config_get("WARN_SIZE_LIMIT")); + bytes_change = labs(newsize - oldsize); + /* Add an extra line before the size output. */ - if (oldsize != newsize || dlsize) + if (bytes_change > limbytes || dlsize) puts(""); - if (oldsize > newsize) { - humanize_number(size, sizeof(size), oldsize - newsize, "B", - HN_AUTOSCALE, HN_IEC_PREFIXES); - printf("The operation will free %s.\n", size); - } else if (newsize > oldsize) { - humanize_number(size, sizeof(size), newsize - oldsize, "B", - HN_AUTOSCALE, HN_IEC_PREFIXES); - printf("The process will require %s more space.\n", size); + if (bytes_change > limbytes) { + if (oldsize > newsize) { + humanize_number(size, sizeof(size), oldsize - newsize, "B", + HN_AUTOSCALE, HN_IEC_PREFIXES); + printf("The operation will free %s.\n", size); + } else if (newsize > oldsize) { + humanize_number(size, sizeof(size), newsize - oldsize, "B", + HN_AUTOSCALE, HN_IEC_PREFIXES); + printf("The process will require %s more space.\n", size); + } } if (dlsize > 0) { @@ -949,14 +954,6 @@ print_jobs_summary(struct pkg_jobs *jobs, size_t *bytes_change, size_t *bytes_do printf("%s to be downloaded.\n", size); } - if (bytes_download) { - *bytes_download = dlsize; - } - - if (bytes_change) { - *bytes_change = labs(newsize - oldsize); - } - return (displayed); } -- 2.7.4