From aa44a7dfdcc54e82f9308ce88aaffee9e21c4cc0 Mon Sep 17 00:00:00 2001 From: Lili Deng Date: Mon, 3 Feb 2020 22:39:54 -0800 Subject: [PATCH] Fix install hyperv-daemon on CentOS. --- .../deps-lis/rpm/lis-daemon.spec | 78 +++++++++---------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/scripts/package_building/deps-lis/rpm/lis-daemon.spec b/scripts/package_building/deps-lis/rpm/lis-daemon.spec index bf4745b6..17dc97c9 100644 --- a/scripts/package_building/deps-lis/rpm/lis-daemon.spec +++ b/scripts/package_building/deps-lis/rpm/lis-daemon.spec @@ -3,6 +3,7 @@ %global hv_vss_daemon hypervvssd %global hv_fcopy_daemon hypervfcopyd +%global udev_prefix 70 # nodebuginfo # norootforbuild @@ -16,30 +17,29 @@ License: GPLv2+ Summary: Microsoft hyper-v daemons Version: 1 Release: 0.29%{?snapver}%{?dist} -Source0: hv_kvp_daemon.c -Source1: hypervkvpd.service -Source2: hypervkvp.rules -Source3: hv_get_dhcp_info.sh -Source4: hv_get_dns_info.sh -Source5: hv_set_ifconfig.sh -Source6: hv_vss_daemon.c -Source7: hypervvss.rules -Source8: hypervvssd.service -Source9: hv_fcopy_daemon.c -Source10: hypervfcopy.rules +Source0: hv_kvp_daemon.c +Source1: hypervkvpd.service +Source2: hypervkvp.rules +Source3: hv_get_dhcp_info.sh +Source4: hv_get_dns_info.sh +Source5: hv_set_ifconfig.sh +Source6: hv_vss_daemon.c +Source7: hypervvss.rules +Source8: hypervvssd.service +Source9: hv_fcopy_daemon.c +Source10: hypervfcopy.rules Source11: hypervfcopyd.service -Source12: Makefile +Source12: Makefile Source13: Build BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: kernel >= 3.10.0-123 -BuildRequires: systemd, kernel-headers +BuildRequires: systemd, kernel-headers Requires(post): systemd Requires(preun): systemd Requires(postun): systemd - %description -Suite of daemons that are needed when Linux guest is running on Windows host with HyperV. +Suite of daemons that are needed when Linux guest is running on Windows host with HyperV. %prep %setup -Tc @@ -57,7 +57,7 @@ cp -pvL %{SOURCE10} %{hv_fcopy_daemon}.service cp -pvL %{SOURCE12} Makefile if [ ! -e "%{SOURCE13}" ]; then - touch %{SOURCE13} + touch %{SOURCE13} fi cp -pvL %{SOURCE13} Build %build @@ -65,6 +65,7 @@ make clean make %install +rm -rf %{buildroot} mkdir -p %{buildroot}%{_sbindir} install -p -m 0755 hv_kvp_daemon %{buildroot}%{_sbindir}/%{hv_kvp_daemon} @@ -79,9 +80,9 @@ install -p -m 0644 %{SOURCE11} %{buildroot}%{_unitdir} # Udev rules mkdir -p %{buildroot}%{_udevrulesdir} -install -p -m 0644 %{SOURCE2} %{buildroot}%{_udevrulesdir}/%{udev_prefix}-70-hv_kvp.rules -install -p -m 0644 %{SOURCE7} %{buildroot}%{_udevrulesdir}/%{udev_prefix}-70-hv_vss.rules -install -p -m 0644 %{SOURCE10} %{buildroot}%{_udevrulesdir}/%{udev_prefix}-70-hv_fcopy.rules +install -p -m 0644 %{SOURCE2} %{buildroot}%{_udevrulesdir}/%{udev_prefix}-hv_kvp.rules +install -p -m 0644 %{SOURCE7} %{buildroot}%{_udevrulesdir}/%{udev_prefix}-hv_vss.rules +install -p -m 0644 %{SOURCE10} %{buildroot}%{_udevrulesdir}/%{udev_prefix}-hv_fcopy.rules # Shell scripts for the KVP daemon mkdir -p %{buildroot}%{_libexecdir}/%{hv_kvp_daemon} @@ -92,41 +93,38 @@ install -p -m 0755 %{SOURCE5} %{buildroot}%{_libexecdir}/%{hv_kvp_daemon}/hv_set # Directory for pool files mkdir -p %{buildroot}%{_sharedstatedir}/hyperv -%preun -if [ $1 -eq 0 ]; then # package is being erased, not upgraded - echo "Removing Package.." - echo "Stopping KVP Daemon...." - systemctl stop hypervkvpd - echo "Stopping FCOPY Daemon...." - systemctl stop hypervfcopyd - echo "Stopping VSS Daemon...." - systemctl stop hypervvssd - rm -rf %{_sharedstatedir}/hyperv || : -fi - %post -if [ $1 > 1 ] ; then - # Upgrade - systemctl --no-reload disable hypervkvpd.service >/dev/null 2>&1 || : - systemctl --no-reload disable hypervvssd.service >/dev/null 2>&1 || : - systemctl --no-reload disable hypervfcopyd.service >/dev/null 2>&1 || : +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl --no-reload disable hypervkvpd.service >/dev/null 2>&1 || : + systemctl --no-reload disable hypervvssd.service >/dev/null 2>&1 || : + systemctl --no-reload disable hypervfcopyd.service >/dev/null 2>&1 || : fi -%postun +%preun +%systemd_preun hypervkvpd.service +%systemd_preun hypervvssd.service +%systemd_preun hypervfcopyd.service + +%postun %systemd_postun hypervkvpd.service +# If removing the package, delete %%{_sharedstatedir}/hyperv directory +if [ "$1" -eq "0" ] ; then + rm -rf %{_sharedstatedir}/hyperv || : +fi %systemd_postun hypervvssd.service %systemd_postun hypervfcopyd.service %files %{_sbindir}/%{hv_kvp_daemon} %{_unitdir}/hypervkvpd.service -%{_udevrulesdir}/%{udev_prefix}-70-hv_kvp.rules +%{_udevrulesdir}/%{udev_prefix}-hv_kvp.rules %dir %{_libexecdir}/%{hv_kvp_daemon} %{_libexecdir}/%{hv_kvp_daemon}/* %dir %{_sharedstatedir}/hyperv %{_sbindir}/%{hv_vss_daemon} %{_unitdir}/hypervvssd.service -%{_udevrulesdir}/%{udev_prefix}-70-hv_vss.rules +%{_udevrulesdir}/%{udev_prefix}-hv_vss.rules %{_sbindir}/%{hv_fcopy_daemon} %{_unitdir}/hypervfcopyd.service -%{_udevrulesdir}/%{udev_prefix}-70-hv_fcopy.rules +%{_udevrulesdir}/%{udev_prefix}-hv_fcopy.rules \ No newline at end of file