Whamcloud - gitweb
LU-9183 llite: handle make the string hashes salt the hash
[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 # If client package is installed when installing server, remove it since
41 # the server package also includes the client.  This can be removed if/when
42 # the packages are split into independent client/server/common packages.
43 Obsoletes:      @PACKAGE@-client
44 %endif
45 Requires:       gcc, make, perl
46 Requires:       kernel-devel
47 Provides:       %{requires_kmod_name} = %{version}
48 Provides:       %{module}-modules = %{version}
49 %if %{with servers}
50 # Only zfs Lustre DKMS Server is supported
51 Provides:       %{module}-osd-zfs = %{version}
52 Provides:       %{module}-osd
53 %endif
54
55 %description
56 This package contains the dkms Lustre kernel modules.
57
58 %prep
59 %setup -q -n @PACKAGE@-%{version}
60
61 %build
62 cat << EOF > dkms.conf
63 # Embryonic lustre-dkms dkms.conf to allow for on-target accurate and full
64 # version re-create during first run of Lustre DKMS module build step.
65 PACKAGE_NAME=%{module}
66 PACKAGE_VERSION=%{version}
67 PACKAGE_CONFIG="/etc/sysconfig/lustre"
68 PRE_BUILD="lustre-dkms_pre-build.sh \$module \$module_version \$kernelver \
69          \$kernel_source_dir \$arch \$source_tree \$dkms_tree"
70 POST_BUILD="lustre-dkms_post-build.sh \$module \$module_version \$kernelver \
71          \$kernel_source_dir \$arch \$source_tree \$dkms_tree"
72 EOF
73 %if %{with servers}
74 cat << EOF >> dkms.conf
75 BUILD_DEPENDS[0]="zfs"
76 EOF
77 %endif
78 cat << EOF >> dkms.conf
79 AUTOINSTALL="yes"
80 REMAKE_INITRD="no"
81 MAKE[0]="make"
82 # just have to set STRIP[0], it will become the new default.
83 STRIP[0]="\$(
84   [[ -r \${PACKAGE_CONFIG} ]] \\
85   && source \${PACKAGE_CONFIG} \\
86   && shopt -q -s extglob \\
87   && [[ \${LUSTRE_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] \\
88   && echo -n no
89 )"
90
91 # at least one module's set of BUILT_MODULE_NAME[]/BUILT_MODULE_LOCATION[]
92 # elements, along with an install path made of either "extra" or "updates"
93 # subdir in its DEST_MODULE_LOCATION[] element, are required to fake during
94 # dkms.conf validity checks of "dkms [add,build]" steps.
95 # Final/full correct BUILT_MODULE_NAME[]/BUILT_MODULE_LOCATION[]/
96 # DEST_MODULE_LOCATION[] sets of values for all modules will be fixed during
97 # on-target post-configure run of dkms.mkconf as part of build step.
98 # it must be for a module shared by both lustre[-client]-dkms packages.
99 BUILT_MODULE_NAME[\${#BUILT_MODULE_NAME[@]}]="lustre"
100 BUILT_MODULE_LOCATION[\${#BUILT_MODULE_LOCATION[@]}]="lustre/llite/"
101 DEST_MODULE_LOCATION[\${#DEST_MODULE_LOCATION[@]}]="/extra/lustre/"
102 EOF
103
104 %install
105 if [ "$RPM_BUILD_ROOT" != "/" ]; then
106     rm -rf $RPM_BUILD_ROOT
107 fi
108 mkdir -p $RPM_BUILD_ROOT/usr/src/
109 cp -rfp ${RPM_BUILD_DIR}/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/
110 %if %{without servers}
111 # To have the directory reflect the DKMS RPM name!
112 mv $RPM_BUILD_ROOT/usr/src/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/%{module}-%{version}
113 %endif
114
115 %clean
116 if [ "$RPM_BUILD_ROOT" != "/" ]; then
117     rm -rf $RPM_BUILD_ROOT
118 fi
119
120 %files
121 %defattr(-,root,root)
122 /usr/src/%{module}-%{version}
123
124 %post
125 for POSTINST in /usr/lib/dkms/common.postinst; do
126     if [ -f $POSTINST ]; then
127         $POSTINST %{module} %{version}
128         exit $?
129     fi
130     echo "WARNING: $POSTINST does not exist."
131 done
132 echo -e "ERROR: DKMS version is too old and %{module} was not"
133 echo -e "built with legacy DKMS support."
134 echo -e "You must either rebuild %{module} with legacy postinst"
135 echo -e "support or upgrade DKMS to a more current version."
136 exit 1
137
138 %preun
139 dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade
140 exit 0
141
142 %changelog
143 * Sat Jan 23 2016 Bruno Faccini <bruno.faccini@intel.com>
144  - detect and handle cases where [spl,zfs]-dkms packages are not built
145  - also handle on-target configure issues
146 * Wed Oct  7 2015 Bruno Faccini <bruno.faccini@intel.com>
147  - adapted for Lustre Client DKMS creation
148  - allow for on-target reconfig to prevent static deps requires
149 * Mon Apr  8 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 2.3.63-1
150 - First DKMS packages.