Building latest git for CentOS

CentOS is a great operating system, but recent versions of software packages is not one of its virtues. For example the current CentOS 7.2 ships with git version 1.8.3 released 2013, almost 3 years ago. And by that time git gained quite some useful features. So lets see how to build RPMs with latest git.

RPM build chroot

First thing is to make a chroot where to build the RPM, because there are a lot of dependencies required for building, which needs to be cleaned up afterwards. Much easier is to just delete the whole chroot dir 🙂

First lets create the chroot directory and  initialize the  rpm database   :

Next  install the latest centos-release package and yum inside :

Next we continue inside the chroot. Lucky us, systemd-nspawn makes it trivial to work inside the chroot :

 

Building RPMs

Next we need to install gcc, and few other packages that are needed to compile RPMs .

And now we need a git SRPM to build. We can just grab the Fedora one which has git 2.7.1. Here https://apps.fedoraproject.org/packages/git/overview/ are all Fedora builds, and I picked the Rawhide version. Clicking on it takes us to a page with build information and there is also a link to download the SRPM for this build. Lets install it :

You can just ignore the warning about missing users. Go to SPECS directory and try to build the RPMs:

Ok, we need to install some dependencies to be able to build. Lets just install them:

and run rpmbuild again:

After the build finishes we have the RPMs in ~/rpmbuild/RPMS:

Exit the chroot and install the following packages for a minimal git installation:

Not, so bad 🙂 Next time I will check how to create a repository .

3 thoughts on “Building latest git for CentOS”

Leave a comment