如何让rpmbuild只构建子包?

Phi*_*hil 3 rpmbuild

我正在从单一来源构建一系列rpms,并且只想构建子包; 即我不想创建一个空的主包,只需要子包.

我该怎么做呢?它是一个rpmbuild开关还是我放入spec文件的东西?

谢谢

Ren*_*neX 9

通常,您通过没有"%files"部分来执行此操作.spec文件中只应包含'%files 子包 '部分.

背景:'%files'部分生成主RPM.'%files' 子包部分生成子包RPM.


sma*_*ani 4

简而言之,rpmbuild 并不直接允许这样做,即使有可能,就减少构建时间而言,它也不会真正为您带来太多好处。rpm 规范文件中的部分%build不知道有关子包的任何信息,因此无论如何它都会构建所有内容。子包仅在 rpmbuild 部分中发挥作用(除了元数据,例如 Requires、Provides 等)%files,其中 rpmbuild 是为了知道哪个子包应该传送已经在%buildroot. 因此,本质上您不妨从 SRPM 构建整套软件包并删除不需要的软件包。

如果您的问题是您想缩短构建时间,那么您可以首先在正在编译的软件包的构建脚本中引入支持,以仅选择性地构建软件包的子集(即,make librarymake documentation)。然后,您可以使用条件宏 [1] 将规范文件的某些部分括起来,然后从命令行定义这些宏:

rpmbuild -ba --define '_build_library' somespecfile.spec
Run Code Online (Sandbox Code Playgroud)

那么,例如,spec 文件中类似的内容应该可以工作:

[...]

%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
Run Code Online (Sandbox Code Playgroud)

不用说,这并不是非常优雅。

[1] http://backreference.org/2011/09/17/some-tips-on-rpm-conditional-macros/