Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Fix install hyperv-daemon on CentOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Feb 5, 2020
1 parent 10ae0c4 commit aa44a7d
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions scripts/package_building/deps-lis/rpm/lis-daemon.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
%global hv_vss_daemon hypervvssd
%global hv_fcopy_daemon hypervfcopyd

%global udev_prefix 70
# nodebuginfo
# norootforbuild

Expand All @@ -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
Expand All @@ -57,14 +57,15 @@ 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
make clean
make

%install
rm -rf %{buildroot}

mkdir -p %{buildroot}%{_sbindir}
install -p -m 0755 hv_kvp_daemon %{buildroot}%{_sbindir}/%{hv_kvp_daemon}
Expand All @@ -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}
Expand All @@ -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

0 comments on commit aa44a7d

Please sign in to comment.