Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
UID -> name for conflicts paths.
Vsevolod Stakhov committed 11 years ago
commit 6ca24db4fe569733dfd0b568c343191eb73c16de
parent 986a841
2 files changed +38 -10
modified libpkg/pkg_jobs_conflicts.c
@@ -335,7 +335,7 @@ pkg_conflicts_check_local_path(const char *path, const char *uid,
	struct pkg_jobs *j)
{
	const char sql_local_conflict[] = ""
-
		"SELECT p.name || '~' || p.origin as uniqueid FROM packages AS p "
+
		"SELECT p.name as uniqueid FROM packages AS p "
		"INNER JOIN files AS f "
		"ON p.id = f.package_id "
		"WHERE f.path = ?1;";
@@ -358,13 +358,15 @@ pkg_conflicts_check_local_path(const char *path, const char *uid,
	sqlite3_bind_text(stmt, 2,
		uid, -1, SQLITE_STATIC);

-
	if (sqlite3_step(stmt) != SQLITE_DONE) {
+
	if (sqlite3_step(stmt) == SQLITE_ROW) {
		/*
		 * We have found the conflict with some other chain, so find that chain
		 * or update the universe
		 */
+
		const char *uid_local = sqlite3_column_text(stmt, 0);
+

		p = pkg_jobs_universe_get_local(j->universe,
-
			sqlite3_column_text(stmt, 0), 0);
+
			uid_local, 0);
		assert(p != NULL);

		pkg_get(p, PKG_UNIQUEID, &uido);
modified libpkg/pkg_jobs_universe.c
@@ -48,7 +48,7 @@ pkg_jobs_universe_get_local(struct pkg_jobs_universe *universe,
{
	struct pkg *pkg = NULL;
	struct pkgdb_it *it;
-
	struct pkg_job_universe_item *unit;
+
	struct pkg_job_universe_item *unit, *cur, *found;

	if (flag == 0) {
		if (!IS_DELETE(universe->j))
@@ -60,9 +60,22 @@ pkg_jobs_universe_get_local(struct pkg_jobs_universe *universe,
	}

	HASH_FIND(hh, universe->items, uid, strlen(uid), unit);
-
	if (unit != NULL && unit->pkg->type == PKG_INSTALLED) {
-
		pkgdb_ensure_loaded(universe->j->db, unit->pkg, flag);
-
		return (unit->pkg);
+
	if (unit != NULL) {
+
		/* Search local in a universe chain */
+
		cur = unit;
+
		found = NULL;
+
		do {
+
			if (cur->pkg->type == PKG_INSTALLED) {
+
				found = cur;
+
				break;
+
			}
+
			cur = cur->prev;
+
		} while (cur != unit);
+

+
		if (found) {
+
			pkgdb_ensure_loaded(universe->j->db, unit->pkg, flag);
+
			return (unit->pkg);
+
		}
	}

	if ((it = pkgdb_query(universe->j->db, uid, MATCH_EXACT)) == NULL)
@@ -82,7 +95,7 @@ pkg_jobs_universe_get_remote(struct pkg_jobs_universe *universe,
{
	struct pkg *pkg = NULL, *selected = NULL;
	struct pkgdb_it *it;
-
	struct pkg_job_universe_item *unit;
+
	struct pkg_job_universe_item *unit, *cur, *found;

	if (flag == 0) {
		flag = PKG_LOAD_BASIC|PKG_LOAD_DEPS|PKG_LOAD_OPTIONS|
@@ -92,8 +105,21 @@ pkg_jobs_universe_get_remote(struct pkg_jobs_universe *universe,

	HASH_FIND(hh, universe->items, uid, strlen(uid), unit);
	if (unit != NULL && unit->pkg->type != PKG_INSTALLED) {
-
		pkgdb_ensure_loaded(universe->j->db, unit->pkg, flag);
-
		return (unit->pkg);
+
		/* Search local in a universe chain */
+
		cur = unit;
+
		found = NULL;
+
		do {
+
			if (cur->pkg->type != PKG_INSTALLED) {
+
				found = cur;
+
				break;
+
			}
+
			cur = cur->prev;
+
		} while (cur != unit);
+

+
		if (found) {
+
			pkgdb_ensure_loaded(universe->j->db, unit->pkg, flag);
+
			return (unit->pkg);
+
		}
	}

	if ((it = pkgdb_repo_query(universe->j->db, uid, MATCH_EXACT,