sysv -> systemd switch [release 2.2.0.3-4mamba;Sat Dec 13 2014]

This commit is contained in:
Silvan Calarco 2024-01-05 21:49:47 +01:00
parent ce10972958
commit 4bfff59189
3 changed files with 108 additions and 9 deletions

11
dkms.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Dynamic Kernel Modules System
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/systemd/scripts/dkms start
ExecStop=/usr/lib/systemd/scripts/dkms stop
[Install]
WantedBy=multi-user.target

View File

@ -1,6 +1,6 @@
Name: dkms Name: dkms
Version: 2.2.0.3 Version: 2.2.0.3
Release: 3mamba Release: 4mamba
Summary: Dynamic Kernel Module Support Summary: Dynamic Kernel Module Support
Group: System/Tools Group: System/Tools
Vendor: openmamba Vendor: openmamba
@ -8,6 +8,8 @@ Distribution: openmamba
Packager: Ercole 'ercolinux' Carpanetto <ercole69@gmail.com> Packager: Ercole 'ercolinux' Carpanetto <ercole69@gmail.com>
URL: http://linux.dell.com/projects.shtml#dkms URL: http://linux.dell.com/projects.shtml#dkms
Source: http://linux.dell.com/dkms/permalink/dkms-%{version}.tar.gz Source: http://linux.dell.com/dkms/permalink/dkms-%{version}.tar.gz
Source1: dkms.service
Source2: dkms.systemd
Patch0: dkms-2.2.0.3-dont_fail_if_module_source_removed.patch Patch0: dkms-2.2.0.3-dont_fail_if_module_source_removed.patch
License: GPL License: GPL
## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-BEGIN
@ -29,27 +31,45 @@ DKMS stands for Dynamic Kernel Module Support. It is designed to create a framew
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" [ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
make install-redhat DESTDIR=%{buildroot} make install-redhat DESTDIR=%{buildroot}
install -D -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/dkms.service
install -D -m0755 %{SOURCE2} %{buildroot}%{_prefix}/lib/systemd/scripts/dkms
rm -f %{buildroot}%{_initrddir}/dkms_autoinstaller
install -d %{buildroot}%{_presetdir}
cat > %{buildroot}%{_presetdir}/50-dkms.preset << _EOF
enable dkms.service
_EOF
%clean %clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" [ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%post %post
%systemd_post %{name}
if [ $1 -ge 1 ]; then if [ $1 -ge 1 ]; then
/sbin/chkconfig --add dkms_autoinstaller systemctl -q enable %{name}
/sbin/service dkms_autoinstaller start systemctl -q start %{name}
fi fi
: :
%preun %preun
if [ $1 -eq 0 ]; then %systemd_preun %{name}
/sbin/chkconfig --del dkms_autoinstaller :
fi
%postun
%systemd_postun %{name}
:
%posttrans
# clean old sysv broken links
find /etc/rc[0-6].d/ -type l -xtype l -exec rm -f {} \;
: :
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%{_sysconfdir}/dkms/template-dkms-mkrpm.spec %{_sysconfdir}/dkms/template-dkms-mkrpm.spec
%{_sysconfdir}/dkms/template-dkms-redhat-kmod.spec %{_sysconfdir}/dkms/template-dkms-redhat-kmod.spec
%{_initrddir}/dkms_autoinstaller
%{_sysconfdir}/bash_completion.d/dkms %{_sysconfdir}/bash_completion.d/dkms
%{_sysconfdir}/dkms/framework.conf %{_sysconfdir}/dkms/framework.conf
%{_sysconfdir}/kernel/postinst.d/dkms %{_sysconfdir}/kernel/postinst.d/dkms
@ -63,10 +83,17 @@ fi
%{_prefix}/lib/dkms/mkkerneldoth %{_prefix}/lib/dkms/mkkerneldoth
%dir %{_localstatedir}/lib/dkms %dir %{_localstatedir}/lib/dkms
%{_localstatedir}/lib/dkms/dkms_dbversion %{_localstatedir}/lib/dkms/dkms_dbversion
%{_mandir}/man8/dkms.8.gz %{_presetdir}/50-dkms.preset
%doc AUTHORS COPYING README.dkms TODO %{_unitdir}/dkms.service
%{_prefix}/lib/systemd/scripts/dkms
%{_mandir}/man8/dkms.8*
%doc AUTHORS COPYING
#README.dkms TODO
%changelog %changelog
* Sat Dec 13 2014 Silvan Calarco <silvan.calarco@mambasoft.it> 2.2.0.3-4mamba
- sysv -> systemd switch
* Sat Apr 13 2013 Silvan Calarco <silvan.calarco@mambasoft.it> 2.2.0.3-3mamba * Sat Apr 13 2013 Silvan Calarco <silvan.calarco@mambasoft.it> 2.2.0.3-3mamba
- added a patch to avoid failed with dkms status and remove if missing source directory - added a patch to avoid failed with dkms status and remove if missing source directory

61
dkms.systemd Normal file
View File

@ -0,0 +1,61 @@
#!/bin/bash
. /etc/default/dkms
# list dkms modules for the current running kernel
list_dkms_modules() {
shopt -s nullglob
declare -a DKMS_MOULES
# dkms status needs uname -r to list correctly intalled version for current kernel
local modules_path=($(dkms status -k "$(uname -r)"|sed -rn 's#(.*), (.*), (.*), (.*): installed#\1/\2/\3/\4#p'))
for p in "${modules_path[@]}"; do
for m in /var/lib/dkms/"$p"/module/*.ko{,gz}; do
m=${m##*/}
m=${m%.gz}
m=${m%.ko}
DKMS_MODULES+=("$m")
done
done
}
# load installed kernel modules for the current kernel version
load_dkms_modules() {
local ret=0
list_dkms_modules
for m in "${DKMS_MODULES[@]}"; do
modprobe "$m"
ret+=$?
done
return $ret
}
# unload installed kernel modules for the current kernel version
unload_dkms_modules() {
list_dkms_modules
# ask for removal
for m in "${DKMS_MODULES[@]}"; do
modprobe --remove --quiet "$m"
done
# check modules are unloaded
# sometimes modprobe -r fail but modules are removed
for m in "${DKMS_MODULES[@]}"; do
[[ -e /sys/modules/$m ]] && return 1
done
return 0
}
case "$1" in
start)
dkms autoinstall -k "$(uname -r)"
[[ $LOAD =~ [Yy][Ee][Ss] ]] && load_dkms_modules
;;
stop)
[[ $UNLOAD =~ [Yy][Ee][Ss] ]] && unload_dkms_modules
;;
*)
echo "usage: $0 {start|stop}" >&2
;;
esac
:
# vim:set ts=2 sw=2 ft=sh et: