Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
scripts: prepend the lines that serves as arguments when formating the scripts from plist
Baptiste Daroussin committed 5 years ago
commit 71930461be8398a71b277239dea95bfc98aca1ed
parent ebeeab1
4 files changed +14 -6
modified libpkg/pkg_ports.c
@@ -552,7 +552,7 @@ meta_exec(struct plist *p, char *line, struct file_attr *a, exec_t type)
	int ret;

	ret = format_exec_cmd(&cmd, line, p->prefix, p->last_file, NULL, 0,
-
	    NULL);
+
	    NULL, false);
	if (ret != EPKG_OK)
		return (EPKG_OK);

@@ -958,7 +958,7 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
	for (int i = 0; i < nitems(script_mapping); i++) {
		if ((o = ucl_object_find_key(obj, script_mapping[i].key))) {
			if (format_exec_cmd(&cmd, ucl_object_tostring(o), p->prefix,
-
			    p->last_file, line, argc, args) != EPKG_OK)
+
			    p->last_file, line, argc, args, false) != EPKG_OK)
				goto keywords_cleanup;
			append_script(p, script_mapping[i].type, cmd);
			free(cmd);
@@ -969,7 +969,7 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
	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)
+
			    p->last_file, line, argc, args, true) != EPKG_OK)
				goto keywords_cleanup;
			pkg_add_lua_script(p->pkg, cmd, lua_mapping[i].type);
			free(cmd);
modified libpkg/private/utils.h
@@ -67,7 +67,7 @@ int mkdirs(const char *path);
int file_to_buffer(const char *, char **, off_t *);
int file_to_bufferat(int, const char *, char **, off_t *);
int format_exec_cmd(char **, const char *, const char *, const char *, char *,
-
    int argc, char **argv);
+
    int argc, char **argv, bool lua);
int is_dir(const char *);
int is_link(const char *);

modified libpkg/utils.c
@@ -180,7 +180,7 @@ file_to_buffer(const char *path, char **buffer, off_t *sz)

int
format_exec_cmd(char **dest, const char *in, const char *prefix,
-
    const char *plist_file, char *line, int argc, char **argv)
+
    const char *plist_file, char *line, int argc, char **argv, bool lua)
{
	xstring *buf;
	char path[MAXPATHLEN];
@@ -189,6 +189,14 @@ format_exec_cmd(char **dest, const char *in, const char *prefix,

	buf = xstring_new();

+
	if (line != NULL) {
+
		if (lua) {
+
			fprintf(buf->fp, "-- args: %s\n", line);
+
		} else {
+
			fprintf(buf->fp, "# args: %s\n", line);
+
		}
+
	}
+

	while (in[0] != '\0') {
		if (in[0] != '%') {
			fputc(in[0], buf->fp);
modified tests/frontend/create.sh
@@ -417,7 +417,7 @@ directories {
    /B = "y";
}
scripts {
-
    post-install = "echo A B";
+
    post-install = "# args: A B\necho A B";
}

EOF