Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Finish supporting multi version repo correctly
Baptiste Daroussin committed 10 years ago
commit 89dc0cf98be424c43b65756ce5df7d55c6391908
parent 1c37f79
4 files changed +27 -12
modified libpkg/pkg_jobs.c
@@ -476,7 +476,7 @@ pkg_jobs_process_add_request(struct pkg_jobs *j)
			 * is newer than a local one
			 */
			un = pkg_jobs_universe_get_upgrade_candidates(j->universe,
-
				d->uid, lp, force);
+
				d->uid, lp, force, NULL);
			if (un == NULL)
				continue;

@@ -731,7 +731,7 @@ end:

static int
pkg_jobs_process_remote_pkg(struct pkg_jobs *j, struct pkg *rp,
-
	struct pkg_job_request_item **req)
+
	struct pkg_job_request_item **req, int with_version)
{
	struct pkg_job_universe_item *nit;
	struct pkg_job_request_item *nrit = NULL;
@@ -749,7 +749,7 @@ pkg_jobs_process_remote_pkg(struct pkg_jobs *j, struct pkg *rp,
	}

	nit = pkg_jobs_universe_get_upgrade_candidates(j->universe, rp->uid, lp,
-
		j->flags & PKG_FLAG_FORCE);
+
		j->flags & PKG_FLAG_FORCE, with_version != 0 ? rp->version : NULL);

	if (nit != NULL) {
		nrit = pkg_jobs_add_req_from_universe(&j->request_add, nit, false, false);
@@ -816,7 +816,7 @@ pkg_jobs_try_remote_candidate(struct pkg_jobs *j, const char *pattern,
				assert(0);

			rc = EPKG_OK;
-
			pkg_jobs_process_remote_pkg(j, p, NULL);
+
			pkg_jobs_process_remote_pkg(j, p, NULL, 0);
			if (rc == EPKG_OK) {
				/* Avoid freeing */
				p = NULL;
@@ -909,7 +909,8 @@ pkg_jobs_find_upgrade(struct pkg_jobs *j, const char *pattern, match_t m)
		rc = EPKG_FATAL;

	while (it != NULL && pkgdb_it_next(it, &p, flags) == EPKG_OK) {
-
		rc = pkg_jobs_process_remote_pkg(j, p, NULL);
+
		rc = pkg_jobs_process_remote_pkg(j, p, NULL,
+
		    strcmp(p->name, pattern));
		if (rc == EPKG_FATAL)
			break;
		else if (rc == EPKG_OK)
modified libpkg/pkg_jobs_universe.c
@@ -1079,7 +1079,7 @@ pkg_jobs_universe_process_upgrade_chains(struct pkg_jobs *j)

struct pkg_job_universe_item*
pkg_jobs_universe_get_upgrade_candidates(struct pkg_jobs_universe *universe,
-
	const char *uid, struct pkg *lp, bool force)
+
	const char *uid, struct pkg *lp, bool force, const char *version)
{
	struct pkg *pkg = NULL, *selected = lp;
	struct pkgdb_it *it;
@@ -1119,6 +1119,9 @@ pkg_jobs_universe_get_upgrade_candidates(struct pkg_jobs_universe *universe,
	kv_init(candidates);
	while (pkgdb_it_next(it, &pkg, flag) == EPKG_OK) {

+
		if (version != NULL && strcmp(pkg->version, version) != 0)
+
			continue;
+

		if (force) {
			/* Just add everything */
			selected = pkg;
modified libpkg/private/pkg_jobs.h
@@ -230,12 +230,14 @@ void pkg_jobs_universe_process_upgrade_chains(struct pkg_jobs *j);
 * - if `lp` is not null it is always added to the universe
 * - if `uid` is in the universe, then the existing upgrade chain is returned
 * - if `force` is true then all candidates are added to the universe
-
 * - if `forece` is false then *all* candidates are added to the universe, but
+
 * - if `force` is false then *all* candidates are added to the universe, but
 * merely if *any* of remote packages is an upgrade for local one
+
 * - if `version` is not null then ensure we are only adding to the universe
+
 * packages that match the given version
 */
struct pkg_job_universe_item*
pkg_jobs_universe_get_upgrade_candidates(struct pkg_jobs_universe *universe,
-
	const char *uid, struct pkg *lp, bool force);
+
	const char *uid, struct pkg *lp, bool force, const char *version);

/*
 * Among a set of job candidates, select the most matching one, depending on job
modified tests/frontend/repo.sh
@@ -114,12 +114,21 @@ EOF
		pkg -C ./pkg.conf update

	# Ensure we can pickup the old version
-
	#atf_check -o match:"Installing test-1\.\.\." \
-
	#	pkg -C ./pkg.conf install -y test-1.0
+
	atf_check -o match:"Installing test-1\.0" \
+
		pkg -C ./pkg.conf install -y test-1.0

-
	#atf_check pkg -C ./pkg.conf upgrade -y
+
	atf_check -o match:"Upgrading.*to 1\.1" \
+
		pkg -C ./pkg.conf install -y test
+

+
	atf_check -o ignore pkg delete -y test
+

+
	atf_check -o match:"Installing test-1\.0" \
+
		pkg -C ./pkg.conf install -y test-1.0
+

+
	atf_check -o match:"Upgrading.*to 1\.1" \
+
		pkg -C ./pkg.conf upgrade -y

-
	#atf_check -o ignore pkg -C ./pkg.conf delete test
+
	atf_check -o ignore pkg -C ./pkg.conf delete -y test

	# Ensure the latest version is installed
	atf_check -o match:"Installing test-1.1" \