Getting a newer version of git onto CentOs 5

Ah the joys of working with vintage OSes.

So if you add the usual yum repositories to CentOs 5, git and curl are available in the updates repository.

However, if you try to use git and do a push to a web DAV-based repository, say somewhere like github.com, you get the following error:

$> git push
fatal: git-push is not available for http/https repository when not compiled with USE_CURL_MULTI

A quick look at the docs on “git http-push” has this note:

*NOTE*: This command is temporarily disabled if your libcurl is older than 7.16, as the combination has been reported not to work and sometimes corrupts repository.

A quick look at the update repository confirms that the version of curl is fairly old: 7.15. Bummer.

Now, you could probably work around this with Remi’s repository. (It’s a repository focused on providing a current LAMP stack on as many distros as possible.) The trouble with Remi is that he tends to want to upgrade your current PHP and Mysql as part of the process. (curl and Mysql being required packages for PHP.)

If you don’t have the time to test out a full lamp upgrade, you don’t feel comfortable using a one-person repository, or if you already have your Web DAV server running using the RPM-based git and you don’t want to change that out, then you know where this goes:

This is probably the ONLY time in the last decade where I have ended up compiling and pathing a local copy of a program!

So for my own reference, and in case it helps you, here’s how to compile up the latest curl and git in /usr/local so you can move on with the rest of your life:

Step 1. – Install required libs. I’m assuming you already have gcc, make, etc present:

yum install autoconf expat-devel gcc gettext-devel libssh2-devel openssl-devel zlib-devel

Step 2. – Download and install curl:

wget http://curl.haxx.se/download/curl-7.30.0.tar.gz
tar xzvf curl-7.30.0.tar.gz
cd curl-7.30.0

make clean
./configure --libdir=/usr/lib64 --with-libssh2 --enable-shared --prefix=/usr/local/
make && make test && make install

Step 3. – If /usr/local is not in your library path, put it there. Man this is old-school stuff:

echo /usr/local/lib >> /etc/ld.so.conf
ldconfig

Step 4. – Now compile git using your new curl:

wget https://www.kernel.org/pub/software/scm/git/git-1.8.3.tar.gz
tar xzvf git-1.8.3.tar.gz
cd git-1.8.3

autoconf
make clean
./configure --with-curl=/usr/local --prefix=/usr/local/
make test && make install

I actually had make test fail on a minor error. After confirming it was ok, I did a make install

Step 5. – Enjoy a new git on your old box. Update paths as necessary.

Leave a Response