#!/bin/bash # vim.SlackBuild # by Stuart Winter for the Slackware porting Project. # Heavily based on the original Slackware build script. # 20-Jun-2004 # Update these with each re-build/upgrade: VIMVER=7.4 CTAGSVER=5.8 # This is the directory in the VIM source archive to cd into. DIRVER=74 # Paths to skeleton port's source & real Slackware source tree: export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM export PORTCWD=$PWD # Temporary build locations: export TMPBUILD=$TMP/build-$PKGNAM export PKG=$TMP/package-$PKGNAM mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD # Determine the CFLAGS for the known architectures: case $ARCH in arm) export SLKCFLAGS="-O2 -march=armv5te" export LIBDIRSUFFIX="" export SLKLDFLAGS="-L/usr/lib${LIBDIRSUFFIX}" ;; *) export SLKCFLAGS="-O2" ;; esac PYVER=$(python -V 2>&1 | cut -f 2 -d' ' | cut -f 1-2 -d.) # Determine VIM patchlevel: if [ -d $CWD/patches ] ; then cd $CWD/patches PATCHLEVEL=$(/bin/ls ?.?.????.gz 2> /dev/null | tail -1 | cut -f 3 -d . ) if [ "$PATCHLEVEL" = "" ]; then PATCHLEVEL=$(/bin/ls ?.?.???.gz 2> /dev/null | tail -1 | cut -f 3 -d . ) if [ "$PATCHLEVEL" = "" ]; then PATCHLEVEL=000 fi fi cd $CWD fi echo "Building patch level: $PATCHLEVEL" ###### Build ctags################################################### cd $TMPBUILD tar xvvf $CWD/ctags-$CTAGSVER.tar.gz cd ctags-$CTAGSVER slackhousekeeping # Configure: CFLAGS="$SLKCFLAGS" \ LDFLAGS="$SLKLDFLAGS" \ ./configure \ --prefix=/usr \ --build=$ARCH-slackware-linux-gnueabi || failconfig # Build: make $NUMJOBS || failmake # Install binary: mkdir -p $PKG/usr/bin install -m755 ctags $PKG/usr/bin # Install man pages: mkdir -p $PKG/usr/man/man1 install -m644 ctags.1 $PKG/usr/man/man1 # Install docs: mkdir -p $PKG/usr/doc/ctags-$CTAGSVER cp -a COPYING EXTENDING.html FAQ INSTALL INSTALL.oth NEWS README \ $PKG/usr/doc/ctags-$CTAGSVER ##### Build vim without X support###################################### config_vim() { CFLAGS=-O2 \ ./configure \ $* \ --prefix=/usr \ --enable-pythoninterp \ --with-python-config-dir=/usr/lib${LIBDIRSUFFIX}/python$PYVER/config \ --enable-perlinterp \ --disable-tclinterp \ --enable-multibyte \ --enable-cscope \ --with-features=huge \ --with-compiledby="" \ --build=$ARCH-slackware-linux-gnueabi } # Extract source: cd $TMPBUILD tar xvvf $CWD/vim-$VIMVER.tar.?z* slackhousekeeping cd vim* || exit 1 # If there's no syntax update, create one: if ! ls $CWD/vim-runtime-syntax-* 1> /dev/null 2> /dev/null ; then rm -rf runtime/syntax.orig cp -a runtime/syntax runtime/syntax.orig echo "Fetching vim syntax updates from ftp.nluug.nl..." rsync -avzcP ftp.nluug.nl::Vim/runtime/syntax/ runtime/syntax/ diff -u -r --new-file runtime/syntax.orig runtime/syntax | gzip -9c > $CWD/vim-runtime-syntax-$(date +%Y%m%d).diff.gz rm -rf runtime/syntax mv runtime/syntax.orig runtime/syntax fi # Apply the syntax update: zcat $CWD/vim-runtime-syntax-*.diff.gz | patch -p0 --verbose || exit 1 # Apply patches: for file in $CWD/patches/?.?.???.gz $CWD/patches/?.?.????.gz ; do if [ -f $file ]; then zcat $file | patch -p0 --verbose || exit 1 fi done # Configure: config_vim \ --without-x \ --disable-gui || failconfig # Build: make $NUMJOBS || failmake # Install into package: make install DESTDIR=$PKG rsync -lprvt $PKG/usr/share/man/ $PKG/usr/man/ rm -r $PKG/usr/share/man cp -a runtime/vimrc_example.vim runtime/vimrc.new # Don't make backups in /var/spool/cron/*, which fixes "crontab -e": zcat $CWD/vim.vimrc.diff.gz | patch -p1 --verbose || exit 1 # Add patched vimrc to the package: cat runtime/vimrc.new > $PKG/usr/share/vim/vimrc.new # Legacy binary links: ( cd $PKG/usr/bin ; rm -rf ex ) ( cd $PKG/usr/bin ; ln -sf vim ex ) ( cd $PKG/usr/bin ; rm -rf rview ) ( cd $PKG/usr/bin ; ln -sf vim rview ) ( cd $PKG/usr/bin ; rm -rf rvim ) ( cd $PKG/usr/bin ; ln -sf vim rvim ) ( cd $PKG/usr/bin ; rm -rf view ) ( cd $PKG/usr/bin ; ln -sf vim view ) ( cd $PKG/usr/bin ; rm -rf eview ) ( cd $PKG/usr/bin ; ln -sf vim eview ) ( cd $PKG/usr/bin ; rm -rf evim ) ( cd $PKG/usr/bin ; ln -sf vim evim ) # Copy docs: mkdir -p $PKG/usr/doc/$PKGNAM-$VIMVER.$PATCHLEVEL cp -a README.txt $PKG/usr/doc/$PKGNAM-$VIMVER.$PATCHLEVEL ( cd $PKG/usr/doc/$PKGNAM-$VIMVER.$PATCHLEVEL ; rm -rf doc ) ( cd $PKG/usr/doc/$PKGNAM-$VIMVER.$PATCHLEVEL ; ln -sf /usr/share/vim/vim$DIRVER doc ) # Package description & install script: mkdir -pm755 $PKG/install install -m644 $CWD/slack-desc.vim $PKG/install/slack-desc cat << EOF > $PKG/install/doinst.sh #!/bin/sh config() { NEW="\$1" OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... } config usr/share/vim/vimrc.new EOF zcat $CWD/doinst.sh.gz >> $PKG/install/doinst.sh ##################################################################### # Start fake root server: start_fakeroot # start the fakeroot server so we can set ownerships # Set generic Slackware packaging policies: cd $PKG slackstripall # strip all .a archives and all ELFs slackgzpages -i # compress man & info pages and delete usr/info/dir slackslack # set all files to root.root, chmod -R og-w, slackchown, slack644docs # Supplement the VERSION with the patch level: VERSION=$VERSION.$PATCHLEVEL export SLACKPACKAGE=$PKGNAM-$VERSION-$PKGARCH-$BUILD.tgz slackmp # run makepkg -l y -c n # Perform any final checks on the package: cd $PKG slackhlinks # search for any hard links