diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df7b3ce --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.tmp diff --git a/create_setup_scripts.sh b/create_setup_scripts.sh new file mode 100755 index 0000000..96e4543 --- /dev/null +++ b/create_setup_scripts.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +function create_script { + gt=`echo $gluex_top | sed -e 's./.\\\\/.g'` + sed -e "s//${gt}/" < $gi_path/$name.template > $1 +} + +gi_path=$1 +gluex_top=$2 +for name in gluex_env_boot.sh gluex_env_boot.csh gluex_env_local.sh gluex_env_local.csh; do + echo creating script $name + create_script $name +done + diff --git a/gluex_env_boot.csh.template b/gluex_env_boot.csh.template new file mode 100644 index 0000000..17b80ef --- /dev/null +++ b/gluex_env_boot.csh.template @@ -0,0 +1,6 @@ +setenv BUILD_SCRIPTS /build_scripts +set build_scripts_this=$BUILD_SCRIPTS +alias gxenv "source $build_scripts_this/gluex_env_clean.csh; setenv BUILD_SCRIPTS $build_scripts_this; source /gluex_env_local.csh \!*" +alias gxclean "source $build_scripts_this/gluex_env_clean.csh" +echo $PATH | grep $build_scripts_this > /dev/null +if ($status) setenv PATH ${build_scripts_this}:$PATH diff --git a/gluex_env_boot.sh.template b/gluex_env_boot.sh.template new file mode 100644 index 0000000..0c86e67 --- /dev/null +++ b/gluex_env_boot.sh.template @@ -0,0 +1,10 @@ +export BUILD_SCRIPTS=/build_scripts +build_scripts_this=$BUILD_SCRIPTS +function gxenv() { source $build_scripts_this/gluex_env_clean.sh; \ + export BUILD_SCRIPTS=$build_scripts_this; \ + source /gluex_env_local.sh $1; \ + } +function gxclean() { source $build_scripts_this/gluex_env_clean.sh; } +if [ `echo $PATH | grep -c $build_scripts_this` -eq 0 ] + then export PATH=$build_scripts_this:$PATH +fi diff --git a/gluex_env_local.csh.template b/gluex_env_local.csh.template new file mode 100644 index 0000000..b71413a --- /dev/null +++ b/gluex_env_local.csh.template @@ -0,0 +1,7 @@ +setenv GLUEX_TOP +if (! $?BUILD_SCRIPTS) setenv BUILD_SCRIPTS $GLUEX_TOP/build_scripts +setenv HALLD_VERSIONS $GLUEX_TOP/halld_versions +source $BUILD_SCRIPTS/gluex_env_version.csh $HALLD_VERSIONS/version_jlab.xml +setenv CCDB_CONNECTION mysql://ccdb_user@hallddb.jlab.org/ccdb +setenv JANA_CALIB_URL $CCDB_CONNECTION +setenv JANA_RESOURCE_DIR $GLUEX_TOP/resources diff --git a/gluex_env_local.sh.template b/gluex_env_local.sh.template new file mode 100644 index 0000000..c583480 --- /dev/null +++ b/gluex_env_local.sh.template @@ -0,0 +1,9 @@ +export GLUEX_TOP= +if [ -z "$BUILD_SCRIPTS" ] + then export BUILD_SCRIPTS=$GLUEX_TOP/build_scripts +fi +export HALLD_VERSIONS=$GLUEX_TOP/halld_versions +source $BUILD_SCRIPTS/gluex_env_version.sh $HALLD_VERSIONS/version_jlab.xml +export CCDB_CONNECTION=mysql://ccdb_user@hallddb.jlab.org/ccdb +export JANA_CALIB_URL=$CCDB_CONNECTION +export JANA_RESOURCE_DIR=$GLUEX_TOP/resources diff --git a/gluex_install.sh b/gluex_install.sh index 84e86be..b82cd2b 100755 --- a/gluex_install.sh +++ b/gluex_install.sh @@ -1,7 +1,18 @@ #!/bin/bash +# GI_PATH is the fully qualified directory that contains this script +gi_script="${BASH_SOURCE[0]}"; +if([ -h "${gi_script}" ]) then + while([ -h "${gi_script}" ]) do gi_script=`readlink "${gi_script}"`; done +fi +pushd . > /dev/null +cd `dirname ${gi_script}` > /dev/null +GI_PATH=`pwd` +popd > /dev/null +# mkdir -p gluex_top pushd gluex_top pwd_string=`pwd` +mkdir -p resources if [ -e build_scripts ] then echo build_scripts already here, skip installation @@ -12,26 +23,23 @@ else git checkout latest popd fi -export GLUEX_TOP=$pwd_string -export BUILD_SCRIPTS=$GLUEX_TOP/build_scripts -rm -fv setup.sh -echo export GLUEX_TOP=$pwd_string > setup.sh -echo export BUILD_SCRIPTS=\$GLUEX_TOP/build_scripts >> setup.sh -echo source \$BUILD_SCRIPTS/gluex_env_version.sh $pwd_string/version_jlab.xml >> setup.sh -rm -fv setup.csh -echo setenv GLUEX_TOP $pwd_string > setup.csh -echo setenv BUILD_SCRIPTS \$GLUEX_TOP/build_scripts >> setup.csh -echo source \$BUILD_SCRIPTS/gluex_env_version.csh $pwd_string/version_jlab.xml >> setup.csh -if [ -f version_jlab.xml ] +if [ -e halld_versions ] then - echo version_jlab.xml exists, skip download + echo halld_versions already here, skip installation else - echo getting version_jlab.xml from halldweb.jlab.org - wget --no-check-certificate https://halldweb.jlab.org/dist/version_jlab.xml + echo cloning halld_versions repository + git clone https://github.com/jeffersonlab/halld_versions fi -source setup.sh +$GI_PATH/create_setup_scripts.sh $GI_PATH $pwd_string +source gluex_env_local.sh make -f $BUILD_SCRIPTS/Makefile_all gluex_pass1 +if [ $? -ne 0 ] +then + echo pass 1 failed, exiting + popd + exit 1 +fi source $BUILD_SCRIPTS/gluex_env_clean.sh -source setup.sh +source gluex_env_local.sh make -f $BUILD_SCRIPTS/Makefile_all gluex_pass2 popd