- Use native systemd services for post 13.1 releases

OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=80
This commit is contained in:
Olaf Hering 2013-12-18 14:50:03 +00:00 committed by Git OBS Bridge
parent b861e778d1
commit c462528d4c
2 changed files with 84 additions and 1 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Dec 18 14:46:37 CET 2013 - ohering@suse.de
- Use native systemd services for post 13.1 releases
------------------------------------------------------------------- -------------------------------------------------------------------
Sun Sep 8 10:36:29 CEST 2013 - ohering@suse.de Sun Sep 8 10:36:29 CEST 2013 - ohering@suse.de

View File

@ -22,8 +22,19 @@
Name: hyper-v Name: hyper-v
ExclusiveArch: %ix86 x86_64 ExclusiveArch: %ix86 x86_64
# systemd for post 13.1 releases
%if 0%{?suse_version} > 1310
%define use_systemd 1
%else
%define use_systemd 0
%endif
%if %{use_systemd}
%{?systemd_requires}
BuildRequires: pkgconfig(systemd)
%else
PreReq: %insserv_prereq PreReq: %insserv_prereq
Requires(pre): coreutils Requires(pre): coreutils
%endif
Summary: Microsoft Hyper-V tools Summary: Microsoft Hyper-V tools
License: GPL-2.0 License: GPL-2.0
Group: System/Kernel Group: System/Kernel
@ -31,7 +42,7 @@ Supplements: modalias(dmi:*svnMicrosoftCorporation*pnVirtualMachine*rnVirtual
Supplements: modalias(pci:v00001414d00005353sv*sd*bc*sc*i*) Supplements: modalias(pci:v00001414d00005353sv*sd*bc*sc*i*)
Url: http://www.kernel.org Url: http://www.kernel.org
# Arbitrary version number # Arbitrary version number
Version: 5 Version: 6
Release: 0 Release: 0
Source5: hyper-v.kvptest.ps1.txt Source5: hyper-v.kvptest.ps1.txt
Source9: hyper-v.include.linux.hyperv.h Source9: hyper-v.include.linux.hyperv.h
@ -90,16 +101,64 @@ cp -avL %{S:20} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_get_dhcp_info
cp -avL %{S:21} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_get_dns_info cp -avL %{S:21} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_get_dns_info
cp -avL %{S:22} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_set_ifconfig cp -avL %{S:22} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_set_ifconfig
chmod 755 $RPM_BUILD_ROOT%{helper_dir}/bin/* chmod 755 $RPM_BUILD_ROOT%{helper_dir}/bin/*
%if %{use_systemd}
d=$RPM_BUILD_ROOT%{_unitdir}
mkdir -vp ${d}
#
cat > ${d}/%{hv_kvp_daemon}.service <<'EOF'
[Unit]
Description=Hyper-V KVP Daemon
ConditionVirtualization=microsoft
[Service]
Environment=%{helper_dir}/bin:/usr/sbin:/usr/bin:/sbin:/bin
Type=forking
# Restart appears to work, but its unsupported
# Reboot required until kernel-user protocol is fixed
ExecStartPre=/usr/bin/mkdir /run/%{hv_kvp_daemon}
ExecStart=/usr/sbin/%{hv_kvp_daemon}
ExecReload=/usr/bin/false
Restart=no
[Install]
WantedBy=default.target
EOF
#
cat > ${d}/%{hv_vss_daemon}.service <<'EOF'
[Unit]
Description=Hyper-V VSS Daemon
ConditionVirtualization=microsoft
[Service]
Type=forking
# Restart appears to work, but its unsupported
# Reboot required until kernel-user protocol is fixed
ExecStartPre=/usr/bin/mkdir /run/%{hv_vss_daemon}
ExecStart=/usr/sbin/%{hv_vss_daemon}
ExecReload=/usr/bin/false
Restart=no
[Install]
WantedBy=default.target
EOF
#
head -n 42 ${d}/*.service
%else
mkdir -p $RPM_BUILD_ROOT/etc/init.d mkdir -p $RPM_BUILD_ROOT/etc/init.d
install -m755 %{S:11} $RPM_BUILD_ROOT/etc/init.d/%{hv_kvp_daemon} install -m755 %{S:11} $RPM_BUILD_ROOT/etc/init.d/%{hv_kvp_daemon}
ln -sfvbn ../../etc/init.d/%{hv_kvp_daemon} $RPM_BUILD_ROOT/usr/sbin/rc%{hv_kvp_daemon} ln -sfvbn ../../etc/init.d/%{hv_kvp_daemon} $RPM_BUILD_ROOT/usr/sbin/rc%{hv_kvp_daemon}
install -m755 %{S:13} $RPM_BUILD_ROOT/etc/init.d/%{hv_vss_daemon} install -m755 %{S:13} $RPM_BUILD_ROOT/etc/init.d/%{hv_vss_daemon}
ln -sfvbn ../../etc/init.d/%{hv_vss_daemon} $RPM_BUILD_ROOT/usr/sbin/rc%{hv_vss_daemon} ln -sfvbn ../../etc/init.d/%{hv_vss_daemon} $RPM_BUILD_ROOT/usr/sbin/rc%{hv_vss_daemon}
%endif
%files %files
%defattr (-,root,root) %defattr (-,root,root)
%doc kvptest.ps1.txt %doc kvptest.ps1.txt
%if %{use_systemd}
%{_unitdir}
%else
/etc/init.d/* /etc/init.d/*
%endif
/usr/sbin/* /usr/sbin/*
%{helper_dir} %{helper_dir}
@ -121,6 +180,10 @@ then
fi fi
rmdir -v /var/opt/hyperv || : rmdir -v /var/opt/hyperv || :
fi fi
%if %{use_systemd}
%{service_add_pre %{hv_kvp_daemon}.service}
%{service_add_pre %{hv_vss_daemon}.service}
%endif
%post %post
board_vendor= board_vendor=
@ -139,18 +202,33 @@ then
fi fi
if test "${board_vendor}" = "Microsoft Corporation" -a "${product_name}" = "Virtual Machine" if test "${board_vendor}" = "Microsoft Corporation" -a "${product_name}" = "Virtual Machine"
then then
%if %{use_systemd}
%{service_add_post %{hv_kvp_daemon}.service}
%{service_add_post %{hv_vss_daemon}.service}
%else
echo "Enabling %{hv_kvp_daemon} on '${product_name}' from '${board_vendor}'" echo "Enabling %{hv_kvp_daemon} on '${product_name}' from '${board_vendor}'"
%{insserv_force_if_yast %{hv_kvp_daemon}} %{insserv_force_if_yast %{hv_kvp_daemon}}
echo "Enabling %{hv_vss_daemon} on '${product_name}' from '${board_vendor}'" echo "Enabling %{hv_vss_daemon} on '${product_name}' from '${board_vendor}'"
%{insserv_force_if_yast %{hv_vss_daemon}} %{insserv_force_if_yast %{hv_vss_daemon}}
%endif
fi fi
%preun %preun
%if %{use_systemd}
%{service_del_preun %{hv_kvp_daemon}.service}
%{service_del_preun %{hv_vss_daemon}.service}
%else
%stop_on_removal %{hv_kvp_daemon} %stop_on_removal %{hv_kvp_daemon}
%stop_on_removal %{hv_vss_daemon} %stop_on_removal %{hv_vss_daemon}
%endif
%postun %postun
# no restart on update because the daemon can not be restarted # no restart on update because the daemon can not be restarted
%if %{use_systemd}
%{service_del_postun %{hv_kvp_daemon}.service}
%{service_del_postun %{hv_vss_daemon}.service}
%else
%insserv_cleanup %insserv_cleanup
%endif
%changelog %changelog