Whamcloud - gitweb
LU-9286 ptlrpc: fix wrong error handlers
[fs/lustre-release.git] / lustre-dkms.spec.in
1 %bcond_without servers
2
3 # Set the package name prefix
4 %if %{with servers}
5     %define module  @PACKAGE@
6 %else
7     %define module  @PACKAGE@-client
8 %endif
9
10 %if %{_vendor}=="redhat" || %{_vendor}=="fedora"
11         %global requires_kmod_name kmod-%{module}
12 %else   #for Suse
13         %global requires_kmod_name %{module}-kmp
14 %endif
15
16 %define buildid 1
17
18 Name:           %{module}-dkms
19
20 Version:        @VERSION@
21 Release:        %{buildid}%{?dist}
22 Summary:        Kernel module(s) (dkms)
23
24 Group:          System Environment/Kernel
25 License:        GPLv2+
26 URL:            http://lustre.opensfs.org/
27 Source0:        @PACKAGE@-%{version}.tar.gz
28 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
29 BuildArch:      noarch
30
31 # DKMS >= 2.2.0.3-28.git.7c3e7c5 to fully support inter-modules deps
32 # (ie, "BUILD_DEPENDS[#]=<pkg>"), and have latest DKMS fixes integrated
33 # for bugs that prevented our module to build/install.
34 Requires:       dkms >= 2.2.0.3-28.git.7c3e7c5
35 %if %{with servers}
36 # Only zfs Lustre DKMS Server is supported
37 Requires:       spl-dkms >= 0.6.1
38 Requires:       zfs-dkms >= 0.6.1
39 Requires:       %{module}-osd-zfs-mount
40 %endif
41 Requires:       gcc, make, perl
42 Requires:       kernel-devel
43 Provides:       %{requires_kmod_name} = %{version}
44 Provides:       %{module}-modules = %{version}
45 %if %{with servers}
46 # Only zfs Lustre DKMS Server is supported
47 Provides:       %{module}-osd-zfs = %{version}
48 Provides:       %{module}-osd
49 %endif
50
51 %description
52 This package contains the dkms Lustre kernel modules.
53
54 %prep
55 %setup -q -n @PACKAGE@-%{version}
56
57 %build
58 cat << EOF > dkms.conf
59 # Embryonic lustre-dkms dkms.conf to allow for on-target accurate and full
60 # version re-create during first run of Lustre DKMS module build step.
61 PACKAGE_NAME=%{module}
62 PACKAGE_VERSION=%{version}
63 PACKAGE_CONFIG="/etc/sysconfig/lustre"
64 PRE_BUILD="lustre-dkms_pre-build.sh \$module \$module_version \$kernelver \
65          \$kernel_source_dir \$arch \$source_tree \$dkms_tree"
66 POST_BUILD="lustre-dkms_post-build.sh \$module \$module_version \$kernelver \
67          \$kernel_source_dir \$arch \$source_tree \$dkms_tree"
68 EOF
69 %if %{with servers}
70 cat << EOF >> dkms.conf
71 BUILD_DEPENDS[0]="zfs"
72 EOF
73 %endif
74 cat << EOF >> dkms.conf
75 AUTOINSTALL="yes"
76 REMAKE_INITRD="no"
77 MAKE[0]="make"
78 # just have to set STRIP[0], it will become the new default.
79 STRIP[0]="\$(
80   [[ -r \${PACKAGE_CONFIG} ]] \\
81   && source \${PACKAGE_CONFIG} \\
82   && shopt -q -s extglob \\
83   && [[ \${LUSTRE_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] \\
84   && echo -n no
85 )"
86
87 # at least one module's set of BUILT_MODULE_NAME[]/BUILT_MODULE_LOCATION[]
88 # elements, along with an install path made of either "extra" or "updates"
89 # subdir in its DEST_MODULE_LOCATION[] element, are required to fake during
90 # dkms.conf validity checks of "dkms [add,build]" steps.
91 # Final/full correct BUILT_MODULE_NAME[]/BUILT_MODULE_LOCATION[]/
92 # DEST_MODULE_LOCATION[] sets of values for all modules will be fixed during
93 # on-target post-configure run of dkms.mkconf as part of build step.
94 # it must be for a module shared by both lustre[-client]-dkms packages.
95 BUILT_MODULE_NAME[\${#BUILT_MODULE_NAME[@]}]="lustre"
96 BUILT_MODULE_LOCATION[\${#BUILT_MODULE_LOCATION[@]}]="lustre/llite/"
97 DEST_MODULE_LOCATION[\${#DEST_MODULE_LOCATION[@]}]="/extra/lustre/"
98 EOF
99
100 %install
101 if [ "$RPM_BUILD_ROOT" != "/" ]; then
102     rm -rf $RPM_BUILD_ROOT
103 fi
104 mkdir -p $RPM_BUILD_ROOT/usr/src/
105 cp -rfp ${RPM_BUILD_DIR}/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/
106 %if %{without servers}
107 # To have the directory reflect the DKMS RPM name!
108 mv $RPM_BUILD_ROOT/usr/src/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/%{module}-%{version}
109 %endif
110
111 %clean
112 if [ "$RPM_BUILD_ROOT" != "/" ]; then
113     rm -rf $RPM_BUILD_ROOT
114 fi
115
116 %files
117 %defattr(-,root,root)
118 /usr/src/%{module}-%{version}
119
120 %post
121 for POSTINST in /usr/lib/dkms/common.postinst; do
122     if [ -f $POSTINST ]; then
123         $POSTINST %{module} %{version}
124         exit $?
125     fi
126     echo "WARNING: $POSTINST does not exist."
127 done
128 echo -e "ERROR: DKMS version is too old and %{module} was not"
129 echo -e "built with legacy DKMS support."
130 echo -e "You must either rebuild %{module} with legacy postinst"
131 echo -e "support or upgrade DKMS to a more current version."
132 exit 1
133
134 %preun
135 dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade
136 exit 0
137
138 %changelog
139 * Sat Jan 23 2016 Bruno Faccini <bruno.faccini@intel.com>
140  - detect and handle cases where [spl,zfs]-dkms packages are not built
141  - also handle on-target configure issues
142 * Wed Oct  7 2015 Bruno Faccini <bruno.faccini@intel.com>
143  - adapted for Lustre Client DKMS creation
144  - allow for on-target reconfig to prevent static deps requires
145 * Fri Apr  8 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 2.3.63-1
146 - First DKMS packages.