Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Create a new DEBUG_SCRIPTS configuration option to run shell script with -x mode
Baptiste Daroussin committed 13 years ago
commit 47b990198b5d952f95bbdb3fae688d77de268cfc
parent b86e274
4 files changed +15 -2
modified libpkg/pkg.h
@@ -264,7 +264,8 @@ typedef enum _pkg_config_key {
	PKG_CONFIG_FETCH_RETRY,
	PKG_CONFIG_PLUGINS_DIR,
	PKG_CONFIG_ENABLE_PLUGINS,
-
	PKG_CONFIG_PLUGINS_SUMMARY
+
	PKG_CONFIG_PLUGINS_SUMMARY,
+
	PKG_CONFIG_DEBUG_SCRIPTS,
} pkg_config_key;

typedef enum {
modified libpkg/pkg_config.c
@@ -191,6 +191,12 @@ static struct config_entry c[] = {
		"NO",
		{ NULL }
	},
+
	[PKG_CONFIG_DEBUG_SCRIPTS] = {
+
		BOOL,
+
		"DEBUG_SCRIPTS",
+
		"NO",
+
		{ NULL }
+
	},
};

static bool parsed = false;
modified libpkg/scripts.c
@@ -56,6 +56,7 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)
	int stdin_pipe[2] = {-1, -1};
	posix_spawn_file_actions_t action;
	bool use_pipe = 0;
+
	bool debug = false;
	ssize_t bytes_written;
	size_t script_cmd_len;
	long argmax;
@@ -90,6 +91,9 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)
		if (j == map[i].a || j == map[i].b) {
			sbuf_reset(script_cmd);
			setenv("PKG_PREFIX", prefix, 1);
+
			pkg_config_bool(PKG_CONFIG_DEBUG_SCRIPTS, &debug);
+
			if (debug)
+
				sbuf_printf(script_cmd, "set -x\n");
			sbuf_printf(script_cmd, "set -- %s-%s",
			    name, version);

modified pkg/pkg.conf.5
@@ -15,7 +15,7 @@
.\"     @(#)pkg.1
.\" $FreeBSD$
.\"
-
.Dd August 29, 2012
+
.Dd September 22, 2012
.Dt PKG.CONF 5
.Os
.Sh NAME
@@ -132,6 +132,8 @@ when fetching the portaudit database.
See
.Xr pkg-audit 8
for more information.
+
.It Cm DEBUG_SCRIPTS: boolean
+
Activate debug mode for scripts (aka set -x)
.El
.Sh ENVIRONMENT
An environment variable with the same name as the option in the configuration