是否可以在spec文件中为子包设置单独的%install部分?
例如,可以为主包指定文件
%files
以及像这样的子包:
%files mysubpackage
然而,我只见过一个
%install
部分,如果我这样做,我会收到错误
%install mysubpackage
答案 0 :(得分:3)
不,您不能拥有,并且您不需要单独的%install 部分。
让我们假设一个典型的例子:你编译一个程序并想要创建两个包; library.rpm和library-devel.rpm(带标题)。然后你会有一个类似这样的spec文件:
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/*
进一步阅读:RPM guide