Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Move upgrade atomicity to per package including during upgrades
Baptiste Daroussin committed 10 years ago
commit a3e90c4259955f06e40720f39783a69fe86f015e
parent 81214ae
5 files changed +8 -27
modified libpkg/pkg_add.c
@@ -837,7 +837,6 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
	/* register the package before installing it in case there are
	 * problems that could be caught here. */
	retcode = pkgdb_register_pkg(db, pkg,
-
			flags & PKG_ADD_UPGRADE,
			flags & PKG_ADD_FORCE);

	if (retcode != EPKG_OK)
@@ -899,9 +898,9 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
		pkg_start_stop_rc_scripts(pkg, PKG_RC_START);

	retcode = pkg_extract_finalize(pkg);
+

cleanup_reg:
-
	if ((flags & PKG_ADD_UPGRADE) == 0)
-
		pkgdb_register_finale(db, retcode);
+
	pkgdb_register_finale(db, retcode);

	if (retcode == EPKG_OK) {
		if ((flags & PKG_ADD_UPGRADE) == 0)
modified libpkg/pkg_jobs.c
@@ -1946,25 +1946,12 @@ pkg_jobs_handle_install(struct pkg_solved *ps, struct pkg_jobs *j,
	if (new->automatic || (j->flags & PKG_FLAG_AUTOMATIC) == PKG_FLAG_AUTOMATIC)
		flags |= PKG_ADD_AUTOMATIC;

-
#if 0
-
	if (old != NULL && !ps->already_deleted) {
-
		if ((retcode = pkg_delete(old, j->db, PKG_DELETE_UPGRADE)) != EPKG_OK) {
-
			pkgdb_transaction_rollback_sqlite(j->db->sqlite, "upgrade");
-
			goto cleanup;
-
		}
-
	}
-
#endif
	if (old != NULL)
		retcode = pkg_add_upgrade(j->db, target, flags, keys, NULL, new, old);
	else
		retcode = pkg_add_from_remote(j->db, target, flags, keys, NULL, new);

-
	if (retcode != EPKG_OK) {
-
		pkgdb_transaction_rollback_sqlite(j->db->sqlite, "upgrade");
-
		return (retcode);
-
	}
-

-
	return (EPKG_OK);
+
	return (retcode);
}

static int
@@ -1992,10 +1979,6 @@ pkg_jobs_execute(struct pkg_jobs *j)

	p = NULL;
	pkg_manifest_keys_new(&keys);
-
	/* Install */
-
	if ((retcode = pkgdb_transaction_begin_sqlite(j->db->sqlite, "upgrade")) !=
-
	    EPKG_OK)
-
		return (retcode);

	pkg_jobs_set_priorities(j);

@@ -2047,7 +2030,6 @@ pkg_jobs_execute(struct pkg_jobs *j)
	}

cleanup:
-
	pkgdb_transaction_commit_sqlite(j->db->sqlite, "upgrade");
	pkgdb_release_lock(j->db, PKGDB_LOCK_EXCLUSIVE);
	pkg_manifest_keys_free(keys);

modified libpkg/pkg_ports.c
@@ -1341,7 +1341,7 @@ pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,

	pkg_emit_install_begin(pkg);

-
	rc = pkgdb_register_pkg(db, pkg, 0, 0);
+
	rc = pkgdb_register_pkg(db, pkg, 0);

	if (rc != EPKG_OK)
		goto cleanup;
modified libpkg/pkgdb.c
@@ -1665,7 +1665,7 @@ prstmt_finalize(struct pkgdb *db)
}

int
-
pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete, int forced)
+
pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int forced)
{
	struct pkg		*pkg2 = NULL;
	struct pkg_dep		*dep = NULL;
@@ -1694,7 +1694,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete, int forced)

	s = db->sqlite;

-
	if (!complete && pkgdb_transaction_begin_sqlite(s, NULL) != EPKG_OK)
+
	if (pkgdb_transaction_begin_sqlite(s, NULL) != EPKG_OK)
		return (EPKG_FATAL);

	/* Prefer new ABI over old one */
@@ -2308,7 +2308,7 @@ pkgdb_register_ports(struct pkgdb *db, struct pkg *pkg)

	pkg_emit_install_begin(pkg);

-
	ret = pkgdb_register_pkg(db, pkg, 0, 0);
+
	ret = pkgdb_register_pkg(db, pkg, 0);
	if (ret == EPKG_OK)
		pkg_emit_install_finished(pkg, NULL);

modified libpkg/private/pkg.h
@@ -681,7 +681,7 @@ int sql_exec(sqlite3 *, const char *, ...);
int get_pragma(sqlite3 *, const char *sql, int64_t *res, bool silence);
int get_sql_string(sqlite3 *, const char *sql, char **res);

-
int pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete, int forced);
+
int pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int forced);
int pkgdb_update_shlibs_required(struct pkg *pkg, int64_t package_id, sqlite3 *s);
int pkgdb_update_shlibs_provided(struct pkg *pkg, int64_t package_id, sqlite3 *s);
int pkgdb_update_provides(struct pkg *pkg, int64_t package_id, sqlite3 *s);