-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchange_bms_osname.sh
executable file
·247 lines (230 loc) · 5.42 KB
/
change_bms_osname.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/bin/bash
print_usage() {
cat <<+
usage: change_bms_osname.sh <target>
where target is one of
"jlab": convert the /group/halld/Software/builds tree at JLab (script must be
executed from a directory named "builds")
"gluex_top": convert a GLUEX_TOP tree (GLUEX_TOP must be defined in the
environment)
"halld_my": convert a HALLD_MY tree (HALLD_MY must be defined in the
environment)
"jana": convert a jana tree (JANA_HOME must be defined in the environment)
"hdds": convert a hdds tree (HDDS_HOME must be defined in the environment)
"halld_recon": convert a halld_recon tree (HALLD_RECON_HOME must be defined in
the environment)
"halld_sim": convert a halld_sim tree (HALLD_SIM_HOME must be defined in the
environment)
"gluex_root_analysis": convert a gluex_root_analysis tree (ROOT_ANALYSIS_HOME
must be defined in the environment)
+
}
oldname[1]=Linux_RHEL8-x86_64-gcc8.5.0
newname[1]=Linux_RHEL8-x86_64-gcc8.5
oldname[2]=Linux_CentOS7-x86_64-gcc4.8.5-cntr
newname[2]=Linux_CentOS7-x86_64-gcc4.8
oldname[3]=Linux_CentOS7.7-x86_64-gcc4.8.5
newname[3]=Linux_CentOS7-x86_64-gcc4.8
oldname[4]=Linux_RHEL7-x86_64-gcc4.8.5
newname[4]=Linux_RHEL7-x86_64-gcc4.8
oldname[5]=Linux_Fedora35-x86_64-gcc11.2.1
newname[5]=Linux_Fedora35-x86_64-gcc11.2
oldname[6]=Linux_Ubuntu20.04-x86_64-gcc9.3.0
newname[6]=Linux_Ubuntu20.04-x86_64-gcc9.3
target=$1
if [ -z "$target" ]
then
echo
echo "error: no target supplied"
echo
print_usage
exit 1
elif [[ "$target" != "jlab" && "$target" != "gluex_top" \
&& "$target" != "halld_my" && "$target" != "jana" \
&& "$target" != "hdds" && "$target" != "halld_recon" \
&& "$target" != "halld_sim" && "$target" != "gluex_root_analysis" ]]
then
echo
echo "error: unknown target: $target"
echo
print_usage
exit 2
fi
if [ "$target" == "gluex_top" ]
then
if [ -z "$GLUEX_TOP" ]
then
echo
echo error: GLUEX_TOP not set
echo
print_usage
exit 3
fi
fi
if [ "$target" == "halld_my" ]
then
if [ -z "$HALLD_MY" ]
then
echo
echo error: HALLD_MY not set
echo
print_usage
exit 4
fi
fi
if [ "$target" == "jana" ]
then
if [ -z "$JANA_HOME" ]
then
echo
echo error: JANA_HOME not set
echo
print_usage
exit 4
fi
fi
if [ "$target" == "hdds" ]
then
if [ -z "$HDDS_HOME" ]
then
echo
echo error: HDDS_HOME not set
echo
print_usage
exit 4
fi
fi
if [ "$target" == "halld_recon" ]
then
if [ -z "$HALLD_RECON_HOME" ]
then
echo
echo error: HALLD_RECON_HOME not set
echo
print_usage
exit 4
fi
fi
if [ "$target" == "halld_sim" ]
then
if [ -z "$HALLD_SIM_HOME" ]
then
echo
echo error: HALLD_SIM_HOME not set
echo
print_usage
exit 4
fi
fi
if [ "$target" == "gluex_root_analysis" ]
then
if [ -z "$ROOT_ANALYSIS_HOME" ]
then
echo
echo error: ROOT_ANALYSIS_HOME not set
echo
print_usage
exit 4
fi
fi
if [ "$target" == "jlab" ]
then
pwd=`pwd`
bn=`basename $pwd`
if [ "$bn" != "builds" ]
then
echo
echo error: not working in builds
echo
print_usage
exit 5
fi
fi
for i in {1..5}
do
if [ "$target" == "jlab" ]
then
# if the new gluex_top does not exist
if [ ! -d ${newname[$i]} ]
then
# create a gluex_top directory for the new name
if [ -d ${oldname[$i]} ]
then
mkdir -v ${newname[$i]}
fi
# make top-level package directories in the new gluex_top
find ${oldname[$i]} -maxdepth 1 -mindepth 1 -type d \
| awk -v newname="${newname[$i]}" -F${oldname[$i]}/ \
'{ print "mkdir -v ./"newname"/"$2 }' | bash
# create soft links to the built package directories pointing from
# the new name directories to the old name directories
find ${oldname[$i]} -maxdepth 2 -mindepth 2 \
| awk -v newname="${newname[$i]}" -F/ \
{'print "ln -sv ../../"$0" "newname"/"$2"/"$3'} | bash
fi
fi
# create soft links parallel to BMS_OSNAMEd subdirectories under
# the old-named package directories with new names pointing to the
# old names in the same directory
if [ "$target" == "gluex_top" ]
then
cd $GLUEX_TOP
dir="."
depth=3
elif [ "$target" == "halld_my" ]
then
cd $HALLD_MY
dir="."
depth=1
elif [ "$target" == "jana" ]
then
jana_root=`dirname $JANA_HOME`
cd $jana_root
dir="."
depth=1
elif [ "$target" == "hdds" ]
then
cd $HDDS_HOME
dir="."
depth=1
elif [ "$target" == "halld_recon" ]
then
cd $HALLD_RECON_HOME
dir="."
depth=1
elif [ "$target" == "halld_sim" ]
then
cd $HALLD_SIM_HOME
dir="."
depth=1
elif [ "$target" == "gluex_root_analysis" ]
then
cd $ROOT_ANALYSIS_HOME
dir="."
depth=1
elif [ "$target" == "jlab" ]
then
dir="${oldname[$i]}"
depth=3
else
echo error: this cannot happen
exit 6
fi
if [ $depth -eq 1 ]
then
find $dir -maxdepth $depth -mindepth $depth -name ${oldname[$i]} \
| awk -F/ -v newname="${newname[$i]}" -v oldname="${oldname[$i]}" \
'{print "ln -sv "oldname" "newname}' | bash
elif [ $depth -eq 3 ]
then
find $dir -maxdepth $depth -mindepth $depth -name ${oldname[$i]} \
| awk -F/ -v newname="${newname[$i]}" -v oldname="${oldname[$i]}" \
-v dirname="$dir" \
'{print "ln -sv "oldname" "dirname"/"$2"/"$3"/"newname}' | bash
else
echo error: this cannot happen
exit 7
fi
done
# command to make a test directory
# find /group/halld/Software/builds -maxdepth 4 -type d | awk -F'/builds/' '{print "mkdir -pv builds/"$2}' | bash