forked from cms-tau-pog/NanoProd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.sh
More file actions
103 lines (90 loc) · 3.51 KB
/
Copy pathenv.sh
File metadata and controls
103 lines (90 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
function run_cmd {
"$@"
RESULT=$?
if (( $RESULT != 0 )); then
echo "Error while running '$@'"
kill -INT $$
fi
}
do_install_cmssw() {
local this_file="$( [ ! -z "$ZSH_VERSION" ] && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "$this_file" )" && pwd )"
export SCRAM_ARCH=$1
local CMSSW_VER=$2
local os_version=$3
if ! [ -f "$this_dir/soft/CentOS$os_version/$CMSSW_VER/.installed" ]; then
run_cmd mkdir -p "$this_dir/soft/CentOS$os_version"
run_cmd cd "$this_dir/soft/CentOS$os_version"
run_cmd source /cvmfs/cms.cern.ch/cmsset_default.sh
if [ -d $CMSSW_VER ]; then
echo "Removing incomplete $CMSSW_VER installation..."
run_cmd rm -rf $CMSSW_VER
fi
echo "Creating $CMSSW_VER area for CentOS$os_version in $PWD ..."
run_cmd scramv1 project CMSSW $CMSSW_VER
run_cmd cd $CMSSW_VER/src
run_cmd eval `scramv1 runtime -sh`
run_cmd ln -s "$this_dir" NanoProd
run_cmd scram b -j8
run_cmd cd "$this_dir"
run_cmd touch "$this_dir/soft/CentOS$os_version/$CMSSW_VER/.installed"
fi
}
install_cmssw() {
local this_file="$( [ ! -z "$ZSH_VERSION" ] && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "$this_file" )" && pwd )"
local scram_arch=$1
local cmssw_version=$2
local os_version=$3
local target_os_version=$4
if [[ $os_version == $target_os_version ]]; then
local env_cmd=""
local env_cmd_args=""
else
if [[ $target_os_version < 8 ]] ; then
local os_type="cc"
else
local os_type="el"
fi
local env_cmd="cmssw-$os_type$target_os_version"
if ! command -v $env_cmd &> /dev/null; then
echo "Unable to do a cross-platform installation for $cmssw_version SCRAM_ARCH=$scram_arch. $env_cmd is not available."
return 1
fi
local env_cmd_args="--command-to-run"
fi
if ! [ -f "$this_dir/soft/CentOS$target_os_version/$CMSSW_VER/.installed" ]; then
run_cmd $env_cmd $env_cmd_args /usr/bin/env -i HOME=$HOME bash "$this_file" install_cmssw $scram_arch $cmssw_version $target_os_version
fi
}
action() {
# determine the directory of this file
local this_file="$( [ ! -z "$ZSH_VERSION" ] && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "$this_file" )" && pwd )"
export PYTHONPATH="$this_dir:$PYTHONPATH"
export LAW_HOME="$this_dir/.law"
export LAW_CONFIG_FILE="$this_dir/NanoProd/config/law.cfg"
export ANALYSIS_PATH="$this_dir"
export ANALYSIS_DATA_PATH="$ANALYSIS_PATH/data"
export X509_USER_PROXY="$ANALYSIS_DATA_PATH/voms.proxy"
run_cmd mkdir -p "$ANALYSIS_DATA_PATH"
local os_version=$(cat /etc/os-release | grep VERSION_ID | sed -E 's/VERSION_ID="([0-9]+).*"/\1/')
local default_cmssw_ver=CMSSW_13_0_7
export DEFAULT_CMSSW_BASE="$ANALYSIS_PATH/soft/CentOS$os_version/$default_cmssw_ver"
run_cmd install_cmssw slc7_amd64_gcc11 $default_cmssw_ver $os_version 7
run_cmd install_cmssw el8_amd64_gcc11 $default_cmssw_ver $os_version 8
if [ ! -z $ZSH_VERSION ]; then
autoload bashcompinit
bashcompinit
fi
source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_102 x86_64-centos${os_version}-gcc11-opt
source /afs/cern.ch/user/m/mrieger/public/law_sw/setup.sh
source "$( law completion )" ""
alias cmsEnv="env -i HOME=$HOME ANALYSIS_PATH=$ANALYSIS_PATH X509_USER_PROXY=$X509_USER_PROXY DEFAULT_CMSSW_BASE=$DEFAULT_CMSSW_BASE $ANALYSIS_PATH/RunKit/cmsEnv.sh"
}
if [ "X$1" = "Xinstall_cmssw" ]; then
do_install_cmssw "${@:2}"
else
action "$@"
fi