From 65f2a73630c79d2a10618c26d566dabefd44d0b4 Mon Sep 17 00:00:00 2001
From: Ger van Diepen <diepen@astron.nl>
Date: Fri, 15 Aug 2008 06:13:34 +0000
Subject: [PATCH] bug 1221: Set LOFARDATAROOT correctly

---
 LCS/Tools/src/lofarinit.csh | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/LCS/Tools/src/lofarinit.csh b/LCS/Tools/src/lofarinit.csh
index 9428a62ee0a..3cce1a26dff 100644
--- a/LCS/Tools/src/lofarinit.csh
+++ b/LCS/Tools/src/lofarinit.csh
@@ -83,6 +83,21 @@ else
         setenv PYTHONPATH ${a_pyt}:$PYTHONPATH
     endif
 
+    # Now define the new LOFARDATAROOT (if possible).
+    # First try as data directory of the LOFAR install directory.
+    set data_path = `echo $LOFARROOT | sed -e 's%/installed.*%%'`
+    if ( "$data_path" != ""  &&  -d $data_path/data ) then
+        setenv LOFARDATAROOT $data_path/data
+    else
+        # Try it as the LOFARDATA directory (part of the source tree).
+        set data_path = `echo $LOFARROOT | sed -e 's%/LOFAR/.*%/LOFAR%'`
+        if ( "$data_path" != ""  &&  -d ${data_path}DATA ) then
+            setenv LOFARDATAROOT ${data_path}DATA
+        else
+            setenv LOFARDATAROOT /opt/lofar/data
+        endif
+    endif
+
     # Create a .glishrc.post in the HOME directory to append
     # the LOFAR libexec to the glish path.
     if ( -f $HOME/.glishrc.post ) then
@@ -90,11 +105,4 @@ else
     endif
     echo "system.path.include := [system.path.include, '$LOFARROOT/libexec/glish']" > $HOME/.glishrc.post
 
-    # Now define the new LOFARDATAROOT
-    set data_path = `echo $LOFARROOT | sed -e 's/\/installed.*$//'`
-    if ( ! -d $data_path/data ) then
-       mkdir $data_path/data
-    endif
-    setenv LOFARDATAROOT $data_path/data
-
 endif
-- 
GitLab