Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Rework all tools to use globals.
Vsevolod Stakhov committed 11 years ago
commit 08be5ccd24ae75d2670a42be829fcdce86b8964e
parent 3754837
18 files changed +75 -172
modified src/add.c
@@ -96,6 +96,7 @@ exec_add(int argc, char **argv)
			break;
		case 'f':
			f |= PKG_ADD_FORCE;
+
			force = true;
			break;
		case 'M':
			f |= PKG_ADD_FORCE_MISSING;
modified src/annotate.c
@@ -50,9 +50,6 @@ enum action {
	SHOW,
};

-
static 	bool yes;
-

-

void
usage_annotate(void)
{
@@ -75,7 +72,7 @@ do_add(struct pkgdb *db, struct pkg *pkg, const char *tag, const char *value)
	int		 ret = EPKG_OK;


-
	if (yes || query_tty_yesno(false, "%n-%v: Add annotation tagged: %S with "
+
	if (query_tty_yesno(false, "%n-%v: Add annotation tagged: %S with "
	               "value: %S? [y/N]: ", pkg, pkg, tag, value)) {

		ret = pkgdb_add_annotation(db, pkg, tag, value);
@@ -110,7 +107,7 @@ do_modify(struct pkgdb *db, struct pkg *pkg, const char *tag, const char *value)
	int		 ret = EPKG_OK;


-
	if (yes || query_tty_yesno(false, "%n-%v: Change annotation tagged: %S to "
+
	if (query_tty_yesno(false, "%n-%v: Change annotation tagged: %S to "
		         "new value: %S? [y/N]: ", pkg, pkg, tag, value)) {
		ret = pkgdb_modify_annotation(db, pkg, tag, value);
		if (ret == EPKG_OK || ret == EPKG_WARN) {
@@ -134,7 +131,7 @@ do_delete(struct pkgdb *db, struct pkg *pkg, const char *tag)
	const char	*pkgname, *pkgversion;
	int		 ret = EPKG_OK;

-
	if (yes || query_tty_yesno(false, "%n-%v: Delete annotation tagged: %S "
+
	if (query_tty_yesno(false, "%n-%v: Delete annotation tagged: %S "
			 "[y/N]: ", pkg, pkg, tag)) {
		ret = pkgdb_delete_annotation(db, pkg, tag);
		if (ret == EPKG_OK) {
@@ -244,8 +241,6 @@ exec_annotate(int argc, char **argv)
		{ NULL,			0,		NULL,	0   },
	};

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

        /* Set default case sensitivity for searching */
        pkgdb_set_case_sensitivity(
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
modified src/autoremove.c
@@ -44,16 +44,15 @@ usage_autoremove(void)
}

int
-
exec_autoremove(__unused int argc, __unused char **argv)
+
exec_autoremove(int argc, char **argv)
{
	struct pkgdb *db = NULL;
	struct pkg_jobs *jobs = NULL;
-
	int retcode;
+
	int retcode = EX_OK;
	int ch;
-
	bool yes = false;
-
	bool dry_run = false;
	nbactions = nbdone = 0;
	pkg_flags f = PKG_FLAG_FORCE;
+
	bool rc;

	struct option longopts[] = {
		{ "dry-run",	no_argument,	NULL,	'n' },
@@ -62,8 +61,6 @@ exec_autoremove(__unused int argc, __unused char **argv)
		{ NULL,		0,		NULL,	0   },
	};

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

	while ((ch = getopt_long(argc, argv, "nqy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'n':
@@ -79,7 +76,7 @@ exec_autoremove(__unused int argc, __unused char **argv)
		default:
			break;
		}
-
        }
+
	}
	argc -= optind;
	argv += optind;

@@ -134,22 +131,16 @@ exec_autoremove(__unused int argc, __unused char **argv)

	if (!quiet || dry_run) {
		print_jobs_summary(jobs,
-
		    "Deinstallation has been requested for the following %d packages:\n\n", nbactions);
-
		if (!yes && !dry_run)
-
			yes = query_yesno(false,
+
				"Deinstallation has been requested for the following %d packages:\n\n", nbactions);
+
			rc = query_yesno(false,
		            "\nProceed with deinstalling packages [y/N]: ");
-
		if (dry_run)
-
			yes = false;
	}
-
	if (!yes || (retcode = pkg_jobs_apply(jobs)) != EPKG_OK) {
-
		retcode = EX_SOFTWARE;
+
	if (dry_run || (retcode = pkg_jobs_apply(jobs)) != EPKG_OK) {
		goto cleanup;
	}

	pkgdb_compact(db);

-
	retcode = EX_OK;
-

cleanup:
	pkg_jobs_free(jobs);
	pkgdb_release_lock(db, PKGDB_LOCK_ADVISORY);
modified src/check.c
@@ -134,6 +134,7 @@ fix_deps(struct pkgdb *db, struct deps_head *dh, int nbpkgs, bool yes)
	struct deps_entry *e = NULL;
	char **pkgs = NULL;
	int i = 0;
+
	bool rc;
	pkg_flags f = PKG_FLAG_AUTOMATIC;

	assert(db != NULL);
@@ -178,10 +179,9 @@ fix_deps(struct pkgdb *db, struct deps_head *dh, int nbpkgs, bool yes)
	/* print a summary before applying the jobs */
	print_jobs_summary(jobs, "The following packages will be installed:\n\n");
	
-
	if (!yes)
-
		yes = query_yesno(false, "\n>>> Try to fix the missing dependencies [y/N]: ");
+
	rc = query_yesno(false, "\n>>> Try to fix the missing dependencies [y/N]: ");

-
	if (yes) {
+
	if (rc) {
		if (pkgdb_access(PKGDB_MODE_WRITE, PKGDB_DB_LOCAL) ==
		    EPKG_ENOACCESS) {
			warnx("Insufficient privileges to modify the package "
@@ -257,7 +257,6 @@ exec_check(int argc, char **argv)
	int flags = PKG_LOAD_BASIC;
	int ret, rc = EX_OK;
	int ch;
-
	bool yes;
	bool dcheck = false;
	bool checksums = false;
	bool recompute = false;
@@ -283,13 +282,6 @@ exec_check(int argc, char **argv)
		{ NULL,			0,		NULL,	0   },
	};

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	struct deps_head dh = STAILQ_HEAD_INITIALIZER(dh);

	while ((ch = getopt_long(argc, argv, "aBCdginrsvxy", longopts, NULL)) != -1) {
modified src/clean.c
@@ -168,8 +168,7 @@ exec_clean(int argc, char **argv)
	char		*paths[2], csum[PKG_FILE_CKSUM_CHARS + 1],
			link_buf[MAXPATHLEN];
	bool		 all = false;
-
	bool		 dry_run = false;
-
	bool		 yes, sumloaded = false;
+
	bool		 sumloaded = false;
	int		 retcode;
	int		 ret;
	int		 ch;
@@ -186,8 +185,6 @@ exec_clean(int argc, char **argv)
		{ NULL,		0,		NULL,	0   },
	};

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

	while ((ch = getopt_long(argc, argv, "anqy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'a':
@@ -306,13 +303,13 @@ exec_clean(int argc, char **argv)

	printf("The cleanup will free %s\n", size);
	if (!dry_run) {
-
		if (!yes)
-
			yes = query_yesno(false,
-
				"\nProceed with cleaning the cache [y/N]: ");
-
		if (yes)
-
			retcode = delete_dellist(&dl);
-
	} else
+
			if (query_yesno(false,
+
			  "\nProceed with cleaning the cache [y/N]: ")) {
+
				retcode = delete_dellist(&dl);
+
			}
+
	} else {
		retcode = EX_OK;
+
	}

cleanup:
	pkgdb_release_lock(db, PKGDB_LOCK_READONLY);
modified src/delete.c
@@ -53,10 +53,7 @@ exec_delete(int argc, char **argv)
	struct pkgdb	*db = NULL;
	match_t		 match = MATCH_EXACT;
	pkg_flags	 f = PKG_FLAG_NONE;
-
	bool		 force = false;
-
	bool		 recursive_flag = false;
-
	bool		 yes;
-
	bool		 dry_run = false;
+
	bool		 recursive_flag = false, rc = false;
	int		 retcode = EX_SOFTWARE;
	int		 ch;
	int		 i;
@@ -78,13 +75,6 @@ exec_delete(int argc, char **argv)

	nbactions = nbdone = 0;

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	while ((ch = getopt_long(argc, argv, "aCDfginqRxy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'a':
@@ -216,11 +206,10 @@ exec_delete(int argc, char **argv)
			retcode = EX_OK;
			goto cleanup;
		}
-
		if (!yes && !dry_run)
-
			yes = query_yesno(false,
+
		rc = query_yesno(false,
		            "\nProceed with deinstalling packages [y/N]: ");
	}
-
	if (!yes || (retcode = pkg_jobs_apply(jobs)) != EPKG_OK)
+
	if (!rc || (retcode = pkg_jobs_apply(jobs)) != EPKG_OK)
		goto cleanup;

	pkgdb_compact(db);
modified src/fetch.c
@@ -58,9 +58,7 @@ exec_fetch(int argc, char **argv)
	const char	*reponame = NULL;
	int		 ch;
	int		 retcode = EX_SOFTWARE;
-
	bool		 auto_update;
-
	bool		 upgrades_for_installed = false;
-
	bool		 yes;
+
	bool		 upgrades_for_installed = false, rc;
	unsigned	 mode;
	match_t		 match = MATCH_EXACT;
	pkg_flags	 f = PKG_FLAG_NONE;
@@ -80,14 +78,6 @@ exec_fetch(int argc, char **argv)
		{ NULL,			0,			NULL,	0   },
	};

-
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	while ((ch = getopt_long(argc, argv, "aCdgiqr:Uuxy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'a':
@@ -203,12 +193,13 @@ exec_fetch(int argc, char **argv)

	if (!quiet) {
		print_jobs_summary(jobs, "The following packages will be fetched:\n\n");
-

-
		if (!yes)
-
			yes = query_yesno(false, "\nProceed with fetching packages [y/N]: ");
+
		rc = query_yesno(false, "\nProceed with fetching packages [y/N]: ");
+
	}
+
	else {
+
		rc = true;
	}
	
-
	if (!yes || pkg_jobs_apply(jobs) != EPKG_OK)
+
	if (!rc || pkg_jobs_apply(jobs) != EPKG_OK)
		goto cleanup;

	retcode = EX_OK;
modified src/info.c
@@ -128,10 +128,6 @@ exec_info(int argc, char **argv)
		{ NULL,			0,			NULL,	0   },
	};

-
	/* Set default case sensitivity for searching */
-
	pkgdb_set_case_sensitivity(
-
	    pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH")));
-

	/* TODO: exclusive opts ? */
	while ((ch = getopt_long(argc, argv, "aAbBCdDeEfF:giIkloOpqrRsx", longopts, NULL)) != -1) {
		switch (ch) {
modified src/install.c
@@ -62,11 +62,9 @@ exec_install(int argc, char **argv)
	int		 ch;
	int		 mode, repo_type;
	int		 lock_type = PKGDB_LOCK_ADVISORY;
-
	bool		 yes, yes_arg;
-
	bool		 auto_update;
+
	bool		 rc = false;
	bool		 local_only = false;
	match_t		 match = MATCH_EXACT;
-
	bool		 dry_run = false;
	pkg_flags	 f = PKG_FLAG_NONE | PKG_FLAG_PKG_VERSION_TEST;

	struct option longopts[] = {
@@ -91,20 +89,10 @@ exec_install(int argc, char **argv)

	nbactions = nbdone = 0;

-
	yes_arg = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
-

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

-
	yes = yes_arg;
-

	if (strcmp(argv[0], "add") == 0) {
		auto_update = false;
		local_only = true;
-
		yes_arg = true;
+
		yes = true;
		quiet = true;
	}

@@ -160,7 +148,7 @@ exec_install(int argc, char **argv)
			match = MATCH_REGEX;
			break;
		case 'y':
-
			yes_arg = true;
+
			yes = true;
			break;
		default:
			usage_install();
@@ -233,22 +221,24 @@ exec_install(int argc, char **argv)
	if (pkg_jobs_solve(jobs) != EPKG_OK)
		goto cleanup;

+
	rc = yes;
	while ((nbactions = pkg_jobs_count(jobs)) > 0) {
		/* print a summary before applying the jobs */
-
		yes = yes_arg;
		if (!quiet || dry_run) {
			print_jobs_summary(jobs,
			    "The following %d packages will be affected (of %d checked):\n\n",
			    nbactions, pkg_jobs_total(jobs));

-
			if (!yes && !dry_run)
-
				yes = query_yesno(false, 
+
			if (!dry_run) {
+
				rc = query_yesno(false,
				    "\nProceed with this action [y/N]: ");
-
			if (dry_run)
-
				yes = false;
+
			}
+
			else {
+
				rc = false;
+
			}
		}

-
		if (yes) {
+
		if (rc) {
			retcode = pkg_jobs_apply(jobs);
			if (retcode == EPKG_CONFLICT) {
				printf("Conflicts with the existing packages "
@@ -274,7 +264,7 @@ cleanup:
	pkg_jobs_free(jobs);
	pkgdb_close(db);

-
	if (!yes && newpkgversion)
+
	if (!rc && newpkgversion)
		newpkgversion = false;

	return (retcode);
modified src/lock.c
@@ -43,8 +43,6 @@ static int exec_lock_unlock(int, char**, enum action);
static int do_lock(struct pkgdb *db, struct pkg *pkg);
static int do_unlock(struct pkgdb *db, struct pkg *pkg);

-
static bool yes = false;	/* Assume yes answer to questions */
-

void
usage_lock(void)
{
@@ -65,7 +63,7 @@ do_lock(struct pkgdb *db, struct pkg *pkg)
		return (EPKG_OK);
	}

-
	if (!yes && !query_yesno(false, "%n-%v: lock this package? [y/N]: ",
+
	if (!query_yesno(false, "%n-%v: lock this package? [y/N]: ",
				 pkg, pkg))
		return (EPKG_OK);

@@ -85,7 +83,7 @@ do_unlock(struct pkgdb *db, struct pkg *pkg)
		return (EPKG_OK);
	}

-
	if (!yes && !query_yesno(false, "%n-%v: unlock this package? [y/N]: ",
+
	if (!query_yesno(false, "%n-%v: unlock this package? [y/N]: ",
				 pkg, pkg))
		return (EPKG_OK);

@@ -150,13 +148,6 @@ exec_lock_unlock(int argc, char **argv, enum action action)
		{ NULL,		0,			NULL,	0   },
	};

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	while ((ch = getopt_long(argc, argv, "aCgilqxy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'a':
modified src/plugins.c
@@ -43,7 +43,7 @@ usage_plugins(void)
}

int
-
exec_plugins(__unused int argc, __unused char **argv)
+
exec_plugins(int argc, char **argv)
{
	struct pkg_plugin *p = NULL;
	int ch;
modified src/query.c
@@ -861,11 +861,6 @@ exec_query(int argc, char **argv)
		{ NULL,			0,			NULL,	0   },
	};

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	while ((ch = getopt_long(argc, argv, "aCe:F:gix", longopts, NULL)) != -1) {
		switch (ch) {
		case 'a':
modified src/rquery.c
@@ -130,15 +130,8 @@ exec_rquery(int argc, char **argv)
		{ NULL,			0,			NULL,	0   },
	};

-
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
-

	portsdir = pkg_object_string(pkg_config_get("PORTSDIR"));

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	while ((ch = getopt_long(argc, argv, "aCgiIxe:r:U", longopts, NULL)) != -1) {
		switch (ch) {
		case 'a':
@@ -187,7 +180,7 @@ exec_rquery(int argc, char **argv)
	if (!index_output) {
		if (argc == 1 && condition == NULL && match == MATCH_EXACT) {
			match = MATCH_ALL;
-
		} else if ((argc == 1) ^ (match == MATCH_ALL ) && condition == NULL) {
+
		} else if (((argc == 1) ^ (match == MATCH_ALL )) && condition == NULL) {
			usage_rquery();
			return (EX_USAGE);
		}
modified src/search.c
@@ -255,7 +255,6 @@ exec_search(int argc, char **argv)
	struct pkgdb_it	*it = NULL;
	struct pkg	*pkg = NULL;
	bool		 atleastone = false;
-
	bool		 auto_update;
	bool		 old_quiet;

	struct option longopts[] = {
@@ -281,12 +280,6 @@ exec_search(int argc, char **argv)
		{ NULL,			0,			NULL,	0   },
	};

-
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
-

-
	/* Set default case sensitivity for searching */
-
	pkgdb_set_case_sensitivity(
-
	    pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH")));
-

	while ((ch = getopt_long(argc, argv, "CcDdefgiL:opqQ:r:RS:sUx", longopts, NULL)) != -1) {
		switch (ch) {
		case 'C':
modified src/set.c
@@ -55,10 +55,10 @@ exec_set(int argc, char **argv)
	struct pkg	*pkg = NULL;
	int		 ch;
	int		 i;
-
	bool		 yes;
	match_t		 match = MATCH_EXACT;
	int64_t		 newautomatic = -1;
	bool		 automatic = false;
+
	bool		 rc = false;
	const char	*errstr;
	char		*neworigin = NULL;
	char		*oldorigin = NULL;
@@ -78,13 +78,6 @@ exec_set(int argc, char **argv)
		{ NULL,			0,			NULL,	0   },
	};

-
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-

-
        /* Set default case sensitivity for searching */
-
        pkgdb_set_case_sensitivity(
-
                pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"))
-
                );
-

	while ((ch = getopt_long(argc, argv, "A:aCgio:xy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'A':
@@ -193,14 +186,12 @@ exec_set(int argc, char **argv)
			return (EX_SOFTWARE);*/
		}

-
		if (!yes) {
-
			if (pkg != NULL)
-
				yes = query_yesno(false, "Change origin from %S to %S for %n-%v? [y/N]: ",
-
				    oldorigin, neworigin, pkg, pkg);
-
			else
-
				yes = query_yesno(false, "Change origin from %S to %S for all dependencies? "
-
				    "[y/N]: ", oldorigin, neworigin);
-
		}
+
		if (pkg != NULL)
+
			rc = query_yesno(false, "Change origin from %S to %S for %n-%v? [y/N]: ",
+
					oldorigin, neworigin, pkg, pkg);
+
		else
+
			rc = query_yesno(false, "Change origin from %S to %S for all dependencies? "
+
					"[y/N]: ", oldorigin, neworigin);
		if (pkg != NULL && yes) {
			if (pkgdb_set(db, pkg, PKG_SET_ORIGIN, neworigin) != EPKG_OK) {
				retcode = EX_IOERR;
@@ -211,7 +202,7 @@ exec_set(int argc, char **argv)
	}
	i = 0;
	do {
-
		bool save_yes = yes;
+
		bool saved_rc = rc;

		if ((it = pkgdb_query(db, argv[i], match)) == NULL) {
			retcode = EX_IOERR;
@@ -223,15 +214,19 @@ exec_set(int argc, char **argv)
				pkg_get(pkg, PKG_AUTOMATIC, &automatic);
				if (automatic == newautomatic)
					continue;
-
				if (!yes) {
+
				if (!rc) {
					if (newautomatic)
-
						yes = query_yesno(false, "Mark %n-%v as automatically installed? [y/N]: ", pkg, pkg);
+
						rc = query_yesno(false,
+
								"Mark %n-%v as automatically installed? [y/N]: ",
+
								pkg, pkg);
					else
-
						yes = query_yesno(false, "Mark %n-%v as not automatically installed? [y/N]: ", pkg, pkg);
+
						rc = query_yesno(false,
+
								"Mark %n-%v as not automatically installed? [y/N]: ",
+
								pkg, pkg);
				}
-
				if (yes)
+
				if (rc)
					pkgdb_set(db, pkg, PKG_SET_AUTOMATIC, newautomatic);
-
				yes = save_yes;
+
				rc = saved_rc;
			}
			if ((sets & ORIGIN) == ORIGIN) {
				struct pkg_dep *d = NULL;
modified src/stats.c
@@ -45,7 +45,7 @@ usage_stats(void)
}

int
-
exec_stats(__unused int argc, __unused char **argv)
+
exec_stats(int argc, char **argv)
{
	struct pkgdb	*db = NULL;
	int64_t		 flatsize = 0;
@@ -112,7 +112,7 @@ exec_stats(__unused int argc, __unused char **argv)
		}
	}

-
	if (opt & STATS_REMOTE && pkg_repos_total_count() > 0) {
+
	if ((opt & STATS_REMOTE) && pkg_repos_total_count() > 0) {
		printf("Remote package database(s):\n");
		printf("\tNumber of repositories: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_REPOS));
		printf("\tPackages available: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_COUNT));
modified src/update.c
@@ -110,7 +110,6 @@ exec_update(int argc, char **argv)
{
	int		 ret;
	int		 ch;
-
	bool		 force = false;
	const char	*reponame = NULL;

	struct option longopts[] = {
modified src/upgrade.c
@@ -54,10 +54,8 @@ exec_upgrade(int argc, char **argv)
	int		 ch;
	int		 lock_type = PKGDB_LOCK_ADVISORY;
	match_t		 match = MATCH_EXACT;
-
	bool		 yes = true, yes_arg = false;
-
	bool		 dry_run = false;
-
	bool		 auto_update;
	int		 done = 0;
+
	bool	rc = false;
	pkg_flags	 f = PKG_FLAG_NONE | PKG_FLAG_PKG_VERSION_TEST;

	struct option longopts[] = {
@@ -78,9 +76,6 @@ exec_upgrade(int argc, char **argv)

	nbactions = nbdone = 0;

-
	yes_arg = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
-
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
-

	while ((ch = getopt_long(argc, argv, "CfFgiInqr:Uxy", longopts, NULL)) != -1) {
		switch (ch) {
		case 'C':
@@ -120,7 +115,7 @@ exec_upgrade(int argc, char **argv)
			match = MATCH_REGEX;
			break;
		case 'y':
-
			yes_arg = true;
+
			yes = true;
			break;
		default:
			usage_upgrade();
@@ -184,19 +179,19 @@ exec_upgrade(int argc, char **argv)

	while ((nbactions = pkg_jobs_count(jobs)) > 0) {
		/* print a summary before applying the jobs */
-
		yes = yes_arg;
+
		rc = yes;
		if (!quiet || dry_run) {
			print_jobs_summary(jobs,
				"The following %d packages will be affected (of %d checked):\n\n",
				nbactions, pkg_jobs_total(jobs));

-
			if (!yes && !dry_run)
-
				yes = query_yesno(false, "\nProceed with this action [y/N]: ");
-
			if (dry_run)
-
				yes = false;
+
			if (!dry_run)
+
				rc = query_yesno(false, "\nProceed with this action [y/N]: ");
+
			else
+
				rc = false;
		}

-
		if (yes) {
+
		if (rc) {
			retcode = pkg_jobs_apply(jobs);
			done = 1;
			if (retcode == EPKG_CONFLICT) {
@@ -216,7 +211,7 @@ exec_upgrade(int argc, char **argv)
		break;
	}

-
	if (done == 0 && yes)
+
	if (done == 0 && rc)
		printf("Your packages are up to date\n");

	retcode = EX_OK;
@@ -226,7 +221,7 @@ cleanup:
	pkgdb_release_lock(db, lock_type);
	pkgdb_close(db);

-
	if (!yes && newpkgversion)
+
	if (!rc && newpkgversion)
		newpkgversion = false;

	return (retcode);