Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge pull request #1213 from vstakhov/master
Vsevolod Stakhov committed 11 years ago
commit a9b8ed06bc758edb8a204a40735b4768404c96ed
parent dc98f9b
4 files changed +27 -6
modified libpkg/pkg_attributes.c
@@ -254,6 +254,7 @@ pkg_conflict_free(struct pkg_conflict *c)
		return;

	free(c->uid);
+
	free(c->digest);
	free(c);
}

modified libpkg/pkg_jobs_conflicts.c
@@ -250,7 +250,8 @@ pkg_conflicts_need_conflict(struct pkg_jobs *j, struct pkg *p1, struct pkg *p2)
static void
pkg_conflicts_register_unsafe(struct pkg *p1, struct pkg *p2,
	const char *path,
-
	enum pkg_conflict_type type)
+
	enum pkg_conflict_type type,
+
	bool use_digest)
{
	struct pkg_conflict *c1, *c2;

@@ -259,6 +260,13 @@ pkg_conflicts_register_unsafe(struct pkg *p1, struct pkg *p2,
	c1->type = c2->type = type;
	c1->uid = strdup(p2->uid);
	c2->uid = strdup(p2->uid);
+

+
	if (use_digest) {
+
		/* We also add digest information into account */
+
		c1->digest = strdup(p2->digest);
+
		c2->digest = strdup(p1->digest);
+
	}
+

	HASH_ADD_KEYPTR(hh, p1->conflicts, c1->uid, strlen(c1->uid), c1);
	HASH_ADD_KEYPTR(hh, p2->conflicts, c2->uid, strlen(c1->uid), c2);
	pkg_debug(2, "registering conflict between %s and %s on path %s",
@@ -292,7 +300,7 @@ pkg_conflicts_register_chain(struct pkg_jobs *j, struct pkg_job_universe_item *u
				/* local <-> remote conflict */
				if (pkg_conflicts_need_conflict(j, p1, p2)) {
					pkg_conflicts_register_unsafe(p1, p2, path,
-
						PKG_CONFLICT_REMOTE_LOCAL);
+
						PKG_CONFLICT_REMOTE_LOCAL, true);
					j->conflicts_registered ++;
					ret = true;
				}
@@ -301,7 +309,7 @@ pkg_conflicts_register_chain(struct pkg_jobs *j, struct pkg_job_universe_item *u
				/* two remote packages */
				if (pkg_conflicts_need_conflict(j, p1, p2)) {
					pkg_conflicts_register_unsafe(p1, p2, path,
-
						PKG_CONFLICT_REMOTE_REMOTE);
+
						PKG_CONFLICT_REMOTE_REMOTE, true);
					j->conflicts_registered ++;
					ret = true;
				}
modified libpkg/pkg_solve.c
@@ -379,6 +379,7 @@ pkg_solve_add_conflict_rule(struct pkg_solve_problem *problem,
	struct pkg_solve_variable *confvar, *curvar;
	struct pkg_solve_rule *rule = NULL;
	struct pkg_solve_item *it = NULL;
+
	struct pkg *other;

	uid = conflict->uid;
	HASH_FIND_STR(problem->variables_by_uid, uid, confvar);
@@ -389,14 +390,15 @@ pkg_solve_add_conflict_rule(struct pkg_solve_problem *problem,

	/* Add conflict rule from each of the alternative */
	LL_FOREACH(confvar, curvar) {
+
		other = curvar->unit->pkg;
		if (conflict->type == PKG_CONFLICT_REMOTE_LOCAL) {
			/* Skip unappropriate packages */
			if (pkg->type == PKG_INSTALLED) {
-
				if (curvar->unit->pkg->type == PKG_INSTALLED)
+
				if (other->type == PKG_INSTALLED)
					continue;
			}
			else {
-
				if (curvar->unit->pkg->type != PKG_INSTALLED)
+
				if (other->type != PKG_INSTALLED)
					continue;
			}
		}
@@ -404,7 +406,16 @@ pkg_solve_add_conflict_rule(struct pkg_solve_problem *problem,
			if (pkg->type == PKG_INSTALLED)
				continue;

-
			if (curvar->unit->pkg->type == PKG_INSTALLED)
+
			if (other->type == PKG_INSTALLED)
+
				continue;
+
		}
+

+
		/*
+
		 * Also if a conflict is digest specific then we skip
+
		 * variables with mismatched digests
+
		 */
+
		if (conflict->digest) {
+
			if (strcmp (conflict->digest, other->digest) != 0)
				continue;
		}

modified libpkg/private/pkg.h
@@ -207,6 +207,7 @@ enum pkg_conflict_type {

struct pkg_conflict {
	char *uid;
+
	char *digest;
	enum pkg_conflict_type type;
	UT_hash_handle	hh;
};