diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-12-01 11:18:19 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-12-01 11:18:19 +0200 |
commit | 801a5790d15e46cc88855e23a78d830ea1f157ad (patch) | |
tree | 47308603fd2a22e6ee080405e15397e36cc472de | |
parent | a66ca57369d355c4555a3d486f0d61185f56b4dc (diff) | |
download | rpm-801a5790d15e46cc88855e23a78d830ea1f157ad.tar.gz rpm-801a5790d15e46cc88855e23a78d830ea1f157ad.tar.bz2 rpm-801a5790d15e46cc88855e23a78d830ea1f157ad.zip |
Pass RPM_BUILD_ROOT to helper scripts through environment always
- Many of the scripts need to know the buildroot in order to figure
out correct resulting paths. This permits unifying the current
adhoc methods of passing the data to the scripts.
-rw-r--r-- | build/files.c | 6 | ||||
-rw-r--r-- | build/rpmbuild_internal.h | 3 | ||||
-rw-r--r-- | build/rpmfc.c | 15 |
3 files changed, 15 insertions, 9 deletions
diff --git a/build/files.c b/build/files.c index d5689e4c9..fa47c77bd 100644 --- a/build/files.c +++ b/build/files.c @@ -2065,7 +2065,7 @@ rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags) * @param fileList packaged file list * @return -1 if skipped, 0 on OK, 1 on error */ -static int checkFiles(StringBuf fileList) +static int checkFiles(const char *buildRoot, StringBuf fileList) { static char * const av_ckfile[] = { "%{?__check_files}", NULL }; StringBuf sb_stdout = NULL; @@ -2081,7 +2081,7 @@ static int checkFiles(StringBuf fileList) rpmlog(RPMLOG_NOTICE, _("Checking for unpackaged file(s): %s\n"), s); - rc = rpmfcExec(av_ckfile, fileList, &sb_stdout, 0); + rc = rpmfcExec(av_ckfile, fileList, &sb_stdout, 0, buildRoot); if (rc < 0) goto exit; @@ -2144,7 +2144,7 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, */ - if (checkFiles(check_fileList) > 0) { + if (checkFiles(spec->buildRoot, check_fileList) > 0) { rc = RPMRC_FAIL; } exit: diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h index 72802886a..565448190 100644 --- a/build/rpmbuild_internal.h +++ b/build/rpmbuild_internal.h @@ -349,10 +349,11 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg); * @param sb_stdin helper input * @retval *sb_stdoutp helper output * @param failnonzero IS non-zero helper exit status a failure? + * @param buildRoot buildRoot directory (or NULL) */ RPM_GNUC_INTERNAL int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp, - int failnonzero); + int failnonzero, const char *buildRoot); /** \ingroup rpmbuild * Post-build processing for policies in binary package(s). diff --git a/build/rpmfc.c b/build/rpmfc.c index e3ea588b9..96c8932e4 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -172,11 +172,12 @@ static void sigpipe_finish(void) * @param writePtr bytes to feed to script on stdin (or NULL) * @param writeBytesLeft no. of bytes to feed to script on stdin * @param failNonZero is script failure an error? + * @param buildRoot buildRoot directory (or NULL) * @return buffered stdout from script, NULL on error */ static StringBuf getOutputFrom(ARGV_t argv, const char * writePtr, size_t writeBytesLeft, - int failNonZero) + int failNonZero, const char *buildRoot) { pid_t child, reaped; int toProg[2] = { -1, -1 }; @@ -208,6 +209,9 @@ static StringBuf getOutputFrom(ARGV_t argv, rpmlog(RPMLOG_DEBUG, "\texecv(%s) pid %d\n", argv[0], (unsigned)getpid()); + if (buildRoot) + setenv("RPM_BUILD_ROOT", buildRoot, 1); + unsetenv("MALLOC_CHECK_"); execvp(argv[0], (char *const *)argv); rpmlog(RPMLOG_ERR, _("Couldn't exec %s: %s\n"), @@ -316,7 +320,7 @@ exit: } int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp, - int failnonzero) + int failnonzero, const char *buildRoot) { char * s = NULL; ARGV_t xav = NULL; @@ -356,7 +360,7 @@ int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp, } /* Read output from exec'd helper. */ - sb = getOutputFrom(xav, buf_stdin, buf_stdin_len, failnonzero); + sb = getOutputFrom(xav, buf_stdin, buf_stdin_len, failnonzero, buildRoot); if (sb_stdoutp != NULL) { *sb_stdoutp = sb; @@ -442,7 +446,7 @@ static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char * nsdep) sb_stdin = newStringBuf(); appendLineStringBuf(sb_stdin, fn); sb_stdout = NULL; - xx = rpmfcExec(av, sb_stdin, &sb_stdout, 0); + xx = rpmfcExec(av, sb_stdin, &sb_stdout, 0, fc->buildRoot); sb_stdin = freeStringBuf(sb_stdin); if (xx == 0 && sb_stdout != NULL) { @@ -1135,7 +1139,8 @@ static rpmRC rpmfcGenerateDependsHelper(const rpmSpec spec, Package pkg, rpmfi f break; } - if (rpmfcExec(dm->argv, sb_stdin, &sb_stdout, failnonzero) == -1) + if (rpmfcExec(dm->argv, sb_stdin, &sb_stdout, + failnonzero, spec->buildRoot) == -1) continue; s = rpmExpand(dm->argv[0], NULL); |