diff --git a/akmods.spec b/akmods.spec index 0349ce4..ac8c3b5 100644 --- a/akmods.spec +++ b/akmods.spec @@ -1,6 +1,6 @@ Name: akmods Version: 0.5.6 -Release: 11%{?dist} +Release: 12%{?dist} Summary: Automatic kmods build and install tool License: MIT @@ -18,13 +18,16 @@ Source7: akmods-shutdown Source8: akmods-shutdown.service Source9: README Source10: LICENSE +Source11: akmods@.service BuildArch: noarch BuildRequires: help2man # not picked up automatically +%if 0%{?rhel} == 6 Requires: %{_bindir}/nohup +%endif Requires: %{_bindir}/flock Requires: %{_bindir}/time @@ -101,6 +104,7 @@ sed "s|@SERVICE@|display-manager.service|" %{SOURCE6} >\ install -pm 0644 %{SOURCE0} %{buildroot}%{_presetdir}/ install -pm 0755 %{SOURCE7} %{buildroot}%{_sbindir}/ install -pm 0644 %{SOURCE8} %{buildroot}%{_unitdir}/ +install -pm 0644 %{SOURCE11} %{buildroot}%{_unitdir}/ %else mkdir -p %{buildroot}%{_initddir}/ install -pm 0755 %{SOURCE4} %{buildroot}%{_initddir}/akmods @@ -126,14 +130,17 @@ useradd -r -g akmods -d /var/cache/akmods/ -s /sbin/nologin \ %if 0%{?fedora} || 0%{?rhel} > 6 %post %systemd_post akmods.service +%systemd_post akmods@.service %systemd_post akmods-shutdown.service %preun %systemd_preun akmods.service +%systemd_preun akmods@.service %systemd_preun akmods-shutdown.service %postun %systemd_postun akmods.service +%systemd_postun akmods@.service %systemd_postun akmods-shutdown.service %else %post @@ -156,6 +163,7 @@ fi %{_sysconfdir}/kernel/postinst.d/akmodsposttrans %if 0%{?fedora} || 0%{?rhel} > 6 %{_unitdir}/akmods.service +%{_unitdir}/akmods@.service %{_sbindir}/akmods-shutdown %{_unitdir}/akmods-shutdown.service %{_presetdir}/95-akmods.preset @@ -168,6 +176,9 @@ fi %changelog +* Wed Dec 13 2017 Nicolas Chauvet - 0.5.6-12 +- Update kernel posttrans method - rhbz#1518401 + * Thu Aug 03 2017 Nicolas Chauvet - 0.5.6-11 - Rework kernel-devel requires on el diff --git a/akmods@.service b/akmods@.service new file mode 100644 index 0000000..946edb0 --- /dev/null +++ b/akmods@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Builds and install new kmods from akmod for a given kernel + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/sbin/akmods --from-kernel-posttrans --kernels %i + +[Install] +WantedBy=multi-user.target diff --git a/akmodsposttrans b/akmodsposttrans old mode 100644 new mode 100755 index c619952..bfe0f3a --- a/akmodsposttrans +++ b/akmodsposttrans @@ -3,6 +3,7 @@ # akmodposttrans - Calls akmods for newly installed kernels # # Copyright (c) 2009 Thorsten Leemhuis +# Copyright (c) 2017 Nicolas Chauvet # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -23,15 +24,24 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -# todo-list: -# - scary idea: install kernel-devel packages on demand? -# - redirect output to a seperate logfile? # just check in case a user calls this directly if [[ ! -w / ]]; then echo "Needs to run as root to be able to install rpms." >&2 - exit 1 + exit 4 fi # needs to run in background as rpmdb might be locked otherwise -nohup /usr/sbin/akmods --from-kernel-posttrans --kernels ${1} &> /dev/null & +if [ -e /bin/systemctl ] ; then + # Exit early if system-update.target is active - rhbz#1518401 + /bin/systemctl is-active system-update.target &>/dev/null + RET=$? + + [ $RET == 0 ] && exit 0 + + /bin/systemctl start akmods@${1}.service --no-block >/dev/null 2>&1 +else + nohup /usr/sbin/akmods --from-kernel-posttrans --kernels ${1} > /dev/null 2>&1 & +fi + +exit 0