How do I make rpmbuild only build subpackages?
Asked Answered
B

4

7

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

Bratislava answered 22/3, 2014 at 6:5 Comment(0)
V
11

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.

Volotta answered 4/4, 2014 at 9:35 Comment(1)
This is the only correct answer here. To avoid building the main package, just leave out the %files section for the main package.Wills
S
4

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/

Siddra answered 22/3, 2014 at 12:36 Comment(0)
U
1

Can you post your spec file? I use subpackages, and it never builds the main package. These are the fields I put in the spec (before the %prep):

Name: xxx 
Version: %{_version}.%{_build}
Release: %{_drop}
Summary: xxx
Group: Applications/Communications
License: xxx
URL: xxx
BuildArch: x86_64

Requires: jpackage-utils
Requires: java

Distribution: CentOS Linux
Vendor: xxx
Packager: xxx

%description
xxx
Udell answered 23/3, 2014 at 8:40 Comment(0)
R
0

It's not what you have to put in your spec it's what you have to have to leave out. I'm not sure exactly what fields you have to leave out, but I suspect it is the %scriptlets and %files for the main package.

The following spec builds two sub-packages and no root package:

Summary : subpackage only rpms
Name    : root
Version : 0.0.1
Release : 1
License : Whatever
Group   : Whatever
URL     : https://mcmap.net/q/1421706/-how-do-i-make-rpmbuild-only-build-subpackages

%description

%prep
%build
%install
touch $RPM_BUILD_ROOT/subpackage-{1,2}

%package subpackage-1
Summary : subpackage-1
%description subpackage-1
%files subpackage-1
/subpackage-1

%package subpackage-2
Summary : subpackage-2
%description subpackage-2
%files subpackage-2
/subpackage-2
Remington answered 28/3, 2014 at 10:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.