#!/bin/bash # # Blueprint to build elvis-2.2_0. # # elvis is a 'vi' editor clone. # # Source code is from: ftp://ftp.cs.pdx.edu/pub/elvis/ # # This architect blueprint is copyright (c)2003-2004 David Horton # dhorton@nospam.speakeasy.net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to: # # Free Software Foundation, Inc. # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # # # Define the package name, source directory, build directory and # staging directory paths. Prefixes to directories may be overridden # by setting shell variables SRC, BUILD and STAGING. For example, # doing "export SRC=/root/foo" before calling this script will override # the default /usr/src and set SRC_DIR to /root/foo/$PKG_NAME instead. # PKG_NAME=$(basename $0) SRC_DIR=${SRC:-/usr/src}/$PKG_NAME BUILD_DIR=${BUILD:-/var/tmp/build}/$PKG_NAME STAGING_DIR=${STAGING:-/var/tmp/staging}/$PKG_NAME # # Check that the source directory really exits and bail out if not. if ! [ -d $SRC_DIR ]; then echo "$PKG_NAME: Cannot find source code directory $SRC_DIR." exit 1 fi # # Do not overwrite existing build directory. if [ -d $BUILD_DIR ]; then echo "$PKG_NAME: Build directory $BUILD_DIR already exists." exit 2 else mkdir -p $BUILD_DIR fi # # Do not overwrite existing staging directory. if [ -d $STAGING_DIR ]; then echo "$PKG_NAME: Staging directory $STAGING_DIR already exists." exit 4 else mkdir -p $STAGING_DIR fi # # This is not one of the packages that can be configured and built # completely outside of the source tree. So in order to leave the # original source untouched, the contents of $SRC_DIR are first copied # to $BUILD_DIR. The copy in $BUILD_DIR is then modified to suit the # configuration. cp -dpR $SRC_DIR/* $BUILD_DIR # # Configure the package. export CC="gcc -mcpu=i386" cd $BUILD_DIR MANPATH=/usr/share/man \ ./configure \ --host=i386-pc-linux-gnu \ --libs=-lncurses \ --prefix=/usr \ --without-gnome \ --without-x \ --without-xft # Make changes to the Makefile so that /etc/elvis/ is created in the # staging area and not in the development system's /etc directory. mv Makefile Makefile.orig sed -e 's!/etc/elvis!$(ETCDIR)/elvis!g' Makefile.orig >Makefile # # Check return status and bail out if it's non-zero. if [ $? -gt 0 ]; then echo "$PKG_NAME: Configuration failed!" exit 8 fi # Build the package. make # # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Build failed!" exit 16 fi # # Install into staging area. mkdir -p $STAGING_DIR/etc mkdir -p $STAGING_DIR/usr/share/man/man1 make \ ETCDIR=$STAGING_DIR/etc \ MANPATH=$STAGING_DIR/usr/share/man \ PREFIX=$STAGING_DIR/usr \ install # # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "$PKG_NAME: Installation to staging area failed!" exit 32 fi # # Post-install tweaking # # The etc/elvis/README file needs to be adjusted because every reference # to a path now says /var/tmp/staging/elvis-2.2_0/. mv $STAGING_DIR/etc/elvis/README $STAGING_DIR/etc/elvis/README.orig sed \ -e "s#$STAGING_DIR##g" \ -e "s/echo //g" \ $STAGING_DIR/etc/elvis/README.orig > $STAGING_DIR/etc/elvis/README rm $STAGING_DIR/etc/elvis/README.orig # # The same thing needs to be done to usr/share/elvis/README. mv $STAGING_DIR/usr/share/elvis/README $STAGING_DIR/usr/share/elvis/README.orig sed \ -e "s#$STAGING_DIR##g" \ $STAGING_DIR/usr/share/elvis/README.orig > $STAGING_DIR/usr/share/elvis/README rm $STAGING_DIR/usr/share/elvis/README.orig # # Make symbolic links for ex, vi and view that point to elvis. ln -s elvis $STAGING_DIR/usr/bin/ex ln -s elvis $STAGING_DIR/usr/bin/vi ln -s elvis $STAGING_DIR/usr/bin/view # # Create manpages for ex, vi and view that open elvis(1) using the groff # include directive. echo ".so elvis.1" >$STAGING_DIR/usr/share/man/man1/ex.1 echo ".so elvis.1" >$STAGING_DIR/usr/share/man/man1/vi.1 echo ".so elvis.1" >$STAGING_DIR/usr/share/man/man1/view.1 # # end of elvis blueprint