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