Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Make 'pkg install' return failure on missing dependencies.
John Hood committed 4 years ago
commit 73dfd7ffc4c8d6e405fdbec138e5e34824bb6ea5
parent 54db538
2 files changed +22 -17
modified libpkg/pkg_jobs.c
@@ -1680,7 +1680,9 @@ jobs_solve_partial_upgrade(struct pkg_jobs *j)
	it = pkghash_iterator(j->request_add);
	while (pkghash_next(&it)) {
		req = it.value;
-
		pkg_jobs_universe_process(j->universe, req->item->pkg);
+
		retcode = pkg_jobs_universe_process(j->universe, req->item->pkg);
+
		if (retcode != EPKG_OK)
+
			return (retcode);
	}
	return (EPKG_OK);
}
@@ -1758,6 +1760,7 @@ jobs_solve_fetch(struct pkg_jobs *j)
	struct pkgdb_it *it;
	struct pkg_job_request *req;
	pkghash_it hit;
+
	pkg_error_t rc;

	if ((j->flags & PKG_FLAG_UPGRADES_FOR_INSTALLED) == PKG_FLAG_UPGRADES_FOR_INSTALLED) {
		if ((it = pkgdb_query(j->db, NULL, MATCH_ALL)) == NULL)
@@ -1784,7 +1787,9 @@ jobs_solve_fetch(struct pkg_jobs *j)
		hit = pkghash_iterator(j->request_add);
		while (pkghash_next(&hit)) {
			req = hit.value;
-
			pkg_jobs_universe_process(j->universe, req->item->pkg);
+
			rc = pkg_jobs_universe_process(j->universe, req->item->pkg);
+
			if (rc != EPKG_OK)
+
				return (rc);
		}
	}

modified src/install.c
@@ -58,6 +58,7 @@ exec_install(int argc, char **argv)
	struct pkg_jobs	*jobs = NULL;
	const char	*reponame = NULL;
	int		 retcode;
+
	int		 status;
	int		 updcode = EPKG_OK;
	int		 ch;
	int		 mode, repo_type;
@@ -188,8 +189,6 @@ exec_install(int argc, char **argv)
		return (EXIT_FAILURE);
	} else if (retcode != EPKG_OK)
		return (EXIT_FAILURE);
-
	else
-
		retcode = EXIT_FAILURE;

	/* first update the remote repositories if needed */
	if (auto_update && pkg_repos_total_count() > 0 &&
@@ -207,6 +206,7 @@ exec_install(int argc, char **argv)
		return (EXIT_FAILURE);
	}

+
	status = EXIT_FAILURE;
	if (pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db) != EPKG_OK)
		goto cleanup;

@@ -222,6 +222,7 @@ exec_install(int argc, char **argv)
	if (pkg_jobs_solve(jobs) != EPKG_OK)
		goto cleanup;

+
	status = EXIT_SUCCESS;
	while ((nbactions = pkg_jobs_count(jobs)) > 0) {
		rc = yes;
		/* print a summary before applying the jobs */
@@ -229,13 +230,13 @@ exec_install(int argc, char **argv)
			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)
+
			break;

-
			if (!dry_run) {
-
				rc = query_yesno(false,
-
				    "\nProceed with this action? ");
-
			} else {
-
				rc = false;
-
			}
+
		if (!quiet) {
+
			rc = query_yesno(false,
+
			    "\nProceed with this action? ");
		}

		if (rc) {
@@ -247,9 +248,10 @@ exec_install(int argc, char **argv)
				    "iteration is needed to resolve them.\n");
				continue;
			}
-
			else if (retcode != EPKG_OK)
+
			else if (retcode != EPKG_OK) {
+
				status = retcode;
				goto cleanup;
-
		} else {
+
			}
		}

		if (messages != NULL) {
@@ -262,10 +264,8 @@ exec_install(int argc, char **argv)
	if (done == 0 && rc)
		printf("The most recent versions of packages are already installed\n");

-
	if (rc)
-
		retcode = EXIT_SUCCESS;
-
	else
-
		retcode = EXIT_FAILURE;
+
	if (!rc)
+
		status = EXIT_FAILURE;

cleanup:
	pkgdb_release_lock(db, lock_type);
@@ -278,5 +278,5 @@ cleanup:
	if (!rc && newpkgversion)
		newpkgversion = false;

-
	return (retcode);
+
	return (status);
}