Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Shell script to build the latest Vim directly from the Mercurial repository

View build-vim.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
#!/bin/bash -e
 
# Shell script to build Vim from sources according to my taste :-)
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: June 22, 2014
# URL: https://gist.github.com/xolox/1274179
#
# This shell script compiles Vim from the latest available sources (cloned and
# updated via Mercurial) on Debian derived distributions (I've successfully
# used this script on Ubuntu 10.04 and 12.04).
#
# To build a debug version of Vim, edit src/Makefile:
#
# 1. Use the gcc -g command line argument to compile with debugging symbols.
# 2. Set STRIP to /bin/true so that debugging symbols are not stripped.
 
REMOTE_REPO=https://vim.googlecode.com/hg/
 
main () {
# Prepare environment.
export CONF_OPT_COMPBY="$(find_compiled_by)"
export CONF_OPT_FEAT='--with-features=huge'
export CONF_OPT_GUI='--enable-gnome-check'
export CONF_OPT_LUA='--enable-luainterp'
export CONF_OPT_LUA_PREFIX='--with-lua-prefix=/usr'
export CONF_OPT_MULTIBYTE='--enable-multibyte'
export CONF_OPT_PYTHON='--enable-pythoninterp'
# Find the local checkout of the remote Mercurial repository.
local LOCAL_REPO=$(find_local_checkout)
# Clone or update the local repository checkout.
if [ -z "$LOCAL_REPO" ]; then
standout "Cloning repository"
hg clone "$REMOTE_REPO" vim
cd vim
else
cd "$LOCAL_REPO"
standout "Pulling updates"
hg pull
standout "Applying updates"
hg update -C
fi
# Make sure build time dependencies are satisfied.
standout "Installing dependencies"
sudo apt-get build-dep vim-gnome
sudo apt-get install autoconf lua5.1 liblua5.1-0-dev
# Rebuild the configure script. This takes a while but skipping this can lead
# to breakage when an incoming update has changed things and you don't
# rebuild the configure script.
standout "Rebuilding ./configure script"
make -C src autoconf
# This is where the magic happens.
standout "Building binaries"
make
standout "Installing files"
sudo make install
}
 
find_compiled_by () {
# Automatically fill in --compiled-by=... based on ~/.gitconfig or ~/.hgrc.
if [ -n "$CONF_OPT_COMPBY" ]; then
# If the compiled-by value has already been set we have nothing to do.
echo $CONF_OPT_COMPBY
return
fi
if [ -e ~/.gitconfig ]; then
# Get the compiled-by value from the user's git configuration file.
local name="$(extract ~/.gitconfig name)"
local email="$(extract ~/.gitconfig email)"
if [ -n "$name" -a -n "$email" ]; then
echo "--with-compiledby=\"$name <$email>\""
return
fi
fi
if [ -e ~/.hgrc ]; then
# Get the compiled-by value from the user's Mercurial configuration file.
local value="$(extract ~/.hgrc username)"
if [ -n "$value" ]; then
echo "--with-compiledby=\"$value\""
return
fi
fi
}
 
find_local_checkout () {
# Find the local checkout of the remote Mercurial repository.
for hg_directory in $(locate "*/.hg"); do
local repository=$(dirname "$hg_directory")
local remote=$(hg -R "$repository" paths | awk -F = '/^default[ \t]*=/ {print $2}' | strip)
if [ "$remote" = "$REMOTE_REPO" ]; then
echo $repository
return
fi
done
}
 
extract () {
# Extract the value of a field in a *.ini style file. Doesn't know about
# sections (will treat all values as being in the same section).
local filename="$1"
local field="$2"
awk -F = "/^[ \t]*$field[ \t]*=/ {print \$2}" $filename | head -n1 | strip
}
 
strip () {
# Strip whitespace from the start and end of each line.
perl -pe 's/^\s*(.*?)\s*$/\1/'
}
 
standout () {
# Print a message that will stand out amongst lots of output.
tput bold
echo && echo "$@" && echo
tput sgr0
}
 
main "$@"
 
# vim: ts=2 sw=2 et
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.