# This script should be sourced, not run.
# EMBOSS UPDATE.
# it assumes \$packages_dir/EMBOSS is a symbolic link to 
# $mirror_dir/emboss.open-bio.org/pub/EMBOSS
#

#site specific variables: season according to taste..

set mirror_dir=('/ftp/mirrors')
set packages_dir=('/site/newprog')
set emboss_config_options=\
('--prefix=/site/prog/emboss --with-pngdriver=/site/lib')

# Now the script proper

set oldpwd=`pwd`

cd $mirror_dir
echo 'updating EMBOSS'
if ( `wget -m 'ftp://emboss.open-bio.org/pub/EMBOSS' |&amp; \
  tail -1 | awk '/^Downloaded:/{print $5}'` != "0" ) then 

    cd ${packages_dir}/EMBOSS
    echo 'new EMBOSS programs found .. installing'
    set latest_emboss=`ls -t EMBOSS*|head -1`

    cd $packages_dir
    rm -Rf EMBOSS-*
    tar zxf EMBOSS/\$latest_emboss
    set emboss_dir=`ls -dt EMBOSS-*[^z]|head -1`

#the next line is necessary on our system but may not be for yours.
    setenv LD_LIBRARYN32_PATH /site/lib

    cd $emboss_dir

# If you have any site specific changes to the source code 
# that you want to include, copy them in here

    ./configure \$emboss_config_options &amp;&amp;\
    make &amp;&amp; \
    make install

#Now unpack and build EMBASSY

    mkdir embassy
    cd embassy

#Unpack and build each package one at a time

    foreach embassadir ( `ls ../../EMBOSS/*gz |grep -v E
MBOSS-` )

	tar zxf $embassadir
	set embassadir_arch=$embassadir:t
	set embassadir_root=$embassadir_arch:r

	cd $embassadir_root:r
	./configure  $emboss_config_options &amp;&amp;\
	make &amp;&amp; \
	make install

	cd ..
    end
else
    echo 'No new version of EMBOSS available'
endif

cd $oldpwd
