[Bio] / FigCommon / configure-env Repository:
ViewVC logotype

View of /FigCommon/configure-env

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (annotate)
Wed Dec 3 18:14:02 2003 UTC (16 years, 7 months ago) by efrank
Branch: MAIN
CVS Tags: delong-01, delong-02
Changes since 1.2: +35 -0 lines

add creation of fig-user-env.csh

#!/bin/sh

#
# FIG/SEED configuration script
#
# This script takes as an argument the name of the environment
# that we are configuring for.  It takes a second argument specifying
# the path to the code installation, i.e., the dirname under which we
# can find FigKernelPackages, bin, and CGI.  This is no longer the same
# as where the data are installed
#
# If no argument is passed, a list of valid environment names will be
# displayed.
#
# 
# We configure the following files (all paths relative to the top 
# of the FIGdisk directory):
#
# NOTE:  all these are now made in ., not in the directories shown.
# That's because this is now called from a makefile, e.g., and the
# caller is responsible for mv'ing them to the right place.
#
# fig-user-env.sh
# FIG/Packages/FIG_Config.pm
# FIG/Packages/FIG_Config.py
# FIG/tool_hdr
# FIG/tool_hdr_py
# bin/start-servers
# bin/stop-servers
# 
########################################################################

#
# Where the output files are to be placed
#
GenDir=`pwd`

#
# Figure out where we are; set the FIG_HOME and 
# EnvDir values.
#
# Now that the code is in one place and the core stuff and
# data are in another, we can't assume we are building in
# the root of the FIG installation.
#
# Take it from the env for now.  Ick

#FIG_HOME=`pwd`
echo "Using FIG_HOME=$FIG_HOME"


#
# Make sure we're running from a real FIGdisk directory, i.e.,
# that FIG_HOME is set right.
#
if [ ! -d $FIG_HOME/env -o ! -d $FIG_HOME/FIG ] ; then
    echo "Please set FIG_HOME correctly"
    exit
fi


#
# Determine what environments are present.
#

AvailableEnvironments=""
for d in $FIG_HOME/env/* ; do
    e=`basename $d`
    AvailableEnvironments="$AvailableEnvironments $e"
done

if [ $# -ne 2 ] ; then
    echo "Usage: $0 environment-name pathToCodeInstallation"
    echo "Available environments: $AvailableEnvironments"
    exit
fi

#
# Check to see if the user picked a valid environment.
#

if [ ! -d "$FIG_HOME/env/$1" ] ; then
    echo "Invalid environment name $1"
    echo "Available environments: $AvailableEnvironments"
    exit
fi

Env=$1

EnvDir=$FIG_HOME/env/$Env

if [ ! -d $EnvDir ] ; then
    echo "Environment directory $Env does not exist, exiting"
    exit
fi

#
# pull off the path to the base of the code installation
#

CodeInstallDir=$2

if [ ! -d $CodeInstallDir ] ; then
    echo "Code Installation Directory $CodeInstallDir does not exist, exiting"
    exit
fi
if [ ! -d $CodeInstallDir/FigKernelPackages ] ; then
    echo "No FigKernelPackages in $CodeInstallDir, exiting"
    exit
fi


#
# Define the tool_hdr locations.
#

ToolHeaderPerl=./tool_hdr
ToolHeaderPython=./tool_hdr_py


#
# Find python. It might be in the env dir, or it might be in the system.
#

if [ -x "$EnvDir/bin/python" ] ; then
    PythonPath=$EnvDir/bin/python
else
    PythonPath=`which python`
fi

if [ ! -x "$PythonPath" ] ; then
    echo "Could not find working python at $PythonPath"
    exit
fi

#
# Find perl. It might be in the env dir, or it might be in the system.
#

if [ -x "$EnvDir/bin/perl" ] ; then
    PerlPath=$EnvDir/bin/perl
else
    PerlPath=`which perl`
fi

if [ ! -x "$PerlPath" ] ; then
    echo "Could not find working perl at $PerlPath"
    exit
fi

#
# Compute python version.
#

PythonVersion=`$PythonPath -c 'import sys; print "%d.%d" % (sys.version_info[:2])'`

#
# Hostname information.
#

MyHostname=`hostname`
MyBaseURL="http://$MyHostname"

#
# Compute some paths.
#

UserPath="$CodeInstallDir/bin/$RTARCH:$FIG_HOME/FIG/bin:$FIG_HOME/bin:$EnvDir/bin"
BLASTMAT="$FIG_HOME/BLASTMAT"
OurPythonStuff="$CodeInstallDir/lib/$RTARCH:$EnvDir/lib/python$PythonVersion/site-packages"

#
# fig-user-env.sh
#

cat <<EOF >fig-user-env.sh
export FIG_HOME=$FIG_HOME
export FIG_ENVIRONMENT=$EnvDir
export FIG_PYTHON=$PythonPath
export FIG_PERL=$PerlPath

export PATH=\${PATH}:$UserPath

DELIM=
if [ -n "\$PYTHONPATH" ] ; then
    DELIM=:
fi
export PYTHONPATH=\${PYTHONPATH}\${DELIM}$OurPythonStuff

export BLASTMAT=$BLASTMAT

EOF

#
# fig-user-env.csh
#

cat <<EOF >fig-user-env.csh

#
# This file is automatically generated by configure-env
# Do not edit by hand, or changes may be lost.
#

setenv FIG_HOME $FIG_HOME
setenv FIG_ENVIRONMENT $EnvDir
setenv FIG_PYTHON $PythonPath
setenv FIG_PERL $PerlPath

setenv PATH \${PATH}:$UserPath

if (\$?PYTHONPATH) then
    setenv PYTHONPATH \${PYTHONPATH}:$OurPythonStuff
else
    setenv PYTHONPATH $OurPythonStuff
endif

if (\$?LD_LIBRARY_PATH) then
    setenv LD_LIBRARY_PATH \${LD_LIBRARY_PATH}:$EnvDir/lib
else
    setenv LD_LIBRARY_PATH $EnvDir/lib
endif

setenv BLASTMAT $BLASTMAT

EOF


#
# FIG_Config.pm
#

cat <<EOF > FIG_Config.pm
package FIG_Config;

# Each setting of a variable MUST be on a single line.  We use code during
# updates to salvage local settings, which will lead to a disaster if you
# do not conform to this rule.

\$fig_disk    = "$FIG_HOME";
\$blastmat    = "\$fig_disk/BLASTMAT";
\$fig         = "\$fig_disk/FIG";
\$bin         = "$CodeInstallDir/bin/$RTARCH";
\$ext_bin     = "$EnvDir/bin";
\$data        = "\$fig/Data";
\$global      = "\$data/Global";
\$organisms   = "\$data/Organisms";
\$RC          = "\$fig_disk/FIG/ResolutionCenter";
\$NR          = "\$fig_disk/FIG/NR";
\$temp        = "\$fig_disk/FIG/Tmp";
\$temp_url    = "$MyBaseURL/FIG-Tmp";
\$cgi_url     = "$MyBaseURL/FIG";

EOF

#
# FIG_Config.py
#

cat <<EOF > FIG_Config.py

import os.path

# Each setting of a variable MUST be on a single line.  We use code during
# updates to salvage local settings, which will lead to a disaster if you
# do not conform to this rule.

fig_disk    = "$FIG_HOME"
blastmat    = os.path.join(fig_disk, "BLASTMAT")
fig         = os.path.join(fig_disk, "FIG")
bin         = os.path.join("$CodeInstallDir/bin/$RTARCH/", "bin")
ext_bin     = os.path.join("$EnvDir", "bin")
data        = os.path.join(fig, "Data")
global_dir      = os.path.join(data, "Global")
organisms   = os.path.join(data, "Organisms")
RC          = os.path.join(fig, "ResolutionCenter")
NR          = os.path.join(fig, "NR")
temp        = os.path.join(fig, "Tmp")
temp_url    = "$MyBaseURL/FIG-Tmp"
cgi_url     = "$MyBaseURL/FIG"

EOF

#
# Tool header.
#

cat <<EOF > $ToolHeaderPerl
#!$PerlPath

use Data::Dumper;
use Carp;

use lib "$CodeInstallDir/lib/$RTARCH/FigKernelPackages";

use FIG_Config;

EOF

cat <<EOF > $ToolHeaderPython
#!$PythonPath


EOF

#
# Start and stop servers scripts.
#

cat <<EOF > start-servers
#!/bin/sh

EOF
chmod +x start-servers

cat <<EOF > stop-servers
#!/bin/sh

EOF
chmod +x stop-servers


#
# Do environment-specific configurations.  We pass the path in
# which the config tools are to find the files to modify
# 

if [ -f $EnvDir/configure-env-specific ] ; then
    . $EnvDir/configure-env-specific $GenDir
fi


#
# Make sure this file ends properly for a perl module.
#
echo "1;" >> FIG_Config.pm


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3