Close

Linux – How to build an RPM package

To do this, you need to use the rpmbuild command.

Announcement

I have released my new course on Udemy, Kubernetes By Example. Sign up now to get free lifetime access!

First you have to install this utility by installing the following package:

$ yum install rpmdevtools

And maybe also the following too:

$ yum install gcc make rpm-build patch
# the following I think are optional:
$ yum pcre-devel openssl-devel rrdtool-devel

You might need to do some patching:

$ patch -p1 --dry-run < /path/to/patch.patch
$ patch -p1 < /path/to/patch.patch

For more info about checkout out:

7 Patch Command Examples to Apply Diff Patch Files in Linux

$ yum info patch
Loaded plugins: rhnplugin, security, ulninfo
*Note* Spacewalk repositories are not listed below. You must run this command as root to access Spacewalk repositories.
Installed Packages
Name        : patch
Arch        : x86_64
Version     : 2.6
Release     : 6.el6
Size        : 172 k
Repo        : installed
From repo   : anaconda-OracleLinuxServer-201507280245.x86_64
Summary     : Utility for modifying/upgrading files
URL         : http://www.gnu.org/software/patch/patch.html
License     : GPLv2+
Description : The patch program applies diff files to originals.  The diff command
            : is used to compare an original to a changed file.  Diff lists the
            : changes made to the file.  A person who has the original file can then
            : use the patch command with the diff file to add the changes to their
            : original file (patching the file).
            :
            : Patch should be installed because it is a common way of upgrading
            : applications.

Next run rpmdev-setuptree, this will result in the rpmbuild folder being created:

[root@puppetmaster ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog
[root@puppetmaster ~]# rpmdev-setuptree 
[root@puppetmaster ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  rpmbuild
[root@puppetmaster ~]# tree rpmbuild/
rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS

5 directories, 0 files
[root@puppetmaster ~]# 

How to Create RPM for Your Own Script in CentOS/RedHat

7 Steps to Build a RPM Package from Source on CentOS / RedHat

https://www.google.co.uk/search?q=rpm+setuptree&ie=utf-8&oe=utf-8&gws_rd=cr&ei=iqy9Vs6LMcve6QTXiLGQBw

http://www.cyberciti.biz/tips/building-a-source-rpm-using-rpmbuild-command.html

https://fedoraproject.org/wiki/How_to_create_an_RPM_package

https://www.google.co.uk/search?q=fpm&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a&channel=sb&gfe_rd=cr&ei=TksAVYqBJsve-gbMzoCgDg#safe=off&rls=org.mozilla:en-GB:official&channel=sb&q=fpm+rpm

https://www.google.co.uk/search?q=fpm&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a&channel=sb&gfe_rd=cr&ei=TksAVYqBJsve-gbMzoCgDg#safe=off&rls=org.mozilla:en-GB:official&channel=sb&q=maven+rpm