summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2022-05-25 15:08:30 +0300
committerPanu Matilainen <pmatilai@redhat.com>2022-06-28 14:51:02 +0300
commit6f945960affc7a2a2b49337458457273d8a4faf5 (patch)
tree34b005de577ce58b0db80744cb66d1f9ca0a5975
parentdd34db9b2560ff6df957e13db17d8f8ece8f3a04 (diff)
downloadrpm-6f945960affc7a2a2b49337458457273d8a4faf5.tar.gz
Remove build tree automatically on successfull binary package creation
Traditionally rpmbuild has only cleaned up the build directory on --rebuild mode, but by default leaving tonnes of digital waste behind in the far more common -bb mode. Default to cleaning up build directory in addition to buildroot on successfull binary package creation, with the exception of short-circuit'ed builds. To go with this, have --noclean affect the build directory removal too. Change the diagnostics message from "--clean" to "rmbuild" because --clean is just misleading as it can get executed by other means too. (cherry picked from commit b34333fa021c0ee7215714eeef96d1a2843ea08e)
-rw-r--r--build/build.c2
-rw-r--r--docs/man/rpmbuild.8.md1
-rw-r--r--rpmbuild.c3
-rw-r--r--tests/rpmbuild.at2
4 files changed, 6 insertions, 2 deletions
diff --git a/build/build.c b/build/build.c
index c88cb25af..44794477c 100644
--- a/build/build.c
+++ b/build/build.c
@@ -432,7 +432,7 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
goto exit;
if ((what & RPMBUILD_RMBUILD) &&
- (rc = doScript(spec, RPMBUILD_RMBUILD, "--clean", NULL, test, sbp)))
+ (rc = doScript(spec, RPMBUILD_RMBUILD, "rmbuild", NULL, test, sbp)))
goto exit;
}
diff --git a/docs/man/rpmbuild.8.md b/docs/man/rpmbuild.8.md
index 947ca25fc..4b2701429 100644
--- a/docs/man/rpmbuild.8.md
+++ b/docs/man/rpmbuild.8.md
@@ -155,6 +155,7 @@ all the stages preceding it), and is one of:
: Build just the binary packages - executes up to and including the
assembly stage, but without creating the source package.
+ On success, the build directory is removed (as in **\--clean**).
**-bp**
diff --git a/rpmbuild.c b/rpmbuild.c
index abe164e32..cb02b31ba 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -270,7 +270,7 @@ static struct poptOption rpmBuildPoptTable[] = {
N_("generate package header(s) compatible with (legacy) rpm v3 packaging"),
NULL},
- { "noclean", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CLEAN,
+ { "noclean", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_CLEAN|RPMBUILD_RMBUILD,
N_("do not execute %clean stage of the build"), NULL },
{ "noprep", '\0', POPT_BIT_SET, &nobuildAmount, RPMBUILD_PREP,
N_("do not execute %prep stage of the build"), NULL },
@@ -649,6 +649,7 @@ int main(int argc, char *argv[])
ba->buildAmount |= RPMBUILD_CLEAN;
if ((buildChar == 'b') && shortCircuit)
break;
+ ba->buildAmount |= RPMBUILD_RMBUILD;
/* fallthrough */
case 'i':
ba->buildAmount |= RPMBUILD_INSTALL;
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 3bdaecc4e..0c8f2f5e8 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -106,6 +106,7 @@ Executing(%build)
Executing(%install)
Executing(%check)
Executing(%clean)
+Executing(rmbuild)
],
[])
@@ -120,6 +121,7 @@ Executing(%build)
Executing(%install)
Executing(%check)
Executing(%clean)
+Executing(rmbuild)
],
[])