Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Make pkg_*_annotate() take a struct pkg*, as conceptually, that is what it operates on.
Matthew Seaman committed 12 years ago
commit 3ee7eeed5c8ab9902d5b4ccc0d7ca2c3be3a26ab
parent 7f80320
3 files changed +25 -18
modified libpkg/pkg.h.in
@@ -984,11 +984,11 @@ struct pkgdb_it * pkgdb_query_shlib_provided(struct pkgdb *db, const char *shlib
 * @param value -- text of the annotation
 * @return An error code
 */
-
int pkgdb_add_annotation(struct pkgdb *db, const char *pkgorigin,
+
int pkgdb_add_annotation(struct pkgdb *db, struct pkg *pkg,
	const char *tag, const char *value);
-
int pkgdb_modify_annotation(struct pkgdb *db, const char *pkgorigin,
+
int pkgdb_modify_annotation(struct pkgdb *db, struct pkg *pkg,
	const char *tag, const char *value);
-
int pkgdb_delete_annotation(struct pkgdb *db, const char *pkgorigin,
+
int pkgdb_delete_annotation(struct pkgdb *db, struct pkg *pkg,
        const char *tag);

#define PKG_LOAD_BASIC			0
modified libpkg/pkg_jobs.c
@@ -1099,7 +1099,7 @@ pkg_jobs_install(struct pkg_jobs *j)
		}

		if (an != NULL) {
-
			pkgdb_add_annotation(j->db, pkgorigin, "repository", pkg_annotation_value(an));
+
			pkgdb_add_annotation(j->db, p, "repository", pkg_annotation_value(an));
		}

		if (oldversion != NULL)
modified libpkg/pkgdb.c
@@ -2760,18 +2760,21 @@ pkgdb_reanalyse_shlibs(struct pkgdb *db, struct pkg *pkg)
}

int
-
pkgdb_add_annotation(struct pkgdb *db, const char *pkgorigin,
-
    const char *tag, const char *value)
+
pkgdb_add_annotation(struct pkgdb *db, struct pkg *pkg, const char *tag,
+
        const char *value)
{
-
	int	rows_changed;
+
	int		 rows_changed;
+
	const char	*pkgorigin;

-
	assert(pkgorigin != NULL && pkgorigin[0] != '\0');
+
	assert(pkg != NULL);
	assert(tag != NULL);
	assert(value != NULL);

	if (!db->prstmt_initialized && prstmt_initialize(db) != EPKG_OK)
		return (EPKG_FATAL);

+
	pkg_get(pkg, PKG_ORIGIN, &pkgorigin);
+

	if (run_prstmt(ANNOTATE1, tag) != SQLITE_DONE
	    ||
	    run_prstmt(ANNOTATE1, value) != SQLITE_DONE
@@ -2792,12 +2795,13 @@ pkgdb_add_annotation(struct pkgdb *db, const char *pkgorigin,
}

int
-
pkgdb_modify_annotation(struct pkgdb *db, const char *pkgorigin,
-
    const char *tag, const char *value)
+
pkgdb_modify_annotation(struct pkgdb *db, struct pkg *pkg, const char *tag,
+
        const char *value)
{
-
	int rows_changed; 
+
	int		 rows_changed; 
+
	const char	*pkgorigin;

-
	assert(pkgorigin != NULL && pkgorigin[0] != '\0');
+
	assert(pkg!= NULL);
	assert(tag != NULL);
	assert(value != NULL);

@@ -2807,6 +2811,8 @@ pkgdb_modify_annotation(struct pkgdb *db, const char *pkgorigin,
	if (pkgdb_transaction_begin(db->sqlite, NULL) != EPKG_OK)
		return (EPKG_FATAL);

+
	pkg_get(pkg, PKG_ORIGIN, &pkgorigin);
+

	if (run_prstmt(ANNOTATE_DEL1, pkgorigin, tag) != SQLITE_DONE
	    ||
	    run_prstmt(ANNOTATE1, tag) != SQLITE_DONE
@@ -2834,13 +2840,13 @@ pkgdb_modify_annotation(struct pkgdb *db, const char *pkgorigin,
}

int
-
pkgdb_delete_annotation(struct pkgdb *db, const char *pkgorigin,
-
    const char *tag)
+
pkgdb_delete_annotation(struct pkgdb *db, struct pkg *pkg, const char *tag)
{
-
	int	rows_changed;
-
	bool	result;
+
	int		 rows_changed;
+
	bool		 result;
+
	const char	*pkgorigin;

-
	assert(pkgorigin != NULL && pkgorigin[0] != '\0');
+
	assert(pkg != NULL);
	assert(tag != NULL);

	if (!db->prstmt_initialized && prstmt_initialize(db) != EPKG_OK)
@@ -2849,6 +2855,8 @@ pkgdb_delete_annotation(struct pkgdb *db, const char *pkgorigin,
	if (pkgdb_transaction_begin(db->sqlite, NULL) != EPKG_OK)
		return (EPKG_FATAL);

+
	pkg_get(pkg, PKG_ORIGIN, &pkgorigin);
+

	result = (run_prstmt(ANNOTATE_DEL1, pkgorigin, tag)
		  == SQLITE_DONE);

@@ -2862,7 +2870,6 @@ pkgdb_delete_annotation(struct pkgdb *db, const char *pkgorigin,
		return (EPKG_FATAL);
	}

-

	if (pkgdb_transaction_commit(db->sqlite, NULL) != EPKG_OK)
		return (EPKG_FATAL);