Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Now test and validate a repository before using it
Baptiste Daroussin committed 13 years ago
commit 97408486b20e98b7bd0137237f093a221a45d862
parent f9482bc
4 files changed +14 -8
modified libpkg/pkg_jobs.c
@@ -77,8 +77,14 @@ pkg_jobs_set_flags(struct pkg_jobs *j, pkg_flags flags)
int
pkg_jobs_set_repository(struct pkg_jobs *j, const char *name)
{
-
	/* TODO should validate if the repository exists */
-
	j->reponame = name;
+
	struct pkg_repo *r;
+

+
	if ((r = pkg_repo_find("name")) == NULL) {
+
		pkg_emit_error("Unknown repository: %s", name);
+
		return (EPKG_FATAL);
+
	}
+

+
	j->reponame = r->reponame;

	return (EPKG_OK);
}
modified pkg/fetch.c
@@ -158,8 +158,8 @@ exec_fetch(int argc, char **argv)
	if (pkg_jobs_new(&jobs, PKG_JOBS_FETCH, db) != EPKG_OK)
		goto cleanup;

-
	if (reponame != NULL)
-
		pkg_jobs_set_repository(jobs, reponame);
+
	if (reponame != NULL && pkg_jobs_set_repository(jobs, reponame) != EPKG_OK)
+
		goto cleanup;

	pkg_jobs_set_flags(jobs, f);

modified pkg/install.c
@@ -157,8 +157,8 @@ exec_install(int argc, char **argv)
	if (pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db) != EPKG_OK)
		goto cleanup;

-
	if (reponame != NULL)
-
		pkg_jobs_set_repository(jobs, reponame);
+
	if (reponame != NULL && pkg_jobs_set_repository(jobs, reponame) != EPKG_OK)
+
		goto cleanup;

	pkg_jobs_set_flags(jobs, f);

modified pkg/upgrade.c
@@ -134,8 +134,8 @@ exec_upgrade(int argc, char **argv)
	if (pkg_jobs_new(&jobs, PKG_JOBS_UPGRADE, db) != EPKG_OK)
		goto cleanup;

-
	if (reponame != NULL)
-
		pkg_jobs_set_repository(jobs, reponame);
+
	if (reponame != NULL && pkg_jobs_set_repository(jobs, reponame) != EPKG_OK)
+
		goto cleanup;

	pkg_jobs_set_flags(jobs, f);