Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: kill useless pkg_manifest_key API
Baptiste Daroussin committed 3 years ago
commit eec0e9003b6fecd42319502436bb392b720222c9
parent 5a84966
16 files changed +80 -173
modified libpkg/libpkg.ver
@@ -94,8 +94,6 @@ global:
	pkg_licenses;
	pkg_list_count;
	pkg_load_metadata;
-
	pkg_manifest_keys_free;
-
	pkg_manifest_keys_new;
	pkg_manifest_parser_free;
	pkg_manifest_parser_new;
	pkg_namecmp;
modified libpkg/pkg.c
@@ -1110,13 +1110,13 @@ pkg_list_free(struct pkg *pkg, pkg_list list) {
}

int
-
pkg_open(struct pkg **pkg_p, const char *path, struct pkg_manifest_key *keys, int flags)
+
pkg_open(struct pkg **pkg_p, const char *path, int flags)
{
	struct archive *a;
	struct archive_entry *ae;
	int ret;

-
	ret = pkg_open2(pkg_p, &a, &ae, path, keys, flags, -1);
+
	ret = pkg_open2(pkg_p, &a, &ae, path, flags, -1);

	if (ret != EPKG_OK && ret != EPKG_END)
		return (EPKG_FATAL);
@@ -1128,13 +1128,13 @@ pkg_open(struct pkg **pkg_p, const char *path, struct pkg_manifest_key *keys, in
}

int
-
pkg_open_fd(struct pkg **pkg_p, int fd, struct pkg_manifest_key *keys, int flags)
+
pkg_open_fd(struct pkg **pkg_p, int fd, int flags)
{
	struct archive *a;
	struct archive_entry *ae;
	int ret;

-
	ret = pkg_open2(pkg_p, &a, &ae, NULL, keys, flags, fd);
+
	ret = pkg_open2(pkg_p, &a, &ae, NULL, flags, fd);

	if (ret != EPKG_OK && ret != EPKG_END)
		return (EPKG_FATAL);
@@ -1146,8 +1146,7 @@ pkg_open_fd(struct pkg **pkg_p, int fd, struct pkg_manifest_key *keys, int flags
}

static int
-
pkg_parse_archive(struct pkg *pkg, struct pkg_manifest_key *keys,
-
    struct archive *a, size_t len)
+
pkg_parse_archive(struct pkg *pkg, struct archive *a, size_t len)
{
	void *buffer;
	int rc;
@@ -1155,14 +1154,14 @@ pkg_parse_archive(struct pkg *pkg, struct pkg_manifest_key *keys,
	buffer = xmalloc(len);

	archive_read_data(a, buffer, len);
-
	rc = pkg_parse_manifest(pkg, buffer, len, keys);
+
	rc = pkg_parse_manifest(pkg, buffer, len);
	free(buffer);
	return (rc);
}

int
pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae,
-
    const char *path, struct pkg_manifest_key *keys, int flags, int fd)
+
    const char *path, int flags, int fd)
{
	struct pkg	*pkg = NULL;
	pkg_error_t	 retcode = EPKG_OK;
@@ -1225,7 +1224,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae,
			strcmp(fpath, "+COMPACT_MANIFEST") == 0) {
			manifest = true;

-
			ret = pkg_parse_archive(pkg, keys, *a, archive_entry_size(*ae));
+
			ret = pkg_parse_archive(pkg, *a, archive_entry_size(*ae));
			if (ret != EPKG_OK) {
				retcode = EPKG_FATAL;
				goto cleanup;
@@ -1236,7 +1235,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae,
		if (!manifest && strcmp(fpath, "+MANIFEST") == 0) {
			manifest = true;

-
			ret = pkg_parse_archive(pkg, keys, *a, archive_entry_size(*ae));
+
			ret = pkg_parse_archive(pkg, *a, archive_entry_size(*ae));
			if (ret != EPKG_OK) {
				if ((flags & PKG_OPEN_TRY) == 0)
					pkg_emit_error("%s is not a valid package: "
modified libpkg/pkg.h.in
@@ -109,7 +109,6 @@ struct pkg_repo;

struct pkg_plugin;

-
struct pkg_manifest_key;
struct pkg_manifest_parser;

typedef struct ucl_object_s pkg_object;
@@ -630,8 +629,8 @@ int pkg_is_valid(const struct pkg * restrict);
 * @param keys manifest keys that should be initialised
 * @param flags open flags
 */
-
int pkg_open(struct pkg **p, const char *path, struct pkg_manifest_key *keys, int flags);
-
int pkg_open_fd(struct pkg **p, int fd, struct pkg_manifest_key *keys, int flags);
+
int pkg_open(struct pkg **p, const char *path, int flags);
+
int pkg_open_fd(struct pkg **p, int fd, int flags);

/**
 * @return the type of the package.
@@ -788,11 +787,9 @@ int pkg_addluascript_fileat(int fd, struct pkg *pkg, const char *path);
 * @param buf An NULL-terminated buffer containing the manifest data.
 * @return An error code.
 */
-
int pkg_parse_manifest(struct pkg *pkg, const char *buf, size_t len, struct pkg_manifest_key *key);
-
int pkg_parse_manifest_file(struct pkg *pkg, const char *, struct pkg_manifest_key *key);
-
int pkg_parse_manifest_fileat(int fd, struct pkg *pkg, const char *, struct pkg_manifest_key *key);
-
int pkg_manifest_keys_new(struct pkg_manifest_key **k);
-
void pkg_manifest_keys_free(struct pkg_manifest_key *k);
+
int pkg_parse_manifest(struct pkg *pkg, const char *buf, size_t len);
+
int pkg_parse_manifest_file(struct pkg *pkg, const char *);
+
int pkg_parse_manifest_fileat(int fd, struct pkg *pkg, const char *);
int pkg_manifest_parser_new(struct pkg_manifest_parser **p);
void pkg_manifest_parser_free(struct pkg_manifest_parser *p);

@@ -1043,7 +1040,7 @@ int pkgdb_compact(struct pkgdb *db);
 * @return An error code.
 */
int pkg_add(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *location);
+
    const char *location);

#define PKG_ADD_UPGRADE			(1U << 0)
/* (1U << 1) removed intentionally */
modified libpkg/pkg_add.c
@@ -999,8 +999,7 @@ pkg_globmatch(char *pattern, const char *name)

static int
pkg_add_check_pkg_archive(struct pkgdb *db, struct pkg *pkg,
-
	const char *path, int flags,
-
	struct pkg_manifest_key *keys, const char *location)
+
	const char *path, int flags, const char *location)
{
	const char	*arch;
	int	ret, retcode;
@@ -1098,8 +1097,7 @@ pkg_add_check_pkg_archive(struct pkgdb *db, struct pkg *pkg,

		if ((flags & PKG_ADD_UPGRADE) == 0 &&
				access(dpath, F_OK) == 0) {
-
			ret = pkg_add(db, dpath, PKG_ADD_AUTOMATIC,
-
					keys, location);
+
			ret = pkg_add(db, dpath, PKG_ADD_AUTOMATIC, location);

			if (ret != EPKG_OK)
				goto cleanup;
@@ -1200,7 +1198,7 @@ pkg_add_triggers(void)

static int
pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *reloc, struct pkg *remote,
+
    const char *reloc, struct pkg *remote,
    struct pkg *local, struct triggers *t)
{
	struct archive		*a;
@@ -1223,7 +1221,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
	 * current archive_entry to the first non-meta file.
	 * If there is no non-meta files, EPKG_END is returned.
	 */
-
	ret = pkg_open2(&pkg, &a, &ae, path, keys, 0, -1);
+
	ret = pkg_open2(&pkg, &a, &ae, path, 0, -1);
	if (ret == EPKG_END)
		extract = false;
	else if (ret != EPKG_OK) {
@@ -1250,8 +1248,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
	 * Additional checks for non-remote package
	 */
	if (remote == NULL) {
-
		ret = pkg_add_check_pkg_archive(db, pkg, path, flags, keys,
-
		    reloc);
+
		ret = pkg_add_check_pkg_archive(db, pkg, path, flags, reloc);
		if (ret != EPKG_OK) {
			/* Do not return error on installed package */
			retcode = (ret == EPKG_INSTALLED ? EPKG_OK : ret);
@@ -1428,28 +1425,28 @@ cleanup:

int
pkg_add(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *location)
+
    const char *location)
{
-
	return pkg_add_common(db, path, flags, keys, location, NULL, NULL, NULL);
+
	return pkg_add_common(db, path, flags, location, NULL, NULL, NULL);
}

int
pkg_add_from_remote(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *location, struct pkg *rp, struct triggers *t)
+
    const char *location, struct pkg *rp, struct triggers *t)
{
-
	return pkg_add_common(db, path, flags, keys, location, rp, NULL, t);
+
	return pkg_add_common(db, path, flags, location, rp, NULL, t);
}

int
pkg_add_upgrade(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *location,
+
    const char *location,
    struct pkg *rp, struct pkg *lp, struct triggers *t)
{
	if (pkgdb_ensure_loaded(db, lp,
	    PKG_LOAD_FILES|PKG_LOAD_SCRIPTS|PKG_LOAD_DIRS|PKG_LOAD_LUA_SCRIPTS) != EPKG_OK)
		return (EPKG_FATAL);

-
	return pkg_add_common(db, path, flags, keys, location, rp, lp, t);
+
	return pkg_add_common(db, path, flags, location, rp, lp, t);
}

int
modified libpkg/pkg_create.c
@@ -465,11 +465,11 @@ pkg_load_message_from_file(int fd, struct pkg *pkg, const char *path)
/* TODO use file descriptor for rootdir */
static int
load_manifest(struct pkg *pkg, const char *metadata, const char *plist,
-
    struct pkg_manifest_key *keys, const char *rootdir)
+
    const char *rootdir)
{
	int ret;

-
	ret = pkg_parse_manifest_file(pkg, metadata, keys);
+
	ret = pkg_parse_manifest_file(pkg, metadata);

	if (ret == EPKG_OK && plist != NULL)
		ret = ports_parse_plist(pkg, plist, rootdir);
@@ -481,29 +481,23 @@ static int
load_metadata(struct pkg *pkg, const char *metadata, const char *plist,
    const char *rootdir)
{
-
	struct pkg_manifest_key *keys = NULL;
	regex_t preg;
	regmatch_t pmatch[2];
	size_t size;
	int fd, i;

-
	pkg_manifest_keys_new(&keys);
-

	/* Let's see if we have a directory or a manifest */
	if ((fd = open(metadata, O_DIRECTORY|O_CLOEXEC)) == -1) {
		if (errno == ENOTDIR)
-
			return (load_manifest(pkg, metadata, plist, keys, rootdir));
+
			return (load_manifest(pkg, metadata, plist, rootdir));
		pkg_emit_errno("open", metadata);
-
		pkg_manifest_keys_free(keys);
		return (EPKG_FATAL);
	}

-
	if ((pkg_parse_manifest_fileat(fd, pkg, "+MANIFEST", keys)) != EPKG_OK) {
-
		pkg_manifest_keys_free(keys);
+
	if ((pkg_parse_manifest_fileat(fd, pkg, "+MANIFEST")) != EPKG_OK) {
		close(fd);
		return (EPKG_FATAL);
	}
-
	pkg_manifest_keys_free(keys);

	pkg_load_message_from_file(fd, pkg, "+DISPLAY");
	if (pkg->desc == NULL)
modified libpkg/pkg_jobs.c
@@ -1051,7 +1051,6 @@ pkg_jobs_find_remote_pattern(struct pkg_jobs *j, struct job_pattern *jp)
{
	int rc = EPKG_OK;
	struct pkg *pkg = NULL;
-
	struct pkg_manifest_key *keys = NULL;
	struct pkg_job_request *req;

	if (!(jp->flags & PKG_PATTERN_FLAG_FILE)) {
@@ -1071,14 +1070,12 @@ pkg_jobs_find_remote_pattern(struct pkg_jobs *j, struct job_pattern *jp)
		rc = pkg_jobs_find_upgrade(j, jp->pattern, jp->match);
	}
	else {
-
		pkg_manifest_keys_new(&keys);
-
		if (pkg_open(&pkg, jp->path, keys, PKG_OPEN_MANIFEST_ONLY) != EPKG_OK) {
+
		if (pkg_open(&pkg, jp->path, PKG_OPEN_MANIFEST_ONLY) != EPKG_OK) {
			rc = EPKG_FATAL;
		} else if (pkg_validate(pkg, j->db) == EPKG_OK) {
			if (j->type == PKG_JOBS_UPGRADE && pkg_jobs_installed_local_pkg(j, pkg) != EPKG_OK) {
				pkg_emit_error("%s is not installed, therefore upgrade is impossible",
							pkg->name);
-
				pkg_manifest_keys_free(keys);
				return (EPKG_NOTINSTALLED);
			}
			pkg->type = PKG_FILE;
@@ -1093,7 +1090,6 @@ pkg_jobs_find_remote_pattern(struct pkg_jobs *j, struct job_pattern *jp)
					jp->pattern);
			rc = EPKG_FATAL;
		}
-
		pkg_manifest_keys_free(keys);
	}

	return (rc);
@@ -2038,8 +2034,7 @@ pkg_jobs_type(struct pkg_jobs *j)
}

static int
-
pkg_jobs_handle_install(struct pkg_solved *ps, struct pkg_jobs *j,
-
		struct pkg_manifest_key *keys)
+
pkg_jobs_handle_install(struct pkg_solved *ps, struct pkg_jobs *j)
{
	struct pkg *new, *old;
	struct pkg_job_request *req;
@@ -2094,9 +2089,9 @@ pkg_jobs_handle_install(struct pkg_solved *ps, struct pkg_jobs *j,
		flags |= PKG_ADD_AUTOMATIC;

	if (old != NULL)
-
		retcode = pkg_add_upgrade(j->db, target, flags, keys, NULL, new, old, &j->triggers);
+
		retcode = pkg_add_upgrade(j->db, target, flags, NULL, new, old, &j->triggers);
	else
-
		retcode = pkg_add_from_remote(j->db, target, flags, keys, NULL, new, &j->triggers);
+
		retcode = pkg_add_from_remote(j->db, target, flags, NULL, new, &j->triggers);

	return (retcode);
}
@@ -2123,7 +2118,6 @@ static int
pkg_jobs_execute(struct pkg_jobs *j)
{
	struct pkg *p;
-
	struct pkg_manifest_key *keys = NULL;
	int retcode = EPKG_FATAL;
	pkg_plugin_hook_t pre, post;

@@ -2155,8 +2149,6 @@ pkg_jobs_execute(struct pkg_jobs *j)

	pkg_plugins_hook_run(pre, j, j->db);

-
	pkg_manifest_keys_new(&keys);
-

	pkg_jobs_set_priorities(j);

	tll_foreach(j->jobs, _p) {
@@ -2195,7 +2187,7 @@ pkg_jobs_execute(struct pkg_jobs *j)
		case PKG_SOLVED_INSTALL:
		case PKG_SOLVED_UPGRADE_INSTALL:
		case PKG_SOLVED_UPGRADE:
-
			retcode = pkg_jobs_handle_install(ps, j, keys);
+
			retcode = pkg_jobs_handle_install(ps, j);
			if (retcode != EPKG_OK)
				goto cleanup;
			break;
@@ -2212,7 +2204,6 @@ pkg_jobs_execute(struct pkg_jobs *j)

cleanup:
	pkgdb_release_lock(j->db, PKGDB_LOCK_EXCLUSIVE);
-
	pkg_manifest_keys_free(keys);

	return (retcode);
}
modified libpkg/pkg_manifest.c
@@ -88,8 +88,6 @@ static struct pkg_manifest_key {
	uint32_t type;
	uint16_t valid_type;
	int (*parse_data)(struct pkg *, const ucl_object_t *, uint32_t);
-
	struct pkg_manifest_key *next;
-
	struct pkg_manifest_key *prev;
} manifest_keys[] = {
	{ "annotations",         PKG_ANNOTATIONS,
			TYPE_SHIFT(UCL_OBJECT), pkg_obj},
@@ -214,45 +212,8 @@ static struct pkg_manifest_key {
	{ "www",                 offsetof(struct pkg, www),
			TYPE_SHIFT(UCL_STRING), pkg_string},

-
	{ NULL, -99, -99, NULL}
};

-
int
-
pkg_manifest_keys_new(struct pkg_manifest_key **key)
-
{
-
	int i;
-
	struct pkg_manifest_key *k;
-

-
	if (*key != NULL)
-
		return (EPKG_OK);
-

-
	for (i = 0; manifest_keys[i].key != NULL; i++) {
-
		k = xcalloc(1, sizeof(struct pkg_manifest_key));
-
		k->key = manifest_keys[i].key;
-
		k->type = manifest_keys[i].type;
-
		k->valid_type = manifest_keys[i].valid_type;
-
		k->parse_data = manifest_keys[i].parse_data;
-
		DL_APPEND(*key, k);
-
	}
-

-
	return (EPKG_OK);
-
}
-

-
static void
-
pmk_free(struct pkg_manifest_key *key)
-
{
-
	free(key);
-
}
-

-
void
-
pkg_manifest_keys_free(struct pkg_manifest_key *key)
-
{
-
	if (key == NULL)
-
		return;
-

-
	LL_FREE(key, pmk_free);
-
}
-

static int
urlencode(const char *src, xstring **dest)
{
@@ -273,7 +234,6 @@ urlencode(const char *src, xstring **dest)
	return (EPKG_OK);
}

-

static int
urldecode(const char *src, xstring **dest)
{
@@ -775,12 +735,20 @@ pkg_set_deps_from_object(struct pkg *pkg, const ucl_object_t *obj)
	return (EPKG_OK);
}

+
static struct pkg_manifest_key *
+
select_manifest_key(const char *key)
+
{
+
	for (int i = 0; i < NELEM(manifest_keys); i++)
+
		if (strcmp(manifest_keys[i].key, key) == 0)
+
			return (&(manifest_keys[i]));
+
	return (NULL);
+
}
static int
-
parse_manifest(struct pkg *pkg, struct pkg_manifest_key *keys, ucl_object_t *obj)
+
parse_manifest(struct pkg *pkg, ucl_object_t *obj)
{
	const ucl_object_t *cur;
	ucl_object_iter_t it = NULL;
-
	struct pkg_manifest_key *selected_key;
+
	struct pkg_manifest_key *selected_key = NULL;
	const char *key;
	int ret = EPKG_OK;

@@ -789,20 +757,16 @@ parse_manifest(struct pkg *pkg, struct pkg_manifest_key *keys, ucl_object_t *obj
		if (key == NULL)
			continue;
		pkg_debug(3, "Manifest: found key: '%s'", key);
-
		LL_FOREACH(keys, selected_key) {
-
			if (strcmp(selected_key->key, key) == 0)
-
				break;
+
		if ((selected_key = select_manifest_key(key)) == NULL) {
+
			pkg_debug(1, "Skipping unknown key '%s'", key);
+
			continue;
		}
-
		if (selected_key != NULL) {
-
			if (TYPE_SHIFT(ucl_object_type(cur)) & selected_key->valid_type) {
-
				ret = selected_key->parse_data(pkg, cur, selected_key->type);
-
				if (ret != EPKG_OK)
-
					return (ret);
-
			} else {
-
				pkg_emit_error("Skipping malformed key '%s'", key);
-
			}
+
		if (TYPE_SHIFT(ucl_object_type(cur)) & selected_key->valid_type) {
+
			ret = selected_key->parse_data(pkg, cur, selected_key->type);
+
			if (ret != EPKG_OK)
+
				return (ret);
		} else {
-
			pkg_debug(1, "Skipping unknown key '%s'", key);
+
			pkg_emit_error("Skipping malformed key '%s'", key);
		}
	}

@@ -810,11 +774,11 @@ parse_manifest(struct pkg *pkg, struct pkg_manifest_key *keys, ucl_object_t *obj
}

int
-
pkg_parse_manifest_ucl (struct pkg *pkg, ucl_object_t *obj, struct pkg_manifest_key *keys)
+
pkg_parse_manifest_ucl(struct pkg *pkg, ucl_object_t *obj)
{
	const ucl_object_t *cur;
	ucl_object_iter_t it = NULL;
-
	struct pkg_manifest_key *sk;
+
	struct pkg_manifest_key *sk = NULL;
	const char *key;

	/* do a minimal validation */
@@ -822,24 +786,20 @@ pkg_parse_manifest_ucl (struct pkg *pkg, ucl_object_t *obj, struct pkg_manifest_
		key = ucl_object_key(cur);
		if (key == NULL)
			continue;
-
		LL_FOREACH(keys, sk) {
-
			if (strcmp(sk->key, key) == 0)
-
				break;
-
		}
-
		if (sk != NULL) {
-
			if (!(sk->valid_type & TYPE_SHIFT(ucl_object_type(cur)))) {
-
				pkg_emit_error("Bad format in manifest for key:"
-
						" %s", key);
-
				return (EPKG_FATAL);
-
			}
+
		if ((sk = select_manifest_key(key)) == NULL)
+
			continue;
+
		if (!(sk->valid_type & TYPE_SHIFT(ucl_object_type(cur)))) {
+
			pkg_emit_error("Bad format in manifest for key:"
+
				" %s", key);
+
			return (EPKG_FATAL);
		}
	}

-
	return (parse_manifest(pkg, keys, obj));
+
	return (parse_manifest(pkg, obj));
}

int
-
pkg_parse_manifest(struct pkg *pkg, const char *buf, size_t len, struct pkg_manifest_key *keys)
+
pkg_parse_manifest(struct pkg *pkg, const char *buf, size_t len)
{
	struct ucl_parser *p = NULL;
	ucl_object_t *obj = NULL;
@@ -865,15 +825,14 @@ pkg_parse_manifest(struct pkg *pkg, const char *buf, size_t len, struct pkg_mani
	}

	ucl_parser_free(p);
-
	rc = pkg_parse_manifest_ucl(pkg, obj, keys);
+
	rc = pkg_parse_manifest_ucl(pkg, obj);
	ucl_object_unref(obj);

	return (rc);
}

int
-
pkg_parse_manifest_fileat(int dfd, struct pkg *pkg, const char *file,
-
    struct pkg_manifest_key *keys)
+
pkg_parse_manifest_fileat(int dfd, struct pkg *pkg, const char *file)
{
	struct ucl_parser *p = NULL;
	ucl_object_t *obj = NULL;
@@ -906,7 +865,7 @@ pkg_parse_manifest_fileat(int dfd, struct pkg *pkg, const char *file,
	}
	ucl_parser_free(p);

-
	rc = pkg_parse_manifest_ucl(pkg, obj, keys);
+
	rc = pkg_parse_manifest_ucl(pkg, obj);
	ucl_object_unref(obj);
	free(data);

@@ -914,9 +873,9 @@ pkg_parse_manifest_fileat(int dfd, struct pkg *pkg, const char *file,
}

int
-
pkg_parse_manifest_file(struct pkg *pkg, const char *file, struct pkg_manifest_key *keys)
+
pkg_parse_manifest_file(struct pkg *pkg, const char *file)
{
-
	return pkg_parse_manifest_fileat(AT_FDCWD, pkg, file, keys);
+
	return pkg_parse_manifest_fileat(AT_FDCWD, pkg, file);
}

int
modified libpkg/pkg_repo_create.c
@@ -344,7 +344,6 @@ pkg_create_repo_worker(int mfd, int ffd, int pip,
	int flags, ret = EPKG_OK;
	size_t sz;
	struct pkg *pkg = NULL;
-
	struct pkg_manifest_key *keys = NULL;
	char *mdigest = NULL;
	char digestbuf[1024];
	xstring *b;
@@ -372,7 +371,6 @@ pkg_create_repo_worker(int mfd, int ffd, int pip,
		break;
	}

-
	pkg_manifest_keys_new(&keys);
	pkg_debug(1, "start worker to parse packages");

	if (ffd != -1)
@@ -432,7 +430,7 @@ pkg_create_repo_worker(int mfd, int ffd, int pip,
		repopath = mp_decode_str(&rbuf, &len);
		if (len == 0) /* empty package name means ends of repo */
			break;
-
		if (pkg_open(&pkg, path, keys, flags) == EPKG_OK) {
+
		if (pkg_open(&pkg, path, flags) == EPKG_OK) {
			off_t mpos, fpos = 0;
			size_t mlen;
			struct stat st;
@@ -529,7 +527,6 @@ pkg_create_repo_worker(int mfd, int ffd, int pip,
	}

cleanup:
-
	pkg_manifest_keys_free(keys);
	xstring_free(b);
	close(pip);
	free(mdigest);
modified libpkg/private/pkg.h
@@ -657,7 +657,7 @@ ucl_object_t *pkg_lua_script_to_ucl(stringlist_t *);
int pkg_script_run_child(int pid, int *pstat, int inputfd, const char* script_name);

int pkg_open2(struct pkg **p, struct archive **a, struct archive_entry **ae,
-
	      const char *path, struct pkg_manifest_key *keys, int flags, int fd);
+
	      const char *path, int flags, int fd);

int pkg_validate(struct pkg *pkg, struct pkgdb *db);

@@ -748,11 +748,9 @@ char *pkg_checksum_generate_fileat(int fd, const char *path,
    pkg_checksum_type_t type);

int pkg_add_upgrade(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *location,
-
    struct pkg *rp, struct pkg *lp, struct triggers *);
+
    const char *location, struct pkg *rp, struct pkg *lp, struct triggers *);
int pkg_add_from_remote(struct pkgdb *db, const char *path, unsigned flags,
-
    struct pkg_manifest_key *keys, const char *location, struct pkg *rp,
-
    struct triggers *);
+
    const char *location, struct pkg *rp, struct triggers *);
void pkg_delete_dir(struct pkg *pkg, struct pkg_dir *dir);
void pkg_delete_file(struct pkg *pkg, struct pkg_file *file);
int pkg_open_root_fd(struct pkg *pkg);
modified libpkg/repo/binary/query.c
@@ -426,7 +426,6 @@ pkg_repo_binary_ensure_loaded(struct pkg_repo *repo,
	struct pkg *pkg, unsigned flags)
{
	sqlite3 *sqlite = PRIV_GET(repo);
-
	struct pkg_manifest_key *keys = NULL;
	struct pkg *cached = NULL;
	char path[MAXPATHLEN];
	int rc;
@@ -458,13 +457,12 @@ pkg_repo_binary_ensure_loaded(struct pkg_repo *repo,
	/*
	 * Try to get that information from fetched package in cache
	 */
-
	pkg_manifest_keys_new(&keys);

	if (pkg_repo_cached_name(pkg, path, sizeof(path)) != EPKG_OK)
		return (EPKG_FATAL);

	pkg_debug(1, "Binary> loading %s", path);
-
	if (pkg_open(&cached, path, keys, PKG_OPEN_TRY) != EPKG_OK) {
+
	if (pkg_open(&cached, path, PKG_OPEN_TRY) != EPKG_OK) {
		pkg_free(cached);
		return EPKG_FATAL;
	}
modified libpkg/repo/binary/update.c
@@ -361,7 +361,7 @@ pkg_repo_binary_register_conflicts(const char *origin, char **conflicts,

static int
pkg_repo_binary_add_from_manifest(const char *buf, sqlite3 *sqlite, size_t len,
-
		struct pkg_manifest_key **keys, struct pkg **p __unused,
+
		struct pkg **p __unused,
		struct pkg_repo *repo)
{
	int rc = EPKG_OK;
@@ -372,8 +372,7 @@ pkg_repo_binary_add_from_manifest(const char *buf, sqlite3 *sqlite, size_t len,
	if (rc != EPKG_OK)
		return (EPKG_FATAL);

-
	pkg_manifest_keys_new(keys);
-
	rc = pkg_parse_manifest(pkg, buf, len, *keys);
+
	rc = pkg_parse_manifest(pkg, buf, len);
	if (rc != EPKG_OK) {
		goto cleanup;
	}
@@ -462,7 +461,6 @@ pkg_repo_binary_update_proceed(const char *name, struct pkg_repo *repo,
	sqlite3 *sqlite = NULL;
	int cnt = 0;
	time_t local_t;
-
	struct pkg_manifest_key *keys = NULL;
	size_t len = 0;
	bool in_trans = false;
	char *path = NULL;
@@ -533,7 +531,7 @@ pkg_repo_binary_update_proceed(const char *name, struct pkg_repo *repo,
		if ((cnt % 10 ) == 0)
			pkg_emit_progress_tick(totallen, len);
		rc = pkg_repo_binary_add_from_manifest(line, sqlite, linelen,
-
		    &keys, &pkg, repo);
+
		    &pkg, repo);
		if (rc != EPKG_OK) {
			pkg_emit_progress_tick(len, len);
			break;
@@ -573,7 +571,6 @@ cleanup:
		free(path);
	}
	pkg_unregister_cleanup_callback(rollback_repo, (void *)name);
-
	pkg_manifest_keys_free(keys);
	pkg_free(pkg);
	free(line);
	if (f != NULL)
modified src/add.c
@@ -72,7 +72,6 @@ exec_add(int argc, char **argv)
	int i;
	int failedpkgcount = 0;
	pkg_flags f = PKG_FLAG_NONE;
-
	struct pkg_manifest_key *keys = NULL;
	const char *location = NULL;

	/* options descriptor */
@@ -140,7 +139,6 @@ exec_add(int argc, char **argv)
	}

	failedpkgs = xstring_new();
-
	pkg_manifest_keys_new(&keys);
	for (i = 0; i < argc; i++) {
		if (is_url(argv[i]) == EPKG_OK) {
			const char *name = strrchr(argv[i], '/');
@@ -176,7 +174,7 @@ exec_add(int argc, char **argv)

		}

-
		if ((retcode = pkg_add(db, file, f, keys, location)) != EPKG_OK) {
+
		if ((retcode = pkg_add(db, file, f, location)) != EPKG_OK) {
			fprintf(failedpkgs->fp, "%s", argv[i]);
			if (i != argc - 1)
				fprintf(failedpkgs->fp, ", ");
@@ -187,7 +185,6 @@ exec_add(int argc, char **argv)
			unlink(file);

	}
-
	pkg_manifest_keys_free(keys);
	pkgdb_release_lock(db, PKGDB_LOCK_EXCLUSIVE);
	pkgdb_close(db);
	
modified src/clean.c
@@ -291,7 +291,6 @@ exec_clean(int argc, char **argv)
	int		 cachefd = -1;
	size_t		 total = 0;
	char		 size[8];
-
	struct pkg_manifest_key *keys = NULL;
#ifdef HAVE_CAPSICUM
	cap_rights_t rights;
#endif
@@ -382,7 +381,6 @@ exec_clean(int argc, char **argv)

	/* Build the list of out-of-date or obsolete packages */

-
	pkg_manifest_keys_new(&keys);
	recursive_analysis(cachefd, db, cachedir, cachedir, &dl, &sumlist, all,
	    &total);
	pkghash_destroy(sumlist);
@@ -411,7 +409,6 @@ exec_clean(int argc, char **argv)
cleanup:
	pkgdb_release_lock(db, PKGDB_LOCK_READONLY);
	pkgdb_close(db);
-
	pkg_manifest_keys_free(keys);
	tll_free_and_free(dl, free);

	if (cachefd != -1)
modified src/info.c
@@ -94,7 +94,6 @@ exec_info(int argc, char **argv)
	bool pkg_exists = false;
	bool origin_search = false;
	bool e_flag = false;
-
	struct pkg_manifest_key *keys = NULL;
#ifdef HAVE_CAPSICUM
	cap_rights_t rights;
#endif
@@ -287,17 +286,15 @@ exec_info(int argc, char **argv)
#endif
		if (opt == INFO_TAG_NAMEVER)
			opt |= INFO_FULL;
-
		pkg_manifest_keys_new(&keys);

		if ((opt & (INFO_RAW | INFO_FILES |
				INFO_DIRS)) == 0)
			open_flags = PKG_OPEN_MANIFEST_COMPACT;

-
		if (pkg_open_fd(&pkg, fd, keys, open_flags) != EPKG_OK) {
+
		if (pkg_open_fd(&pkg, fd, open_flags) != EPKG_OK) {
			close(fd);
			return (1);
		}
-
		pkg_manifest_keys_free(keys);
		print_info(pkg, opt);
		close(fd);
		pkg_free(pkg);
modified src/query.c
@@ -891,7 +891,6 @@ exec_query(int argc, char **argv)
	struct pkgdb		*db = NULL;
	struct pkgdb_it		*it = NULL;
	struct pkg		*pkg = NULL;
-
	struct pkg_manifest_key	*keys = NULL;
	char			*pkgname = NULL;
	int			 query_flags = PKG_LOAD_BASIC;
	match_t			 match = MATCH_EXACT;
@@ -1000,12 +999,10 @@ exec_query(int argc, char **argv)
		} else if ((query_flags & PKG_LOAD_FILES) == 0) {
			open_flags = PKG_OPEN_MANIFEST_ONLY;
		}
-
		pkg_manifest_keys_new(&keys);
-
		if (pkg_open(&pkg, pkgname, keys, open_flags) != EPKG_OK) {
+
		if (pkg_open(&pkg, pkgname, open_flags) != EPKG_OK) {
			return (EXIT_FAILURE);
		}

-
		pkg_manifest_keys_free(keys);
		print_query(pkg, argv[0], multiline);
		pkg_free(pkg);
		return (EXIT_SUCCESS);
modified tests/lib/manifest.c
@@ -123,19 +123,13 @@ test_manifest(void)
	struct pkg_option *option = NULL;
	struct pkg_category *category = NULL;
	struct pkg_file *file = NULL;
-
        struct pkg_manifest_key *keys = NULL;
	const char *pkg_str;
	int64_t pkg_int;
	int i;

-
	pkg_manifest_keys_new(&keys);
-
	ATF_REQUIRE(keys != NULL);
-

	ATF_REQUIRE_EQ(EPKG_OK, pkg_new(&p, PKG_FILE));
	ATF_REQUIRE(p != NULL);
-
	ATF_REQUIRE_EQ(EPKG_OK, pkg_parse_manifest(p, manifest, strlen(manifest), keys));
-

-
	pkg_manifest_keys_free(keys);
+
	ATF_REQUIRE_EQ(EPKG_OK, pkg_parse_manifest(p, manifest, strlen(manifest)));

	ATF_REQUIRE(pkg_get(p, PKG_NAME, &pkg_str) == EPKG_OK);
	ATF_REQUIRE(strcmp(pkg_str, "foobar") == 0);