Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make rpmbuild only build subpackages?

Tags:

rpmbuild

I am building a series of rpms from a single source and want to only build the subpackages; i.e. I don't want an empty main package created, only the subpackages.

How do I do this? is it an rpmbuild switch or something I put in to the spec file?

thanks

like image 692
Phil Avatar asked Mar 22 '14 06:03

Phil


2 Answers

Typically you do this by not having a '%files' section. Only '%files subpackage' sections should be present in the spec file.

Background: The '%files' section generates the main RPM. The '%files' subpackage sections generate the subpackage RPMs.

like image 158
ReneX Avatar answered Sep 28 '22 02:09

ReneX


Short answer, rpmbuild does not directly allow this to be done, and even if it were possible, it wouldn't really buy you much as far as reduction of the build time is concerned. The %build section in the rpm spec file does not know anything about subpackages, so it will build everything anyway. Subpackages only come into play (beyond the metadata such as Requires, Provides, etc) in the %files section, where rpmbuild is to know which subpackage should ship a file already appropriately built and installed in the %buildroot. So essentially you might as well build the entire set of packages from the SRPM and delete the packages you do not need.

If your issue is that you would like to shorten the build time, what you could to is first introduce support in the build scripts of the software package you are compiling to only selectively build a subset of the package (i.e. make library, make documentation, etc). Then, you can enclose certain sections of your spec file with conditional macros [1], and then define those macros from the command line:

rpmbuild -ba --define '_build_library' somespecfile.spec

So then for instance something like this in the specfile should work:

[...]

%if 0%{?_build_library:1}
Package libs
Summary: Libraries for %{name}
%description libs
Libraries for %{name}
%endif

%if 0%{?_build_docs:1}
Package docs
Summary: Documentation for %{name}
%description docs
Documentation for %{name}
%endif

[...]

%build
%if 0%{?_build_library:1}
make libs
%endif

if 0%{?_build_docs:1}
make docs
%endif


%install
%if 0%{?_build_library:1}
%make_install libs
%endif

if 0%{?_build_docs:1}
%make_install docs
%endif


%if 0%{?_build_library:1}
%files libs
%{_libdir}/*.so*
%endif

if 0%{?_build_docs:1}
%files docs
%doc doc/html
%endif

Needless to say this is not terribly elegant.

[1] http://backreference.org/2011/09/17/some-tips-on-rpm-conditional-macros/

like image 36
smani Avatar answered Sep 28 '22 02:09

smani