[英]How to rpm execute python script
I have to develop a RPM package that merge some files, checking for existing files and directories, renaming files etc.. 我必须开发一个RPM软件包,合并一些文件,检查现有文件和目录,重命名文件等。
I developed a python script that do it, so executing python3 my_script.py it works perfectly. 我开发了执行此操作的python脚本,因此执行python3 my_script.py可以完美地工作。
Now I have to create a RPM package that should execute the python script. 现在,我必须创建一个应该执行python脚本的RPM包。
I looked for rpmbuild, but when I install the RPM nothing appens, maybe I'm on the wrong way. 我寻找了rpmbuild,但是当我安装RPM时,什么也没发现,也许我走错了路。
Any suggestions or web tutorials? 有任何建议或网络教程吗?
Thanks 谢谢
I solved my problem thanks to some guides and tutorials I found on the net, this is a sample .spec that generates a .rpm which save installation files under /opt/mytest directory: 由于在网上找到了一些指南和教程,我解决了我的问题,这是一个示例.spec,它生成一个.rpm并将安装文件保存在/ opt / mytest目录下:
Name: mytest
Version: 1.0
Release: 1%{?dist}
Summary: A test script
Group: Utilities
License: GPL
URL: http://www.mypage.com
Source0: mytest-1.0.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description A test script inside a simple RPM package
%prep
%setup -q
%build
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT/opt/mytest
install app.py $RPM_BUILD_ROOT/opt/mytest/app.py
%clean
rm -rf $RPM_BUILD_ROOT
%files
%dir /opt/mytest
%defattr(-,root,root,-)
/opt/mytest/app.py
/opt/mytest/app.pyc
/opt/mytest/app.pyo
%post
chmod 755 -R /opt/mytest
cd /opt/mytest
python3 app.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.