CE-cms-swinst 5.15 KB
Newer Older
Christoph Wissing's avatar
Christoph Wissing committed
1
#!/bin/bash
Andrea Sciaba's avatar
Andrea Sciaba committed
2

Andrea Sciaba's avatar
Andrea Sciaba committed
3
export LANG=C
4

5
6
warning=0
error=0
7

8
9
workdir=`mktemp -d workdirXXXXXX`
cd $workdir
Andrea Sciaba's avatar
Andrea Sciaba committed
10
cp $SAME_SENSOR_HOME/tests/cmssw_required_version_list.txt .
11

Andrea Sciaba's avatar
Andrea Sciaba committed
12
13
14
isEGEE=0
isOSG=0
hasCVMFS=0
15
if [ -n "$OSG_GRID" ] ; then
16
    isOSG=1
Andrea Sciaba's avatar
Andrea Sciaba committed
17
    [ -f $OSG_GRID/setup.sh ] && source $OSG_GRID/setup.sh
18
    if [ -d $OSG_APP/cmssoft/cms ] ;then
Andrea Sciaba's avatar
Andrea Sciaba committed
19
        SW_DIR=$OSG_APP/cmssoft/cms
20
    elif [ -d $CVMFS/cms.cern.ch ] ; then
Andrea Sciaba's avatar
Andrea Sciaba committed
21
        SW_DIR=$CVMFS/cms.cern.ch
22
    elif [ -d /cvmfs/cms.cern.ch ] ; then
Andrea Sciaba's avatar
Andrea Sciaba committed
23
        SW_DIR=/cvmfs/cms.cern.ch
24
    else
Andrea Sciaba's avatar
Andrea Sciaba committed
25
26
27
        echo "ERROR: Cannot find CMS software in OSG node"
	echo "summary: SW_DIR_UNDEF"
        exit $SAME_ERROR
28
    fi
Andrea Sciaba's avatar
Andrea Sciaba committed
29
30
    echo "SwArea: $SW_DIR"
    
31
32
33
elif [ -n "$VO_CMS_SW_DIR" ] ; then
    isEGEE=1
    SW_DIR=$VO_CMS_SW_DIR
Andrea Sciaba's avatar
Andrea Sciaba committed
34
35
36
37
38
39
40
41
42
43
44
45
    echo "SwArea: $SW_DIR"

elif [ -d $CVMFS/cms.cern.ch ] ; then
    hasCVMFS=1
    SW_DIR=$CVMFS/cms.cern.ch
    echo "SwArea: $SW_DIR"

elif [ -d /cvmfs/cms.cern.ch ] ; then
    hasCVMFS=1
    SW_DIR=/cvmfs/cms.cern.ch
    echo "SwArea: $SW_DIR"

Andrea Sciaba's avatar
Andrea Sciaba committed
46
else
Andrea Sciaba's avatar
Andrea Sciaba committed
47
48
    echo "ERROR: Neither VO_CMS_SW_DIR nor OSG_GRID defined and no CVMFS"
    echo "summary: SW_DIR_UNDEF"
Andrea Sciaba's avatar
Andrea Sciaba committed
49
50
51
    exit $SAME_ERROR
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
52
53
54
if [ ! -d $SW_DIR -o ! -r $SW_DIR ] ; then
    echo "ERROR: software directory non existent or non readable"
    echo "summary: SW_DIR_NOT_READABLE"
Andrea Sciaba's avatar
Andrea Sciaba committed
55
56
57
    exit $SAME_ERROR
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
58
59
echo
echo -n "Software location: "
60
if [ "`echo $SW_DIR | cut -d / -f 2`" == "afs" ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
61
62
    echo "AFS"
    SPACE=`fs lq $SW_DIR | tail -1 | awk '{print (\$2-\$3)/1024 }'`
Christoph Wissing's avatar
Christoph Wissing committed
63
elif [ "`echo $SW_DIR | cut -d / -f 2`" == "cvmfs" ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
64
65
    hasCVMFS=1
    echo "CVMFS"
66
else
Andrea Sciaba's avatar
Andrea Sciaba committed
67
68
    echo "local"
    SPACE=`df -k -P $SW_DIR | tail -1 | awk '{print \$4/1024}'`
69
fi
Christoph Wissing's avatar
Christoph Wissing committed
70
71
# Disk space check only for non-CVMFS
if [ $hasCVMFS == 0  ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
72
    echo "FreeSWAreaSpace: $SPACE MB"
73
74
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
75
76
77
78
79
80
81
82
tmpfile=`mktemp /tmp/tmp.XXXXXXXXXX`
source $SW_DIR/cmsset_default.sh > $tmpfile 2>&1
result=$?
if [ $result != 0 ] ; then
    cat $tmpfile
    rm -f $tmpfile
    echo "ERROR: CMS software initialisation script cmsset_default.sh failed"
    echo "summary: NO_SETUP_SCRIPT"
83
84
    exit $SAME_ERROR
fi
Andrea Sciaba's avatar
Andrea Sciaba committed
85
rm -f $tmpfile
86

Andrea Sciaba's avatar
Andrea Sciaba committed
87
88
echo
echo "Default SCRAM_ARCH: $SCRAM_ARCH"
Andrea Sciaba's avatar
Andrea Sciaba committed
89
90

if [ -z $CMS_PATH ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
91
92
93
    echo "ERROR: CMS_PATH not defined"
    echo "summary: CMS_PATH_UNDEF"
    exit $SAME_ERROR
Andrea Sciaba's avatar
Andrea Sciaba committed
94
95
96
fi

if [ ! -d $CMS_PATH ] ; then
Andrea Sciaba's avatar
Andrea Sciaba committed
97
98
99
    echo "ERROR: CMS_PATH directory $CMS_PATH not existing"
    echo "summary: NO_CMS_PATH"
    exit $SAME_ERROR
Andrea Sciaba's avatar
Andrea Sciaba committed
100
101
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
102
echo -n "scramv1_version: "
103
scramv1 version
Andrea Sciaba's avatar
Andrea Sciaba committed
104
105
result=$?
if [ $result != 0 ]
106
then
Andrea Sciaba's avatar
Andrea Sciaba committed
107
108
109
    echo "ERROR: scramv1 command not found"
    echo "summary: NO_SCRAMV1"
    exit $SAME_ERROR
Andrea Sciaba's avatar
Andrea Sciaba committed
110
111
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
112
113
114
echo
echo "Retrieving list of CMSSW versions installed..."
archs_defined='slc5_amd64_gcc434 slc5_amd64_gcc462 slc5_amd64_gcc472 slc6_amd64_gcc472 slc6_amd64_gcc481'
115
116
for arch in $archs_defined
do
Andrea Sciaba's avatar
Andrea Sciaba committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
    export SCRAM_ARCH=$arch
    export BUILD_ARCH=$arch
    echo "SCRAM_ARCH: $arch"
    scramv1 list -c CMSSW > scramv1_list_output.txt
    listerror=$?
    if [ $listerror != 0 ]
    then
	echo "WARNING: could not list CMSSW versions with scramv1"
    fi
    touch scramv1_list_output.txt
    cat scramv1_list_output.txt | tr -s " " | cut -d " " -f2 | sort -u > cmssw_installed_${arch}.txt
    rm -f scramv1_list_output.txt
    cat cmssw_installed_${arch}.txt >> cmssw_installed_version_list.txt
    if [ -d $CMS_PATH/${arch}/cms/cms-common/1.0 ]; then
	echo "Recent cms-common RPM already installed:"
	ls -d $CMS_PATH/${arch}/cms/cms-common/1.0/* | grep -v etc
    else
	echo "Old style cms-common RPM installed."
    fi
    echo
137
done
Andrea Sciaba's avatar
Andrea Sciaba committed
138
139
140

missing=0
failproject=0
Andrea Sciaba's avatar
Andrea Sciaba committed
141
for cmsver in `cat cmssw_required_version_list.txt`
Andrea Sciaba's avatar
Andrea Sciaba committed
142
do
Andrea Sciaba's avatar
Andrea Sciaba committed
143
144
145
    grep -x $cmsver cmssw_installed_version_list.txt >& /dev/null
    result=$?
    if [ $result != 0 ]
146
    then
Andrea Sciaba's avatar
Andrea Sciaba committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	echo "ERROR: Required CMSSW version $cmsver not installed"
	error=1
	errorSummary="REQ_CMSSW_NOT_FOUND"
    else
	echo "Checking version $cmsver installation..."
       # execute in a subprocess commands that require scram 
	$SAME_SENSOR_HOME/tests/TestCmsswVersion.sh $cmsver
	TestResult=$?
	if [ $TestResult != 0 ]
	then
	    error=1
	    echo "ERROR: Some of the required CMSSW versions not working"
	    errorSummary="summary: REQ_CMSSW_NOT_WORKING"
	fi
161
    fi
Andrea Sciaba's avatar
Andrea Sciaba committed
162
163
done

164
165
166
167
168
# Check for Python2.6 installation needed for WMAgent
# Check for a SW tag to be added
no_comp_area=0
no_phython_found=0

Andrea Sciaba's avatar
Andrea Sciaba committed
169
170
171
echo
echo "Check for Python2.6 for WMAgent..."
wma_arch=slc5_amd64_gcc434
172
if [ -d $CMS_PATH/COMP ]; then
Andrea Sciaba's avatar
Andrea Sciaba committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
    if [ -d $CMS_PATH/COMP/$wma_arch/external/python ]; then
	declare -a PYTHON26
	PYTHON26=($(ls $CMS_PATH/COMP/$wma_arch/external/python | grep 2.6))
	N_PYTHON26=${#PYTHON26[*]}
	if [ $N_PYTHON26 -lt 1 ]; then
	    error=1
	    echo "ERROR: No Python2.6 installed in COMP area. It is broken!"
	    errorSummary="summary: NO_PYTHON26_FOUND"
	else
	    echo "These Python2.6 versions exist:"
	    echo "${PYTHON26[@]}"
	fi
    else 
	error=1
	echo "ERROR: No Python releases found in COMP area - it's broken!"
	errorSummary="summary: NO_PYTHON_FOUND"
189
190
    fi
else
Andrea Sciaba's avatar
Andrea Sciaba committed
191
192
193
    warning=1
    echo "WARNING: No COMP area found"
    echo "summary: NO_COMP_AREA"
194
195
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
196
echo
197
198
199

if [[ $error == 1 ]]
then
Andrea Sciaba's avatar
Andrea Sciaba committed
200
201
    echo $errorSummary
    exit $SAME_ERROR
202
203
204
205
fi

if [[ $warning == 1 ]]
then
Andrea Sciaba's avatar
Andrea Sciaba committed
206
207
    echo $errorSummary
    exit $SAME_WARNING
208
209
fi

Andrea Sciaba's avatar
Andrea Sciaba committed
210
211
echo "All checks OK"
echo "summary: OK"
212
exit $SAME_OK