rpm subpackages %install section

Viewed 1786

Is it possible to have a separate %install section for a subpackage in a spec file?

For example, files can be specified for the main package as

%files

and for the subpackage like this:

%files mysubpackage

however, I have only seen one

%install

section, and I get an error if I do

%install mysubpackage
1 Answers

no, you cannot have, and you don't need a separate %install section.

Let's suppose a typical example: you compile a program and want to create two packages; library.rpm and library-devel.rpm (with the headers). Then you'll have a spec file something like this:

Name: library
# probably some other fields...

%description
describre library

%package devel
Summary: headers for library

%description devel
describe library-devel package

%prep
# some common prep code for both packages; eg
%setup -q

%build
make (or whatever to build your program)

%install
# install files for both rpm packages; library AND headers
mkdir -p ${RPM_BUILD_ROOT}/%_libdir/
mkdir -p ${RPM_BUILD_ROOT}/usr/include/

cp library.so* ${RPM_BUILD_ROOT}/%_libdir/
cp include/*.h* ${RPM_BUILD_ROOT}/usr/include/

%files
%defattr(-,root,root)
%_libdir/*.so.*

%files devel
%defattr(-,root,root)
%_libdir/*.so # yes; if you use version numbers; the versioned .so go in the normal package; the one without version number in the devel package
/usr/include/*

further reading: RPM packaging guide

Related