Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Do not skip the proceed action question when the size or the action is below the limit set in pkg.conf. Only skip printing it
Baptiste Daroussin committed 10 years ago
commit 8a955e6edecf7b473e382ed58beab313a0e744d4
parent b65f236
8 files changed +33 -66
modified 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,
modified 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? ");
modified 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));
modified 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? ");
modified 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;
			}
		}
modified 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 *);
modified 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;
			}
		}
modified 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);
}