1
by Matt Domsch
Import upstream version 2.0.17.4 |
1 |
%{?!module_name: %{error: You did not specify a module name (%%module_name)}} |
2 |
%{?!version: %{error: You did not specify a module version (%%version)}} |
|
3 |
%{?!kernel_versions: %{error: You did not specify kernel versions (%%kernel_version)}} |
|
4 |
%{?!packager: %define packager DKMS <dkms-devel@lists.us.dell.com>}
|
|
5 |
%{?!license: %define license Unknown}
|
|
6 |
%{?!_dkmsdir: %define _dkmsdir /var/lib/dkms}
|
|
7 |
%{?!_srcdir: %define _srcdir %_prefix/src}
|
|
8 |
||
9 |
Summary: %{module_name} %{version} dkms package |
|
10 |
Name: %{module_name} |
|
11 |
Version: %{version} |
|
12 |
License: %license |
|
13 |
Release: 1dkms |
|
14 |
BuildArch: noarch |
|
15 |
Group: System/Kernel |
|
16 |
Requires: dkms >= 1.95 |
|
17 |
BuildRequires: dkms |
|
18 |
Source0: %{module_name}-%{version}-mktarball.dkms.tgz |
|
19 |
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root/ |
|
20 |
||
21 |
%description
|
|
22 |
Kernel modules for %{module_name} %{version} in a DKMS wrapper. |
|
23 |
||
24 |
%prep
|
|
25 |
/usr/sbin/dkms mktarball -m %module_name -v %version %mktarball_line --archive `basename %{SOURCE0}`
|
|
26 |
cp -af %{_dkmsdir}/%{module_name}/%{version}/tarball/`basename %{SOURCE0}` %{SOURCE0} |
|
27 |
||
28 |
%install
|
|
29 |
if [ "$RPM_BUILD_ROOT" != "/" ]; then |
|
30 |
rm -rf $RPM_BUILD_ROOT
|
|
31 |
fi |
|
32 |
mkdir -p $RPM_BUILD_ROOT/%{_srcdir}/%{module_name}-%{version}/ |
|
33 |
install -m 644 %{SOURCE0} $RPM_BUILD_ROOT/%{_srcdir}/%{module_name}-%{version} |
|
34 |
||
35 |
%clean
|
|
36 |
if [ "$RPM_BUILD_ROOT" != "/" ]; then |
|
37 |
rm -rf $RPM_BUILD_ROOT
|
|
38 |
fi |
|
39 |
||
40 |
%post
|
|
41 |
# Determine current arch / kernel
|
|
42 |
[ `uname -m` == "x86_64" ] && [ `cat /proc/cpuinfo | grep -c "Intel"` -gt 0 ] && [ -e /etc/redhat-release ] && [ `grep -c "Taroon" /etc/redhat-release` -gt 0 ] && c_arch="ia32e" || c_arch=`uname -m` |
|
43 |
c_kern=`uname -r` |
|
44 |
||
45 |
# Load prebuilt binaries
|
|
46 |
echo -e ""
|
|
47 |
echo -e "Loading kernel module source and prebuilt module binaries (if any)"
|
|
48 |
dkms ldtarball --archive %{_srcdir}/%{module_name}-%{version}/%{module_name}-%{version}-mktarball.dkms.tgz >/dev/null 2>&1 |
|
49 |
||
50 |
# Install prebuilt binaries
|
|
51 |
echo -e "Installing prebuilt kernel module binaries (if any)"
|
|
52 |
IFS=' |
|
53 |
' |
|
54 |
for kern in `dkms status -m %{module_name} -v %{version} -a $c_arch | grep ": built" | awk {'print $3'} | sed 's/,$//'`; do |
|
55 |
dkms install -m %{module_name} -v %{version} -k $kern -a $c_arch >/dev/null 2>&1 |
|
56 |
done |
|
57 |
unset IFS |
|
58 |
||
59 |
# If nothing installed for `uname -r` build and install it
|
|
60 |
if [ `dkms status -m %{module_name} -v %{version} -k $c_kern -a $c_arch | grep -c ": installed"` -eq 0 ]; then |
|
61 |
if [ `echo $c_kern | grep -c "BOOT"` -eq 0 ] && [ -e /lib/modules/$c_kern/build/include ]; then
|
|
62 |
dkms build -m %{module_name} -v %{version} |
|
63 |
dkms install -m %{module_name} -v %{version} |
|
64 |
elif [ `echo $c_kern | grep -c "BOOT"` -gt 0 ]; then
|
|
65 |
echo -e ""
|
|
66 |
echo -e "Module build for the currently running kernel was skipped since you"
|
|
67 |
echo -e "are running a BOOT variant of the kernel."
|
|
68 |
else |
|
69 |
echo -e ""
|
|
70 |
echo -e "Module build for the currently running kernel was skipped since the"
|
|
71 |
echo -e "kernel source for this kernel does not seem to be installed."
|
|
72 |
fi |
|
73 |
fi |
|
74 |
||
75 |
echo -e ""
|
|
76 |
echo -e "Your DKMS tree now includes:"
|
|
77 |
dkms status -m %{module_name} -v %{version} |
|
78 |
exit 0 |
|
79 |
||
80 |
%preun
|
|
81 |
echo -e |
|
82 |
echo -e "Uninstall of %{module_name} module (version %{version}) beginning:" |
|
83 |
dkms remove -m %{module_name} -v %{version} --all --rpm_safe_upgrade |
|
84 |
exit 0 |
|
85 |
||
86 |
%files
|
|
87 |
%defattr(-,root,root)
|
|
88 |
/usr/src/%{module_name}-%{version}/ |
|
89 |
||
90 |
%changelog
|
|
91 |
* %(date "+%a %b %d %Y") %packager %{version}-%{release}
|
|
92 |
- Automatic build by DKMS |
|
93 |