To speed up some work processes with a single RPM package will bring more flexibility than deployment of single files/directories across different systems. Also a possibility to upgrade the installations without tracking of file versions over different systems.
This example will describe how to package a example script into a RPM package.
This could be also a full application or a file-set. In this case sync-brain.sh, script with sync logic.
Build process was set up on openSUSE 15.0.
zypper in rpm-build |
1 2 | mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros |
Now in Folder SPECS create your project spec-file:
vim /root/rpmbuild/SPECS/sync-brain.spec |
# spec file for package sync-brain Name: sync-brain Version: 0.1 Release: 3 Summary: Project for doing sync things License: non-free Group: Productivity/Networking/Security Url: zeldor.biz BuildRoot: %{_tmppath}/%{name}-%{version}-build Packager: Igor Drobot <kiwi@zeldor.biz> %description A really great tool to sync things %prep mkdir -p %{_builddir}/opt/sync-brain cp -r %{_sourcedir}/** %{_builddir}/opt/sync-brain %install install -m 0755 -d $RPM_BUILD_ROOT/opt/sync-brain mv %{_builddir}/** $RPM_BUILD_ROOT/opt/sync-brain %files %defattr(-,root,root) /* %clean rm -rf %{_builddir}/** </kiwi@zeldor.biz> |
Start the build process with an rpm -b command:
rpmbuild -ba SPECS/project.spec |
sync-brain.sh script, which should be packaged was placed in SOURCES directory. After a sucessfull build, RPM-Package will be found under RPMS.
Now try to install your RPM package:
rpm -Uvh RPMS/x86_64/sync-brain-0.1-2.x86_64.rpm |
Possible stages:
%pre – This is where code is run before the install scripts run.
%preun – The section where code is executed prior to uninstall
%post – Section for code to be executed after installation
%postun – Section for code to be executed after uninstallation
[…] you ever tried to package a simple application with rpmbuild, you may know, what a pain it could be. Writing of a spec file, understand the errors and the […]