public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpm] pmatilai-v6: Restore strict order of build scriptlet stdout/stderr output
@ 2026-11-23 9:32 Panu Matilainen
0 siblings, 0 replies; only message in thread
From: Panu Matilainen @ 2026-11-23 9:32 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : c9c421374caba48ed27b6a1e73eca7e8beb0bda0
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2019-08-23T13:32:44+03:00
Stats : +307/-2 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/c9c421374caba48ed27b6a1e73eca7e8beb0bda0?branch=pmatilai-v6
Log:
Restore strict order of build scriptlet stdout/stderr output
---
diff --git a/0001-Support-running-rpmfcExec-without-any-piped-input-ou.patch b/0001-Support-running-rpmfcExec-without-any-piped-input-ou.patch
new file mode 100644
index 0000000..bdc5a5c
--- /dev/null
+++ b/0001-Support-running-rpmfcExec-without-any-piped-input-ou.patch
@@ -0,0 +1,51 @@
+From ad4673589428db6e3b9fecd6f151eb899500336d Mon Sep 17 00:00:00 2001
+Message-Id: <ad4673589428db6e3b9fecd6f151eb899500336d.1566556207.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Thu, 15 Aug 2019 14:00:43 +0300
+Subject: [PATCH 1/3] Support running rpmfcExec() without any piped
+ input/output
+
+Having a function called getOutputFrom() which doesn't is a wee bit
+weird but what the hey...
+
+No behavior changes here, but this is needed for the next steps.
+---
+ build/rpmfc.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/build/rpmfc.c b/build/rpmfc.c
+index 80da96f3a..94b4620d2 100644
+--- a/build/rpmfc.c
++++ b/build/rpmfc.c
+@@ -268,8 +268,9 @@ static int getOutputFrom(ARGV_t argv,
+ int status;
+ int myerrno = 0;
+ int ret = 1; /* assume failure */
++ int doio = (writePtr || sb_stdout || dup);
+
+- if (pipe(toProg) < 0 || pipe(fromProg) < 0) {
++ if (doio && (pipe(toProg) < 0 || pipe(fromProg) < 0)) {
+ rpmlog(RPMLOG_ERR, _("Couldn't create pipe for %s: %m\n"), argv[0]);
+ return -1;
+ }
+@@ -303,6 +304,9 @@ static int getOutputFrom(ARGV_t argv,
+ return -1;
+ }
+
++ if (!doio)
++ goto reap;
++
+ close(toProg[0]);
+ close(fromProg[1]);
+
+@@ -376,6 +380,7 @@ static int getOutputFrom(ARGV_t argv,
+ if (fromProg[0] >= 0)
+ close(fromProg[0]);
+
++reap:
+ /* Collect status from prog */
+ reaped = waitpid(child, &status, 0);
+ rpmlog(RPMLOG_DEBUG, "\twaitpid(%d) rc %d status %x\n",
+--
+2.21.0
+
diff --git a/0002-Restore-strict-order-of-build-scriptlet-stdout-stder.patch b/0002-Restore-strict-order-of-build-scriptlet-stdout-stder.patch
new file mode 100644
index 0000000..3b74b95
--- /dev/null
+++ b/0002-Restore-strict-order-of-build-scriptlet-stdout-stder.patch
@@ -0,0 +1,116 @@
+From 3a510926449f1dd779a2933dfaa17de3d03a4ea4 Mon Sep 17 00:00:00 2001
+Message-Id: <3a510926449f1dd779a2933dfaa17de3d03a4ea4.1566556207.git.pmatilai@redhat.com>
+In-Reply-To: <ad4673589428db6e3b9fecd6f151eb899500336d.1566556207.git.pmatilai@redhat.com>
+References: <ad4673589428db6e3b9fecd6f151eb899500336d.1566556207.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Thu, 15 Aug 2019 14:10:07 +0300
+Subject: [PATCH 2/3] Restore strict order of build scriptlet stdout/stderr
+ output (#794)
+
+Commit 18e8f4e9b2dd170d090843adf5b5084658d68cf7 and related changes
+caused us to capture and re-emit stdout of all build scriptlets,
+whether we actually use the output for anything or not. Besides doing
+a whole bunch of work for nothing, this can disrupt the output of
+build scriptlets by making the output jerky and out of order, at least
+inside mock and other tools which in turn grab rpm output. This makes
+troubleshooting failed builds unnecessarily hard for no good reason.
+
+Handle the whole thing in a different way: on regular builds, don't
+capture anything where we don't actually need to. This restores the
+natural flow of output. We still need to somehow handle quiet builds
+though, and we can't use redirect to /dev/null from %___build_pre like
+we used to, because dynamic buildrequires need to provide output even
+on quiet builds. So somewhat counter-intuitively, we need to capture
+the output in order to discard it.
+
+Closes: #794
+---
+ build/build.c | 19 +++++++++++--------
+ 1 file changed, 11 insertions(+), 8 deletions(-)
+
+diff --git a/build/build.c b/build/build.c
+index 3887457d3..dc196090f 100644
+--- a/build/build.c
++++ b/build/build.c
+@@ -60,7 +60,6 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name,
+ int argc = 0;
+ const char **argv = NULL;
+ FILE * fp = NULL;
+- FILE * cmdOut = rpmIsVerbose() ? stdout : NULL;
+
+ FD_t fd = NULL;
+ rpmRC rc = RPMRC_FAIL; /* assume failure */
+@@ -156,7 +155,7 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name,
+
+ rpmlog(RPMLOG_NOTICE, _("Executing(%s): %s\n"), name, buildCmd);
+ if (rpmfcExec((ARGV_const_t)argv, NULL, sb_stdoutp, 1,
+- spec->buildSubdir, cmdOut)) {
++ spec->buildSubdir, NULL)) {
+ rpmlog(RPMLOG_ERR, _("Bad exit status from %s (%s)\n"),
+ scriptName, name);
+ goto exit;
+@@ -242,6 +241,9 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
+ int missing_buildreqs = 0;
+ int test = (what & RPMBUILD_NOBUILD);
+ char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL;
++ /* handle quiet mode by capturing the output into a sink buffer */
++ StringBuf sink = NULL;
++ StringBuf *sbp = rpmIsVerbose() ? NULL : &sink;
+
+ if (rpmExpandNumeric("%{?source_date_epoch_from_changelog}") &&
+ getenv("SOURCE_DATE_EPOCH") == NULL) {
+@@ -292,7 +294,7 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
+
+ if ((what & RPMBUILD_PREP) &&
+ (rc = doScript(spec, RPMBUILD_PREP, "%prep",
+- getStringBuf(spec->prep), test, NULL)))
++ getStringBuf(spec->prep), test, sbp)))
+ goto exit;
+
+ if (what & RPMBUILD_BUILDREQUIRES)
+@@ -321,17 +323,17 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
+
+ if ((what & RPMBUILD_BUILD) &&
+ (rc = doScript(spec, RPMBUILD_BUILD, "%build",
+- getStringBuf(spec->build), test, NULL)))
++ getStringBuf(spec->build), test, sbp)))
+ goto exit;
+
+ if ((what & RPMBUILD_INSTALL) &&
+ (rc = doScript(spec, RPMBUILD_INSTALL, "%install",
+- getStringBuf(spec->install), test, NULL)))
++ getStringBuf(spec->install), test, sbp)))
+ goto exit;
+
+ if ((what & RPMBUILD_CHECK) &&
+ (rc = doScript(spec, RPMBUILD_CHECK, "%check",
+- getStringBuf(spec->check), test, NULL)))
++ getStringBuf(spec->check), test, sbp)))
+ goto exit;
+
+ if ((what & RPMBUILD_PACKAGESOURCE) &&
+@@ -358,11 +360,11 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
+
+ if ((what & RPMBUILD_CLEAN) &&
+ (rc = doScript(spec, RPMBUILD_CLEAN, "%clean",
+- getStringBuf(spec->clean), test, NULL)))
++ getStringBuf(spec->clean), test, sbp)))
+ goto exit;
+
+ if ((what & RPMBUILD_RMBUILD) &&
+- (rc = doScript(spec, RPMBUILD_RMBUILD, "--clean", NULL, test, NULL)))
++ (rc = doScript(spec, RPMBUILD_RMBUILD, "--clean", NULL, test, sbp)))
+ goto exit;
+ }
+
+@@ -373,6 +375,7 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
+ (void) unlink(spec->specFile);
+
+ exit:
++ freeStringBuf(sink);
+ free(cookie);
+ spec->rootDir = NULL;
+ if (rc != RPMRC_OK && rc != RPMRC_MISSINGBUILDREQUIRES &&
+--
+2.21.0
+
diff --git a/0003-Drop-the-no-longer-needed-rpmfcExec-output-duplicati.patch b/0003-Drop-the-no-longer-needed-rpmfcExec-output-duplicati.patch
new file mode 100644
index 0000000..39efd1e
--- /dev/null
+++ b/0003-Drop-the-no-longer-needed-rpmfcExec-output-duplicati.patch
@@ -0,0 +1,131 @@
+From d472c20a5f6f4046d461c1148a29fba154b2e78b Mon Sep 17 00:00:00 2001
+Message-Id: <d472c20a5f6f4046d461c1148a29fba154b2e78b.1566556207.git.pmatilai@redhat.com>
+In-Reply-To: <ad4673589428db6e3b9fecd6f151eb899500336d.1566556207.git.pmatilai@redhat.com>
+References: <ad4673589428db6e3b9fecd6f151eb899500336d.1566556207.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Thu, 15 Aug 2019 14:45:31 +0300
+Subject: [PATCH 3/3] Drop the no longer needed rpmfcExec() output duplication
+ support
+
+This effectively reverts commit 5fe8c9e6d55fe101c81399423a1e1b0f42882143,
+but no functional changes as nothing was using this anymore.
+---
+ build/build.c | 2 +-
+ build/files.c | 2 +-
+ build/rpmbuild_internal.h | 3 +--
+ build/rpmfc.c | 14 ++++++--------
+ 4 files changed, 9 insertions(+), 12 deletions(-)
+
+diff --git a/build/build.c b/build/build.c
+index dc196090f..08c2df1e4 100644
+--- a/build/build.c
++++ b/build/build.c
+@@ -155,7 +155,7 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name,
+
+ rpmlog(RPMLOG_NOTICE, _("Executing(%s): %s\n"), name, buildCmd);
+ if (rpmfcExec((ARGV_const_t)argv, NULL, sb_stdoutp, 1,
+- spec->buildSubdir, NULL)) {
++ spec->buildSubdir)) {
+ rpmlog(RPMLOG_ERR, _("Bad exit status from %s (%s)\n"),
+ scriptName, name);
+ goto exit;
+diff --git a/build/files.c b/build/files.c
+index d54d67f38..ad4f462f1 100644
+--- a/build/files.c
++++ b/build/files.c
+@@ -2781,7 +2781,7 @@ static int checkFiles(const char *buildRoot, StringBuf fileList)
+
+ rpmlog(RPMLOG_NOTICE, _("Checking for unpackaged file(s): %s\n"), s);
+
+- rc = rpmfcExec(av_ckfile, fileList, &sb_stdout, 0, buildRoot, NULL);
++ rc = rpmfcExec(av_ckfile, fileList, &sb_stdout, 0, buildRoot);
+ if (rc < 0)
+ goto exit;
+
+diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
+index 16d72ec9f..f3c8b5658 100644
+--- a/build/rpmbuild_internal.h
++++ b/build/rpmbuild_internal.h
+@@ -490,11 +490,10 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg);
+ * @retval *sb_stdoutp helper output
+ * @param failnonzero IS non-zero helper exit status a failure?
+ * @param buildRoot buildRoot directory (or NULL)
+- * @param dup duplicate output (or NULL)
+ */
+ RPM_GNUC_INTERNAL
+ int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
+- int failnonzero, const char *buildRoot, FILE *dup);
++ 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 94b4620d2..abfee8332 100644
+--- a/build/rpmfc.c
++++ b/build/rpmfc.c
+@@ -260,7 +260,7 @@ static rpmds rpmdsSingleNS(rpmstrPool pool,
+ static int getOutputFrom(ARGV_t argv,
+ const char * writePtr, size_t writeBytesLeft,
+ StringBuf sb_stdout,
+- int failNonZero, const char *buildRoot, FILE *dup)
++ int failNonZero, const char *buildRoot)
+ {
+ pid_t child, reaped;
+ int toProg[2] = { -1, -1 };
+@@ -268,7 +268,7 @@ static int getOutputFrom(ARGV_t argv,
+ int status;
+ int myerrno = 0;
+ int ret = 1; /* assume failure */
+- int doio = (writePtr || sb_stdout || dup);
++ int doio = (writePtr || sb_stdout);
+
+ if (doio && (pipe(toProg) < 0 || pipe(fromProg) < 0)) {
+ rpmlog(RPMLOG_ERR, _("Couldn't create pipe for %s: %m\n"), argv[0]);
+@@ -369,8 +369,6 @@ static int getOutputFrom(ARGV_t argv,
+ buf[iorc] = '\0';
+ if (sb_stdout)
+ appendStringBuf(sb_stdout, buf);
+- if (dup)
+- fprintf(dup, "%s", buf);
+ }
+ }
+
+@@ -402,7 +400,7 @@ exit:
+ }
+
+ int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
+- int failnonzero, const char *buildRoot, FILE *dup)
++ int failnonzero, const char *buildRoot)
+ {
+ char * s = NULL;
+ ARGV_t xav = NULL;
+@@ -448,7 +446,7 @@ int rpmfcExec(ARGV_const_t av, StringBuf sb_stdin, StringBuf * sb_stdoutp,
+ sb = newStringBuf();
+ }
+ ec = getOutputFrom(xav, buf_stdin, buf_stdin_len, sb,
+- failnonzero, buildRoot, dup);
++ failnonzero, buildRoot);
+ if (ec) {
+ sb = freeStringBuf(sb);
+ goto exit;
+@@ -498,7 +496,7 @@ static ARGV_t runCmd(const char *cmd,
+ argvAdd(&av, cmd);
+
+ appendLineStringBuf(sb_stdin, fn);
+- if (rpmfcExec(av, sb_stdin, &sb_stdout, 0, buildRoot, NULL) == 0) {
++ if (rpmfcExec(av, sb_stdin, &sb_stdout, 0, buildRoot) == 0) {
+ argvSplit(&output, getStringBuf(sb_stdout), "\n\r");
+ }
+
+@@ -1359,7 +1357,7 @@ static rpmRC rpmfcApplyExternal(rpmfc fc)
+ free(s);
+
+ if (rpmfcExec(dm->argv, sb_stdin, &sb_stdout,
+- failnonzero, fc->buildRoot, NULL) == -1)
++ failnonzero, fc->buildRoot) == -1)
+ continue;
+
+ if (sb_stdout == NULL) {
+--
+2.21.0
+
diff --git a/rpm.spec b/rpm.spec
index 91a3d8c..4a3ee44 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -21,7 +21,7 @@
%global rpmver 4.15.0
%global snapver beta
-%global rel 2
+%global rel 3
%global srcver %{version}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x}
@@ -34,7 +34,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
-Release: %{?snapver:0.%{snapver}.}%{rel}%{?dist}.3
+Release: %{?snapver:0.%{snapver}.}%{rel}%{?dist}
Url: http://www.rpm.org/
Source0: http://ftp.rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
%if %{with int_bdb}
@@ -54,6 +54,10 @@ Patch6: 0001-find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
# https://github.com/rpm-software-management/rpm/commit/4b15a9e48bd3d4bef96e8a8865044346be20d6dc
Patch101: 0001-Do-not-set-RPMTAG_BUILDTIME-to-SOURCE_DATE_EPOCH-whe.patch
+Patch110: 0001-Support-running-rpmfcExec-without-any-piped-input-ou.patch
+Patch111: 0002-Restore-strict-order-of-build-scriptlet-stdout-stder.patch
+Patch112: 0003-Drop-the-no-longer-needed-rpmfcExec-output-duplicati.patch
+
# These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch
# Probably to be upstreamed in slightly different form
@@ -539,6 +543,9 @@ make check || (cat tests/rpmtests.log; exit 0)
%doc doc/librpm/html/*
%changelog
+* Fri Aug 23 2019 Panu Matilainen <pmatilai@redhat.com> - 4.15.0-0.beta.3
+- Restore strict order of build scriptlet stdout/stderr output
+
* Thu Aug 15 2019 Miro Hrončok <mhroncok@redhat.com> - 4.15.0-0.beta.2.3
- Rebuilt for Python 3.8
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 9:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 9:32 [rpms/rpm] pmatilai-v6: Restore strict order of build scriptlet stdout/stderr output Panu Matilainen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox