Commit 93948752 authored by Andrea Valassi's avatar Andrea Valassi
Browse files

Comprehensive review of logical/physical paths in reloaction as in CORAL

(CORALCOOL-2876)


git-svn-id: file:///git/lcgcool.svndb/cool/trunk@19934 4525493e-7705-40b1-a816-d608a930855b
parent 8bf3b9f4
......@@ -299,7 +299,7 @@ function(_coral_write_env_conf filename)
<env:config xmlns:env=\"EnvSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"EnvSchema EnvSchema.xsd \">\n")
foreach(root_var ${root_vars})
get_filename_component(_path ${${root_var}} REALPATH) # see CORALCOOL-2836
get_filename_component(_path ${${root_var}} REALPATH) # see CORALCOOL-2836 and CORALCOOL-2876
set(data "${data} <env:default variable=\"${root_var}\">${_path}</env:default>\n")
endforeach()
......
......@@ -5,7 +5,6 @@ if [ "$BASH_SOURCE" != "$0" ]; then # See CORALCOOL-2823
fi
topdirl=`dirname $0`
topdirl=`cd $topdirl; pwd -L`
topdirp=`cd $topdirl; pwd -P`
# Check optional arguments
msg=0
......@@ -23,78 +22,152 @@ if [ "$1" == "" ]; then
exit 1
fi
# Override CORALSYS/COOLSYS and LCG_releases_base if this installation
# was relocated (CORALCOOL-2829; new relocation replacing CORALCOOL-2787)
# Relocate also python and all other externals for relocations out of lcgcmake
# If pythonExecutable is not found, try appending LCG_VERSION (CORALCOOL-2856)
envxml=$topdirp/env/@env_xml_basename@
# Read original CORALSYS/COOLSYS and LCG_releases_base from project xenv
# [NB these values are always REALPATHs! see CORALCOOL-2876 and CORALCOOL-2836]
envxml=$topdirl/env/@env_xml_basename@
project=`basename $envxml .xenv`
projsysold=`more $envxml | grep variable=\"${project}SYS\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
lcgrelold=`more $envxml | grep variable=\"LCG_releases_base\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ "$msg" == "v" ]; then
echo ""
echo "[DEBUG] Read build-time values from $envxml"
echo "[DEBUG] old -> ${project}SYS = $projsysold"
echo "[DEBUG] old -> LCG_releases_base = $lcgrelold"
fi
# Do original CORALSYS/COOLSYS and LCG_releases_base respect lcgcmake policies?
# [NB this check is not always needed, but we do it here for better readability]
# [NB the check makes sense as both are REALPATHs, see above and CORALCOOL-2876]
lcgrelold_lcgcmake=`dirname $projsysold`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
if [ "$lcgrelold" == "$lcgrelold_lcgcmake" ]; then
if [ "$msg" == "v" ]; then
echo "[DEBUG] Build-time values are consistent with lcgcmake paths"
fi
lcgcmake_paths=1
else
if [ "$msg" == "v" ]; then
echo "[DEBUG] Build-time values are NOT consistent with lcgcmake paths"
fi
lcgcmake_paths=0
fi
# Read original pythonExecutable from this file cc-run
# [NB pythonExecutable from lcgcmake contains the package version without hash]
# [NB lcgversion is not always needed, but we do it here for better readability]
pythonExecutable=@PYTHON_EXECUTABLE_CCPATH@ # may start by {LCG_releases_base}
lcgversion=@LCG_VERSION@
lcgrelold=`more $envxml | grep variable=\"LCG_releases_base\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ "$msg" == "v" ]; then
echo "[DEBUG] envxml is $envxml"
echo "[DEBUG] lcgrelold is $lcgrelold"
echo ""
echo "[DEBUG] Read build-time values from cc-run"
echo "[DEBUG] old -> python = $pythonExecutable"
echo "[DEBUG] old -> LCG_VERSION = $lcgversion"
echo ""
fi
# Check if LCG_releases_base has been set before calling this script
# Determine the path to the python executable accordingly
if [ "$LCG_releases_base" != "" ]; then
pythonExecutable=`echo ${pythonExecutable} | sed "s|^{LCG_releases_base}|${LCG_releases_base}|"`
if [ "$msg" == "v" ]; then
echo "[DEBUG] LCG_releases_base is $LCG_releases_base"
echo "[DEBUG] LCG_releases_base found in environment: OVERRIDE it"
echo "[DEBUG] new -> LCG_releases_base = $LCG_releases_base"
echo "[DEBUG] new -> python = $pythonExecutable"
echo ""
fi
pythonExecutable=`echo ${pythonExecutable} | sed "s|{LCG_releases_base}|${LCG_releases_base}|"`
else
pythonExecutable=`echo ${pythonExecutable} | sed "s|{LCG_releases_base}|${lcgrelold}|"`
pythonExecutable=`echo ${pythonExecutable} | sed "s|^{LCG_releases_base}|${lcgrelold}|"`
if [ "$msg" == "v" ]; then
echo "[DEBUG] LCG_releases_base NOT found in environment: use xenv value"
echo "[DEBUG] new -> LCG_releases_base = $lcgrelold"
echo "[DEBUG] new -> python = $pythonExecutable"
echo ""
fi
fi
project=`basename $envxml .xenv`
projsysold=`more $envxml | grep variable=\"${project}SYS\" | tr "<" " " | tr ">" " " | awk '{print $3}'`
if [ -d $projsysold ]; then projsysold=`cd $projsysold; pwd -P`; fi
# Is this directory in the original location determined by 'make install'
# or was this relocated elsewhere (eg via lcgcmake rpm installation)?
projsysnew=$topdirl
if [ -d $projsysold ]; then projsysoldp=`cd $projsysold; pwd -P`; fi
if [ -d $projsysnew ]; then projsysnewp=`cd $projsysnew; pwd -P`; fi
if [ "$msg" == "v" ]; then
echo "[DEBUG] projsysold is $projsysold"
echo "[DEBUG] projsysnew is $projsysnew"
echo "[DEBUG] Is this directory in its original build-time location?"
echo "[DEBUG] old -> ${project}SYS = $projsysold"
echo "[DEBUG] new -> ${project}SYS = $projsysnew"
echo "[DEBUG] Resolve all symlinks before comparing original and current locations"
echo "[DEBUG] old (phys) -> ${project}SYS = $projsysoldp"
echo "[DEBUG] new (phys) -> ${project}SYS = $projsysnewp"
echo ""
fi
if [ "$projsysnew" != "$projsysold" ]; then # project was relocated
# Override CORALSYS/COOLSYS if relocated (CORALCOOL-2829, CORALCOOL-2876)
if [ "$projsysnewp" == "$projsysoldp" ]; then
if [ "$msg" == "v" ]; then
echo "[DEBUG] This directory is in its original build-time location"
echo "[DEBUG] new -> ${project}SYS = $projsysold"
echo ""
fi
else
if [ "$project" == "CORAL" ]; then
export CORALSYS=$projsysnew
else
export COOLSYS=$projsysnew
fi
if [ "$LCG_releases_base" == "" ]; then
lcgrelold_lcgcmake=`dirname $projsysold`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
lcgrelold_lcgcmake=`dirname $lcgrelold_lcgcmake`
if [ "$msg" == "v" ]; then
echo "[DEBUG] This directory was moved: OVERRIDE ${project}SYS"
echo "[DEBUG] new -> ${project}SYS = $projsysnew"
echo ""
fi
# If LCG_releases_base has been set before calling this script,
# use the externally provided value: nothing else to do here
if [ "$LCG_releases_base" != "" ]; then
if [ "$msg" == "v" ]; then
echo "[DEBUG] LCG_releases_base found in environment: keep it"
echo ""
fi
# Override LCG_releases_base (including python and all other externals)
# if installation was relocated AND it follows lcgcmake path policies
else
if [ "$msg" == "v" ]; then
echo "[DEBUG] lcgrelold_lcgcmake is $lcgrelold_lcgcmake"
echo "[DEBUG] LCG_releases_base NOT found in environment"
fi
if [ "$lcgrelold" == "$lcgrelold_lcgcmake" ]; then # lcgcmake dir structure
lcgrelnew_lcgcmake=`dirname $projsysnew`
lcgrelnew_lcgcmake=`dirname $lcgrelnew_lcgcmake`
lcgrelnew_lcgcmake=`dirname $lcgrelnew_lcgcmake`
if [ "$lcgcmake_paths" == "0" ]; then
if [ "$msg" == "v" ]; then
echo "[DEBUG] lcgrelnew_lcgcmake is $lcgrelnew_lcgcmake"
# Example: relocated local CORAL build against fixed LCG_release_base
echo "[DEBUG] Build-time LCG_releases_base NOT consistent with lcgcmake: keep as-is"
fi
export LCG_releases_base=$lcgrelnew_lcgcmake
pythonExecutable=`echo ${pythonExecutable} | sed "s|${lcgrelold_lcgcmake}|${lcgrelnew_lcgcmake}|"`
else
lcgrelnew=`dirname $projsysnew`
lcgrelnew=`dirname $lcgrelnew`
lcgrelnew=`dirname $lcgrelnew`
export LCG_releases_base=$lcgrelnew
pythonExecutable=`echo ${pythonExecutable} | sed "s|^${lcgrelold}|${lcgrelnew}|"`
if [ "$msg" == "v" ]; then
echo "[DEBUG] Build-time LCG_releases_base consistent with lcgcmake: OVERRIDE it"
echo "[DEBUG] new -> LCG_releases_base = $LCG_releases_base"
echo "[DEBUG] new -> python = $pythonExecutable"
echo ""
fi
# If pythonExecutable is not found, append LCG_VERSION (CORALCOOL-2856)
if [ ! -f ${pythonExecutable} ] && [ "$lcgversion" != "" ]; then
lcgrelnew_lcgcmake2=$lcgrelnew_lcgcmake/$lcgversion
lcgrelnew2=$lcgrelnew/LCG_$lcgversion
export LCG_releases_base=$lcgrelnew2
pythonExecutable=`echo ${pythonExecutable} | sed "s|^${lcgrelnew}|${lcgrelnew2}|"`
if [ "$msg" == "v" ]; then
echo "[DEBUG] lcgrelnew_lcgcmake2 is $lcgrelnew_lcgcmake2"
echo "[DEBUG] Python not found: OVERRIDE it by appending LCG_VERSION"
echo "[DEBUG] new -> LCG_releases_base = $LCG_releases_base"
echo "[DEBUG] new -> python = $pythonExecutable"
echo ""
fi
export LCG_releases_base=$lcgrelnew_lcgcmake2
pythonExecutable=`echo ${pythonExecutable} | sed "s|${lcgrelnew_lcgcmake}|${lcgrelnew_lcgcmake2}|"`
fi
else
: # noop (e.g. relocated local CORAL build against fixed LCG_release_base)
fi
fi
fi
if [ "$msg" == "v" ]; then
echo "[DEBUG] pythonExecutable is $pythonExecutable"
fi
# Old workaround for CORALCOOL-2803 on cc7
# [This was wrong as it did not identify and fix the real issue!]
###export PYTHONHOME=`dirname ${pythonExecutable}`
###export PYTHONHOME=`dirname ${PYTHONHOME}`
# Add protections against pre-existing PYTHONHOME and PYTHONPATH
# Protections against pre-existing PYTHONHOME and PYTHONPATH (CORALCOOL-2803)
unset PYTHONHOME
unset PYTHONPATH
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment