Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add support for using ${ABI} in PACKAGESITE
Bryan Drewery committed 13 years ago
commit ac8d8a017ea1da284068bc19ca402e51b38c2f9b
parent 9329490
2 files changed +37 -1
modified libpkg/pkg_config.c
@@ -44,6 +44,8 @@
#define LIST 2
#define INTEGER 3

+
#define ABI_VAR_STRING "${ABI}"
+

struct pkg_config_kv {
	char *key;
	char *value;
@@ -253,6 +255,34 @@ parse_configuration(yaml_document_t *doc, yaml_node_t *node)
	}
}

+
/**
+
 * @brief Substitute PACKAGESITE variables
+
 */
+
static void
+
subst_packagesite(void)
+
{
+
	const char *variable_string;
+
	const char *oldval;
+
	const char *myarch;
+
	struct sbuf *newval;
+

+
	oldval = c[PKG_CONFIG_REPO].val;
+

+
	if ((variable_string = strstr(oldval, ABI_VAR_STRING)) == NULL)
+
		return;
+

+
	newval = sbuf_new_auto();
+
	sbuf_bcat(newval, oldval, variable_string - oldval);
+
	pkg_config_string(PKG_CONFIG_ABI, &myarch);
+
	sbuf_cat(newval, myarch);
+
	sbuf_cat(newval, variable_string + strlen(ABI_VAR_STRING));
+
	sbuf_finish(newval);
+

+
	free(c[PKG_CONFIG_REPO].val);
+
	c[PKG_CONFIG_REPO].val = strdup(sbuf_data(newval));
+
	sbuf_free(newval);
+
}
+

int
pkg_config_string(pkg_config_key key, const char **val)
{
@@ -268,6 +298,9 @@ pkg_config_string(pkg_config_key key, const char **val)
		return (EPKG_FATAL);
	}

+
	if (key == PKG_CONFIG_REPO)
+
		subst_packagesite();
+

	*val = c[key].val;

	if (*val == NULL)
modified pkg/pkg.conf.5
@@ -15,7 +15,7 @@
.\"     @(#)pkg.1
.\" $FreeBSD$
.\"
-
.Dd June 12, 2012
+
.Dd August 14, 2012
.Dt PKG.CONF 5
.Os
.Sh NAME
@@ -75,6 +75,9 @@ By default this option is disabled.
.It Cm PACKAGESITE: string
Specifies the remote location to use
when fetching the database file and packages.
+
This supports using
+
.Sy ${ABI}
+
to create a dynamic URL based on the ABI being used.
.It Cm PKG_CACHEDIR: string
Specifies the cache directory for packages.
The default value