Reputation: 663
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
Upvotes: 8
Views: 2794
Reputation: 37792
No, you cannot have, and you don't need, a separate %install
section. The %install
section should install all files for all (sub)packages, and then the individual %files
sections differentiate which files are for which (sub)packages.
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
describe 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
Upvotes: 12