Skip to content

Instantly share code, notes, and snippets.

@borgand
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borgand/ce5ac045c8c07d24c753 to your computer and use it in GitHub Desktop.
Save borgand/ce5ac045c8c07d24c753 to your computer and use it in GitHub Desktop.
Compile static git (e.g. for use in jailed server environment). NB! The kernel version must match that of the destination for the binary to work.
#!/bin/sh
# What git version to build
git_version="2.2.2"
# let's make sure we have all we need to proceed
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel autoconf
# Download sources
cd /tmp
if [[ ! -d git-$git_version ]]; then
curl https://www.kernel.org/pub/software/scm/git/git-$git_version.tar.gz | tar xzv
fi
cd git-$git_version/
# compile and install
make configure
./configure --prefix=/tmp/git-static CFLAGS="${CFLAGS} -static" NO_OPENSSL=1 NO_CURL=1
sudo make install
# Now package it to tarball
cd /tmp
tar zcvf /tmp/git-static-$git_version.tgz git-static
echo "Static git: /tmp/git-static-$git_version.tgz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment