Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add support for @unexec
jlaffaye committed 15 years ago
commit 34726ab4e365500f6455a58835eb2d9e7e0fc65b
parent 568f162
2 files changed +36 -7
modified libpkg/pkg_manifest.c
@@ -23,6 +23,7 @@ static int m_parse_dep(struct pkg *pkg, char *buf);
static int m_parse_conflict(struct pkg *pkg, char *buf);
static int m_parse_maintainer(struct pkg *pkg, char *buf);
static int m_parse_exec(struct pkg *pkg, char *buf);
+
static int m_parse_unexec(struct pkg *pkg, char *buf);
static int m_parse_set_string(struct pkg *pkg, char *buf, pkg_attr attr);

#define MANIFEST_FORMAT_KEY "@pkg_format_version"
@@ -43,6 +44,7 @@ static struct manifest_key {
	{ "@conflict", m_parse_conflict},
	{ "@maintainer", m_parse_maintainer},
	{ "@exec", m_parse_exec},
+
	{ "@unexec", m_parse_unexec},
};

#define manifest_key_len (int)(sizeof(manifest_key)/sizeof(manifest_key[0]))
@@ -121,6 +123,20 @@ m_parse_exec(struct pkg *pkg, char *buf)
}

static int
+
m_parse_unexec(struct pkg *pkg, char *buf)
+
{
+
	while (isspace(*buf))
+
		buf++;
+

+
	if (*buf == '\0')
+
		return (EPKG_FATAL);
+

+
	pkg_addexec(pkg, buf, PKG_UNEXEC);
+

+
	return (EPKG_OK);
+
}
+

+
static int
m_parse_option(struct pkg *pkg, char *buf)
{
	char *value;
modified tests/manifest.c
@@ -20,6 +20,8 @@ char manifest[] = ""
	"@conflict bar-*\n"
	"@exec true && echo hello\n"
	"@exec false || echo world\n"
+
	"@unexec true && echo good\n"
+
	"@unexec false || echo bye\n"
	"@option foo true\n"
	"@option bar false\n";

@@ -187,15 +189,26 @@ START_TEST(parse_manifest)
	execs = pkg_execs(p);
	fail_if(execs == NULL);
	for (i = 0; execs[i] != NULL; i++) {
-
		if (i == 0) {
-
			fail_unless(pkg_exec_type(execs[i]) == PKG_EXEC);
-
			fail_unless(strcmp(pkg_exec_cmd(execs[i]), "true && echo hello") == 0);
-
		} else if (i == 1) {
-
			fail_unless(pkg_exec_type(execs[i]) == PKG_EXEC);
-
			fail_unless(strcmp(pkg_exec_cmd(execs[i]), "false || echo world") == 0);
+
		switch (i) {
+
			case 0:
+
				fail_unless(pkg_exec_type(execs[i]) == PKG_EXEC);
+
				fail_unless(strcmp(pkg_exec_cmd(execs[i]), "true && echo hello") == 0);
+
				break;
+
			case 1:
+
				fail_unless(pkg_exec_type(execs[i]) == PKG_EXEC);
+
				fail_unless(strcmp(pkg_exec_cmd(execs[i]), "false || echo world") == 0);
+
				break;
+
			case 2:
+
				fail_unless(pkg_exec_type(execs[i]) == PKG_UNEXEC);
+
				fail_unless(strcmp(pkg_exec_cmd(execs[i]), "true && echo good") == 0);
+
				break;
+
			case 3:
+
				fail_unless(pkg_exec_type(execs[i]) == PKG_UNEXEC);
+
				fail_unless(strcmp(pkg_exec_cmd(execs[i]), "false || echo bye") == 0);
+
				break;
		}
	}
-
	fail_unless(i == 2);
+
	fail_unless(i == 4);

	options = pkg_options(p);
	fail_if(options == NULL);