#!/bin/sh # # update-vim-sources - update Vim sources with patches # from Bram Moolenaar . # # Thanks to Bram for patches! :-) # # Usage: source this script into your shell (I'm using zsh) # and yo can use function 'update-vim' for automaticaly # update. Function 'patch_sources 6.1.345' can be used # patch is already downloaded (or simply saved between # patches). With 'make_distribution' you can create your # own tarball with sources # # Developed by Lubomir Host 'rajo' # Copyright (c) 2003 Platon SDG # Licensed under terms of GNU General Public License. # All rights reserved. # # $Platon$ # Define vim version: VIM_VER="vim61" VIM_VER_LONG="vim-6.1" VIM_VER_EGREP="^6\.1\." # Web site where patches are located #URL="ftp://ftp.vim.org/pub/vim/unstable/patches/" URL="ftp://ftp.vim.org/pub/vim/patches/" # Directory where Vim sources are located #SRC_DIR="/opt/scratch/rajo/src/own" #SRC_DIR="/usr/src/vim" SRC_DIR="$HOME/tmp/vim" # Where save tar-bziped archiv DIST_DIR="$HOME/public_html/vim/dist" # # END of user setup ###################################################### # '6.0.0.099' --> '98' # for version 6.0.001 return empty string old_version() { # if [ "x$1" = "x6.0.001" ]; then # echo; # return; # fi # echo $1 | awk 'BEGIN {FS="."} { print "." $3 - 1 }' # echo $1 | awk 'BEGIN {FS="."} { print ".0" $3 - 1 }' echo $1 | awk 'BEGIN {FS="."} { print ".0" $3 - 1 }' } # '6.0.099' --> '99' new_version() { # echo $1 | awk 'BEGIN {FS="."} { print "." $3 - 1 + 1 }' echo $1 | awk 'BEGIN {FS="."} { print "." $3 }' } # download file from website download_patch() { local DIR DIR=`pwd`; cd $SRC_DIR/patches && \ wget -nH -nd $URL/$1 || \ ( sleep 100; wget -nH -nd $URL/$1 ) || return 1 ; cd $DIR } # # Extract ChangeLog information # filter_patch() { awk 'BEGIN { skip = 1; } /^------/ { skip = 0; getline; next; } /^\*\*\* / { exit; } skip == 0 { printf " %s\n", $0; } ' } # # You can build Debian package - changelog si modified automaticaly # with proper entry # modify_changelog() { local DIR local patches #patches=`echo $* | awk -v RS=' ' '{ print;}' |sort -r -u -z` #echo "patches='$patches'" #if [ $# -gt 1 ]; then # echo "Error: modify_changelog() allows only 1 argument!" > /dev/stderr # exit 1; #fi DIR="`pwd`"; cd $SRC_DIR \ && here="`pwd`" \ && for i in $*; do \ test -f patches/$i \ && cp $VIM_VER/debian/changelog $VIM_VRE/debian/changelog.before-$i \ && ( echo "vim ($i) unstable; urgency=low" \ && echo && echo " * Apply upstream patch:" \ && filter_patch < patches/$i \ && echo " -- Lubomir Host `date -R`" \ && echo ) > $VIM_VRE/debian/changelog \ && cat $VIM_VRE/debian/changelog.before-$i >> $VIM_VRE/debian/changelog done cd "$DIR" } # # Aply one patch to vim sources # patch_sources() { local DIR DIR="`pwd`"; cd $SRC_DIR \ && here="`pwd`" \ && for i in $*; do \ cd "$here/patches" \ && echo "--Using patch $i" \ && patch -p0 < $i \ && modify_changelog $i \ && cd "$here" \ && ln -s $VIM_VER $VIM_VER`new_version $i` || return 1 done cd "$DIR" } make_distribution() { local DIR DIST_FILE OLD_DIST_FILE DIR=`pwd`; DIST_FILE="$DIST_DIR/$VIM_VER_LONG`new_version $1`-all.tar.bz2" OLD_DIST_FILE="$DIST_DIR/$VIM_VER_LONG`old_version $1`-all.tar.bz2" cd /opt/scratch/rajo/src/vim/ && \ tar cIf $DIST_FILE $VIM_VER`new_version $1` && \ chmod a+r $DIST_FILE && \ rm -f $OLD_DIST_FILE || return 1 cd $DIR } # # Update vim sources # update-vim() { local DIR TMP_FILE DIR=`pwd`; TMP_FILE=`tempfile -p update_vim-zsh || mktemp /tmp/update_vim-zshXXXXXX || echo /tmp/update_vim-zsh$$` echo "Looking for new patches..."; wget -O - $URL 2> /dev/null | awk 'BEGIN { FS=">" } {print $2}' | \ egrep "$VIM_VER_EGREP" | sed 's/<.*//g;' > $TMP_FILE cd $SRC_DIR/patches && \ ( NEW_PATCHES="`ls -1| egrep "$VIM_VER_EGREP" | diff - $TMP_FILE | awk '{ print $2 }'`" if [ -z "$NEW_PATCHES" ]; then echo "No new patches..." else for i in `echo $NEW_PATCHES` do download_patch $i && patch_sources $i || exit 1 done #cd $SRC_DIR/$VIM_VER && make && make install cd $SRC_DIR/$VIM_VER && make && echo && echo "=================================" && su root -c make install fi ) rm -f $TMP_FILE cd $DIR } # # Completition function for zsh # compctl -K _vimhelptargets vimhelp compctl -K _vimhelptargets gvimhelp _vimhelptargets() { # local VIM vimversion tagsfile # vimpath=`vim -e -u NONE -U NONE \ # --cmd 'set term=dumb' \ # --cmd 'set t_cm=' \ # --cmd ':echo $VIM' \ # --cmd ':q!' \ # | sed 's/^.*\[[0-9]\+;[0-9][Hm]//g;' |xxd` # vimversion=$(vim --version |& head -1 | sed -e 's/VIM - Vi IMproved \([^ ]\+\).*/vim\1/; s/\.//; ') # tagsfile="$vimpath/$vimversion/doc/tags" tagsfile="$HOME/install/share/vim/vim61/doc/tags" reply=($( cat $tagsfile | sed -e 's/ .*//' )) } # vim: ft=zsh # vim600: fdm=marker fmr={,} fdc=3 fdl=0