From fd0dd6ecd8cf5665b998ca8a8a994a96ba75cb6f 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 | 163 +++++++++++++----- 1 file changed, 120 insertions(+), 43 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..8b9596fc 100644 --- a/scripts/package_building/deps-lis/rpm/lis-daemon.spec +++ b/scripts/package_building/deps-lis/rpm/lis-daemon.spec @@ -3,6 +3,8 @@ %global hv_vss_daemon hypervvssd %global hv_fcopy_daemon hypervfcopyd +%global snapver .20180415git +%global udev_prefix 70 # nodebuginfo # norootforbuild @@ -16,30 +18,78 @@ 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 -Requires(post): systemd -Requires(preun): systemd -Requires(postun): systemd - +Requires: hypervkvpd = %{version}-%{release} +Requires: hypervvssd = %{version}-%{release} +Requires: hypervfcopyd = %{version}-%{release} +BuildRequires: systemd, kernel-headers %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. + +%package -n hypervkvpd +Summary: HyperV key value pair (KVP) daemon +Group: System Environment/Daemons +Requires: kernel >= 3.10.0-123 +BuildRequires: systemd, kernel-headers +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%description -n hypervkvpd +Hypervkvpd is an implementation of HyperV key value pair (KVP) +functionality for Linux. The daemon first registers with the +kernel driver. After this is done it collects information +requested by Windows Host about the Linux Guest. It also supports +IP injection functionality on the Guest. + +%package -n hypervvssd +Summary: HyperV VSS daemon +Group: System Environment/Daemons +Requires: kernel >= 3.10.0-123 +BuildRequires: systemd, kernel-headers +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%description -n hypervvssd +Hypervvssd is an implementation of HyperV VSS functionality +for Linux. The daemon is used for host initiated guest snapshot +on HyperV hypervisor. The daemon first registers with the +kernel driver. After this is done it waits for instructions +from Windows Host if to "freeze" or "thaw" the filesystem +on the Linux Guest. + +%package -n hypervfcopyd +Summary: HyperV FCOPY daemon +Group: System Environment/Daemons +Requires: kernel >= 3.10.0-123 +BuildRequires: systemd, kernel-headers +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%description -n hypervfcopyd +Hypervfcopyd is an implementation of file copy service functionality +for Linux Guest running on HyperV. The daemon enables host to copy +a file (over VMBUS) into the Linux Guest. The daemon first registers +with the kernel driver. After this is done it waits for instructions +from Windows Host. %prep %setup -Tc @@ -57,7 +107,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 +115,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 +130,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 +143,67 @@ 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 || : +%post -n hypervkvpd +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl --no-reload disable hypervkvpd.service >/dev/null 2>&1 || : 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 || : -fi +%preun -n hypervkvpd +%systemd_preun hypervkvpd.service -%postun +%postun -n hypervkvpd +# hypervkvpd daemon does NOT support restarting (driver, neither) %systemd_postun hypervkvpd.service +# If removing the package, delete %%{_sharedstatedir}/hyperv directory +if [ "$1" -eq "0" ] ; then + rm -rf %{_sharedstatedir}/hyperv || : +fi + + +%post -n hypervvssd +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl --no-reload disable hypervvssd.service >/dev/null 2>&1 || : +fi + +%postun -n hypervvssd %systemd_postun hypervvssd.service + +%preun -n hypervvssd +%systemd_preun hypervvssd.service + + +%post -n hypervfcopyd +if [ $1 -gt 1 ] ; then + # Upgrade + systemctl --no-reload disable hypervfcopyd.service >/dev/null 2>&1 || : +fi + +%postun -n hypervfcopyd %systemd_postun hypervfcopyd.service +%preun -n hypervfcopyd +%systemd_preun hypervfcopyd.service + + %files +# the base package does not contain any files. + +%files -n hypervkvpd %{_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 + +%files -n hypervvssd %{_sbindir}/%{hv_vss_daemon} %{_unitdir}/hypervvssd.service -%{_udevrulesdir}/%{udev_prefix}-70-hv_vss.rules +%{_udevrulesdir}/%{udev_prefix}-hv_vss.rules + +%files -n hypervfcopyd %{_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