rpmbuild %clean phase without removing files
Asked Answered
H

2

12

I am getting the following in my build log:

Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.CgE2Qn
+ umask 022
+ cd /export/home/svn_checkouts/*snip*/Output/release/bin/packaging/BUILD
+ /bin/rm -rf /export/home/svn_checkouts/*snip*/Output/release/bin
+ exit 0

I'd like to avoid rpmbuild deleting all the files in my build directory as I need them for other things after the RPM is built. Can I override this behavior?

I read that some versions of RPM support a --noclean argument, but ours doesn't unfortunately.

Hazelhazelnut answered 11/12, 2012 at 23:29 Comment(0)
H
11

Turns out I just needed to provide my own %clean directive in the spec file and leave it blank to override the default. For some reason I didn't expect that to work. ;)

A define can conditionalize the %Clean% phase so that the same effect as --noclean can be achieved.

%Clean
%if "%{noclean}" == ""
   rm -rf $RPM_BUILD_ROOT
%endif

Called with rpmbuild --define 'noclean 1' to disable cleaning.

Hazelhazelnut answered 11/12, 2012 at 23:39 Comment(1)
Alas, this doesn't work with RPM version 4.11.1 : if noclean is undefined, %{noclean} gets expanded to % { n o c l e a n } (without the spaces) rather than an empty string.Biserrate
W
3

For building from spec-file, rpmbuild has the -bi option. It leaves the $RPM_BUILD_ROOT as is; it does no %clean.

  -bi     build through %install (%prep, %build, then install) from <specfile>

(rpmbuild --help)


For building from SRPM (a source RPM package; yumdownloader will get you those), there is also --recompile option:

 --rebuild    build binary package from <source package>
 --recompile  build through %install (%prep, %build, then install) from <source package>

Finally, there is --noclean option for rpmbuild — but in my case (RPM version 4.11.3) it didn't work.

Willowwillowy answered 11/4, 2016 at 14:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.