zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Build RPM package

December 3, 2018 by Igor Drobot 1 Comment

RPM logo

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

zypper in rpm-build

1
2
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

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

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>

# 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

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

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

Filed Under: Linux Tagged With: Automation, Linux, RPM

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Trackbacks

  1. Packaging with FPM says:
    December 3, 2018 at 21:20

    […] 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 […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok