Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
format_exec_cmd is safer and return error on failure
Baptiste Daroussin committed 14 years ago
commit 0a65555c4b65efa416d2d1647206515995865516
parent b7b193e
3 files changed +21 -3
modified libpkg/pkg_ports.c
@@ -106,7 +106,7 @@ ports_parse_plist(struct pkg *pkg, char *plist)
				while (isspace(buf[0]))
					buf++;

-
				if (format_exec_cmd(&cmd, buf, prefix, last_plist_file) < 0)
+
				if (format_exec_cmd(&cmd, buf, prefix, last_plist_file) != EPKG_OK)
					continue;

				if (plist_p[1] == 'u') {
modified libpkg/pkg_util.c
@@ -152,9 +152,21 @@ format_exec_cmd(char **dest, const char *in, const char *prefix, const char *pli
					sbuf_cat(buf, prefix);
					break;
				case 'F':
+
					if (plist_file == NULL) {
+
						pkg_emit_error("No files defined \%F couldn't be expanded, ignoring %s", in);
+
						sbuf_finish(buf);
+
						sbuf_free(buf);
+
						return (EPKG_FATAL);
+
					}
					sbuf_cat(buf, plist_file);
					break;
				case 'f':
+
					if (plist_file == NULL) {
+
						pkg_emit_error("No files defined \%f couldn't be expanded, ignoring %s", in);
+
						sbuf_finish(buf);
+
						sbuf_free(buf);
+
						return (EPKG_FATAL);
+
					}
					if (prefix[strlen(prefix) - 1] == '/')
						snprintf(path, sizeof(path), "%s%s", prefix, plist_file);
					else
@@ -164,6 +176,12 @@ format_exec_cmd(char **dest, const char *in, const char *prefix, const char *pli
					sbuf_cat(buf, cp);
					break;
				case 'B':
+
					if (plist_file == NULL) {
+
						pkg_emit_error("No files defined \%B couldn't be expanded, ignoring %s", in);
+
						sbuf_finish(buf);
+
						sbuf_free(buf);
+
						return (EPKG_FATAL);
+
					}
					if (prefix[strlen(prefix) - 1] == '/')
						snprintf(path, sizeof(path), "%s%s", prefix, plist_file);
					else
@@ -188,7 +206,7 @@ format_exec_cmd(char **dest, const char *in, const char *prefix, const char *pli
	*dest = strdup(sbuf_data(buf));
	sbuf_free(buf);
	
-
	return (0);
+
	return (EPKG_OK);
}

int
modified pkg/Makefile
@@ -23,7 +23,7 @@ SRCS= add.c \
		which.c
BINDIR=		/usr/sbin

-
.if exists(../.git)
+
.if exists(../.git) && exists(/usr/local/bin/git)
GITHASH!=	git rev-parse HEAD
CFLAGS+=	-DGITHASH=\"${GITHASH}\"
.endif