Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Force installing/upgradeing pkg first
Baptiste Daroussin committed 14 years ago
commit da8a46f51994c190fc4f1a60148c2206071a4a32
parent 423611f
2 files changed +59 -0
modified pkg/install.c
@@ -56,6 +56,7 @@ exec_install(int argc, char **argv)
	struct pkgdb *db = NULL;
	struct pkg_jobs *jobs = NULL;
	const char *reponame = NULL;
+
	char *pkgargs[1];
	int retcode = 1;
	int ch;
	bool yes = false;
@@ -112,6 +113,35 @@ exec_install(int argc, char **argv)
		goto cleanup;
	}

+
	pkgargs[0] = (char *)"pkg";
+
	if ((it = pkgdb_query_installs(db, MATCH_EXACT, 1, pkgargs, reponame, false)) != NULL) {
+
		if (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC|PKG_LOAD_DEPS) == EPKG_OK) {
+
			pkg_jobs_add(jobs, pkg);
+
			pkg = NULL;
+
		}
+
		if (!quiet) {
+
			print_jobs_summary(jobs, PKG_JOBS_INSTALL,
+
			    "An upgrade of pkg as been found it needs to be installed first.\n"
+
			    "After this upgrade it is recommanded that you do a full upgrade using:\n"
+
			    " pkg upgrade\n\n");
+
			if (!yes)
+
				pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
+
			if (!yes)
+
				yes = query_yesno("\nProceed with upgrading [y/N]: ");
+
		}
+
		if (yes)
+
			if (pkg_jobs_apply(jobs, 0) != EPKG_OK)
+
				goto cleanup;
+

+
		if (messages != NULL) {
+
			sbuf_finish(messages);
+
			printf("%s", sbuf_data(messages));
+
		}
+
		retcode = 0;
+
		goto cleanup;
+
	}
+

+
	it = NULL;
	if ((it = pkgdb_query_installs(db, match, argc, argv, reponame, force)) == NULL)
		goto cleanup;

modified pkg/upgrade.c
@@ -49,6 +49,7 @@ exec_upgrade(int argc, char **argv)
	struct pkg *pkg = NULL;
	struct pkg_jobs *jobs = NULL;
	const char *reponame = NULL;
+
	char *pkgargs[1];
	int retcode = 1;
	int ch;
	bool yes = false;
@@ -95,6 +96,34 @@ exec_upgrade(int argc, char **argv)
		goto cleanup;
	}

+
	pkgargs[0] = (char *)"pkg";
+
	if ((it = pkgdb_query_installs(db, MATCH_EXACT, 1, pkgargs, reponame, false)) != NULL) {
+
		if (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC|PKG_LOAD_DEPS) == EPKG_OK) {
+
			pkg_jobs_add(jobs, pkg);
+
			pkg = NULL;
+
		}
+
		if (!quiet) {
+
			print_jobs_summary(jobs, PKG_JOBS_INSTALL,
+
			    "An upgrade of pkg as been found it needs to be installed first.\n"
+
			    "After this upgrade it is recommanded that you do a full upgrade using:\n"
+
			    " pkg upgrade\n\n");
+
			if (!yes)
+
				pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
+
			if (!yes)
+
				yes = query_yesno("\nProceed with upgrading [y/N]: ");
+
		}
+
		if (yes)
+
			if (pkg_jobs_apply(jobs, 0) != EPKG_OK)
+
				goto cleanup;
+

+
		if (messages != NULL) {
+
			sbuf_finish(messages);
+
			printf("%s", sbuf_data(messages));
+
		}
+
		retcode = 0;
+
		goto cleanup;
+
	}
+

	if ((it = pkgdb_query_upgrades(db, reponame, all)) == NULL) {
		goto cleanup;
	}