diff --git a/module-contrib/plugsched.service b/module-contrib/plugsched.service index b7cfbf3f89926794a78dedd6f87f0507b59e3870..a6473fa20a7e019e08c94e1ee987b2945d1f5e8b 100644 --- a/module-contrib/plugsched.service +++ b/module-contrib/plugsched.service @@ -7,8 +7,8 @@ ConditionKernelCommandLine=!plugsched.enable=0 [Service] Type=oneshot -ExecStartPre=/usr/bin/bash -c "hotfix_conflict_check /var/plugsched/$(uname -r)/tainted_functions" -ExecStart=/usr/local/bin/scheduler-install install +ExecStartPre=/usr/bin/bash -c "/var/plugsched/$(uname -r)/hotfix_conflict_check /var/plugsched/$(uname -r)/tainted_functions" +ExecStart=/usr/bin/bash -c "/var/plugsched/$(uname -r)/scheduler-install install" [Install] WantedBy=multi-user.target diff --git a/module-contrib/scheduler-install b/module-contrib/scheduler-install index 64cde05e88de34cf4f5fd6aa43e9ab5a4e3d4e92..899855d6a5f8be8b00e578dd6cfb5a894004d108 100755 --- a/module-contrib/scheduler-install +++ b/module-contrib/scheduler-install @@ -58,17 +58,17 @@ uninstall_module() { fi } -if [ $1 == "install" ]; then +if [ "$1" == "install" ]; then if [ "$cursys" == "$mod" ]; then /usr/bin/mkdir -p /run/plugsched /usr/bin/cp $modfile /run/plugsched/scheduler.ko - /usr/local/bin/symbol_resolve /run/plugsched/scheduler.ko /proc/kallsyms + /var/plugsched/$(uname -r)/symbol_resolve /run/plugsched/scheduler.ko /proc/kallsyms install_module /run/plugsched/scheduler.ko else warn "Error: kernel version is not same as plugsched version!" exit 1 fi -elif [ $1 == "uninstall" ]; then +elif [ "$1" == "uninstall" ]; then uninstall_module /usr/bin/rm -rf /run/plugsched else diff --git a/module-contrib/scheduler.spec b/module-contrib/scheduler.spec index b36d628f3dca34c88f8b7f1eab4114a5fb6da06b..969818a854549e596ee0dac474de89444ace69e4 100644 --- a/module-contrib/scheduler.spec +++ b/module-contrib/scheduler.spec @@ -49,17 +49,16 @@ awk -F '[(,)]' '$2!=""{print $2" "$3" vmlinux"}' %{_modpath}/tainted_functions{. %install #install tool, module and systemd service -mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_prefix}/lib/systemd/system mkdir -p %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch} -install -m 755 %{_tmpdir}/symbol_resolve/symbol_resolve %{buildroot}%{_bindir}/symbol_resolve +install -m 755 %{_tmpdir}/symbol_resolve/symbol_resolve %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/symbol_resolve install -m 755 %{_modpath}/scheduler.ko %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/scheduler.ko install -m 444 %{_sourcedir}/tainted_functions %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/tainted_functions -install -m 755 %{SOURCE1} %{buildroot}%{_bindir} +install -m 755 %{SOURCE1} %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch} install -m 644 %{SOURCE2} %{buildroot}%{_prefix}/lib/systemd/system -install -m 755 %{SOURCE3} %{buildroot}%{_bindir}/hotfix_conflict_check +install -m 755 %{SOURCE3} %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/hotfix_conflict_check install -m 644 %{SOURCE4} %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/version install -m 644 %{SOURCE5} %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/sched_boundary.yaml @@ -67,35 +66,40 @@ install -m 644 %{SOURCE5} %{buildroot}%{_localstatedir}/plugsched/%{KVER}-%{KREL %post sync -if [ $1 == 1 ]; then - echo "Installing scheduler" - systemctl daemon-reload - systemctl enable plugsched - systemctl start plugsched -elif [ $1 == 2 ]; then - echo "Upgrading scheduler - install new version." - /sbin/rmmod scheduler || echo "scheduler module not loaded. Skip rmmod and continue upgrade." +if [ "$(uname -r)" != "%{KVER}-%{KREL}.%{_arch}" ]; then + echo "INFO: scheduler dose not match kernel, skip load module..." + exit 0 fi +echo "Installing scheduler" +systemctl daemon-reload +systemctl enable plugsched +systemctl start plugsched + #uninstall kernel module before remove this rpm-package %preun -systemctl daemon-reload -if [ $1 == 0 ]; then - echo "Uninstalling scheduler" - /usr/local/bin/scheduler-install uninstall || exit 1 -elif [ $1 == 1 ]; then - echo "Upgrading scheduler - uninstall old version." - systemctl start scheduler +if [ "$(uname -r)" != "%{KVER}-%{KREL}.%{_arch}" ]; then + echo "INFO: scheduler dose not match kernel, skip unload module..." + exit 0 fi +echo "Uninstalling scheduler" +/var/plugsched/$(uname -r)/scheduler-install uninstall || exit 1 + +%postun +systemctl daemon-reload + %files -%{_bindir}/symbol_resolve -%{_bindir}/scheduler-install -%{_bindir}/hotfix_conflict_check +%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/symbol_resolve +%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/scheduler-install +%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/hotfix_conflict_check %{_prefix}/lib/systemd/system/plugsched.service %{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/scheduler.ko %{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/tainted_functions %{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/version %{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch}/sched_boundary.yaml +%dir +%{_localstatedir}/plugsched/%{KVER}-%{KREL}.%{_arch} + %changelog