-
Notifications
You must be signed in to change notification settings - Fork 28
/
spl-modules.spec.in
576 lines (490 loc) · 15.4 KB
/
spl-modules.spec.in
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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# The following block is used to allow the source RPM to be rebuilt
# against specific kernels. It is preferable that rpmbuild define the
# require_kver, require_kdir, require_obj constants for us, but if it does not
# not we attempt to determine the correct values based on your distro.
# kdir: Full path to the kernel source headers
# kobj: Full path to the kernel build objects
# kver: Kernel version
# kpkg: Kernel package name
# kdevpkg: Kernel devel package name
# kverpkg: Kernel package version
%if %{defined require_kver}
%define kver %{require_kver}
%endif
%if %{defined require_kdir}
%define kdir %{require_kdir}
%endif
%if %{defined require_kobj}
%define kobj %{require_kobj}
%endif
# Set using 'rpmbuild ... --with kernel ...', defaults to enabled.
%if %{defined _with_kernel}
%define with_kernel 1
%else
%if %{defined _without_kernel}
%define with_kernel 0
%else
%define with_kernel 1
%endif
%endif
# Set using 'rpmbuild ... --with kernel-debug ...', defaults to disabled.
%if %{defined _with_kernel_debug}
%define with_kernel_debug 1
%else
%if %{defined _without_kernel_debug}
%define with_kernel_debug 0
%else
%define with_kernel_debug 0
%endif
%endif
# Set using 'rpmbuild ... --with kernel-dkms ...', defaults to disabled.
%if %{defined _with_kernel_dkms}
%define with_kernel_dkms 1
%else
%if %{defined _without_kernel_dkms}
%define with_kernel_dkms 0
%else
%define with_kernel_dkms 0
%endif
%endif
# Set using 'rpmbuild ... --with debug ...', defaults to disabled.
%if %{defined _with_debug}
%define kdebug --enable-debug
%else
%if %{defined _without_debug}
%define kdebug --disable-debug
%else
%define kdebug --disable-debug
%endif
%endif
# Set using 'rpmbuild ... --with debug-log ...', defaults to enabled.
%if %{defined _with_debug_log}
%define kdebug_log --enable-debug-log
%else
%if %{defined _without_debug_log}
%define kdebug_log --disable-debug-log
%else
%define kdebug_log --enable-debug-log
%endif
%endif
# Set using 'rpmbuild ... --with debug-kmem ...', defaults to enabled.
%if %{defined _with_debug_kmem}
%define kdebug_kmem --enable-debug-kmem
%else
%if %{defined _without_debug_kmem}
%define kdebug_kmem --disable-debug-kmem
%else
%define kdebug_kmem --enable-debug-kmem
%endif
%endif
# Set using 'rpmbuild ... --with debug-tracking ...', defaults to disabled.
%if %{defined _with_debug_kmem_tracking}
%define kdebug_kmem_tracking --enable-debug-kmem-tracking
%else
%if %{defined _without_debug_kmem_tracking}
%define kdebug_kmem_tracking --disable-debug-kmem-tracking
%else
%define kdebug_kmem_tracking --disable-debug-kmem-tracking
%endif
%endif
# SLES:
%if %{defined suse_version}
%if %{undefined kver}
%ifarch ppc64
%define kverextra ppc64
%else
%define kverextra default
%endif
%if %{suse_version} >= 1100
%define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
%define krelease %{klnk}/include/config/kernel.release
%else
%define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
%define krelease %{klnk}/.kernelrelease
%endif
%define kver_kern %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1)
%define kver_dbug %{nil}
%else
%define kver_kern %{kver}
%define kver_dbug %{nil}
%endif
%if %{undefined kverextra}
%define kverextra %(echo %{kver_kern} | cut -f3 -d'-')
%endif
%define kpkg_kern kernel-%{kverextra}
%define kpkg_dbug %{nil}
%define kpkg_dkms dkms
%define kdevpkg_kern kernel-source
%define kdevpkg_dbug %{nil}
%define kdevpkg_dkms dkms
%define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/-%{kverextra}//g')
%define kverpkg_dbug %{nil}
%define kverpkg_dkms 2.2.0.2
# The kernel and rpm versions do not strictly match under SLES11
# e.g. kernel version 2.6.27.19-5 != rpm version 2.6.27.19-5.1
%if %{suse_version} >= 1100
%define koppkg >=
%else
%define koppkg =
%endif
%if %{undefined kdir}
%define kdir_kern %{_usrsrc}/linux-%{kverpkg_kern}
%define kdir_dbug %{nil}
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{nil}
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}-obj/%{_target_cpu}/%{kverextra}
%define kobj_dbug %{nil}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{nil}
%endif
%else
# RHEL 5.x/6.x, CHAOS 5.x:
%if %{defined el5} || %{defined el6} || %{defined ch5}
%if %{undefined kver}
%define klnk %{_usrsrc}/kernels/*/include/config
%define kver_kern %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} -v debug)) | tail -1)
%define kver_dbug %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} debug)) | tail -1)
%else
%define kver_kern %{kver}
%define kver_dbug %{kver}.debug
%endif
%define kpkg_kern kernel
%define kpkg_dbug kernel-debug
%define kpkg_dkms dkms
%define kdevpkg_kern kernel-devel
%define kdevpkg_dbug kernel-debug-devel
%define kdevpkg_dkms dkms
%define kverpkg_dkms 2.2.0.2
%if %{defined el6} || %{defined ch5}
%define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/.%{_target_cpu}//g')
%define kverpkg_dbug %(echo %{kver_dbug} | %{__sed} -e 's/.%{_target_cpu}//g' | %{__sed} -e 's/.debug//g')
%else
%define kverpkg_kern %{kver_kern}
%define kverpkg_dbug %{kver_dbug}
%endif
%define koppkg =
%if %{undefined kdir}
%if %{defined el6} || %{defined ch5}
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
%else
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}-%{_target_cpu}
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}-%{_target_cpu}
%endif
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{kdir}.debug
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}
%define kobj_dbug %{kdir_dbug}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{kobj}.debug
%endif
%else
# Fedora:
%if %{defined fedora}
%if %{undefined kver}
%define klnk %{_usrsrc}/kernels/*/include/config
%define kver_kern %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} -v debug)) | tail -1)
%define kver_dbug %((echo X; ((%{__cat} %{klnk}/kernel.release
2>/dev/null) | %{__grep} debug)) | tail -1)
%else
%define kver_kern %{kver}
%define kver_dbug %{kver}.debug
%endif
%define kpkg_kern kernel
%define kpkg_dbug kernel-debug
%define kpkg_dkms dkms
%define kdevpkg_kern kernel-devel
%define kdevpkg_dbug kernel-debug-devel
%define kdevpkg_dkms dkms
%define kverpkg_dkms 2.2.0.2
%define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/.%{_target_cpu}//g')
%define kverpkg_dbug %(echo %{kver_dbug} | %{__sed} -e 's/.%{_target_cpu}//g' | %{__sed} -e 's/.debug//g')
%define koppkg =
%if %{undefined kdir}
%define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
%define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{kdir}.debug
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}
%define kobj_dbug %{kdir_dbug}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{kobj}.debug
%endif
%else
# Unsupported distro:
%if %{undefined kver}
%define kver_kern %(uname -r)
%define kver_dbug %{nil}
%else
%define kver_kern %{kver}
%define kver_dbug %{nil}
%endif
%define kverpkg_kern %{kver_kern}
%define kverpkg_dbug %{nil}
%define kverpkg_dkms %{nil}
%if %{undefined kdir}
%define kdir_kern /lib/modules/%{kver_kern}/build
%define kdir_dbug %{nil}
%else
%define kdir_kern %{kdir}
%define kdir_dbug %{nil}
%endif
%if %{undefined kobj}
%define kobj_kern %{kdir_kern}
%define kobj_dbug %{nil}
%else
%define kobj_kern %{kobj}
%define kobj_dbug %{nil}
%endif
%endif
%endif
%endif
# Distro agnostic:
%define name @PACKAGE@-modules
%define version @VERSION@
# The kernel version should only be appended to a binary RPM. When
# building a source RPM it must be kernel version agnostic. This means
# the source RPM must never specify a required kernel version, but the
# final RPM should be keyed to the kernel version it was built against.
%if %{defined build_src_rpm}
%define rel_kern @SPL_META_RELEASE@
%define rel_dbug @SPL_META_RELEASE@
%define rel_dkms @SPL_META_RELEASE@
%if %{defined kpkg_kern}
%define req_kern %{kpkg_kern}
%endif
%if %{defined kpkg_dbug}
%define req_dbug %{kpkg_dbug}
%endif
%if %{defined kpkg_dkms}
%define req_dkms %{kpkg_dkms}
%endif
%if %{defined kdevpkg_kern}
%define devreq_kern %{kdevpkg_kern}
%endif
%if %{defined kdevpkg_dbug}
%define devreq_dbug %{kdevpkg_dbug}
%endif
%else
%define relext_kern %(echo %{kverpkg_kern} | %{__sed} -e 's/-/_/g')
%define relext_dbug %(echo %{kverpkg_dbug} | %{__sed} -e 's/-/_/g')
%define rel_kern @SPL_META_RELEASE@_%{relext_kern}
%define rel_dbug @SPL_META_RELEASE@_%{relext_dbug}
%define rel_dkms @SPL_META_RELEASE@
%if %{defined kpkg_kern}
%define req_kern %{kpkg_kern} %{koppkg} %{kverpkg_kern}
%endif
%if %{defined kpkg_dbug}
%define req_dbug %{kpkg_dbug} %{koppkg} %{kverpkg_dbug}
%endif
%if %{defined kpkg_dkms}
%define req_dkms %{kpkg_dkms} >= %{kverpkg_dkms}
%endif
%if %{defined kdevpkg_kern}
%define devreq_kern %{kdevpkg_kern} %{koppkg} %{kverpkg_kern}
%endif
%if %{defined kdevpkg_dbug}
%define devreq_dbug %{kdevpkg_dbug} %{koppkg} %{kverpkg_dbug}
%endif
%endif
Summary: Solaris Porting Layer Modules
Group: Utilities/System
Name: %{name}
Version: %{version}
Release: %{rel_kern}
License: @LICENSE@
URL: git://github.com/zfsonlinux/spl.git
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
Source: @PACKAGE@-%{version}.tar.gz
%if %{?with_kernel}
%if %{defined req_kern}
Requires: %{req_kern}
%endif
%if %{defined kdevpkg_kern}
BuildRequires: %{kdevpkg_kern}
%endif
%endif
%description
The %{name} package contains kernel modules for emulating Solaris style
primatives in the linux kernel. These include, but are not limited to:
atomic, condvar, debug, error, memory, kobject, kstat, mutex, rwlock,
taskq, thread, time, and vnode APIs.
%if %{?with_kernel}
%package devel
Summary: Solaris Porting Layer Headers and Symbols
Group: Development/Libraries
Release: %{rel_kern}
%if %{defined devreq_kern}
Requires: %{devreq_kern}
%endif
%if %{defined kdevpkg_kern}
BuildRequires: %{kdevpkg_kern}
%endif
%description devel
The %{name}-devel package contains the header files and Module{s}.symvers
symbols needed for building additional modules which use %{name}.
%endif
%if %{?with_kernel_debug}
%package debug
Summary: Solaris Porting Layer Debug Modules
Group: Utilities/System
Release: %{rel_dbug}
%if %{defined req_dbug}
Requires: %{req_dbug}
%endif
%if %{defined kdevpkg_dbug}
BuildRequires: %{kdevpkg_dbug}
%endif
%description debug
The %{name}-debug package contains kernel modules for emulating Solaris
style primatives in the linux kernel. These include, but are not limited
to: atomic, condvar, debug, error, memory, kobject, kstat, mutex,
rwlock, taskq, thread, time, and vnode APIs.
%package debug-devel
Summary: Solaris Porting Layer Debug Headers and Symbols
Group: Development/Libraries
Release: %{rel_dbug}
%if %{defined devreq_dbug}
Requires: %{devreq_dbug}
%endif
%if %{defined kdevpkg_dbug}
BuildRequires: %{kdevpkg_dbug}
%endif
%description debug-devel
The %{name}-debug-devel package contains the header files and
Module{s}.symvers symbols needed for building additional modules which
use %{name}-debug.
%endif
%if %{?with_kernel_dkms}
%package dkms
Summary: Solaris Porting Layer Modules (DKMS)
Group: Utilities/System
Release: %{rel_dkms}
Provides: %{name}
BuildArch: noarch
%if %{defined req_dkms}
Requires: %{req_dkms}
%endif
%if %{defined kdevpkg_dkms}
BuildRequires: %{kdevpkg_dkms}
%endif
%description dkms
The %{name}-dkms package contains all the necessary pieces to build and
install Solaris Porting Layer (SPL) kernel modules with Dynamic Kernel
Modules Support (DKMS). The SPL modules emulate Solaris style primatives
in the the linux kernel. They include, but are not limited to: atomic,
condvar, debug, error, memory, kobject, kstat, mutex, rwlock, taskq,
thread, time, and vnode APIs.
%endif
%prep
%setup -n @PACKAGE@-%{version}
%build
rm -rf $RPM_BUILD_ROOT
%if %{?with_kernel}
%configure --with-config=kernel \
--with-linux=%{kdir_kern} --with-linux-obj=%{kobj_kern} \
%{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
make
make DESTDIR=$RPM_BUILD_ROOT install
%endif
%if %{?with_kernel_debug}
%configure --with-config=kernel \
--with-linux=%{kdir_dbug} --with-linux-obj=%{kobj_dbug} \
%{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
make
make DESTDIR=$RPM_BUILD_ROOT install
%endif
%if %{?with_kernel_dkms}
%configure --with-config=kernel \
%{kdebug} %{kdebug_log} %{kdebug_kmem} %{kdebug_kmem_tracking}
make dist
mkdir -p $RPM_BUILD_ROOT/%{_prefix}/src
tar -xf @PACKAGE@-%{version}.tar.gz -C $RPM_BUILD_ROOT/%{_prefix}/src
cp -af dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/@PACKAGE@-%{version}
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%if %{?with_kernel}
%files
%defattr(-, root, root)
/lib/modules/%{kver_kern}/*
%files devel
%defattr(-,root,root)
%{_prefix}/src/*/%{kver_kern}
%post
if [ -f /boot/System.map-%{kver_kern} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_kern} %{kver_kern} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun
if [ -f /boot/System.map-%{kver_kern} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_kern} %{kver_kern} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun devel
rmdir %{_prefix}/src/@PACKAGE@-%{version}-@SPL_META_RELEASE@ 2>/dev/null
exit 0
%endif
%if %{?with_kernel_debug}
%files debug
%defattr(-, root, root)
/lib/modules/%{kver_dbug}/*
%files debug-devel
%defattr(-,root,root)
%{_prefix}/src/*/%{kver_dbug}
%post debug
if [ -f /boot/System.map-%{kver_dbug} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_dbug} %{kver_dbug} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun debug
if [ -f /boot/System.map-%{kver_dbug} ]; then
/sbin/depmod -ae -F /boot/System.map-%{kver_dbug} %{kver_dbug} || exit 0
else
/sbin/depmod -a || exit 0
fi
%postun debug-devel
rmdir %{_prefix}/src/@PACKAGE@-%{version}-@SPL_META_RELEASE@ 2>/dev/null
exit 0
%endif
%if %{?with_kernel_dkms}
%files dkms
%defattr(-,root,root)
%{_prefix}/src/@PACKAGE@-%{version}
%post dkms
for POSTINST in %{_prefix}/lib/dkms/common.postinst; do
if [ -f $POSTINST ]; then
$POSTINST @PACKAGE@ %{version}
exit $?
fi
echo "WARNING: $POSTINST does not exist."
done
echo -e "ERROR: DKMS version is too old and @PACKAGE@ was not"
echo -e "built with legacy DKMS support."
echo -e "You must either rebuild @PACKAGE@ with legacy postinst"
echo -e "support or upgrade DKMS to a more current version."
exit 1
%preun dkms
echo -e
echo -e "Uninstall of @PACKAGE@ module (version %{version}) beginning:"
dkms remove -m @PACKAGE@ -v %{version} --all --rpm_safe_upgrade
exit 0
%endif