Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a function to convert the new ABI to legacy version
Baptiste Daroussin committed 11 years ago
commit 49e0d8c76264575bac1d2ba8dc23db49634fcea4
parent 9ffb1c5
2 files changed +38 -0
modified libpkg/pkg_elf.c
@@ -890,6 +890,42 @@ cleanup:
}

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

+
	/* Lower case the OS */
+
	while (arch[i] != ':') {
+
		dest[i] = tolower(arch[i]);
+
		i++;
+
	}
+
	dest[i++] = ':';
+

+
	/* Copy the version */
+
	while (arch[i] != ':') {
+
		dest[i] = arch[i];
+
		i++;
+
	}
+
	dest[i++] = ':';
+
	if (arch[i] == '*') {
+
		dest[i++] = '*';
+
		return (0);
+
	}
+

+
	for (arch_trans = machine_arch_translation; arch_trans->elftype != NULL;
+
	    arch_trans++) {
+
		if (strcmp(arch, arch_trans->archid) == 0) {
+
			strlcpy(dest + i, arch_trans->elftype,
+
			    sz - (arch - dest));
+
			break;
+
		}
+
	}
+

+
	return (0);
+
}
+

+
int
pkg_get_myarch_legacy(char *dest, size_t sz)
{
	int i, err;
modified libpkg/private/pkg.h
@@ -608,4 +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);
+

#endif