Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Complete lua support for keywords
Baptiste Daroussin committed 6 years ago
commit 17ae0fc411b9ca01724026f6d9e5321e588b87f0
parent b1d34f6
1 file changed +20 -2
modified libpkg/pkg_ports.c
@@ -114,8 +114,6 @@ keyword_open_schema(void)
		"    post-install-lua = { type = string }; "
		"    pre-deinstall-lua = { type = string }; "
		"    post-deinstall-lua = { type = string }; "
-
		"    pre-upgrade-lua = { type = string }; "
-
		"    post-upgrade-lua = { type = string }; "
		"    messages: {"
		"        type = array; "
		"        items = {"
@@ -728,6 +726,16 @@ static struct keyact {
	{ NULL, NULL },
};

+
static struct lua_map {
+
	const char *key;
+
	pkg_lua_script type;
+
} lua_mapping[] = {
+
	{ "pre-install-lua", PKG_LUA_PRE_INSTALL },
+
	{ "post-install-lua", PKG_LUA_POST_INSTALL },
+
	{ "pre-deinstall-lua", PKG_LUA_PRE_DEINSTALL },
+
	{ "post-deinstall-lua", PKG_LUA_POST_DEINSTALL },
+
};
+

static void
populate_keywords(struct plist *p)
{
@@ -908,6 +916,16 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
		free(cmd);
	}

+
	for (int i = 0; i < nitems(lua_mapping); i++) {
+
		if ((o = ucl_object_find_key(obj, lua_mapping[i].key))) {
+
			if (format_exec_cmd(&cmd, ucl_object_tostring(o), p->prefix,
+
			    p->last_file, line, argc, args) != EPKG_OK)
+
				goto keywords_cleanup;
+
			pkg_add_lua_script(p->pkg, cmd, lua_mapping[i].type);
+
			free(cmd);
+
		}
+
	}
+

	if ((o = ucl_object_find_key(obj, "messages"))) {
		while ((cur = ucl_iterate_object(o, &it, true))) {
			elt = ucl_object_find_key(cur, "message");