Skip to content

Commit

Permalink
Remove build tree automatically on successfull binary package creation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmatilai authored and ffesti committed May 25, 2022
1 parent 6f9cc38 commit b34333f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions docs/man/rpmbuild.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
3 changes: 2 additions & 1 deletion rpmbuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/rpmbuild.at
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Executing(%build)
Executing(%install)
Executing(%check)
Executing(%clean)
Executing(rmbuild)
],
[])

Expand All @@ -120,6 +121,7 @@ Executing(%build)
Executing(%install)
Executing(%check)
Executing(%clean)
Executing(rmbuild)
],
[])

Expand Down

0 comments on commit b34333f

Please sign in to comment.