diff options
Diffstat (limited to 'build/build.c')
-rw-r--r-- | build/build.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/build/build.c b/build/build.c index 04b039c5e..81152e53e 100644 --- a/build/build.c +++ b/build/build.c @@ -69,7 +69,7 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name, pid_t pid; pid_t child; int status; - rpmRC rc; + rpmRC rc = RPMRC_FAIL; /* assume failure */ switch (what) { case RPMBUILD_PREP: @@ -118,13 +118,11 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name, fd = rpmMkTempFile(spec->rootDir, &scriptName); if (Ferror(fd)) { rpmlog(RPMLOG_ERR, _("Unable to open temp file: %s\n"), Fstrerror(fd)); - rc = RPMRC_FAIL; goto exit; } if ((fp = fdopen(Fileno(fd), "w")) == NULL) { rpmlog(RPMLOG_ERR, _("Unable to open stream: %s\n"), strerror(errno)); - rc = RPMRC_FAIL; goto exit; } @@ -151,7 +149,6 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name, } if (buildDir && buildDir[0] != '/') { - rc = RPMRC_FAIL; goto exit; } @@ -160,8 +157,6 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name, rpmlog(RPMLOG_NOTICE, _("Executing(%s): %s\n"), name, buildCmd); if (!(child = fork())) { - /* NSPR messes with SIGPIPE, reset to default for the kids */ - signal(SIGPIPE, SIG_DFL); errno = 0; (void) execvp(argv[0], (char *const *)argv); @@ -176,21 +171,19 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name, if (pid == -1) { rpmlog(RPMLOG_ERR, _("Error executing scriptlet %s (%s)\n"), scriptName, name); - rc = RPMRC_FAIL; goto exit; } if (!WIFEXITED(status) || WEXITSTATUS(status)) { rpmlog(RPMLOG_ERR, _("Bad exit status from %s (%s)\n"), scriptName, name); - rc = RPMRC_FAIL; } else rc = RPMRC_OK; exit: Fclose(fd); if (scriptName) { - if (rc == RPMRC_OK) + if (rc == RPMRC_OK && !rpmIsDebug()) (void) unlink(scriptName); free(scriptName); } @@ -209,6 +202,21 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what) int test = (what & RPMBUILD_NOBUILD); char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL; + if (rpmExpandNumeric("%{?source_date_epoch_from_changelog}") && + getenv("SOURCE_DATE_EPOCH") == NULL) { + /* Use date of first (== latest) changelog entry */ + Header h = spec->packages->header; + struct rpmtd_s td; + if (headerGet(h, RPMTAG_CHANGELOGTIME, &td, (HEADERGET_MINMEM|HEADERGET_RAW))) { + char sdestr[22]; + snprintf(sdestr, sizeof(sdestr), "%lli", + (long long) rpmtdGetNumber(&td)); + rpmlog(RPMLOG_NOTICE, _("setting %s=%s\n"), "SOURCE_DATE_EPOCH", sdestr); + setenv("SOURCE_DATE_EPOCH", sdestr, 0); + rpmtdFreeData(&td); + } + } + /* XXX TODO: rootDir is only relevant during build, eliminate from spec */ spec->rootDir = buildArgs->rootdir; if (!spec->recursing && spec->BACount) { |