将额外文件添加到rpm构建过程中

4
我有一个支持添加Python插件的应用程序源代码。我编写了一个Python脚本,并希望构建一个定制的RPM,默认情况下包含我的脚本,以便在RPM安装后无需额外添加它。
现在据我所知,这有两个部分:
1. 将文件添加到源代码中。 2. 在.spec文件中列出该文件。
我如何知道将文件放在源代码中的位置?我如何指定要复制我的脚本的路径?spec文件包含类似以下文本-
%if %{with_python}
%files python
%{_mandir}/man5/collectd-python*
%{_libdir}/%{name}/python.so

//Something like this?

// %{_libdir}/%{name}/gearman.py 
// %{_libdir}/%{name}/redis.py
%endif
1个回答

5

您需要知道在目标安装中放置脚本文件的位置(例如 /usr/lib/myApp/plugins/myNiceScript.py)

在 spec-File(%install 部分)中,您需要将脚本复制到 %{buildroot} 下的目标目录中(该目录必须首先创建)。

%install
...
# in case the dir does not exist:
mkdir -p %{buildroot}/usr/lib/myApp/plugins

cp whereitis/myNiceScript.py   %{buildroot}/usr/lib/myApp/plugins

最后,在%files部分必须定义文件标志。例如,如果您的文件在root下需要有644:

%files
...
%defattr(644,root,root)
/usr/lib/myApp/plugins/myNiceScript.py

如果在安装过程中需要创建插件目录,则也需要定义以下标志:

%defattr(755,root,root)
%dir /usr/lib/myApp/plugins

1
你能详细说明一下 whereitis 吗?它是否必须在 tar.gztar.bz2 中? - erbdex
你可以选择任何你喜欢的。你额外脚本的位置(源)并不重要。rpm文件只包含有关目标的信息 - 而不是源代码。 - tue

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接