#! /bin/bash # script to deduce ICEDUST_HOME and ICEDUST_PROJECT variables usage () { cat <&1 |tee $DebugStream |grep 'ICEDUST_packages\.git' &> "$DebugStream" ; then IcedustHome="`dirname "$LocalGitTopLevel"`" IcedustProject="`basename "$IcedustHome"`" IcedustHome="`dirname "$IcedustHome"`" elif git remote -v 2>&1 |tee $DebugStream |grep 'ICEDUST_externals_.*\.git' &> "$DebugStream" ; then IcedustHome="`dirname "$LocalGitTopLevel"`" IcedustHome="`dirname "$IcedustHome"`" IcedustProject="`basename "$IcedustHome"`" IcedustHome="`dirname "$IcedustHome"`" elif git remote -v 2>&1 |tee $DebugStream |grep 'ICEDUST_repository\.git' &> "$DebugStream" ; then #IcedustProject="`basename "$LocalGitTopLevel"`" IcedustHome="`dirname "$LocalGitTopLevel"`" else Error="ICEDUST_HOME not set, ICEDUST_PROJECT not set and the current git repository doesn't look setup for ICEDUST. Need more information..." fi elif [ -d packages ] && [ -d cmt ]; then IcedustProject="`basename "$(pwd)"`" IcedustHome="`dirname "$(pwd)"`" elif [ -d CMT ] && [ -d cmake ] && [ -d documentation ]; then IcedustHome="`pwd`" #IcedustProject="`basename "$(pwd)"`" else Error="ICEDUST_HOME not set, ICEDUST_PROJECT not set and not in a git version controlled directory. Need more information..." fi fi if [ -z "$Error" ] && [ -n "$IcedustHome" ];then if [ -z "$IcedustProject" ];then # Don't have ICEDUST_PROJECT if pwd | grep "$IcedustHome" &>$DebugStream ; then IcedustProject="`pwd | sed -e 's!^.*'"$IcedustHome"'/\?\([^/]*\).*!\1!'`" else Error="ICEDUST_PROJECT not set, ICEDUST_HOME set, but not in a working directory that contains the ICEDUST_HOME path." fi elif pwd | grep "$IcedustHome" &>$DebugStream ; then IcedustHome="`pwd | sed -e 's!^\(.*'"$IcedustHome"'\)/.*!\1!'`" fi fi # did we have an error? if [ -n "$Error" ];then echo "icedust-home: Error: $Error" exit 1 fi [ -z "$IcedustHome" ] && IcedustHome="$ICEDUST_HOME" [ -z "$IcedustProject" ] && IcedustProject="$ICEDUST_PROJECT" # output for subsequent programs to use echo -n "ICEDUST_HOME=$IcedustHome;" echo "ICEDUST_PROJECT=$IcedustProject;"