Whamcloud - gitweb
LU-6824 ldiskfs: add dir htree growing warning patch
[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 dkms add stage.
55 PACKAGE_NAME=%{module}
56 PACKAGE_VERSION=%{version}
57 POST_ADD="lustre-dkms_post-add.sh \$module \$module_version \$kernelver \
58          \$kernel_source_dir \$arch \$source_tree \$dkms_tree"
59 # at least one DEST_MODULE_LOCATION[] element, along with an install
60 # path made of either "extra" or "updates" subdir, are required during
61 # dkms.conf validity check of "dkms add" step.
62 DEST_MODULE_LOCATION[${#DEST_MODULE_LOCATION[@]}]="/extra/lnet/"
63 EOF
64
65 cat << EOF > lustre-dkms_post-add.sh
66 #!/bin/bash
67 # \$1 : \$module
68 # \$2 : \$module_version
69 # \$3 : \$kernelver
70 # \$4 : \$kernel_source_dir
71 # \$5 : \$arch
72 # \$6 : \$source_tree
73 # \$7 : \$dkms_tree
74
75 if [ \$1 = "lustre-client" ] ; then
76         SERVER="--disable-server"
77 else
78         SPL_VERSION=\$(dkms status -m spl -k \$3/\$5 | awk -F', ' '{print \$2; exit 0}' | sed 's/: added\$//')
79         ZFS_VERSION=\$(dkms status -m zfs -k \$3/\$5 | awk -F', ' '{print \$2; exit 0}' | sed 's/: added\$//')
80
81         SERVER="--enable-server --disable-ldiskfs --with-linux=\$4 --with-linux-obj=\$4 \\
82                --with-spl=\$6/spl-\${SPL_VERSION} \\
83                --with-spl-obj=\$7/spl/\${SPL_VERSION}/\$3/\$5 \\
84                --with-zfs=\$6/zfs-\${ZFS_VERSION} \\
85                --with-zfs-obj=\$7/zfs/\${ZFS_VERSION}/\$3/\$5"
86 fi
87
88 rpm -qa | grep krb5-devel >/dev/null
89 if [ \$? == 0 ] ; then
90         GSS="--enable-gss"
91 else
92         GSS="--disable-gss"
93 fi
94
95 # run a configure pass to clean "--enable-dist" only effect and also to
96 # ensure local/on-target environment to be taken into account
97 ./configure --enable-modules --disable-iokit --disable-snmp --disable-doc \\
98         --disable-utils --disable-tests --disable-maintainer-mode \\
99         \$GSS \$SERVER \\
100         --disable-manpages --disable-dlc
101 # re-create dkms.conf based on this
102 lustre/scripts/dkms.mkconf -n \$1 -v \$2 -f ./dkms.conf
103 EOF
104
105 chmod 755 lustre-dkms_post-add.sh
106
107 sed -i 's/BUILDID[[:print:]]*/BUILDID = %{buildid}/' META
108 sed -i 's/PRISTINE[[:print:]]*/PRISTINE = 1/' META
109 cp META ldiskfs/META
110
111 %install
112 if [ "$RPM_BUILD_ROOT" != "/" ]; then
113     rm -rf $RPM_BUILD_ROOT
114 fi
115 mkdir -p $RPM_BUILD_ROOT/usr/src/
116 cp -rfp ${RPM_BUILD_DIR}/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/
117 %if %{without servers}
118 # To have the directory reflect the DKMS RPM name!
119 mv $RPM_BUILD_ROOT/usr/src/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/%{module}-%{version}
120 %endif
121
122 %clean
123 if [ "$RPM_BUILD_ROOT" != "/" ]; then
124     rm -rf $RPM_BUILD_ROOT
125 fi
126
127 %files
128 %defattr(-,root,root)
129 /usr/src/%{module}-%{version}
130
131 %post
132 for POSTINST in /usr/lib/dkms/common.postinst; do
133     if [ -f $POSTINST ]; then
134         $POSTINST %{module} %{version}
135         exit $?
136     fi
137     echo "WARNING: $POSTINST does not exist."
138 done
139 echo -e "ERROR: DKMS version is too old and %{module} was not"
140 echo -e "built with legacy DKMS support."
141 echo -e "You must either rebuild %{module} with legacy postinst"
142 echo -e "support or upgrade DKMS to a more current version."
143 exit 1
144
145 %preun
146 dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade
147 exit 0
148
149 %changelog
150 * Wed Oct  7 2015 Bruno Faccini <bruno.faccini@intel.com>
151  - adapted for Lustre Client DKMS creation
152  - allow for on-target reconfig to prevent static deps requires
153 * Fri Apr  8 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 2.3.63-1
154 - First DKMS packages.