Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Register automatic deps for install and keep information during upgrades
Baptiste Daroussin committed 14 years ago
commit f25cfea9e88f6875619f7dd954dbc3b6ec919949
parent e3c6057
4 files changed +11 -6
modified libpkg/pkg.h
@@ -594,7 +594,7 @@ int pkgdb_compact(struct pkgdb *db);
 * @return An error code.
 */
int pkg_add(struct pkgdb *db, const char *path);
-
int pkg_add2(struct pkgdb *db, const char *path, int upgrade);
+
int pkg_add2(struct pkgdb *db, const char *path, int upgrade, int automatic);

/**
 * Allocate a new pkg_jobs.
modified libpkg/pkg_add.c
@@ -81,11 +81,11 @@ do_extract(struct archive *a, struct archive_entry *ae)
int
pkg_add(struct pkgdb *db, const char *path)
{
-
	return (pkg_add2(db, path, 0));
+
	return (pkg_add2(db, path, 0, 0));
}

int
-
pkg_add2(struct pkgdb *db, const char *path, int upgrade)
+
pkg_add2(struct pkgdb *db, const char *path, int upgrade, int automatic)
{
	struct archive *a;
	struct archive_entry *ae;
@@ -116,6 +116,9 @@ pkg_add2(struct pkgdb *db, const char *path, int upgrade)
		goto cleanup;
	}

+
	if (automatic == 1)
+
		pkg_setautomatic(pkg);
+

	if (uname(&u) != 0) {
		EMIT_ERRNO("uname", "");
		retcode = EPKG_FATAL;
modified libpkg/pkg_jobs.c
@@ -91,7 +91,7 @@ pkg_jobs_install(struct pkg_jobs *j)
		snprintf(path, sizeof(path), "%s/%s", cachedir,
				 pkg_get(p, PKG_REPOPATH));

-
		if (pkg_add(j->db, path) != EPKG_OK) {
+
		if (pkg_add2(j->db, path, 0, pkg_isautomatic(p)) != EPKG_OK) {
			return (EPKG_FATAL);
		}
	}
@@ -212,8 +212,10 @@ add_dep(struct pkg_jobs *j, struct pkg_jobs_node *n)
			ndep->pkg = pkgdb_query_remote(j->db, pkg_dep_origin(dep));
			if (ndep->pkg == NULL)
				EMIT_MISSING_DEP(n->pkg, dep);
-
			else
+
			else {
+
				pkg_setautomatic(ndep->pkg);
				add_dep(j, ndep);
+
			}
		}
		add_parent(ndep, n);
	}
modified libpkg/pkg_upgrade.c
@@ -9,7 +9,7 @@ pkg_upgrade(struct pkgdb *db, struct pkg *pkg, const char *path)

	if ((ret = pkg_delete2(pkg, db, 1, 0)) != EPKG_OK)
		return (ret);
-
	if ((ret = pkg_add2(db, path, 0)) != EPKG_OK)
+
	if ((ret = pkg_add2(db, path, 0,pkg_isautomatic(pkg))) != EPKG_OK)
		return (ret);

	return (EPKG_OK);