[Rpm-maint] [PATCH 2/3] Use /bin/sh -c to run helper
Alexey Gladkov
gladkov.alexey at gmail.com
Mon Nov 22 13:48:41 UTC 2010
Signed-off-by: Alexey Gladkov <gladkov.alexey at gmail.com>
---
build/rpmfc.c | 31 +++++++++++++++++++++++++------
macros.in | 3 +++
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index f3c0672..a063d24 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -187,6 +187,10 @@ static StringBuf getOutputFrom(const char * dir, ARGV_t argv,
int sigpipe = sigpipe_init();
int ret = 1; /* assume failure */
+ StringBuf cmd;
+ int i;
+ char *buf = NULL;
+
if (sigpipe < 0 || pipe(toProg) < 0 || pipe(fromProg) < 0) {
rpmlog(RPMLOG_ERR, _("Couldn't create pipe for %s: %m\n"), argv[0]);
return NULL;
@@ -211,13 +215,28 @@ static StringBuf getOutputFrom(const char * dir, ARGV_t argv,
_exit(EXIT_FAILURE);
}
- rpmlog(RPMLOG_DEBUG, "\texecv(%s) pid %d\n",
- argv[0], (unsigned)getpid());
-
unsetenv("MALLOC_CHECK_");
- execvp(argv[0], (char *const *)argv);
- rpmlog(RPMLOG_ERR, _("Couldn't exec %s: %s\n"),
- argv[0], strerror(errno));
+
+ cmd = newStringBuf();
+
+ if ((buf = rpmExpand("%{__build_autodeps_pre}", NULL)) != NULL) {
+ appendStringBuf(cmd, buf);
+ buf = _free(buf);
+ }
+
+ for (i = 0; argv[i] != NULL; i++) {
+ appendStringBuf(cmd, argv[i]);
+ appendStringBuf(cmd, " ");
+ }
+
+ if ((buf = rpmExpand("%{__build_autodeps_post}", NULL)) != NULL) {
+ appendStringBuf(cmd, buf);
+ buf = _free(buf);
+ }
+
+ execlp("/bin/sh", "/bin/sh", "-c", getStringBuf(cmd), NULL);
+ rpmlog(RPMLOG_ERR, _("Couldn't exec /bin/sh: %s: %s\n"),
+ strerror(errno), getStringBuf(cmd));
_exit(EXIT_FAILURE);
}
if (child < 0) {
diff --git a/macros.in b/macros.in
index 9e18472..d316374 100644
--- a/macros.in
+++ b/macros.in
@@ -720,6 +720,9 @@ print (t)\
#%{___build_post}\
#%{nil}
+%__build_autodeps_pre %{__rpm_env}
+%__build_autodeps_post %{nil}
+
#==============================================================================
# ---- Scriptlet templates.
# Macro(s) that expand to a command and script that is executed.
--
1.7.3.2
More information about the Rpm-maint
mailing list