Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Generally change annotation key -> tag
Matthew Seaman committed 13 years ago
commit 17aed2483a74b603bcdb4050f23bfdd49a2911a4
parent ff4745a
16 files changed +129 -122
modified libpkg/pkg.c
@@ -903,51 +903,51 @@ pkg_addshlib_provided(struct pkg *pkg, const char *name)
}

int
-
pkg_addannotation(struct pkg *pkg, const char *key, const char *value)
+
pkg_addannotation(struct pkg *pkg, const char *tag, const char *value)
{
	struct pkg_note *an = NULL;

	assert(pkg != NULL);
-
	assert(key != NULL);
+
	assert(tag != NULL);
	assert(value != NULL);

-
	/* Keys are unique per-package */
+
	/* Tags are unique per-package */

-
	HASH_FIND_STR(pkg->annotations, __DECONST(char *, key), an);
+
	HASH_FIND_STR(pkg->annotations, __DECONST(char *, tag), an);
	if (an != NULL) {
-
		pkg_emit_error("duplicate annotation listing: %s -- %s,"
-
			       " ignoring", key, value);
+
		pkg_emit_error("duplicate annotation tag: %s value: %s,"
+
			       " ignoring", tag, value);
		return (EPKG_OK);
	}
	an = NULL;
	pkg_annotation_new(&an);

-
	sbuf_set(&an->key, key);
+
	sbuf_set(&an->tag, tag);
	sbuf_set(&an->value, value);

	HASH_ADD_KEYPTR(hh, pkg->annotations,
-
	    __DECONST(char *, pkg_annotation_key(an)),
-
	    strlen(pkg_annotation_key(an)), an);
+
	    __DECONST(char *, pkg_annotation_tag(an)),
+
	    strlen(pkg_annotation_tag(an)), an);

	return (EPKG_OK);
}

int
-
pkg_delannotation(struct pkg *pkg, const char *key)
+
pkg_delannotation(struct pkg *pkg, const char *tag)
{
	struct pkg_note *an = NULL;

	assert(pkg != NULL);
-
	assert(key != NULL);
+
	assert(tag != NULL);

-
	HASH_FIND_STR(pkg->annotations, __DECONST(char *, key), an);
+
	HASH_FIND_STR(pkg->annotations, __DECONST(char *, tag), an);
	if (an != NULL) {
		HASH_DEL(pkg->annotations, an);
		pkg_annotation_free(an);
		return (EPKG_OK);
	} else {
-
		pkg_emit_error("deleting key \'%s\' -- no matching annotation "
-
			       "found", key);
+
		pkg_emit_error("deleting annotation tagged \'%s\' -- "
+
			       "not found", tag);
		return (EPKG_WARN);
	}
}
modified libpkg/pkg.h.in
@@ -765,13 +765,13 @@ int pkg_addshlib_provided(struct pkg *pkg, const char *name);
 * Add annotation key+value pair
 * @return An error code
 */
-
int pkg_addannotation(struct pkg *pkg, const char *key, const char *value);
+
int pkg_addannotation(struct pkg *pkg, const char *tag, const char *value);

/**
 * Delete annotation identified by the key
 * @return An error code
 */
-
int pkg_delannotation(struct pkg *pkg, const char *key);
+
int pkg_delannotation(struct pkg *pkg, const char *tag);

/**
 * Parse a manifest and set the attributes of pkg accordingly.
@@ -843,7 +843,7 @@ const char *pkg_option_value(struct pkg_option const * const);
const char *pkg_shlib_name(struct pkg_shlib const * const);

/* pkg_note */
-
const char *pkg_annotation_key(struct pkg_note const * const);
+
const char *pkg_annotation_tag(struct pkg_note const * const);
const char *pkg_annotation_value(struct pkg_note const * const);

/**
@@ -970,11 +970,11 @@ struct pkgdb_it * pkgdb_query_shlib_provided(struct pkgdb *db, const char *shlib
 * @return An error code
 */
int pkgdb_add_annotation(struct pkgdb *db, const char *pkgname,
-
	const char *pkgversion, const char *key, const char *value);
+
	const char *pkgversion, const char *tag, const char *value);
int pkgdb_modify_annotation(struct pkgdb *db, const char *pkgname,
-
	const char *pkgversion, const char *key, const char *value);
+
	const char *pkgversion, const char *tag, const char *value);
int pkgdb_delete_annotation(struct pkgdb *db, const char *pkgname,
-
        const char *pkgversion, const char *key);
+
        const char *pkgversion, const char *tag);

#define PKG_LOAD_BASIC			0
#define PKG_LOAD_DEPS			(1U << 0)
modified libpkg/pkg_attributes.c
@@ -434,17 +434,17 @@ pkg_annotation_free(struct pkg_note *an)
	if (an == NULL)
		return;

-
	sbuf_free(an->key);
+
	sbuf_free(an->tag);
	sbuf_free(an->value);
	free(an);
}

const char *
-
pkg_annotation_key(struct pkg_note const * const an)
+
pkg_annotation_tag(struct pkg_note const * const an)
{
	assert(an != NULL);

-
	return (sbuf_get(an->key));
+
	return (sbuf_get(an->tag));
}

const char *
modified libpkg/pkg_manifest.c
@@ -987,7 +987,7 @@ emit_manifest(struct pkg *pkg, yaml_emitter_t *emitter, bool compact)
	while (pkg_annotations(pkg, &note) == EPKG_OK) {
		if (map == -1)
			manifest_append_map(map, mapping, "annotations", FLOW);
-
		manifest_append_kv(map, pkg_annotation_key(note),
+
		manifest_append_kv(map, pkg_annotation_tag(note),
		    pkg_annotation_value(note), PLAIN);
	}

modified libpkg/pkgdb.c
@@ -152,8 +152,8 @@ load_val(sqlite3 *db, struct pkg *pkg, const char *sql, unsigned flags,
}

static int
-
load_key_val(sqlite3 *db, struct pkg *pkg, const char *sql, unsigned flags,
-
	     int (*pkg_addkeyval)(struct pkg *pkg, const char *key, const char *val),
+
load_tag_val(sqlite3 *db, struct pkg *pkg, const char *sql, unsigned flags,
+
	     int (*pkg_addtagval)(struct pkg *pkg, const char *tag, const char *val),
	     int list)
{
	sqlite3_stmt	*stmt;
@@ -172,7 +172,7 @@ load_key_val(sqlite3 *db, struct pkg *pkg, const char *sql, unsigned flags,
	sqlite3_bind_int64(stmt, 1, pkg->rowid);

	while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
-
		pkg_addkeyval(pkg, sqlite3_column_text(stmt, 0),
+
		pkg_addtagval(pkg, sqlite3_column_text(stmt, 0),
			      sqlite3_column_text(stmt, 1));
	}
	sqlite3_finalize(stmt);
@@ -644,11 +644,11 @@ pkgdb_init(sqlite3 *sdb)
        "CREATE TABLE pkg_annotation ("
                "package_id INTERGER REFERENCES packages(id)"
                      " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
                "key_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
+
                "tag_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
                      " ON DELETE CASCADE ON UPDATE RESTRICT,"
		"value_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
		      " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
		"UNIQUE (package_id, key_id)"
+
		"UNIQUE (package_id, tag_id)"
	");"

	/* Mark the end of the array */
@@ -1967,12 +1967,12 @@ pkgdb_load_annotations(struct pkgdb *db, struct pkg *pkg)
	char		 sql[BUFSIZ];
	const char	*reponame = NULL;
	const char	*basesql = ""
-
		"SELECT k.annotation AS key, v.annotation AS value"
+
		"SELECT k.annotation AS tag, v.annotation AS value"
		"  FROM %Q.pkg_annotation p"
-
		"    JOIN %Q.annotation k ON (p.key_id = k.annotation_id)"
+
		"    JOIN %Q.annotation k ON (p.tag_id = k.annotation_id)"
		"    JOIN %Q.annotation v ON (p.value_id = v.annotation_id)"
		"  WHERE p.package_id = ?1"
-
		"  ORDER BY key, value";
+
		"  ORDER BY tag, value";

	assert(db != NULL && pkg != NULL);

@@ -1985,7 +1985,7 @@ pkgdb_load_annotations(struct pkgdb *db, struct pkg *pkg)
		sqlite3_snprintf(sizeof(sql), sql, basesql, "main",
                    "main", "main");

-
	return (load_key_val(db->sqlite, pkg, sql, PKG_LOAD_ANNOTATIONS,
+
	return (load_tag_val(db->sqlite, pkg, sql, PKG_LOAD_ANNOTATIONS,
		   pkg_addannotation, PKG_ANNOTATIONS));
}

@@ -2050,7 +2050,7 @@ pkgdb_load_options(struct pkgdb *db, struct pkg *pkg)
		sqlite3_snprintf(sizeof(sql), sql, basesql, "main");
	}

-
	return (load_key_val(db->sqlite, pkg, sql, PKG_LOAD_OPTIONS,
+
	return (load_tag_val(db->sqlite, pkg, sql, PKG_LOAD_OPTIONS,
		    pkg_addoption, PKG_OPTIONS));
}

@@ -2231,7 +2231,7 @@ static sql_prstmt sql_prepared_statements[PRSTMT_LAST] = {
	},
	[ANNOTATE2] = {
		NULL,
-
		"INSERT OR ROLLBACK INTO pkg_annotation(package_id, key_id, value_id) "
+
		"INSERT OR ROLLBACK INTO pkg_annotation(package_id, tag_id, value_id) "
		"VALUES (?1,"
		" (SELECT annotation_id FROM annotation WHERE annotation = ?2),"
		" (SELECT annotation_id FROM annotation WHERE annotation = ?3))",
@@ -2239,7 +2239,7 @@ static sql_prstmt sql_prepared_statements[PRSTMT_LAST] = {
	},
	[ANNOTATE_ADD1] = {
		NULL,
-
		"INSERT OR IGNORE INTO pkg_annotation(package_id, key_id, value_id) "
+
		"INSERT OR IGNORE INTO pkg_annotation(package_id, tag_id, value_id) "
		"VALUES ("
		" (SELECT id FROM packages WHERE name = ?1 AND version = ?2),"
		" (SELECT annotation_id FROM annotation WHERE annotation = ?3),"
@@ -2251,14 +2251,14 @@ static sql_prstmt sql_prepared_statements[PRSTMT_LAST] = {
		"DELETE FROM pkg_annotation WHERE "
		"package_id IN"
                " (SELECT id FROM packages WHERE name = ?1 AND version = ?2) "
-
		"AND key_id IN"
-
		" (SELECT key_id FROM annotation WHERE annotation = ?3)",
+
		"AND tag_id IN"
+
		" (SELECT tag_id FROM annotation WHERE annotation = ?3)",
		"TTT",
	},
	[ANNOTATE_DEL2] = {
		NULL,
		"DELETE FROM annotation WHERE"
-
		" annotation_id NOT IN (SELECT key_id FROM pkg_annotation) AND"
+
		" annotation_id NOT IN (SELECT tag_id FROM pkg_annotation) AND"
		" annotation_id NOT IN (SELECT value_id FROM pkg_annotation)",
		"",
	},
@@ -2688,14 +2688,14 @@ pkgdb_insert_annotations(struct pkg *pkg, int64_t package_id, sqlite3 *s)
	struct pkg_note	*note = NULL;

	while (pkg_annotations(pkg, &note) == EPKG_OK) {
-
		if (run_prstmt(ANNOTATE1, pkg_annotation_key(note))
+
		if (run_prstmt(ANNOTATE1, pkg_annotation_tag(note))
		    != SQLITE_DONE
		    ||
		    run_prstmt(ANNOTATE1, pkg_annotation_value(note))
		    != SQLITE_DONE
		    ||
		    run_prstmt(ANNOTATE2, package_id,
-
			pkg_annotation_key(note),
+
			pkg_annotation_tag(note),
			pkg_annotation_value(note))
		    != SQLITE_DONE) {
			ERROR_SQLITE(s);
@@ -2775,13 +2775,13 @@ pkgdb_reanalyse_shlibs(struct pkgdb *db, struct pkg *pkg)

int
pkgdb_add_annotation(struct pkgdb *db, const char *pkgname,
-
    const char *pkgversion, const char *key, const char *value)
+
    const char *pkgversion, const char *tag, const char *value)
{
	int	rows_changed;

	assert(pkgname != NULL && pkgname[0] != '\0');
	assert(pkgversion != NULL && pkgversion[0] != '\0');
-
	assert(key != NULL);
+
	assert(tag != NULL);
	assert(value != NULL);

	if (!db->prstmt_initialized && prstmt_initialize(db) != EPKG_OK)
@@ -2790,11 +2790,11 @@ pkgdb_add_annotation(struct pkgdb *db, const char *pkgname,
	if (pkgdb_transaction_begin(db->sqlite, NULL) != EPKG_OK)
		return (EPKG_FATAL);

-
	if (run_prstmt(ANNOTATE1, key) != SQLITE_DONE
+
	if (run_prstmt(ANNOTATE1, tag) != SQLITE_DONE
	    ||
	    run_prstmt(ANNOTATE1, value) != SQLITE_DONE
	    ||
-
	    run_prstmt(ANNOTATE_ADD1, pkgname, pkgversion, key, value)
+
	    run_prstmt(ANNOTATE_ADD1, pkgname, pkgversion, tag, value)
	    != SQLITE_DONE) {
		ERROR_SQLITE(db->sqlite);
		pkgdb_transaction_rollback(db->sqlite, NULL);
@@ -2802,7 +2802,7 @@ pkgdb_add_annotation(struct pkgdb *db, const char *pkgname,
	}

	/* Expect rows_changed == 1 unless there's already an
-
	   annotation using the given key */
+
	   annotation using the given tag */

	rows_changed = sqlite3_changes(db->sqlite);

@@ -2814,13 +2814,13 @@ pkgdb_add_annotation(struct pkgdb *db, const char *pkgname,

int
pkgdb_modify_annotation(struct pkgdb *db, const char *pkgname,
-
    const char *pkgversion, const char *key, const char *value)
+
    const char *pkgversion, const char *tag, const char *value)
{
	int rows_changed; 

	assert(pkgname != NULL && pkgname[0] != '\0');
	assert(pkgversion != NULL && pkgversion[0] != '\0');
-
	assert(key != NULL);
+
	assert(tag != NULL);
	assert(value != NULL);

	if (!db->prstmt_initialized && prstmt_initialize(db) != EPKG_OK)
@@ -2829,13 +2829,13 @@ pkgdb_modify_annotation(struct pkgdb *db, const char *pkgname,
	if (pkgdb_transaction_begin(db->sqlite, NULL) != EPKG_OK)
		return (EPKG_FATAL);

-
	if (run_prstmt(ANNOTATE_DEL1, pkgname, pkgversion, key) != SQLITE_DONE
+
	if (run_prstmt(ANNOTATE_DEL1, pkgname, pkgversion, tag) != SQLITE_DONE
	    ||
-
	    run_prstmt(ANNOTATE1, key) != SQLITE_DONE /* is this necessary? */
+
	    run_prstmt(ANNOTATE1, tag) != SQLITE_DONE
	    ||
	    run_prstmt(ANNOTATE1, value) != SQLITE_DONE
	    ||
-
	    run_prstmt(ANNOTATE_ADD1, pkgname, pkgversion, key, value) !=
+
	    run_prstmt(ANNOTATE_ADD1, pkgname, pkgversion, tag, value) !=
	        SQLITE_DONE
	    ||
	    run_prstmt(ANNOTATE_DEL2) != SQLITE_DONE) {
@@ -2856,14 +2856,14 @@ pkgdb_modify_annotation(struct pkgdb *db, const char *pkgname,

int
pkgdb_delete_annotation(struct pkgdb *db, const char *pkgname,
-
    const char *pkgversion, const char *key)
+
    const char *pkgversion, const char *tag)
{
	int	rows_changed;
	bool	result;

	assert(pkgname != NULL && pkgname[0] != '\0');
	assert(pkgversion != NULL && pkgversion[0] != '\0');
-
	assert(key != NULL);
+
	assert(tag != NULL);

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

-
	result = (run_prstmt(ANNOTATE_DEL1, pkgname, pkgversion, key) == SQLITE_DONE);
+
	result = (run_prstmt(ANNOTATE_DEL1, pkgname, pkgversion, tag)
+
		  == SQLITE_DONE);

	rows_changed = sqlite3_changes(db->sqlite);

modified libpkg/pkgdb_repo.c
@@ -157,7 +157,7 @@ static sql_prstmt sql_prepared_statements[PRSTMT_LAST] = {
	},
	[ANNOTATE2] = {
		NULL,
-
		"INSERT OR ROLLBACK INTO pkg_annotate(package_id, key_id, value_id) "
+
		"INSERT OR ROLLBACK INTO pkg_annotate(package_id, tag_id, value_id) "
		"VALUES (?1,"
		" (SELECT annotation_id FROM annotation WHERE annotation=?2),"
		" (SELECT annotation_id FROM annotation WHERE annotation=?3))",
@@ -587,15 +587,15 @@ try_again:

	note = NULL;
	while (pkg_annotations(pkg, &note) == EPKG_OK) {
-
		const char *note_key = pkg_annotation_key(note);
+
		const char *note_tag = pkg_annotation_tag(note);
		const char *note_val = pkg_annotation_value(note);

-
		ret = run_prepared_statement(ANNOTATE1, note_key);
+
		ret = run_prepared_statement(ANNOTATE1, note_tag);
		if (ret == SQLITE_DONE) 
			ret = run_prepared_statement(ANNOTATE1, note_val);
		if (ret == SQLITE_DONE)
			ret = run_prepared_statement(ANNOTATE2, package_id,
-
				  note_key, note_val);
+
				  note_tag, note_val);
		if (ret != SQLITE_DONE) {
			ERROR_SQLITE(sqlite);
			return (EPKG_FATAL);
modified libpkg/private/db_upgrades.h
@@ -314,16 +314,16 @@ static struct db_upgrades {
        "CREATE TABLE pkg_annotation ("
                "package_id INTERGER REFERENCES packages(id)"
                      " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
                "key_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
+
                "tag_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
                      " ON DELETE CASCADE ON UPDATE RESTRICT,"
		"value_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
	 	      " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
	        "UNIQUE(package_id, key_id)"
+
	        "UNIQUE(package_id, tag_id)"
	");"
	"CREATE INDEX pkg_annotation_package_id ON pkg_annotation(package_id);"
	"INSERT INTO annotation (annotation_id, annotation)"
	        "SELECT abstract_id, abstract FROM abstract;"
-
	"INSERT INTO pkg_annotation (package_id,key_id,value_id)"
+
	"INSERT INTO pkg_annotation (package_id,tag_id,value_id)"
	        "SELECT package_id,key_id,value_id FROM pkg_abstract;"
	"DROP INDEX pkg_abstract_package_id;"
	"DROP TABLE pkg_abstract;"
modified libpkg/private/pkg.h
@@ -244,7 +244,7 @@ struct pkg_config_value {
};

struct pkg_note {
-
	struct sbuf	*key;
+
	struct sbuf	*tag;
	struct sbuf	*value;
	UT_hash_handle	 hh;
};
modified libpkg/private/repodb.h
@@ -122,11 +122,11 @@ static const char initsql[] = ""
	"CREATE TABLE pkg_annotation ("
	    "package_id INTERGER REFERENCES packages(id)"
	    " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
	    "key_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
+
	    "tag_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
	    " ON DELETE CASCADE ON UPDATE RESTRICT,"
	    "value_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
	    " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
	    "UNIQUE (package_id, key_id)"
+
	    "UNIQUE (package_id, tag_id)"
	");"
	"PRAGMA user_version=%d;"
	;
@@ -194,15 +194,15 @@ static const struct repo_changes repo_upgrades[] = {
	 "CREATE TABLE %Q.pkg_annotation ("
	        "package_id INTEGER REFERENCES packages(id)"
	        " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
	        "key_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
+
	        "tag_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
	        " ON DELETE CASCADE ON UPDATE RESTRICT,"
	        "value_id INTEGER NOT NULL REFERENCES annotation(annotation_id)"
	        " ON DELETE CASCADE ON UPDATE RESTRICT,"
-
	        "UNIQUE (package_id, key_id)"
+
	        "UNIQUE (package_id, tag_id)"
	 ");"
	 "INSERT INTO %Q.annotation (annotation_id, annotation)"
	        " SELECT abstract_id, abstract FROM %Q.abstract;"
-
	 "INSERT INTO %Q.pkg_annotation (package_id,key_id,value_id)"
+
	 "INSERT INTO %Q.pkg_annotation (package_id,tag_id,value_id)"
	        " SELECT package_id,key_id,value_id FROM %Q.pkg_abstract;"
	 "DROP TABLE pkg_abstract;"
	 "DROP TABLE abstract;"
@@ -234,7 +234,7 @@ static const struct repo_changes repo_downgrades[] = {
	 "INSERT INTO %Q.abstract (abstract_id, abstract)"
	        " SELECT annotation_id, annotation FROM %Q.annotation;"
	 "INSERT INTO %Q.pkg_abstract (package_id,key_id,value_id)"
-
	        " SELECT package_id,key_id,value_id FROM %Q.pkg_annotation;"
+
	        " SELECT package_id,tag_id,value_id FROM %Q.pkg_annotation;"
	 "DROP TABLE pkg_annotation;"
	 "DROP TABLE annotation;"
	},
modified pkg/annotate.c
@@ -50,81 +50,88 @@ static bool yes;
void
usage_annotate(void)
{
-
	fprintf(stderr, "usage: pkg annotate [-giqxy] [-A|-M] <pkg-name> <key> [<value>]\n");
-
	fprintf(stderr, "       pkg annotate [-giqxy] -D <pkg-name> <key>\n");
-
	fprintf(stderr, "       pkg annotate [-qy] -a [-A|-M] <key> [<value>]\n");
-
	fprintf(stderr, "       pkg annotate [-qy] -a -D <key>\n");
-
	fprintf(stderr, "For more information see 'pkg help annotate'.\n");
+
	fprintf(stderr,
+
            "usage: pkg annotate [-giqxy] [-A|M] <pkg-name> <tag> [<value>]\n");
+
	fprintf(stderr,
+
            "       pkg annotate [-giqxy] -D <pkg-name> <tag>\n");
+
	fprintf(stderr,
+
            "       pkg annotate [-qy] -a [-A|M] <tag> [<value>]\n");
+
	fprintf(stderr,
+
            "       pkg annotate [-qy] -a -D <tag>\n");
+
	fprintf(stderr,
+
            "For more information see 'pkg help annotate'.\n");
}

static int
do_add(struct pkgdb *db, const char *pkgname, const char *pkgversion,
-
       const char *key, const char *value)
+
       const char *tag, const char *value)
{
	int	 ret = EPKG_OK;

-
	if (yes || query_tty_yesno("%s-%s: Add annotation %s => %s? [y/N]: ",
-
			 pkgname, pkgversion, key, value)) {
+
	if (yes || query_tty_yesno("%s-%s: Add annotation tagged: %s with "
+
	               "value: %s? [y/N]: ", pkgname, pkgversion,
+
                       tag, value)) {
		ret = pkgdb_add_annotation(db, pkgname, pkgversion,
-
                          key, value);
+
                          tag, value);
		if (ret == EPKG_OK) {
			if (!quiet)
-
				printf("Annotated %s-%s: %s\n", pkgname,
-
				     pkgversion, key);
+
				printf("%s-%s: added annotation tagged: %s\n",
+
				     pkgname, pkgversion, tag);
		} else if (ret == EPKG_WARN) {
			if (!quiet)
-
				warnx("%s-%s: Can't add annotation %s -- "
+
				warnx("%s-%s: Can't add annotation tagged: %s -- "
				     "already exists", pkgname, pkgversion,
-
				     key );
+
				     tag );
		} else
-
			warnx("%s-%s: Failed to add annotation %s", pkgname,
-
			     pkgversion, key);
+
			warnx("%s-%s: Failed to add annotation tagged: %s",
+
			     pkgname, pkgversion, tag);
	}
	return (ret);
}

static int
do_modify(struct pkgdb *db, const char *pkgname, const char *pkgversion,
-
	  const char *key, const char *value)
+
	  const char *tag, const char *value)
{
	int	ret = EPKG_OK;

-
	if (yes || query_tty_yesno("%s-%s: Change %s annotation to "
-
		         "%s => %s? [y/N]: ",
-
			 pkgname, pkgversion, key, key, value)) {
+
	if (yes || query_tty_yesno("%s-%s: Change annotation tagged: %s to "
+
		         "new value: %s? [y/N]: ",
+
			 pkgname, pkgversion, tag, value)) {
		ret = pkgdb_modify_annotation(db, pkgname, pkgversion,
-
                          key, value);
-
		if (ret == EPKG_OK) {
+
                          tag, value);
+
		if (ret == EPKG_OK || ret == EPKG_WARN) {
			if (!quiet)
-
				printf("Modified annotation %s-%s: %s\n",
-
				       pkgname, pkgversion, key);
+
				printf("%s-%s: Modified annotation tagged: "
+
				       "%s\n", pkgname, pkgversion, tag);
		} else
-
			warnx("%s-%s: Failed to modify annotation %s", pkgname,
-
			     pkgversion, key);
+
			warnx("%s-%s: Failed to modify annotation tagged: %s",
+
			     pkgname, pkgversion, tag);
	}
	return (ret);
} 

static int
do_delete(struct pkgdb *db, const char *pkgname, const char *pkgversion,
-
	  const char *key)
+
	  const char *tag)
{
	int	ret = EPKG_OK;

-
	if (yes || query_tty_yesno("%s-%s: Delete %s annotation [y/N]: ",
-
			 pkgname, pkgversion, key)) {
-
		ret = pkgdb_delete_annotation(db, pkgname, pkgversion, key);
+
	if (yes || query_tty_yesno("%s-%s: Delete annotation tagged: %s [y/N]: ",
+
			 pkgname, pkgversion, tag)) {
+
		ret = pkgdb_delete_annotation(db, pkgname, pkgversion, tag);
		if (ret == EPKG_OK) {
			if (!quiet)
-
				printf("Deleted annotation %s-%s: %s\n",
-
				       pkgname, pkgversion, key);
+
				printf("%s-%s: Deleted annotation tagged: %s\n",
+
				       pkgname, pkgversion, tag);
		} else if (ret == EPKG_WARN) {
			if (!quiet)
-
				warnx("%s-%s: Can't delete annotation %s -- "
-
				     "nonexistent", pkgname, pkgversion, key);
+
				warnx("%s-%s: Can't delete annotation tagged: "
+
				     "%s -- because there is none", pkgname,
+
				     pkgversion, tag);
		} else
-
			warnx("%s-%s: Failed to delete annotation %s", pkgname,
-
			     pkgversion, key);
+
			warnx("%s-%s: Failed to delete annotation tagged: %s",
+
			     pkgname, pkgversion, tag);
	}
	return (ret);
} 
@@ -160,7 +167,7 @@ exec_annotate(int argc, char **argv)
	struct pkgdb_it	*it       = NULL;
	struct pkg	*pkg      = NULL;
	enum action	 action   = NONE;
-
	const char	*key;
+
	const char	*tag;
	const char	*value;
	const char	*pkgname;
	const char	*pkgversion;
@@ -218,11 +225,11 @@ exec_annotate(int argc, char **argv)

	if (match == MATCH_ALL) {
		pkgname = NULL;
-
		key     = argv[0];
+
		tag     = argv[0];
		value   = (argc > 1) ? argv[1] : NULL;
	} else {
		pkgname = argv[0];
-
		key     = argv[1];
+
		tag     = argv[1];
		value   = (argc > 2) ? argv[2] : NULL;
	}

@@ -273,13 +280,13 @@ exec_annotate(int argc, char **argv)
			exitcode = EX_USAGE;
			break;
		case ADD:
-
			retcode = do_add(db, pkgname, pkgversion, key, value);
+
			retcode = do_add(db, pkgname, pkgversion, tag, value);
			break;
		case MODIFY:
-
			retcode = do_modify(db, pkgname, pkgversion, key, value);
+
			retcode = do_modify(db, pkgname, pkgversion, tag, value);
			break;
		case DELETE:
-
			retcode = do_delete(db, pkgname, pkgversion, key);
+
			retcode = do_delete(db, pkgname, pkgversion, tag);
			break;
		}

modified pkg/main.c
@@ -64,7 +64,7 @@ static struct commands {
	void (* const usage)(void);
} cmd[] = {
	{ "add", "Registers a package and installs it on the system", exec_add, usage_add},
-
	{ "annotate", "Add or modify key-value style annotations on packages", exec_annotate, usage_annotate},
+
	{ "annotate", "Add, modify or delete tag-value style annotations on packages", exec_annotate, usage_annotate},
	{ "audit", "Reports vulnerable packages", exec_audit, usage_audit},
	{ "autoremove", "Removes orphan packages", exec_autoremove, usage_autoremove},
	{ "backup", "Backs-up and restores the local package database", exec_backup, usage_backup},
modified pkg/pkg-query.8
@@ -135,7 +135,7 @@ for provided shared libraries
for annotations
.El
.It Cm \&%# Ns Op drCFODLUGBbA
-
Returns the number of element in the list
+
Returns the number of elements in the list
.Bl -tag -width indent
.It Cm d
for dependencies
@@ -209,11 +209,11 @@ Expands to the list of groups needed by the matched package.
Expands to the list of shared libraries used by programs from the matched package.
.It Cm \&%b
Expands to the list of shared libraries provided by the matched package.
-
.It Cm \&A Ns Op kv
+
.It Cm \&A Ns Op tv
Expands to the list of annotations for the matched package,
where
-
.Cm k
-
stands for the annotation key, and
+
.Cm t
+
stands for the annotation tag, and
.Cm v
stands for the annotation value.
.El
modified pkg/pkg-rquery.8
@@ -178,11 +178,11 @@ Expands to the list of license(s) for the matched package.
Expands to the list of shared libraries used by programs from the matched package.
.It Cm \&%b
Expands to the list of shared libraries provided by the matched package.
-
.It Cm \&%A Ns Op kv
+
.It Cm \&%A Ns Op tv
Expands to the list of annotations associated with the matched
package, where
-
.Cm k
-
stands for the annotation key, and
+
.Cm t
+
stands for the annotation tag, and
.Cm v
stands for the annotation value.
.El
modified pkg/pkg-search.8
@@ -234,8 +234,7 @@ or
options, then each output field will be tagged with the field name.
.Bl -tag -width 2n
.It Sy annotations
-
Freeform arbitrary text in key-value format that can be added to
-
any package. 
+
Arbitrary text in tag-value format that can be added to any package. 
.It Sy arch
The architecture string indicating what OS version and CPU architecture
the package is suitable for.
modified pkg/query.c
@@ -312,8 +312,8 @@ format_str(struct pkg *pkg, struct sbuf *dest, const char *qstr, void *data)
				break;
			case 'A':
				qstr++;
-
				if (qstr[0] == 'k')
-
					sbuf_cat(dest, pkg_annotation_key((struct pkg_note *)data));
+
				if (qstr[0] == 't')
+
					sbuf_cat(dest, pkg_annotation_tag((struct pkg_note *)data));
				else if (qstr[0] == 'v')
					sbuf_cat(dest, pkg_annotation_value((struct pkg_note *)data));
				break;
modified pkg/utils.c
@@ -443,7 +443,7 @@ print_info(struct pkg * const pkg, unsigned int options)
					printf("%-15s:\n", "Annotations");
				while (pkg_annotations(pkg, &note) == EPKG_OK)
					printf("%s%-15s: %s\n", tab,
-
					       pkg_annotation_key(note),
+
					       pkg_annotation_tag(note),
					       pkg_annotation_value(note));
			}
			break;