rpm subpackages %install section
Asked Answered
L

1

8

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
Leporine answered 21/9, 2017 at 11:17 Comment(1)
Remember - %install is at RPM build time. The scriptlets are executed at install time, e.g. %post. Those allow subpackages.Derwon
V
11

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

Viewless answered 21/9, 2017 at 12:22 Comment(4)
Erm I'm a bit confused, how does this work? Does the install section somehow automagicaly pick the right rpm for each command? They can be installed separately right, what's up with that?Incendiarism
in %install you install all files for all (sub)packages, you make the separation in the %files sections which are different for each (sub)package.Viewless
Ahhh, ok my misconception was that I thought the commands in the install section are packed in the rpms as well. Ermm, but then once you have the rpms built. How do they know where to install what?Incendiarism
Actually that's really helpful. Thanks!Incendiarism

© 2022 - 2024 — McMap. All rights reserved.