Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
in manifest add both arch (ALTABI) and abi (ABI) for compat with ancient version
Baptiste Daroussin committed 11 years ago
commit 860ca232dce6bcdd5a102f2eb19de924976c0ab4
parent 49e0d8c
8 files changed +24 -7
modified libpkg/pkg.c
@@ -49,6 +49,7 @@ struct pkg_key pkg_keys[PKG_NUM_FIELDS] = {
	[PKG_DESC] = { "desc", UCL_STRING },
	[PKG_MTREE] = { "mtree", UCL_STRING },
	[PKG_MESSAGE] = { "message", UCL_STRING },
+
	[PKG_ABI] = { "abi", UCL_STRING },
	[PKG_ARCH] = { "arch", UCL_STRING },
	[PKG_MAINTAINER] = { "maintainer", UCL_STRING },
	[PKG_WWW] = { "www", UCL_STRING },
modified libpkg/pkg.h.in
@@ -243,6 +243,7 @@ typedef enum {
	PKG_MTREE,
	PKG_MESSAGE,
	PKG_ARCH,
+
	PKG_ABI,
	PKG_MAINTAINER,
	PKG_WWW,
	PKG_PREFIX,
modified libpkg/pkg_add.c
@@ -183,6 +183,7 @@ pkg_add_check_pkg_archive(struct pkgdb *db, struct pkg *pkg,
	struct pkg_manifest_key *keys, const char *location)
{
	const char	*arch;
+
	const char	*abi;
	const char	*origin;
	const char	*name;
	int	ret, retcode;
@@ -192,7 +193,10 @@ pkg_add_check_pkg_archive(struct pkgdb *db, struct pkg *pkg,
	const char	*ext;
	struct pkg	*pkg_inst = NULL;

-
	pkg_get(pkg, PKG_ARCH, &arch, PKG_ORIGIN, &origin, PKG_NAME, &name);
+
	pkg_get(pkg, PKG_ARCH, &arch, PKG_ABI, &abi, PKG_ORIGIN, &origin, PKG_NAME, &name);
+
	if (abi != NULL)
+
		arch = abi;
+

	if (!is_valid_abi(arch, true)) {
		if ((flags & PKG_ADD_FORCE) == 0) {
			return (EPKG_FATAL);
modified libpkg/pkg_elf.c
@@ -890,11 +890,12 @@ cleanup:
}

int
-
arch_to_legacy(char *arch, char *dest, size_t sz)
+
pkg_arch_to_legacy(const char *arch, char *dest, size_t sz)
{
	int i = 0;
	struct arch_trans *arch_trans;

+
	bzero(dest, sz);
	/* Lower case the OS */
	while (arch[i] != ':') {
		dest[i] = tolower(arch[i]);
@@ -915,7 +916,7 @@ arch_to_legacy(char *arch, char *dest, size_t sz)

	for (arch_trans = machine_arch_translation; arch_trans->elftype != NULL;
	    arch_trans++) {
-
		if (strcmp(arch, arch_trans->archid) == 0) {
+
		if (strcmp(arch + i, arch_trans->archid) == 0) {
			strlcpy(dest + i, arch_trans->elftype,
			    sz - (arch - dest));
			break;
modified libpkg/pkg_manifest.c
@@ -76,6 +76,7 @@ static struct manifest_key {
	int (*parse_data)(struct pkg *, const ucl_object_t *, int);
} manifest_keys[] = {
	{ "annotations",         PKG_ANNOTATIONS,         UCL_OBJECT, pkg_obj},
+
	{ "abi",                 PKG_ABI,                 UCL_STRING, pkg_string},
	{ "arch",                PKG_ARCH,                UCL_STRING, pkg_string},
	{ "categories",          PKG_CATEGORIES,          UCL_ARRAY,  pkg_array},
	{ "comment",             PKG_COMMENT,             UCL_STRING, pkg_string},
@@ -873,8 +874,9 @@ pkg_emit_object(struct pkg *pkg, short flags)
	struct pkg_provide	*provide  = NULL;
	struct sbuf		*tmpsbuf  = NULL;
	int i;
-
	const char *comment, *desc, *message, *repopath;
+
	const char *comment, *desc, *message, *repopath, *abi;
	const char *script_types = NULL;
+
	char legacyarch[BUFSIZ];
	lic_t licenselogic;
	int64_t pkgsize;
	ucl_object_iter_t it = NULL;
@@ -887,6 +889,7 @@ pkg_emit_object(struct pkg *pkg, short flags)
		PKG_NAME,
		PKG_ORIGIN,
		PKG_VERSION,
+
		PKG_ABI,
		PKG_ARCH,
		PKG_MAINTAINER,
		PKG_PREFIX,
@@ -902,6 +905,9 @@ pkg_emit_object(struct pkg *pkg, short flags)
	    PKG_ANNOTATIONS, &annotations, PKG_LICENSES, &licenses,
	    PKG_CATEGORIES, &categories, PKG_REPOPATH, &repopath);

+
	pkg_get(pkg, PKG_ABI, &abi);
+
	pkg_arch_to_legacy(abi, legacyarch, BUFSIZ);
+
	pkg_set(pkg, PKG_ARCH, legacyarch);
	pkg_debug(4, "Emitting basic metadata");
	for (i = 0; recopies[i] != -1; i++) {
		key = pkg_keys[recopies[i]].name;
modified libpkg/pkgdb.c
@@ -1545,7 +1545,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete, int forced)
	const char		*mtree, *origin, *name, *version, *name2;
	const char		*version2, *comment, *desc, *message;
	const char		*arch, *maintainer, *www, *prefix;
-
	const char		*digest;
+
	const char		*digest, *abi;

	bool			 automatic;
	int64_t			 flatsize, licenselogic;
@@ -1572,6 +1572,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete, int forced)
		PKG_DESC,	&desc,
		PKG_MESSAGE,	&message,
		PKG_ARCH,	&arch,
+
		PKG_ABI,	&abi,
		PKG_MAINTAINER,	&maintainer,
		PKG_WWW,	&www,
		PKG_PREFIX,	&prefix,
@@ -1583,6 +1584,9 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete, int forced)
		PKG_LICENSES,	&licenses,
		PKG_CATEGORIES,	&categories);

+
	/* Prefer new ABI over old one */
+
	if (abi != NULL)
+
		arch = abi;
	/*
	 * Insert mtree record
	 */
modified libpkg/pkgdb_iterator.c
@@ -64,7 +64,7 @@ static struct column_mapping {
		PKG_SQLITE_BOOL
	} pkg_type;
} columns[] = {
-
	{ "arch",	PKG_ARCH, PKG_SQLITE_STRING },
+
	{ "arch",	PKG_ABI, PKG_SQLITE_STRING },
	{ "automatic",	PKG_AUTOMATIC, PKG_SQLITE_BOOL },
	{ "cksum",	PKG_CKSUM, PKG_SQLITE_STRING },
	{ "comment",	PKG_COMMENT, PKG_SQLITE_STRING },
modified libpkg/private/pkg.h
@@ -608,6 +608,6 @@ int pkg_addoption(struct pkg *pkg, const char *name, const char *value);
int pkg_addoption_default(struct pkg *pkg, const char *key, const char *default_value);
int pkg_addoption_description(struct pkg *pkg, const char *key, const char *description);

-
int pkg_arch_to_legacy(char *arch, char *dest, size_t sz);
+
int pkg_arch_to_legacy(const char *arch, char *dest, size_t sz);

#endif