-
Notifications
You must be signed in to change notification settings - Fork 20
/
update_opa_spec.sh
executable file
·246 lines (215 loc) · 7.97 KB
/
update_opa_spec.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
#!/bin/bash
# BEGIN_ICS_COPYRIGHT8 ****************************************
#
# Copyright (c) 2015-2020, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# END_ICS_COPYRIGHT8 ****************************************
#[ICS VERSION STRING: unknown]
id=$(./get_id_and_versionid.sh | cut -f1 -d' ')
versionid=$(./get_id_and_versionid.sh | cut -f2 -d' ')
from=$1
to=$2
if [ "$from" = "" -o "$to" = "" ]
then
echo "Usage: update_opa-ff_spec.sh spec-in-file spec-file"
exit 1
fi
if [ "$from" != "$to" ]
then
cp $from $to
fi
sed -i "s/__RPM_FS/OPA_FEATURE_SET=opa10/g" $to
source ./OpenIb_Host/ff_filegroups.sh
sed -i "/__RPM_OPASNAPCONFIG1/d" $to
sed -i "/__RPM_OPASNAPCONFIG2/d" $to
if [ "$id" = "rhel" -o "$id" = "centos" -o "$id" = "rocky" ]
then
GE_7_4=$(echo "$versionid >= 7.4" | bc)
GE_7_5=$(echo "$versionid >= 7.5" | bc)
# __RPM_REQ_BASIC -
sed -i "s/__RPM_REQ_BASIC1/expect%{?_isa}, tcl%{?_isa}, openssl%{?_isa}, expat%{?_isa}, libibumad%{?_isa}, libibverbs%{?_isa}/g" $to
sed -i "/__RPM_REQ_BASIC2/d" $to
# __RPM_REQ_OPAMGT_DEV - different for RHEL7.4 and greater
if [ $GE_7_4 = 1 ]
then
sed -i "s/__RPM_REQ_OPAMGT_DEV/rdma-core-devel, openssl-devel, opa-libopamgt,/g" $to
else
sed -i "s/__RPM_REQ_OPAMGT_DEV/libibumad-devel, libibverbs-devel, openssl-devel, opa-libopamgt/g" $to
fi
# __RPM_BLDREQ - different for RHEL 7.5, RHEL7.4, or earlier
if [ $GE_7_4 = 1 ]
then
sed -i "s/__RPM_BLDREQ1/expat-devel, gcc-c++, openssl-devel, ncurses-devel, tcl-devel, zlib-devel, rdma-core-devel, ibacm-devel/g" $to
sed -i "/__RPM_BLDREQ2/d" $to
else
sed -i "s/__RPM_BLDREQ1/expat-devel, gcc-c++, openssl-devel, ncurses-devel, tcl-devel, zlib-devel, libibumad-devel, libibverbs-devel, ibacm-devel/g" $to
sed -i "/__RPM_BLDREQ2/d" $to
fi
# __RPM_REQ_ADDR_RES,__RPM_REQ_OPAMGT and __RPM_DEBUG same for all RHEL versions
sed -i "s/__RPM_REQ_ADDR_RES/opa-basic-tools ibacm/g" $to
sed -i "s/__RPM_REQ_OPAMGT/libibumad%{?_isa}, libibverbs%{?_isa}, openssl%{?_isa}/g" $to
sed -i "/__RPM_DEBUG_PKG/,+1d" $to
#Setup Epoch tags for RHEL rpms
sed -i "s/__RPM_EPOCH_BASIC/Epoch: 1/g" $to
sed -i "s/__RPM_EPOCH_FF/Epoch: 1/g" $to
sed -i "s/__RPM_EPOCH_ADDR_RES/Epoch: 1/g" $to
sed -i "s/__RPM_EPOCH_LIBOPAMGT/Epoch: 1/g" $to
elif [ "$id" = "sles" ]
then
GE_11_1=$(echo "$versionid >= 11.1" | bc)
GE_12_2=$(echo "$versionid >= 12.2" | bc)
GE_12_3=$(echo "$versionid >= 12.3" | bc)
# __RPM_DEBUG_PKG - needed for SLES 11.1 and greater
if [ $GE_11_1 = 1 ]
then
sed -i "s/__RPM_DEBUG_PKG/%debug_package/g" $to
else
sed -i "/__RPM_DEBUG_PKG/,+1d" $to
fi
# __RPM_REQ_BASIC, __RPM_BLDREQ, and __RPM_REQ_OPAMGT_DEV different for SLES 12.3 and greater
if [ $GE_12_3 = 1 ]
then
sed -i "s/__RPM_REQ_BASIC1/libexpat1, libibmad5, libibumad3, libibverbs1, openssl, expect, tcl/g" $to
sed -i "/__RPM_REQ_BASIC2/d" $to
sed -i "s/__RPM_BLDREQ1/libexpat-devel, gcc-c++, libopenssl-devel, ncurses-devel, tcl-devel, zlib-devel, rdma-core-devel, ibacm-devel/g" $to
sed -i "/__RPM_BLDREQ2/d" $to
sed -i "s/__RPM_REQ_OPAMGT_DEV/rdma-core-devel, libopenssl-devel, opa-libopamgt/g" $to
else
sed -i "s/__RPM_REQ_BASIC1/libexpat1, libibmad5, libibumad3, libibverbs1, openssl, expect, tcl/g" $to
sed -i "/__RPM_REQ_BASIC2/d" $to
sed -i "s/__RPM_BLDREQ1/libexpat-devel, gcc-c++, libopenssl-devel, ncurses-devel, tcl-devel, zlib-devel, libibumad-devel, libibverbs-devel, ibacm-devel/g" $to
sed -i "/__RPM_BLDREQ2/d" $to
sed -i "s/__RPM_REQ_OPAMGT_DEV/libibumad-devel, libibverbs-devel, libopenssl-devel, opa-libopamgt/g" $to
fi
# __RPM_REQ_ADDR_RES same for all SLES versions
sed -i "s/__RPM_REQ_ADDR_RES/opa-basic-tools, ibacm/g" $to
# __RPM_REQ_OPAMGT same for all SLES versions
sed -i "s/__RPM_REQ_OPAMGT/libibumad3, libibverbs1, openssl/g" $to
#Cleanup EPOCH macros from sles spec.
#Note that SUSE discourages and does not use epochs
sed -i "/__RPM_EPOCH_*/d" $to
elif [ "$id" = "fedora" ]
then
# __RPM_REQ_BASIC -
sed -i "s/__RPM_REQ_BASIC1/expect%{?_isa}, tcl%{?_isa}, openssl%{?_isa}, expat%{?_isa}, libibumad%{?_isa}, libibverbs%{?_isa}/g" $to
sed -i "/__RPM_REQ_BASIC2/d" $to
# __RPM_REQ_OPAMGT_DEV - different for RHEL7.4 and greater
sed -i "s/__RPM_REQ_OPAMGT_DEV/rdma-core-devel, openssl-devel, opa-libopamgt,/g" $to
# __RPM_BLDREQ - different for RHEL 7.5, RHEL7.4, or earlier
sed -i "s/__RPM_BLDREQ1/expat-devel, gcc-c++, openssl-devel, ncurses-devel, tcl-devel, zlib-devel, rdma-core-devel, ibacm-devel/g" $to
sed -i "/__RPM_BLDREQ2/d" $to
# __RPM_REQ_ADDR_RES,__RPM_REQ_OPAMGT and __RPM_DEBUG same for all RHEL versions
sed -i "s/__RPM_REQ_ADDR_RES/opa-basic-tools ibacm/g" $to
sed -i "s/__RPM_REQ_OPAMGT/libibumad%{?_isa}, libibverbs%{?_isa}, openssl%{?_isa}/g" $to
sed -i "/__RPM_DEBUG_PKG/,+1d" $to
#Setup Epoch tags for RHEL rpms
sed -i "s/__RPM_EPOCH_BASIC/Epoch: 1/g" $to
sed -i "s/__RPM_EPOCH_FF/Epoch: 1/g" $to
sed -i "s/__RPM_EPOCH_ADDR_RES/Epoch: 1/g" $to
sed -i "s/__RPM_EPOCH_LIBOPAMGT/Epoch: 1/g" $to
else
echo ERROR: Unsupported distribution: $id $versionid
exit 1
fi
> .tmpspec
while read line
do
if [ "$line" = "__RPM_BASIC_FILES" ]
then
for i in $basic_tools_sbin $basic_tools_sbin_sym
do
echo "%{_sbindir}/$i" >> .tmpspec
done
for i in $basic_tools_opt
do
echo "/usr/lib/opa/tools/$i" >> .tmpspec
done
for i in $basic_mans
do
echo "%{_mandir}/man1/${i}.gz" >> .tmpspec
done
for i in $basic_samples
do
echo "/usr/share/opa/samples/$i" >> .tmpspec
done
else
echo "$line" >> .tmpspec
fi
done < $to
mv .tmpspec $to
> .tmpspec
while read line
do
if [ "$line" = "__RPM_FF_FILES" ]
then
for i in $ff_tools_sbin opafmconfigcheck opafmconfigdiff
do
echo "%{_sbindir}/$i" >> .tmpspec
done
for i in $ff_tools_opt $ff_tools_misc $ff_tools_exp $ff_libs_misc
do
echo "/usr/lib/opa/tools/$i" >> .tmpspec
done
for i in $help_doc
do
echo "/usr/share/opa/help/$i" >> .tmpspec
done
for i in $ff_tools_fm
do
echo "/usr/lib/opa/fm_tools/$i" >> .tmpspec
done
for i in $ff_iba_samples
do
echo "/usr/share/opa/samples/$i" >> .tmpspec
done
for i in $ff_mans
do
echo "%{_mandir}/man8/${i}.gz" >> .tmpspec
done
for i in $mpi_apps_files
do
echo "/usr/src/opa/mpi_apps/$i" >> .tmpspec
done
else
echo "$line" >> .tmpspec
fi
done < $to
mv .tmpspec $to
> .tmpspec
while read line
do
if [ "$line" = "__RPM_SNAP_FILES" ]
then
for i in $opasnapconfig_bin
do
echo "/usr/lib/opa/tools/$i" >> .tmpspec
done
else
echo "$line" >> .tmpspec
fi
done < $to
mv .tmpspec $to
exit 0