-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlnx_en.spec
executable file
·447 lines (387 loc) · 13.4 KB
/
mlnx_en.spec
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
#
# Copyright (c) 2012 Mellanox Technologies. All rights reserved.
#
# This Software is licensed under one of the following licenses:
#
# 1) under the terms of the "Common Public License 1.0" a copy of which is
# available from the Open Source Initiative, see
# http://www.opensource.org/licenses/cpl.php.
#
# 2) under the terms of the "The BSD License" a copy of which is
# available from the Open Source Initiative, see
# http://www.opensource.org/licenses/bsd-license.php.
#
# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
# copy of which is available from the Open Source Initiative, see
# http://www.opensource.org/licenses/gpl-license.php.
#
# Licensee has the right to choose one of the above licenses.
#
# Redistributions of source code must retain the above copyright
# notice and one of the license notices.
#
# Redistributions in binary form must reproduce both the above copyright
# notice, one of the license notices in the documentation
# and/or other materials provided with the distribution.
#
#
# KMP is disabled by default
%{!?KMP: %global KMP 0}
%global WITH_SYSTEMD %(if ( test -d "/lib/systemd/system" > /dev/null || test -d "%{_prefix}/lib/systemd/system" > /dev/null); then echo -n '1'; else echo -n '0'; fi)
%{!?MEMTRACK: %global MEMTRACK 0}
%{!?MLX4: %global MLX4 1}
%{!?MLX5: %global MLX5 1}
%{!?KVERSION: %global KVERSION %(uname -r)}
%global kernel_version %{KVERSION}
%global krelver %(echo -n %{KVERSION} | sed -e 's/-/_/g')
# take path to kernel sources if provided, otherwise look in default location (for non KMP rpms).
%{!?K_SRC: %global K_SRC /lib/modules/%{KVERSION}/build}
%if "%{_vendor}" == "suse"
%if %{!?KVER:1}%{?KVER:0}
%ifarch x86_64
%define flav debug default kdump smp xen
%else
%define flav bigsmp debug default kdump kdumppae smp vmi vmipae xen xenpae pae ppc64
%endif
%endif
%if %{!?KVER:0}%{?KVER:1}
%define flav %(echo %{KVER} | awk -F"-" '{print $3}')
%endif
%endif
%if "%{_vendor}" == "redhat"
%if %{!?KVER:1}%{?KVER:0}
%define flav ""
%endif
%if %{!?KVER:0}%{?KVER:1}
%if "%{flav}" == ""
%define flav default
%endif
%endif
%endif
%{!?_name: %global _name mlnx-en}
%{!?_version: %global _version 3.1}
%{!?_release: %global _release 1.0.4.0.g25ab699}
Name: %{_name}
Group: System Environment
Version: %{_version}
Release: %{_release}%{?_dist}
License: GPLv2 or BSD
Url: http://www.mellanox.com
Group: System Environment/Kernel
Vendor: Mellanox Technologies
Source0: %{_name}-%{_version}.tgz
Source1: mlx4.files
Provides: %{_name}
%if "%{KMP}" == "1"
Conflicts: mlnx_en
%endif
BuildRoot: %{?build_root:%{build_root}}%{!?build_root:/var/tmp/MLNX_EN}
Summary: mlnx-en kernel module(s)
%description
ConnectX Ehternet device driver
The driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
%package doc
Summary: Documentation for the Mellanox Ethernet Driver for Linux
Group: System/Kernel
%description doc
Documentation for the Mellanox Ethernet Driver for Linux
The driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
%package sources
Summary: Sources for the Mellanox Ethernet Driver for Linux
Group: System Environment/Libraries
%description sources
Sources for the Mellanox Ethernet Driver for Linux
The driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
%package utils
Summary: Utilities for the Mellanox Ethernet Driver for Linux
Group: System Environment/Libraries
conflicts: ofed-scripts
%description utils
Utilities for the Mellanox Ethernet Driver for Linux
The driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
%package KMP
Summary: mlnx-en kernel module(s)
Group: System/Kernel
%description KMP
mlnx-en kernel module(s)
The driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
# build KMP rpms?
%if "%{KMP}" == "1"
%global kernel_release() $(make -C %{1} kernelrelease | grep -v make | tail -1)
BuildRequires: %kernel_module_package_buildreqs
%(echo "Requires: mlnx-en-utils" > ${RPM_BUILD_ROOT}/preamble)
%kernel_module_package -f %{SOURCE1} %flav -p ${RPM_BUILD_ROOT}/preamble
%else # not KMP
%global kernel_source() %{K_SRC}
%global kernel_release() %{KVERSION}
%global flavors_to_build default
%package -n mlnx_en
Version: %{_version}
Release: %{_release}.%{krelver}
Requires: coreutils
Requires: kernel
Requires: pciutils
Requires: grep
Requires: perl
Requires: procps
Requires: module-init-tools
Requires: mlnx-en-utils
Group: System Environment/Base
Summary: Ethernet NIC Driver
%description -n mlnx_en
ConnectX Ehternet device driver
The driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-3.1-1.0.4.tgz
%endif #end if "%{KMP}" == "1"
#
# setup module sign scripts if paths to the keys are given
#
%global WITH_MOD_SIGN %(if ( test -f "$MODULE_SIGN_PRIV_KEY" && test -f "$MODULE_SIGN_PUB_KEY" ); \
then \
echo -n '1'; \
else \
echo -n '0'; fi)
%if "%{WITH_MOD_SIGN}" == "1"
# call module sign script
%global __modsign_install_post \
%{_builddir}/%{name}-%{version}/source/ofed_scripts/tools/sign-modules %{buildroot}/lib/modules/ || exit 1 \
%{nil}
%global __debug_package 1
%global buildsubdir %{name}-%{version}
# Disgusting hack alert! We need to ensure we sign modules *after* all
# invocations of strip occur, which is in __debug_install_post if
# find-debuginfo.sh runs, and __os_install_post if not.
#
%global __spec_install_post \
%{?__debug_package:%{__debug_install_post}} \
%{__arch_install_post} \
%{__os_install_post} \
%{__modsign_install_post} \
%{nil}
%endif # end of setup module sign scripts
#
%if "%{_vendor}" == "suse"
%debug_package
%endif
%if "%{_vendor}" == "redhat"
%global __find_requires %{nil}
%endif
%if "%{_vendor}" == "wrs"
%global __python_provides %{nil}
%global __python_requires %{nil}
%endif
# set modules dir
%if "%{_vendor}" == "redhat"
%if 0%{?fedora}
%global install_mod_dir updates
%else
%global install_mod_dir extra/%{name}
%endif
%endif
%if "%{_vendor}" == "suse"
%global install_mod_dir updates
%endif
%{!?install_mod_dir: %global install_mod_dir updates}
%prep
%setup
set -- *
mkdir source
mv "$@" source/
mkdir obj
%build
rm -rf %{buildroot}
export EXTRA_CFLAGS='-DVERSION=\"%version\"'
for flavor in %{flavors_to_build}; do
rm -rf obj/$flavor
cp -r source obj/$flavor
cd $PWD/obj/$flavor
export KSRC=%{kernel_source $flavor}
export KVERSION=%{kernel_release $KSRC}
export MLNX_EN_PATCH_PARAMS="--kernel $KVERSION --kernel-sources $KSRC"
%if "%{MEMTRACK}" == "1"
export MLNX_EN_PATCH_PARAMS="$MLNX_EN_PATCH_PARAMS --with-memtrack"
%endif
%if "%{MLX4}" == "0"
export MLNX_EN_PATCH_PARAMS="$MLNX_EN_PATCH_PARAMS --without-mlx4"
%endif
%if "%{MLX5}" == "0"
export MLNX_EN_PATCH_PARAMS="$MLNX_EN_PATCH_PARAMS --without-mlx5"
%endif
find compat -type f -exec touch -t 200012201010 '{}' \; || true
./scripts/mlnx_en_patch.sh $MLNX_EN_PATCH_PARAMS %{?_smp_mflags}
make KSRC=$KSRC V=0 %{?_smp_mflags}
cd -
done
gzip -c source/scripts/mlx4_en.7 > mlx4_en.7.gz
cd source/ofed_scripts/utils
python setup.py build
cd -
%install
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=%{install_mod_dir}
for flavor in %{flavors_to_build}; do
cd $PWD/obj/$flavor
export KSRC=%{kernel_source $flavor}
export KVERSION=%{kernel_release $KSRC}
make install KSRC=$KSRC MODULES_DIR=$INSTALL_MOD_DIR DESTDIR=%{buildroot} KERNELRELEASE=$KVERSION
# Cleanup unnecessary kernel-generated module dependency files.
find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \;
cd -
done
# Set the module(s) to be executable, so that they will be stripped when packaged.
find %{buildroot} -type f -name \*.ko -exec %{__chmod} u+x \{\} \;
%if "%{_vendor}" == "redhat"
%if "%{KMP}" == "1"
%{__install} -d %{buildroot}%{_sysconfdir}/depmod.d/
for module in `find %{buildroot}/ -name '*.ko'`
do
ko_name=${module##*/}
mod_name=${ko_name/.ko/}
mod_path=${module/*%{name}}
mod_path=${mod_path/\/${ko_name}}
echo "override ${mod_name} * weak-updates/%{name}${mod_path}" >> %{buildroot}%{_sysconfdir}/depmod.d/%{name}.conf
done
%endif
%endif
install -D -m 644 mlx4_en.7.gz %{buildroot}/%{_mandir}/man7/mlx4_en.7.gz
install -D -m 755 source/ofed_scripts/common_irq_affinity.sh %{buildroot}/%{_sbindir}/common_irq_affinity.sh
install -D -m 755 source/ofed_scripts/set_irq_affinity.sh %{buildroot}/%{_sbindir}/set_irq_affinity.sh
install -D -m 755 source/ofed_scripts/show_irq_affinity.sh %{buildroot}/%{_sbindir}/show_irq_affinity.sh
install -D -m 755 source/ofed_scripts/set_irq_affinity_bynode.sh %{buildroot}/%{_sbindir}/set_irq_affinity_bynode.sh
install -D -m 755 source/ofed_scripts/set_irq_affinity_cpulist.sh %{buildroot}/%{_sbindir}/set_irq_affinity_cpulist.sh
install -D -m 755 source/ofed_scripts/sysctl_perf_tuning %{buildroot}/sbin/sysctl_perf_tuning
install -D -m 755 source/ofed_scripts/mlnx_tune %{buildroot}/usr/sbin/mlnx_tune
install -D -m 755 source/ofed_scripts/connectx4_eth_max_performance %{buildroot}/usr/sbin/connectx4_eth_max_performance
install -D -m 644 source/scripts/mlnx-en.conf %{buildroot}/etc/mlnx-en.conf
install -D -m 755 source/scripts/mlnx-en.d %{buildroot}/etc/init.d/mlnx-en.d
mkdir -p %{buildroot}/%{_prefix}/src
cp -r source %{buildroot}/%{_prefix}/src/%{name}-%{version}
touch ofed-files
cd source/ofed_scripts/utils
python setup.py install -O1 --root=%{buildroot} --record ../../../ofed-files
cd -
if [[ "$(ls %{buildroot}/%{_bindir}/tc_wrap.py* 2>/dev/null)" != "" ]]; then
echo '%{_bindir}/tc_wrap.py*' >> ofed-files
fi
%if "%{WITH_SYSTEMD}" == "1"
install -D -m 644 source/scripts/mlnx-en.d.service %{buildroot}/%{_prefix}/lib/systemd/system/mlnx-en.d.service
%endif
%postun doc
if [ -f %{_mandir}/man7/mlx4_en.7.gz ]; then
exit 0
fi
%if "%{KMP}" != "1"
%post -n mlnx_en
/sbin/depmod -r -ae %{KVERSION}
# W/A for OEL6.7 inbox modules get locked in memory
# in dmesg we get: Module mlx4_core locked in memory until next boot
if (grep -qiE "Oracle.*6.7" /etc/issue 2>/dev/null); then
/sbin/dracut --force
fi
%postun -n mlnx_en
if [ $1 = 0 ]; then # 1 : Erase, not upgrade
/sbin/depmod -r -ae %{KVERSION}
# W/A for OEL6.7 inbox modules get locked in memory
# in dmesg we get: Module mlx4_core locked in memory until next boot
if (grep -qiE "Oracle.*6.7" /etc/issue 2>/dev/null); then
/sbin/dracut --force
fi
fi
%endif
%post -n mlnx-en-utils
if [ $1 -eq 1 ]; then # 1 : This package is being installed
if [[ -f /etc/redhat-release || -f /etc/rocks-release ]]; then
perl -i -ne 'if (m@^#!/bin/bash@) {
print q@#!/bin/bash
#
# Bring up/down mlnx-en.d
#
# chkconfig: 2345 05 95
# description: Activates/Deactivates mlnx-en Driver to \
# start at boot time.
#
### BEGIN INIT INFO
# Provides: mlnx-en.d
### END INIT INFO
@;
} else {
print;
}' /etc/init.d/mlnx-en.d
/sbin/chkconfig mlnx-en.d off >/dev/null 2>&1 || true
/usr/bin/systemctl disable mlnx-en.d >/dev/null 2>&1 || true
/sbin/chkconfig --del mlnx-en.d >/dev/null 2>&1 || true
/sbin/chkconfig --add mlnx-en.d >/dev/null 2>&1 || true
/sbin/chkconfig mlnx-en.d on >/dev/null 2>&1 || true
/usr/bin/systemctl enable mlnx-en.d >/dev/null 2>&1 || true
fi
if [ -f /etc/SuSE-release ]; then
local_fs='$local_fs'
perl -i -ne "if (m@^#!/bin/bash@) {
print q@#!/bin/bash
### BEGIN INIT INFO
# Provides: mlnx-en.d
# Required-Start: $local_fs
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 2 6
# Description: Activates/Deactivates mlnx-en.d Driver to \
# start at boot time.
### END INIT INFO
@;
} else {
print;
}" /etc/init.d/mlnx-en.d
/sbin/chkconfig mlnx-en.d off >/dev/null 2>&1 || true
/usr/bin/systemctl disable mlnx-en.d >/dev/null 2>&1 || true
/sbin/insserv -r mlnx-en.d >/dev/null 2>&1 || true
/sbin/insserv mlnx-en.d >/dev/null 2>&1 || true
/sbin/chkconfig mlnx-en.d on >/dev/null 2>&1 || true
/usr/bin/systemctl enable mlnx-en.d >/dev/null 2>&1 || true
fi
%if "%{WITH_SYSTEMD}" == "1"
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
fi # 1 : closed
# END of post utils
%preun -n mlnx-en-utils
if [ $1 = 0 ]; then # 1 : Erase, not upgrade
/sbin/chkconfig mlnx-en.d off >/dev/null 2>&1 || true
/usr/bin/systemctl disable mlnx-en.d >/dev/null 2>&1 || true
if [[ -f /etc/redhat-release || -f /etc/rocks-release ]]; then
/sbin/chkconfig --del mlnx-en.d >/dev/null 2>&1 || true
fi
if [ -f /etc/SuSE-release ]; then
/sbin/insserv -r mlnx-en.d >/dev/null 2>&1 || true
fi
fi
# END of pre uninstall utils
%postun -n mlnx-en-utils
%if "%{WITH_SYSTEMD}" == "1"
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
#end of post uninstall
%clean
rm -rf %{buildroot}
%if "%{KMP}" != "1"
%files -n mlnx_en
/lib/modules/%{KVERSION}/
%endif
%files doc
%defattr(-,root,root,-)
%{_mandir}/man7/mlx4_en.7.gz
%files sources
%defattr(-,root,root,-)
%{_prefix}/src/%{name}-%{version}
%files utils -f ofed-files
%defattr(-,root,root,-)
%{_sbindir}/*
/sbin/*
%config(noreplace) /etc/mlnx-en.conf
/etc/init.d/mlnx-en.d
%if "%{WITH_SYSTEMD}" == "1"
%{_prefix}/lib/systemd/system/mlnx-en.d.service
%endif
%changelog
* Mon Mar 24 2014 Alaa Hleihel <[email protected]>
- Use one source rpm for KMP and none-KMP rpms.
* Tue May 1 2012 Vladimir Sokolovsky <[email protected]>
- Created spec file for mlnx_en