]> git.proxmox.com Git - mirror_zfs.git/blob - zfs-modules.spec.in
Illumos #3090 and #3102
[mirror_zfs.git] / zfs-modules.spec.in
1 # The following block is used to allow the source RPM to be rebuilt
2 # against specific kernels. It is preferable that rpmbuild define the
3 # require_kver, require_kdir, require_obj constants for us, but if it does not
4 # not we attempt to determine the correct values based on your distro.
5
6 # kdir: Full path to the kernel source headers
7 # kobj: Full path to the kernel build objects
8 # kver: Kernel version
9 # kpkg: Kernel package name
10 # kdevpkg: Kernel devel package name
11 # kverpkg: Kernel package version
12
13 %if %{defined require_kver}
14 %define kver %{require_kver}
15 %endif
16
17 %if %{defined require_kdir}
18 %define kdir %{require_kdir}
19 %endif
20
21 %if %{defined require_kobj}
22 %define kobj %{require_kobj}
23 %endif
24
25 # Set using 'rpmbuild ... --with kernel ...', defaults to enabled.
26 %if %{defined _with_kernel}
27 %define with_kernel 1
28 %else
29 %if %{defined _without_kernel}
30 %define with_kernel 0
31 %else
32 %define with_kernel 1
33 %endif
34 %endif
35
36 # Set using 'rpmbuild ... --with kernel-debug ...', defaults to disabled.
37 %if %{defined _with_kernel_debug}
38 %define with_kernel_debug 1
39 %else
40 %if %{defined _without_kernel_debug}
41 %define with_kernel_debug 0
42 %else
43 %define with_kernel_debug 0
44 %endif
45 %endif
46
47 # Set using 'rpmbuild ... --with kernel-dkms ...', defaults to disabled.
48 %if %{defined _with_kernel_dkms}
49 %define with_kernel_dkms 1
50 %else
51 %if %{defined _without_kernel_dkms}
52 %define with_kernel_dkms 0
53 %else
54 %define with_kernel_dkms 0
55 %endif
56 %endif
57
58 # Set using 'rpmbuild ... --with debug ...', defaults to disabled.
59 %if %{defined _with_debug}
60 %define kdebug --enable-debug
61 %else
62 %if %{defined _without_debug}
63 %define kdebug --disable-debug
64 %else
65 %define kdebug --disable-debug
66 %endif
67 %endif
68
69 # Set using 'rpmbuild ... --with debug-dmu-tx ...', defaults to disabled.
70 %if %{defined _with_debug_dmu_tx}
71 %define kdebug_dmu_tx --enable-debug-dmu-tx
72 %else
73 %if %{defined _without_debug_dmu_tx}
74 %define kdebug_dmu_tx --disable-debug-dmu-tx
75 %else
76 %define kdebug_dmu_tx --disable-debug-dmu-tx
77 %endif
78 %endif
79
80 # SLES:
81 %if %{defined suse_version}
82 %if %{undefined kver}
83 %ifarch ppc64
84 %define kverextra ppc64
85 %else
86 %define kverextra default
87 %endif
88
89 %if %{suse_version} >= 1100
90 %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
91 %define krelease %{klnk}/include/config/kernel.release
92 %else
93 %define klnk %{_usrsrc}/linux-obj/%{_target_cpu}/%{kverextra}
94 %define krelease %{klnk}/.kernelrelease
95 %endif
96
97 %define kver_kern %((echo X; %{__cat} %{krelease} 2>/dev/null)|tail -1)
98 %define kver_dbug %{nil}
99 %else
100 %define kver_kern %{kver}
101 %define kver_dbug %{nil}
102 %endif
103
104 %if %{undefined kverextra}
105 %define kverextra %(echo %{kver_kern} | cut -f3 -d'-')
106 %endif
107
108 %define kpkg_kern kernel-%{kverextra}
109 %define kpkg_dbug %{nil}
110 %define kpkg_dkms dkms
111
112 %define kdevpkg_kern kernel-source
113 %define kdevpkg_dbug %{nil}
114 %define kdevpkg_dkms dkms
115
116 %define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/-%{kverextra}//g')
117 %define kverpkg_dbug %{nil}
118 %define kverpkg_dkms 2.2.0.2
119
120 # The kernel and rpm versions do not strictly match under SLES11
121 # e.g. kernel version 2.6.27.19-5 != rpm version 2.6.27.19-5.1
122 %if %{suse_version} >= 1100
123 %define koppkg >=
124 %else
125 %define koppkg =
126 %endif
127
128 %if %{undefined kdir}
129 %define kdir_kern %{_usrsrc}/linux-%{kverpkg_kern}
130 %define kdir_dbug %{nil}
131 %else
132 %define kdir_kern %{kdir}
133 %define kdir_dbug %{nil}
134 %endif
135
136 %if %{undefined kobj}
137 %define kobj_kern %{kdir_kern}-obj/%{_target_cpu}/%{kverextra}
138 %define kobj_dbug %{nil}
139 %else
140 %define kobj_kern %{kobj}
141 %define kobj_dbug %{nil}
142 %endif
143 %else
144
145 # RHEL 5.x/6.x, CHAOS 5.x:
146 %if %{defined el5} || %{defined el6} || %{defined ch5}
147 %if %{undefined kver}
148 %define klnk %{_usrsrc}/kernels/*/include/config
149 %define kver_kern %((echo X; ((%{__cat} %{klnk}/kernel.release
150 2>/dev/null) | %{__grep} -v debug)) | tail -1)
151 %define kver_dbug %((echo X; ((%{__cat} %{klnk}/kernel.release
152 2>/dev/null) | %{__grep} debug)) | tail -1)
153 %else
154 %define kver_kern %{kver}
155 %define kver_dbug %{kver}.debug
156 %endif
157
158 %define kpkg_kern kernel
159 %define kpkg_dbug kernel-debug
160 %define kpkg_dkms dkms
161
162 %define kdevpkg_kern kernel-devel
163 %define kdevpkg_dbug kernel-debug-devel
164 %define kdevpkg_dkms dkms
165
166 %define kverpkg_dkms 2.2.0.2
167 %if %{defined el6} || %{defined ch5}
168 %define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/.%{_target_cpu}//g')
169 %define kverpkg_dbug %(echo %{kver_dbug} | %{__sed} -e 's/.%{_target_cpu}//g' | %{__sed} -e 's/.debug//g')
170 %else
171 %define kverpkg_kern %{kver_kern}
172 %define kverpkg_dbug %{kver_dbug}
173 %endif
174
175 %define koppkg =
176
177 %if %{undefined kdir}
178 %if %{defined el6} || %{defined ch5}
179 %define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
180 %define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
181 %else
182 %define kdir_kern %{_usrsrc}/kernels/%{kver_kern}-%{_target_cpu}
183 %define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}-%{_target_cpu}
184 %endif
185 %else
186 %define kdir_kern %{kdir}
187 %define kdir_dbug %{kdir}.debug
188 %endif
189
190 %if %{undefined kobj}
191 %define kobj_kern %{kdir_kern}
192 %define kobj_dbug %{kdir_dbug}
193 %else
194 %define kobj_kern %{kobj}
195 %define kobj_dbug %{kobj}.debug
196 %endif
197 %else
198
199 # Fedora:
200 %if %{defined fedora}
201 %if %{undefined kver}
202 %define klnk %{_usrsrc}/kernels/*/include/config
203 %define kver_kern %((echo X; ((%{__cat} %{klnk}/kernel.release
204 2>/dev/null) | %{__grep} -v debug)) | tail -1)
205 %define kver_dbug %((echo X; ((%{__cat} %{klnk}/kernel.release
206 2>/dev/null) | %{__grep} debug)) | tail -1)
207 %else
208 %define kver_kern %{kver}
209 %define kver_dbug %{kver}.debug
210 %endif
211
212 %define kpkg_kern kernel
213 %define kpkg_dbug kernel-debug
214 %define kpkg_dkms dkms
215
216 %define kdevpkg_kern kernel-devel
217 %define kdevpkg_dbug kernel-debug-devel
218 %define kdevpkg_dkms dkms
219
220 %define kverpkg_dkms 2.2.0.2
221 %define kverpkg_kern %(echo %{kver_kern} | %{__sed} -e 's/.%{_target_cpu}//g')
222 %define kverpkg_dbug %(echo %{kver_dbug} | %{__sed} -e 's/.%{_target_cpu}//g' | %{__sed} -e 's/.debug//g')
223
224 %define koppkg =
225
226 %if %{undefined kdir}
227 %define kdir_kern %{_usrsrc}/kernels/%{kver_kern}
228 %define kdir_dbug %{_usrsrc}/kernels/%{kver_dbug}
229 %else
230 %define kdir_kern %{kdir}
231 %define kdir_dbug %{kdir}.debug
232 %endif
233
234 %if %{undefined kobj}
235 %define kobj_kern %{kdir_kern}
236 %define kobj_dbug %{kdir_dbug}
237 %else
238 %define kobj_kern %{kobj}
239 %define kobj_dbug %{kobj}.debug
240 %endif
241 %else
242
243 # Unsupported distro:
244 %if %{undefined kver}
245 %define kver_kern %(uname -r)
246 %define kver_dbug %{nil}
247 %else
248 %define kver_kern %{kver}
249 %define kver_dbug %{nil}
250 %endif
251
252 %define kverpkg_kern %{kver_kern}
253 %define kverpkg_dbug %{nil}
254 %define kverpkg_dkms %{nil}
255
256 %if %{undefined kdir}
257 %define kdir_kern /lib/modules/%{kver_kern}/build
258 %define kdir_dbug %{nil}
259 %else
260 %define kdir_kern %{kdir}
261 %define kdir_dbug %{nil}
262 %endif
263
264 %if %{undefined kobj}
265 %define kobj_kern %{kdir_kern}
266 %define kobj_dbug %{nil}
267 %else
268 %define kobj_kern %{kobj}
269 %define kobj_dbug %{nil}
270 %endif
271
272 %endif
273 %endif
274 %endif
275
276 # spldir: Full path to the spl source headers
277 # splobj: Full path to the spl build objects
278 # splver: Spl version
279 # splpkg: Spl package name
280 # spldevpkg: Spl devel package name
281 # splverpkg: Spl package version
282
283 %if %{defined require_splver}
284 %define splver %{require_splver}
285 %endif
286
287 %if %{defined require_spldir}
288 %define spldir %{require_spldir}
289 %endif
290
291 %if %{defined require_splobj}
292 %define splobj %{require_splobj}
293 %endif
294
295 %if %{undefined splver}
296 %define spllnk_kern %{_usrsrc}/spl-*/%{kver_kern}
297 %define spllnk_dbug %{_usrsrc}/spl-*/%{kver_dbug}
298 %define spllnk_dkms %{_var}/lib/dkms/spl/*/build
299
300 %define splver_kern %((echo X; %{__cat} %{spllnk_kern}/spl.release
301 2>/dev/null) | tail -1)
302 %define splver_dbug %((echo X; %{__cat} %{spllnk_dbug}/spl.release
303 2>/dev/null) | tail -1)
304 %define splver_dkms %((echo X; %{__cat} %{spllnk_dkms}/spl.release
305 2>/dev/null) | tail -1)
306 %else
307 %define splver_kern %{splver}
308 %define splver_dbug %{splver}
309 %define splver_dksm %{splver}
310 %endif
311
312 %define splpkg_kern spl-modules
313 %define splpkg_dbug spl-modules-debug
314 %define splpkg_dkms spl-modules-dkms
315
316 %define spldevpkg_kern spl-modules-devel
317 %define spldevpkg_dbug spl-modules-debug-devel
318 %define spldevpkg_dkms spl-modules-dkms
319
320 %define splverpkg_kern %{splver_kern}
321 %define splverpkg_dbug %{splver_dbug}
322 %define splverpkg_dkms %{splver_dkms}
323
324 %if %{undefined spldir}
325 %define spldir_kern %{_usrsrc}/spl-%{splver_kern}/%{kver_kern}
326 %define spldir_dbug %{_usrsrc}/spl-%{splver_dbug}/%{kver_dbug}
327 %define spldir_dkms %{_usrsrc}/spl-%{splver_dkms}
328 %else
329 %define spldir_kern %{spldir}
330 %define spldir_dbug %{spldir}.debug
331 %define spldir_dkms %{spldir}
332 %endif
333
334 %if %{undefined splobj}
335 %define splobj_kern %{spldir_kern}
336 %define splobj_dbug %{spldir_dbug}
337 %define splobj_dkms %{spldir_dkms}
338 %else
339 %define splobj_kern %{splobj}
340 %define splobj_dbug %{splobj}.debug
341 %define splobj_dkms %{splobj}
342 %endif
343
344
345 # Distro agnostic:
346 %define name @PACKAGE@-modules
347 %define version @VERSION@
348
349 # The kernel version should only be appended to a binary RPM. When
350 # building a source RPM it must be kernel version agnostic. This means
351 # the source RPM must never specify a required kernel version, but the
352 # final RPM should be keyed to the kernel version it was built against.
353 %if %{defined build_src_rpm}
354
355 %define rel_kern @ZFS_META_RELEASE@
356 %define rel_dbug @ZFS_META_RELEASE@
357 %define rel_dkms @ZFS_META_RELEASE@
358
359 %if %{defined kpkg_kern}
360 %define req_kern %{kpkg_kern}
361 %endif
362 %if %{defined kpkg_dbug}
363 %define req_dbug %{kpkg_dbug}
364 %endif
365 %if %{defined kpkg_dkms}
366 %define req_dkms %{kpkg_dkms}
367 %endif
368
369 %define splreq_kern %{splpkg_kern}
370 %define splreq_dbug %{splpkg_dbug}
371 %define splreq_dkms %{splpkg_dkms}
372
373 %define spldevreq_kern %{spldevpkg_kern}
374 %define spldevreq_dbug %{spldevpkg_dbug}
375 %define spldevreq_dkms %{spldevpkg_dkms}
376
377 %else
378
379 %define relext_kern %(echo %{kverpkg_kern} | %{__sed} -e 's/-/_/g')
380 %define relext_dbug %(echo %{kverpkg_dbug} | %{__sed} -e 's/-/_/g')
381 %define rel_kern @ZFS_META_RELEASE@_%{relext_kern}
382 %define rel_dbug @ZFS_META_RELEASE@_%{relext_dbug}
383 %define rel_dkms @ZFS_META_RELEASE@
384
385 %if %{defined kpkg_kern}
386 %define req_kern %{kpkg_kern} %{koppkg} %{kverpkg_kern}
387 %endif
388 %if %{defined kpkg_dbug}
389 %define req_dbug %{kpkg_dbug} %{koppkg} %{kverpkg_dbug}
390 %endif
391 %if %{defined kpkg_dkms}
392 %define req_dkms %{kpkg_dkms} >= %{kverpkg_dkms}
393 %endif
394
395 %define splreq_kern %{splpkg_kern} = %{splverpkg_kern}_%{relext_kern}
396 %define splreq_dbug %{splpkg_dbug} = %{splverpkg_dbug}_%{relext_dbug}
397 %define splreq_dkms %{splpkg_dkms} = %{splverpkg_dkms}
398
399 %define spldevreq_kern %{spldevpkg_kern} = %{splverpkg_kern}_%{relext_kern}
400 %define spldevreq_dbug %{spldevpkg_dbug} = %{splverpkg_dbug}_%{relext_dbug}
401 %define spldevreq_dkms %{spldevpkg_dkms} = %{splverpkg_dkms}
402
403 %endif
404
405 Summary: ZFS File System
406 Group: Utilities/System
407 Name: %{name}
408 Version: %{version}
409 Release: %{rel_kern}
410 License: @ZFS_META_LICENSE@
411 URL: git://github.com/zfsonlinux/zfs.git
412 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id} -un)
413 Source: @PACKAGE@-%{version}.tar.gz
414
415 %if %{?with_kernel}
416
417 %if %{defined req_kern}
418 Requires: %{req_kern}
419 %endif
420 %if %{defined kdevpkg_kern}
421 BuildRequires: %{kdevpkg_kern}
422 %endif
423 %if %{defined splreq_kern}
424 Requires: %{splreq_kern}
425 %endif
426 %if %{defined spldevpkg_kern}
427 BuildRequires: %{spldevpkg_kern}
428 %endif
429 Provides: lustre-backend-fs
430
431 %endif
432
433 %description
434 The %{name} package contains kernel modules and support utilities for
435 the %{name} file system.
436
437 %if %{?with_kernel}
438
439 %package devel
440 Summary: ZFS File System Headers and Symbols
441 Group: Development/Libraries
442 Release: %{rel_kern}
443 %if %{defined devreq_kern}
444 Requires: %{devreq_kern}
445 %endif
446 %if %{defined kdevpkg_kern}
447 BuildRequires: %{kdevpkg_kern}
448 %endif
449 %if %{defined spldevreq_kern}
450 Requires: %{spldevreq_kern}
451 %endif
452 %if %{defined spldevpkg_kern}
453 BuildRequires: %{spldevpkg_kern}
454 %endif
455
456 %description devel
457 The %{name}-devel package contains the kernel header files and
458 Module.symvers symbols needed for building additional modules
459 which use %{name}.
460
461 %endif
462 %if %{?with_kernel_debug}
463
464 %package debug
465 Summary: ZFS File System (Debug)
466 Group: Utilities/System
467 Release: %{rel_dbug}
468 %if %{defined req_dbug}
469 Requires: %{req_dbug}
470 %endif
471 %if %{defined kdevpkg_dbug}
472 BuildRequires: %{kdevpkg_dbug}
473 %endif
474 %if %{defined splreq_dbug}
475 Requires: %{splreq_dbug}
476 %endif
477 %if %{defined spldevpkg_dbug}
478 BuildRequires: %{spldevpkg_dbug}
479 %endif
480 Provides: lustre-backend-fs
481
482 %description debug
483 The %{name}-debug package contains debug kernel modules and support
484 utilities for the %{name} file system.
485
486 %package debug-devel
487 Summary: ZFS File System Headers and Symbols (Debug)
488 Group: Development/Libraries
489 Release: %{rel_dbug}
490 %if %{defined devreq_dbug}
491 Requires: %{devreq_dbug}
492 %endif
493 %if %{defined kdevpkg_dbug}
494 BuildRequires: %{kdevpkg_dbug}
495 %endif
496 %if %{defined spldevreq_dbug}
497 Requires: %{spldevreq_dbug}
498 %endif
499 %if %{defined spldevpkg_dbug}
500 BuildRequires: %{spldevpkg_dbug}
501 %endif
502
503 %description debug-devel
504 The %{name}-debug-devel package contains the debug kernel header files
505 and Module.symvers symbols needed for building additional modules
506 which use %{name}.
507
508 %endif
509 %if %{?with_kernel_dkms}
510
511 %package dkms
512 Summary: ZFS File System (DKMS)
513 Group: Utilities/System
514 Release: %{rel_dkms}
515 Provides: %{name}
516 BuildArch: noarch
517 %if %{defined req_dkms}
518 Requires: %{req_dkms}
519 %endif
520 %if %{defined kdevpkg_dkms}
521 BuildRequires: %{kdevpkg_dkms}
522 %endif
523 %if %{defined splreq_dkms}
524 Requires: %{splreq_dkms}
525 %endif
526 %if %{defined spldevpkg_dkms}
527 BuildRequires: %{spldevpkg_dkms}
528 %endif
529 Provides: lustre-backend-fs
530
531 %description dkms
532 The %{name}-dkms package contains the necessary pieces to build and
533 install the ZFS kernel modules with Dynamic Kernel Modules Support
534 (DKMS).
535
536 %endif
537
538 %prep
539 %setup -n @PACKAGE@-%{version}
540 %build
541 rm -rf $RPM_BUILD_ROOT
542
543 %if %{with_kernel}
544
545 %configure --with-linux=%{kdir_kern} --with-linux-obj=%{kobj_kern} \
546 --with-spl=%{spldir_kern} --with-spl-obj=%{splobj_kern} \
547 --with-config=kernel %{kdebug} %{kdebug_dmu_tx}
548 make
549 make DESTDIR=$RPM_BUILD_ROOT install
550
551 %endif
552 %if %{?with_kernel_debug}
553
554 %configure --with-linux=%{kdir_dbug} --with-linux-obj=%{kobj_dbug} \
555 --with-spl=%{spldir_dbug} --with-spl-obj=%{splobj_dbug} \
556 --with-config=kernel %{kdebug} %{kdebug_dmu_tx}
557 make
558 make DESTDIR=$RPM_BUILD_ROOT install
559
560 %endif
561 %if %{?with_kernel_dkms}
562
563 %configure %{kdebug} %{kdebug_dmu_tx}
564 make dist
565 mkdir -p $RPM_BUILD_ROOT/%{_prefix}/src
566 tar -xf @PACKAGE@-%{version}.tar.gz -C $RPM_BUILD_ROOT/%{_prefix}/src
567 cp -af dkms.conf $RPM_BUILD_ROOT/%{_prefix}/src/@PACKAGE@-%{version}
568
569 %endif
570
571 %clean
572 rm -rf $RPM_BUILD_ROOT
573
574 %if %{?with_kernel}
575
576 %files
577 %defattr(-, root, root)
578 /lib/modules/%{kver_kern}/*
579
580 %files devel
581 %defattr(-,root,root)
582 %{_prefix}/src/*/%{kver_kern}
583
584 %post
585 if [ -f /boot/System.map-%{kver_kern} ]; then
586 /sbin/depmod -ae -F /boot/System.map-%{kver_kern} %{kver_kern} || exit 0
587 else
588 /sbin/depmod -a || exit 0
589 fi
590
591 %postun
592 if [ -f /boot/System.map-%{kver_kern} ]; then
593 /sbin/depmod -ae -F /boot/System.map-%{kver_kern} %{kver_kern} || exit 0
594 else
595 /sbin/depmod -a || exit 0
596 fi
597
598 %postun devel
599 rmdir %{_prefix}/src/@PACKAGE@-%{version}-@ZFS_META_RELEASE@ 2>/dev/null
600 exit 0
601
602 %endif
603 %if %{?with_kernel_debug}
604
605 %files debug
606 %defattr(-, root, root)
607 /lib/modules/%{kver_dbug}/*
608
609 %files debug-devel
610 %defattr(-,root,root)
611 %{_prefix}/src/*/%{kver_dbug}
612
613 %post debug
614 if [ -f /boot/System.map-%{kver_dbug} ]; then
615 /sbin/depmod -ae -F /boot/System.map-%{kver_dbug} %{kver_dbug} || exit 0
616 else
617 /sbin/depmod -a || exit 0
618 fi
619
620 %postun debug
621 if [ -f /boot/System.map-%{kver_dbug} ]; then
622 /sbin/depmod -ae -F /boot/System.map-%{kver_dbug} %{kver_dbug} || exit 0
623 else
624 /sbin/depmod -a || exit 0
625 fi
626
627 %postun debug-devel
628 rmdir %{_prefix}/src/@PACKAGE@-%{version}-@ZFS_META_RELEASE@ 2>/dev/null
629 exit 0
630
631 %endif
632 %if %{?with_kernel_dkms}
633
634 %files dkms
635 %defattr(-,root,root)
636 %{_prefix}/src/@PACKAGE@-%{version}
637
638 %post dkms
639 for POSTINST in %{_prefix}/lib/dkms/common.postinst; do
640 if [ -f $POSTINST ]; then
641 $POSTINST @PACKAGE@ %{version}
642 exit $?
643 fi
644 echo "WARNING: $POSTINST does not exist."
645 done
646 echo -e "ERROR: DKMS version is too old and @PACKAGE@ was not"
647 echo -e "built with legacy DKMS support."
648 echo -e "You must either rebuild @PACKAGE@ with legacy postinst"
649 echo -e "support or upgrade DKMS to a more current version."
650 exit 1
651
652 %preun dkms
653 echo -e
654 echo -e "Uninstall of @PACKAGE@ module (version %{version}) beginning:"
655 dkms remove -m @PACKAGE@ -v %{version} --all --rpm_safe_upgrade
656 exit 0
657
658 %endif