2

I have to develop a RPM package that merge some files, checking for existing files and directories, renaming files etc..

I developed a python script that do it, so executing python3 my_script.py it works perfectly.

Now I have to create a RPM package that should execute the python script.

I looked for rpmbuild, but when I install the RPM nothing appens, maybe I'm on the wrong way.

Any suggestions or web tutorials?

Thanks

2
  • so, er, where is your code? In this case, a .spec would be apropriate. Commented Jun 18, 2014 at 12:47
  • rpm packages don't generally execute scripts like that, they usually install things that the user can then execute... unless you mean you need to execute this script during installation of some other piece of software that you want to package as an rpm. Commented Jun 18, 2014 at 13:19

1 Answer 1

2

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:

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
Sign up to request clarification or add additional context in comments.

1 Comment

what the install means for a python script ? install app.py $RPM_BUILD_ROOT/opt/mytest/app.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.