File dkms.spec of Package dkms
#
# spec file for package dkms
#
%if 0%{?rhel} == 5
%define _sharedstatedir /var/lib
%endif
Summary: Dynamic Kernel Module Support Framework
Name: dkms
Version: 2.3
Release: 0.1
License: GPL-2.0+
Vendor: The Bumblebee Project
Group: System Environment/Base
BuildArch: noarch
URL: https://github.com/dell/dkms
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source0: https://github.com/dell/dkms/archive/%{version}/dkms-%{version}.tar.gz
Source1: %{name}.service
Source2: %{name}.default
Source100: %{name}.changes
Source101: %{name}.rpmlintrc
# because Mandriva calls this package dkms-minimal
Provides: dkms-minimal = %{version}
Requires: coreutils
Requires: cpio
Requires: findutils
Requires: gawk
Requires: gcc
Requires: grep
Requires: gzip
Requires: kernel-devel
Requires: sed
Requires: tar
Requires: which
Requires: bash > 1.99
%if 0%{?suse_version}
Patch0: %{name}-%{version}-compat_suse_init_script.diff
%endif
%if 0%{?fedora} || 0%{?rhel} >= 7
Requires: kmod
%else
Requires: module-init-tools
%endif
%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1230
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%else
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service
%endif
%if 0%{?fedora} || 0%{?suse_version}
Requires: kernel-devel
%endif
%description
This package contains the framework for the Dynamic Kernel Module Support (DKMS)
method for installing module RPMS as originally developed by Dell.
%prep
%setup -q
%if 0%{?suse_version}
%patch0
%endif
%build
%triggerpostun -- %{name} < 1.90.00-1
for dir in `find %{_localstatedir}/%{name} -type d -maxdepth 1 -mindepth 1`; do
mv -f $dir %{_localstatedir}/lib/%{name}
done
[ -e %{_sysconfdir}/dkms_framework.conf ] && ! [ -e %{_sysconfdir}/%{name}/framework.conf ] && mkdir %{_sysconfdir}/%{name} && cp -a %{_sysconfdir}/dkms_framework.conf %{_sysconfdir}/%{name}/framework.conf
arch_used=""
[ `uname -m` == "x86_64" ] && [ `cat /proc/cpuinfo | grep -c "Intel"` -gt 0 ] && arch_used="ia32e" || arch_used=`uname -m`
echo ""
echo "ALERT! ALERT! ALERT!"
echo ""
echo "You are using a version of DKMS which does not support multiple system"
echo "architectures. Your DKMS tree will now be modified to add this support."
echo ""
echo "The upgrade will assume all built modules are for arch: $arch_used"
current_kernel=`uname -r`
dkms_tree="%{_localstatedir}/lib/%{name}"
source_tree="%{_prefix}/src"
tmp_location="/tmp"
dkms_frameworkconf="%{_sysconfdir}/%{name}/framework.conf"
. $dkms_frameworkconf 2>/dev/null
echo ""
echo "Fixing directories."
for directory in `find $dkms_tree -type d -name "module" -mindepth 3 -maxdepth 4`; do
dir_to_fix=`echo $directory | sed 's#/module$##'`
echo "Creating $dir_to_fix/$arch_used..."
mkdir $dir_to_fix/$arch_used
mv -f $dir_to_fix/* $dir_to_fix/$arch_used 2>/dev/null
done
echo ""
echo "Fixing symlinks."
for symlink in `find $dkms_tree -type l -name "kernel*" -mindepth 2 -maxdepth 2`; do
symlink_kernelname=`echo $symlink | sed 's#.*/kernel-##'`
dir_of_symlink=`echo $symlink | sed 's#/kernel-.*$##'`
cd $dir_of_symlink
read_link="$symlink"
while [ -L "$read_link" ]; do
read_link=`ls -l $read_link | sed 's/.*-> //'`
done
if [ `echo $read_link | sed 's#/# #g' | wc -w | awk {'print $1'}` -lt 3 ]; then
echo "Updating $symlink..."
ln -sf $read_link/$arch_used kernel-$symlink_kernelname-$arch_used
rm -f $symlink
fi
cd -
done
echo ""
%install
rm -rf $RPM_BUILD_ROOT
%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1230
make install-redhat-systemd DESTDIR=$RPM_BUILD_ROOT \
SBIN=$RPM_BUILD_ROOT%{_sbindir} \
VAR=$RPM_BUILD_ROOT%{_localstatedir}/lib/%{name} \
MAN=$RPM_BUILD_ROOT%{_mandir}/man8 \
ETC=$RPM_BUILD_ROOT%{_sysconfdir}/%{name} \
BASHDIR=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d \
LIBDIR=$RPM_BUILD_ROOT%{_prefix}/lib/%{name}
#
# Replace the systemd service
#
rm $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
install -m 644 %{SOURCE1} "%{buildroot}%{_unitdir}/%{name}.service"
#
# Add defaults
#
%if 0%{?suse_version}
mkdir -p "%{buildroot}%{_sysconfdir}/default"
install -m 644 %{SOURCE2} "%{buildroot}%{_sysconfdir}/default/dkms"
%endif
%else
make install-redhat-sysv DESTDIR=$RPM_BUILD_ROOT \
SBIN=$RPM_BUILD_ROOT%{_sbindir} \
VAR=$RPM_BUILD_ROOT%{_localstatedir}/lib/%{name} \
MAN=$RPM_BUILD_ROOT%{_mandir}/man8 \
ETC=$RPM_BUILD_ROOT%{_sysconfdir}/%{name} \
BASHDIR=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d \
LIBDIR=$RPM_BUILD_ROOT%{_prefix}/lib/%{name}
%if 0%{?suse_version}
# create rcdkms_autoinstaller symlink for openSUSE
mkdir -p $RPM_BUILD_ROOT/%{_initddir}
mv $RPM_BUILD_ROOT/etc/rc.d/init.d/dkms_autoinstaller $RPM_BUILD_ROOT/%{_initddir}/dkms_autoinstaller
ln -sf %{_initddir}/dkms_autoinstaller $RPM_BUILD_ROOT/usr/sbin/rcdkms_autoinstaller
%endif
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1230
%pre
%service_add_pre %{name}.service
%post
# make it more secure
if [ ! -d %{_tmppath}/dkms ] ;
then
mkdir -p %{_tmppath}/dkms
chmod 700 %{_tmppath}/dkms
fi
sed -i -e 's,# tmp_location="/tmp",tmp_location="%{_tmppath}/dkms",' %{_sysconfdir}/dkms/framework.conf
#
%service_add_post %{name}.service
#
# Allways enable and start this service
#
systemctl enable dkms.service >/dev/null 2>&1 || :
systemctl start dkms.service >/dev/null 2>&1 || :
%preun
if [ $1 -eq 0 ]; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
fi
#
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
# remove on uninstall
[ $1 -lt 1 ] && rm -rf %{_tmppath}/dkms || :
%else
%post
# enable on initial install
[ $1 -lt 2 ] && /sbin/chkconfig --add dkms_autoinstaller >/dev/null 2>&1 ||:
[ $1 -lt 2 ] && /sbin/chkconfig dkms_autoinstaller on >/dev/null 2>&1 ||:
# make it more secure
if [ ! -d %{_tmppath}/dkms ] ;
then
mkdir -p %{_tmppath}/dkms
chmod 700 %{_tmppath}/dkms
fi
sed -i -e 's,# tmp_location="/tmp",tmp_location="%{_tmppath}/dkms",' %{_sysconfdir}/dkms/framework.conf
%preun
# remove on uninstall
[ $1 -lt 1 ] && /sbin/chkconfig dkms_autoinstaller off >/dev/null 2>&1 ||:
[ $1 -lt 1 ] && /sbin/chkconfig --del dkms_autoinstaller >/dev/null 2>&1 ||:
%endif
%files
%defattr(-,root,root)
%doc sample.spec sample.conf AUTHORS COPYING README.dkms
%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1230
%{_unitdir}/%{name}.service
%if 0%{?suse_version}
%config %{_sysconfdir}/default/dkms
%endif
%else
%{_initrddir}/%{name}_autoinstaller
%if 0%{?suse_version}
%{_sbindir}/rcdkms_autoinstaller
%endif
%endif
%{_prefix}/lib/%{name}
%{_mandir}/*/*
%{_sbindir}/%{name}
%{_localstatedir}/lib/%{name}
%config(noreplace) %{_sysconfdir}/%{name}
# these dirs are for plugins - owned by other packages
%{_sysconfdir}/kernel/postinst.d/%{name}
%{_sysconfdir}/kernel/prerm.d/%{name}
%{_sysconfdir}/bash_completion.d/%{name}
%if 0%{?suse_version}
%doc sample-suse-9-mkkmp.spec sample-suse-10-mkkmp.spec
# suse doesnt yet support /etc/kernel/{prerm.d,postinst.d}, but will fail build
# with unowned dirs if we dont own them ourselves
# when opensuse *does* add this support, we will need to BuildRequires kernel
%dir %{_sysconfdir}/kernel
%dir %{_sysconfdir}/kernel/postinst.d
%dir %{_sysconfdir}/kernel/prerm.d
%endif
%changelog