Instantly share code, notes, and snippets.

What would you like to do?
How to create an RPM from source with spec file
# How to create an RPM from source with spec file
# This is for Redhat versions of linux. Sometimes when you search for an rpm package,
# it is either outdated or not available. The only thing available is the source code.
# You can create a custom RPM package from source.
# For this example, I'll be using the latest version of Git, currently v.
# Step: 1
# Install rpmbuild
yum install -y rpm-build
# Step: 2
# Create rpmbuild folders in your home directory
# Step: 3
# Download the source file
# Source files are usually available in tar.gz or tar.bz2 format. Create a src folder
# in your home directory to store your files, download the file, uncompress it and
# move the compressed file to the rpm build SOURCES directory
mkdir -p ~/src && cd ~/src
tar -xzvf git-
mv git- ~/rpmbuild/SOURCES
# Step: 4
# Locate .spec file and build rpm
# If you get any errors during build, it is usually because of dependencies. Simply
# install the dependencies with `yum install [dependency]` and run rpmbuild again.
cd ~/src/git- && ls | grep *.spec
rpmbuild -ba git.spec

This comment has been minimized.

udondan commented Nov 10, 2015

On newer git versions git.spec needs to be built from template:

make git.spec

This comment has been minimized.

omps commented Mar 15, 2016

do you know how can i change the path from /usr/bin to /opt/git/bin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment