Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
jobs: drop pkg_jobs_universe_change_uid()
Isaac Freund committed 1 year ago
commit 27b0e2bda463befbb56ac5fd8467def295eccc86
parent 3231c9b
3 files changed +0 -128
modified libpkg/pkg_jobs.c
@@ -870,20 +870,6 @@ pkg_jobs_process_remote_pkg(struct pkg_jobs *j, struct pkg *rp,
	return (nrit != NULL ? EPKG_OK : EPKG_FATAL);
}

-
static bool
-
pkg_jobs_has_replacement(struct pkg_jobs *j, const char *uid)
-
{
-
	struct pkg_job_replace *cur;
-

-
	LL_FOREACH(j->universe->uid_replaces, cur) {
-
		if (STREQ(cur->new_uid, uid)) {
-
			return (true);
-
		}
-
	}
-

-
	return (false);
-
}
-

static int
pkg_jobs_try_remote_candidate(struct pkg_jobs *j, const char *cond, const char *pattern, match_t m)
{
@@ -901,9 +887,6 @@ pkg_jobs_try_remote_candidate(struct pkg_jobs *j, const char *cond, const char *

	while (pkgdb_it_next(it, &p, flags) == EPKG_OK) {
		xstring_renew(qmsg);
-
		if (pkg_jobs_has_replacement(j, p->uid)) {
-
			dbg(1, "replacement %s is already used", p->uid);
-
		}
	}


@@ -1825,40 +1808,6 @@ jobs_solve_fetch(struct pkg_jobs *j)
	return (EPKG_OK);
}

-
static void
-
pkg_jobs_apply_replacements(struct pkg_jobs *j)
-
{
-
	struct pkg_job_replace *r;
-
	static const char sql[] = ""
-
		"UPDATE packages SET name=?1 "
-
		" WHERE name=?2;" ;
-
	sqlite3_stmt *stmt;
-
	int ret;
-

-
	if (j->universe->uid_replaces == NULL)
-
		return;
-

-
	dbg(4, "running '%s'", sql);
-
	ret = sqlite3_prepare_v2(j->db->sqlite, sql, -1, &stmt, NULL);
-
	if (ret != SQLITE_OK) {
-
		ERROR_SQLITE(j->db->sqlite, sql);
-
		return;
-
	}
-

-
	LL_FOREACH(j->universe->uid_replaces, r) {
-
		dbg(4, "changing uid %s -> %s", r->old_uid, r->new_uid);
-
		sqlite3_bind_text(stmt, 1, r->new_uid, -1, SQLITE_TRANSIENT);
-
		sqlite3_bind_text(stmt, 2, r->old_uid, -1, SQLITE_TRANSIENT);
-

-
		if (sqlite3_step(stmt) != SQLITE_DONE)
-
			ERROR_STMT_SQLITE(j->db->sqlite, stmt);
-

-
		sqlite3_reset(stmt);
-
	}
-

-
	sqlite3_finalize(stmt);
-
}
-

static int
solve_with_external_cudf_solver(struct pkg_jobs *j, const char *solver)
{
@@ -2000,8 +1949,6 @@ pkg_jobs_solve(struct pkg_jobs *j)
	if (ret != EPKG_OK)
		return (ret);

-
	pkg_jobs_apply_replacements(j);
-

	/* Check if we need to fetch and re-run the solver */
	tll_foreach(j->jobs, job) {
		struct pkg *p;
modified libpkg/pkg_jobs_universe.c
@@ -827,14 +827,6 @@ pkg_jobs_universe_provide_free(struct pkg_job_provide *pr)
	}
}

-
static void
-
pkg_jobs_universe_replacement_free(struct pkg_job_replace *r)
-
{
-
	free(r->new_uid);
-
	free(r->old_uid);
-
	free(r);
-
}
-

void
pkg_jobs_universe_free(struct pkg_jobs_universe *universe)
{
@@ -856,7 +848,6 @@ pkg_jobs_universe_free(struct pkg_jobs_universe *universe)
	while (pkghash_next(&it))
		pkg_jobs_universe_provide_free(it.value);
	pkghash_destroy(universe->provides);
-
	LL_FREE(universe->uid_replaces, pkg_jobs_universe_replacement_free);
}

struct pkg_jobs_universe *
@@ -876,58 +867,6 @@ pkg_jobs_universe_find(struct pkg_jobs_universe *universe, const char *uid)
	return (pkghash_get_value(universe->items, uid));
}

-
void
-
pkg_jobs_universe_change_uid(struct pkg_jobs_universe *universe,
-
	struct pkg_job_universe_item *unit,
-
	const char *new_uid, bool update_rdeps)
-
{
-
	struct pkg_dep *rd = NULL, *d = NULL;
-
	struct pkg_job_universe_item *found, *tmp;
-

-
	struct pkg *lp;
-
	struct pkg_job_replace *replacement;
-

-
	if (update_rdeps) {
-
		/* For all rdeps update deps accordingly */
-
		while (pkg_rdeps(unit->pkg, &rd) == EPKG_OK) {
-
			found = pkg_jobs_universe_find(universe, rd->uid);
-
			if (found == NULL) {
-
				lp = pkg_jobs_universe_get_local(universe, rd->uid, 0);
-
				/* XXX */
-
				assert(lp != NULL);
-
				pkg_jobs_universe_process_item(universe, lp, &found);
-
			}
-

-
			if (found != NULL) {
-
				while (pkg_deps(found->pkg, &d) == EPKG_OK) {
-
					if (STREQ(d->uid, unit->pkg->uid)) {
-
						free(d->uid);
-
						d->uid = xstrdup(new_uid);
-
					}
-
				}
-
			}
-
		}
-
	}
-

-
	replacement = xcalloc(1, sizeof(*replacement));
-
	replacement->old_uid = xstrdup(unit->pkg->uid);
-
	replacement->new_uid = xstrdup(new_uid);
-
	LL_PREPEND(universe->uid_replaces, replacement);
-

-
	tmp = pkghash_delete(universe->items, unit->pkg->uid);
-
	if (tmp != NULL)
-
		tmp->inhash = false;
-
	free(unit->pkg->uid);
-
	unit->pkg->uid = xstrdup(new_uid);
-

-
	found = pkghash_get_value(universe->items, new_uid);
-
	if (found != NULL)
-
		DL_APPEND(found, unit);
-
	else
-
		pkghash_safe_add(universe->items, new_uid, unit, NULL);
-

-
}
-

static struct pkg_job_universe_item *
pkg_jobs_universe_select_max_ver(struct pkg_job_universe_item *chain)
{
modified libpkg/private/pkg_jobs.h
@@ -75,17 +75,10 @@ struct pkg_job_provide {
	struct pkg_job_provide *next, *prev;
};

-
struct pkg_job_replace {
-
	char *new_uid;
-
	char *old_uid;
-
	struct pkg_job_replace *next;
-
};
-

struct pkg_jobs_universe {
	pkghash *items;		/* package uid, pkg_job_universe_item */
	pkghash *seen;		/* package digest, pkg_job_universe_item */
	pkghash *provides;	/* shlibs, pkg_job_provide */
-
	struct pkg_job_replace *uid_replaces;
	struct pkg_jobs *j;
	size_t nitems;
};
@@ -185,13 +178,6 @@ int pkg_jobs_universe_add_pkg(struct pkg_jobs_universe *universe,
	struct pkg *pkg, bool force, struct pkg_job_universe_item **found);

/*
-
 * Change uid for universe item
-
 */
-
void pkg_jobs_universe_change_uid(struct pkg_jobs_universe *universe,
-
	struct pkg_job_universe_item *unit,
-
	const char *new_uid, bool update_rdeps);
-

-
/*
 * Find local package in db or universe
 */
struct pkg* pkg_jobs_universe_get_local(struct pkg_jobs_universe *universe,