Talk:Vim

vim71_install.sh
set -e
 * 1) !/bin/sh


 * 1) Version 1.2c, 2007-10-05
 * 2) - Updated 2007-05-30 by Chris Shymanik (chris@chipsncheese.com)
 * 3)   - Minor revision 1.2b on 2007-09-19 to fix an end-of-install bug.
 * 4)   - Updated VIM to version 7.1.
 * 5)   - Added some error checking and an option to clean DISTDIR.
 * 1)   - Added some error checking and an option to clean DISTDIR.


 * 1) USER CONFIGURATION OPTIONS

SRCDIR=${HOME}/source INSTALLDIR=${HOME}/share/vim DISTDIR=${HOME}/dist DISTDEL="Yes" BINDIR=${HOME}/bin NICE=19 VIM="vim-7.1"
 * 1) Where do you want all this stuff built?
 * 2) ***Don't pick a directory that already exists!***
 * 3) We clean up after ourselves at the end!
 * 1) And where should it be installed?
 * 1) Set DISTDIR to somewhere persistent.
 * 1) Delete contents of DISTDIR after installation? (Default: Yes)
 * 1) Set BINDIR to wherever you keep your binaries.
 * 2) The default is, ~/bin (/home/username/bin).
 * 1) Set whatever nice value you wish here.
 * 2) Higher values indicate lower priority,
 * 3) Lower values indicate higher priority.
 * 4) Range: -20 to 20
 * 1) Name of the VIM install package
 * 2) (without any extension, ie: .tar.bz2)

VIMFEATURES="--prefix=${HOME} \ --enable-perlinterp \ --enable-rubyinterp \ --enable-multibyte \ --disable-netbeans \ --with-features=big \ --disable-gui \ --without-x"
 * 1) What features of VIM do you wish to enable or disable?
 * 2) ***Probably best not to change anything here!***

sleep 1s
 * 1) DO NOT MODIFY BELOW ##########

export PATH=${INSTALLDIR}/bin:$PATH
 * 1) Push the install dir's bin directory into the path.

if [ -d ${SRCDIR} ]; then echo "Source directory already exists! Cleaning it..." rm -rf ${SRCDIR}/* else echo "Creating source directory..." mkdir -p ${SRCDIR} fi
 * 1) Pre-download clean-up and checking.
 * 2) Clear and/or create the source directory.

if [ -d ${INSTALLDIR} ]; then echo "Install directory exists! Removing contents..." rm -rf ${INSTALLDIR}/* else echo "Creating installation directory..." mkdir -p ${INSTALLDIR} fi if [ -d ${BINDIR} ]; then echo "Deleting vim binary if it exists..." rm ${BINDIR}/vim >/dev/null 2>&1 else echo "Creating BINDIR if it doesn't exist..." mkdir -p ${BINDIR} >/dev/null 2>&1 fi
 * 1) Check for existing vim install and remove it if exists. Else create it.

set +e cd ${DISTDIR} WGETOPT="-t1 -T10 -w5 -q -c"
 * 1) Grab the required source archives.
 * 1) Wget options

if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then echo "Skipping wget of ${VIM}.tar.bz2" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${VIM}.tar.bz2 # If primary mirror fails, use the alternative mirror. if [ -a ${DISTDIR}/${VIM}.tar.bz2 ]; then echo "Got ${VIM}.tar.bz2" else wget $WGETOPT ftp://ftp.vim.org/pub/vim/unix/${VIM}.tar.bz2 # Check to make sure the alternative mirror worked. if [ -a ${DISTDIR}/${VIM}.tar.gz ]; then echo "Got ${VIM}.tar.gz" else echo "Failed to get ${VIM}.tar.bz2. Aborting install!" exit 0 fi fi fi
 * 1) Do a bit of error checking while grabbing the sources.

set -e cd ${SRCDIR} echo "Extracting ${VIM}..." tar xjf ${DISTDIR}/${VIM}.tar.bz2 echo "Done."
 * 1) Unpack the source archives.

cd ${SRCDIR}/vim*/src ./configure ${VIMFEATURES} nice -n ${NICE} make mv ${SRCDIR}/vim*/src/vim ${BINDIR}/ mv ${SRCDIR}/vim*/runtime/* ${INSTALLDIR}/
 * 1) Compile and install the package(s).
 * 1) make clean
 * 1) Move our newly created binary to our binaries directory.
 * 1) Move the contents of the runtime directory to our install path.

sleep 2s cd ${HOME} && clear
 * 1) Post install clean-up.

strip --strip-all ${BINDIR}/vim
 * 1) Strip debug info out of the binary.

rm -rf ${SRCDIR} if [ ${DISTDEL} == "Yes" ]; then rm -rf ${DISTDIR} elif [ ${DISTDEL} == "No" ]; then echo "Your DISTDIR will not be cleaned." else echo "Unknown DISTDEL option! Wiping the contents of your DISTDIR by default." sleeps 1s rm -rf ${DISTDIR} fi

echo "Installation completed!" `date +%r`
 * 1) End of install


 * EOF

vim70_install.sh
set -e
 * 1) !/bin/sh

SRCDIR=${HOME}/source INSTALLDIR=${HOME}/share/vim DISTDIR=${HOME}/dist BINDIR=${HOME}/bin NICE=19 VIM="vim-7.0" VERSION="70"
 * 1) Where do you want all this stuff built?
 * 2) ***Don't pick a directory that already exists!***
 * 3) We clean up after ourselves at the end!
 * 1) And where should it be installed?
 * 1) Set DISTDIR to somewhere persistent.
 * 1) Set BINDIR to wherever you keep your binaries.
 * 2) The default is, ~/bin (/home/username/bin).
 * 1) Set whatever nice value you wish here.
 * 2) Higher values indicate lower priority,
 * 3) Lower values indicate higher priority.
 * 4) Range: -20 to 20
 * 1) Name of the VIM install package
 * 2) (without any extension, ie: .tar.bz2)
 * 1) Version of VIM to install
 * 2) Note: This is required due to VIM's poor packaging setup.
 * 3) ***DO NOT USE PERIODS HERE!!***

VIMFEATURES="--prefix=${HOME} \ --enable-perlinterp \ --enable-rubyinterp \ --enable-multibyte \ --disable-netbeans \ --with-features=big \ --disable-gui \ --without-x"
 * 1) What features of VIM do you wish to enable or disable?
 * 2) ***Probably best not to change anything here!***

rm -rf $SRCDIR $DISTDIR
 * 1) Pre-download clean-up:
 * 2) Comment out $DISTDIR if you plan to re-compile more than once
 * 3) this session (modify the end of this script as well if you do!).
 * 4) Example: rm -rf $SRCDIR

export PATH=${INSTALLDIR}/bin:$PATH mkdir -p ${SRCDIR} mkdir -p ${INSTALLDIR} mkdir -p ${DISTDIR} mkdir -p ${BINDIR}
 * 1)  End of User-Editable Bits
 * 2) Push the install dir's bin directory into the path.
 * 1) Setup needed directories

cd ${DISTDIR} wget -c ftp://ftp.vim.org/pub/vim/unix/${VIM}.tar.bz2
 * 1) Get all the required packages.
 * 2) Uncomment the following two lines if you opted to not
 * 3) clean out your DIST directory.

echo -- Unpacking downloaded archives. -- cd ${SRCDIR} echo Extracting ${VIM}... nice -n ${NICE} tar jxf ${DISTDIR}/${VIM}.tar.bz2 echo Done.

cd ${SRCDIR}/vim${VERSION}/src ./configure ${VIMFEATURES} nice -n ${NICE} make mv ${SRCDIR}/vim${VERSION}/src/vim ${BINDIR}/ mv ${SRCDIR}/vim${VERSION}/runtime/* ${INSTALLDIR}/
 * 1) Build it!
 * 1) make clean
 * 1) Move our newly created binary to our binaries directory.
 * 1) Move the contents of the runtime directory to our install path.

strip --strip-all ${BINDIR}/vim
 * 1) Session Clean-up!
 * 2) Kill some Lemmings...
 * 3) I mean, strip debug info out of our binary!

rm -rf $SRCDIR $DISTDIR
 * 1) Comment out $DISTDIR if you plan to re-compile more than once
 * 2) this session.
 * 3) Example: rm -rf $SRCDIR

echo -- INSTALL COMPLETE! --

It might also be a good idea to apply all the current patches in the above script before building. Below is an example:

PATCH_LEVEL=192 cd ${SRCDIR} wget ftp://ftp.vim.org/pub/vim/patches/7.0/7.0.001-100.gz gunzip 7.0.001-100.gz for i in $(seq 101 $PATCH_LEVEL); do  wget ftp://ftp.vim.org/pub/vim/patches/7.0/7.0.${i} done

cd vim${VERSION}/ for i in $(ls ../7.0.*); do  patch -fp0 < $i done

note: if you are going to add the above snippet to your vim install script to add patches, add it before the line


 * 1) Build it!