8e8f9a7
# HyperV KVP daemon binary name
8e8f9a7
%global hv_kvp_daemon hypervkvpd
8e8f9a7
# HyperV VSS daemon binary name
8e8f9a7
%global hv_vss_daemon hypervvssd
8e8f9a7
# snapshot version
8e8f9a7
%global snapver .20130826git
8e8f9a7
# use hardened build
8e8f9a7
%global _hardened_build 1
8e8f9a7
8e8f9a7
Name:     hyperv-daemons
8e8f9a7
Version:  0
269fc42
Release:  0.2%{?snapver}%{?dist}
8e8f9a7
Summary:  HyperV daemons suite
8e8f9a7
8e8f9a7
Group:    System Environment/Daemons
8e8f9a7
License:  GPLv2
8e8f9a7
URL:      http://www.kernel.org
8e8f9a7
8e8f9a7
# Source files obtained from kernel upstream 2013-08-26.
8e8f9a7
# git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
8e8f9a7
# The daemon and scripts are located in "master branch - /tools/hv"
8e8f9a7
# COPYING -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/COPYING?id=refs/tags/next-20130822 
8e8f9a7
Source0:  COPYING
8e8f9a7
8e8f9a7
# HYPERV KVP DAEMON
8e8f9a7
# hv_kvp_daemon.c -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_kvp_daemon.c?id=refs/tags/next-20130822
8e8f9a7
Source1:  hv_kvp_daemon.c
8e8f9a7
# hv_get_dhcp_info.sh -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_get_dhcp_info.sh?id=refs/tags/next-20130822
8e8f9a7
Source2:  hv_get_dhcp_info.sh
8e8f9a7
# hv_get_dns_info.sh -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_get_dns_info.sh?id=refs/tags/next-20130822
8e8f9a7
Source3:  hv_get_dns_info.sh
8e8f9a7
# hv_set_ifconfig.sh -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_set_ifconfig.sh?id=refs/tags/next-20130822
8e8f9a7
Source4:  hv_set_ifconfig.sh
8e8f9a7
Source5:  hypervkvpd.service
8e8f9a7
8e8f9a7
# HYPERV VSS DAEMON
8e8f9a7
# hv_vss_daemon.c -> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/plain/tools/hv/hv_vss_daemon.c?id=refs/tags/next-20130822
8e8f9a7
Source100:  hv_vss_daemon.c
8e8f9a7
Source101:  hypervvssd.service
8e8f9a7
8e8f9a7
# HYPERV KVP DAEMON
8e8f9a7
# Correct paths to external scripts ("/usr/libexec/hypervkvpd").
8e8f9a7
Patch0:   hypervkvpd-0-corrected_paths_to_external_scripts.patch
8e8f9a7
# use quoted include for linux/hyperv.h because we use gcc option
8e8f9a7
# -iquote for include PATH where it is located. This is because
8e8f9a7
# some headers in system include PATH are also in kernel-devel
8e8f9a7
# package.
8e8f9a7
Patch1:   hypervkvpd-0-include_fix.patch
8e8f9a7
# rhbz#872566
8e8f9a7
Patch2:   hypervkvpd-0-long_file_names_from_readdir.patch
8e8f9a7
# Remove daemon() call and let systemd handle it
8e8f9a7
Patch3:   hypervkvpd-0-dont_call_deamon.patch
8e8f9a7
8e8f9a7
# HYPERV VSS DAEMON
8e8f9a7
# use quoted include for linux/hyperv.h because we use gcc option
8e8f9a7
# -iquote for include PATH where it is located. This is because
8e8f9a7
# some headers in system include PATH are also in kernel-devel
8e8f9a7
# package.
8e8f9a7
Patch100:   hypervvssd-0-fix_includes.patch
8e8f9a7
# Remove daemon() call and let systemd handle it
8e8f9a7
Patch101:   hypervvssd-0-dont_call_daemon.patch
8e8f9a7
8e8f9a7
BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
8e8f9a7
# HyperV is available only on x86 architectures
8e8f9a7
ExclusiveArch:  i686 x86_64
8e8f9a7
Requires:       hypervkvpd = %{version}-%{release}
8e8f9a7
Requires:       hypervvssd = %{version}-%{release}
8e8f9a7
8e8f9a7
%description
8e8f9a7
Suite of daemons that are needed when Linux guest
8e8f9a7
is running on Windows Host with HyperV.
8e8f9a7
8e8f9a7
8e8f9a7
%package -n hypervkvpd
8e8f9a7
Summary: HyperV key value pair (KVP) daemon
8e8f9a7
Group:   System Environment/Daemons
8e8f9a7
Requires: %{name}-license = %{version}-%{release}
8e8f9a7
BuildRequires: systemd, kernel-devel
8e8f9a7
Requires(post):   systemd
8e8f9a7
Requires(preun):  systemd
8e8f9a7
Requires(postun): systemd
8e8f9a7
8e8f9a7
%description -n hypervkvpd
8e8f9a7
Hypervkvpd is an implementation of HyperV key value pair (KVP) 
8e8f9a7
functionality for Linux. The daemon first registers with the
8e8f9a7
kernel driver. After this is done it collects information 
8e8f9a7
requested by Windows Host about the Linux Guest. It also supports
8e8f9a7
IP injection functionality on the Guest.
8e8f9a7
8e8f9a7
8e8f9a7
%package -n hypervvssd
8e8f9a7
Summary: HyperV VSS daemon
8e8f9a7
Group:   System Environment/Daemons
8e8f9a7
Requires: %{name}-license = %{version}-%{release}
8e8f9a7
BuildRequires: systemd, kernel-devel
8e8f9a7
Requires(post):   systemd
8e8f9a7
Requires(preun):  systemd
8e8f9a7
Requires(postun): systemd
8e8f9a7
8e8f9a7
%description -n hypervvssd
8e8f9a7
Hypervvssd is an implementation of HyperV VSS functionality
8e8f9a7
for Linux. The daemon is used for host initiated guest snapshot
8e8f9a7
on HyperV hypervisor. The daemon first registers with the
8e8f9a7
kernel driver. After this is done it waits for instructions 
8e8f9a7
from Windows Host if to "freeze" or "thaw" the filesystem
8e8f9a7
on the Linux Guest.
8e8f9a7
8e8f9a7
8e8f9a7
%package license
8e8f9a7
Summary:    License of the HyperV daemons suite
8e8f9a7
Group:      Applications/System
8e8f9a7
BuildArch:  noarch
8e8f9a7
8e8f9a7
%description license
8e8f9a7
Contains license of the HyperV daemons suite.
8e8f9a7
8e8f9a7
8e8f9a7
%prep
8e8f9a7
%setup -Tc
8e8f9a7
cp -pvL %{SOURCE0} COPYING
8e8f9a7
8e8f9a7
cp -pvL %{SOURCE1} hv_kvp_daemon.c
8e8f9a7
cp -pvL %{SOURCE2} hv_get_dhcp_info.sh
8e8f9a7
cp -pvL %{SOURCE3} hv_get_dns_info.sh
8e8f9a7
cp -pvL %{SOURCE4} hv_set_ifconfig.sh
8e8f9a7
cp -pvL %{SOURCE5} hypervkvpd.service
8e8f9a7
8e8f9a7
cp -pvL %{SOURCE100} hv_vss_daemon.c
8e8f9a7
cp -pvL %{SOURCE101} hypervvssd.service
8e8f9a7
8e8f9a7
%patch0 -p1 -b .external_scripts
8e8f9a7
%patch1 -p1 -b .include
8e8f9a7
%patch2 -p1 -b .long_names
8e8f9a7
%patch3 -p1 -b .daemon
8e8f9a7
8e8f9a7
%patch100 -p1 -b .include
8e8f9a7
%patch101 -p1 -b .daemon
8e8f9a7
8e8f9a7
8e8f9a7
%build
8e8f9a7
# kernel-devel version
8e8f9a7
%{!?kversion: %global kversion `ls %{_usrsrc}/kernels | sort -dr | head -n 1`}
8e8f9a7
8e8f9a7
# HYPERV KVP DAEMON
8e8f9a7
gcc \
8e8f9a7
    $RPM_OPT_FLAGS \
8e8f9a7
    -iquote %{_usrsrc}/kernels/%{kversion}/include \
8e8f9a7
    -c hv_kvp_daemon.c
8e8f9a7
    
8e8f9a7
gcc \
8e8f9a7
    $RPM_LD_FLAGS \
8e8f9a7
    hv_kvp_daemon.o \
8e8f9a7
    -o %{hv_kvp_daemon}
8e8f9a7
8e8f9a7
# HYPERV VSS DAEMON
8e8f9a7
gcc \
8e8f9a7
    $RPM_OPT_FLAGS \
8e8f9a7
    -iquote %{_usrsrc}/kernels/%{kversion}/include \
8e8f9a7
    -c hv_vss_daemon.c
8e8f9a7
    
8e8f9a7
gcc \
8e8f9a7
    $RPM_LD_FLAGS \
8e8f9a7
    hv_vss_daemon.o \
8e8f9a7
    -o %{hv_vss_daemon}
8e8f9a7
8e8f9a7
8e8f9a7
%install
8e8f9a7
rm -rf %{buildroot}
8e8f9a7
8e8f9a7
mkdir -p %{buildroot}%{_sbindir}
8e8f9a7
install -p -m 0755 %{hv_kvp_daemon} %{buildroot}%{_sbindir}
8e8f9a7
install -p -m 0755 %{hv_vss_daemon} %{buildroot}%{_sbindir}
8e8f9a7
mkdir -p %{buildroot}%{_unitdir}
8e8f9a7
# Systemd unit file
8e8f9a7
install -p -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}
8e8f9a7
install -p -m 0644 %{SOURCE101} %{buildroot}%{_unitdir}
269fc42
# Shell scripts for the KVP daemon
269fc42
mkdir -p %{buildroot}%{_libexecdir}/%{hv_kvp_daemon}
269fc42
install -p -m 0755 hv_get_dhcp_info.sh %{buildroot}%{_libexecdir}/%{hv_kvp_daemon}/hv_get_dhcp_info
269fc42
install -p -m 0755 hv_get_dns_info.sh %{buildroot}%{_libexecdir}/%{hv_kvp_daemon}/hv_get_dns_info
269fc42
install -p -m 0755 hv_set_ifconfig.sh %{buildroot}%{_libexecdir}/%{hv_kvp_daemon}/hv_set_ifconfig
8e8f9a7
# Directory for pool files
8e8f9a7
mkdir -p %{buildroot}%{_sharedstatedir}/hyperv
8e8f9a7
8e8f9a7
8e8f9a7
%post -n hypervkvpd
8e8f9a7
%systemd_post hypervkvpd.service
8e8f9a7
8e8f9a7
%preun -n hypervkvpd
8e8f9a7
%systemd_preun hypervkvpd.service
8e8f9a7
8e8f9a7
%postun -n hypervkvpd
8e8f9a7
# hypervkvpd daemon does NOT support restarting (driver, neither)
8e8f9a7
%systemd_postun hypervkvpd.service
8e8f9a7
# If removing the package, delete %%{_sharedstatedir}/hyperv directory
8e8f9a7
if [ "$1" -eq "0" ] ; then
8e8f9a7
    rm -rf %{_sharedstatedir}/hyperv || :
8e8f9a7
fi
8e8f9a7
8e8f9a7
8e8f9a7
%post -n hypervvssd
8e8f9a7
%systemd_post hypervvssd.service
8e8f9a7
8e8f9a7
%postun -n hypervvssd
8e8f9a7
%systemd_postun hypervvssd.service
8e8f9a7
8e8f9a7
%preun -n hypervvssd
8e8f9a7
%systemd_preun hypervvssd.service
8e8f9a7
8e8f9a7
8e8f9a7
%files -n hypervkvpd
8e8f9a7
%{_sbindir}/%{hv_kvp_daemon}
8e8f9a7
%{_unitdir}/hypervkvpd.service
269fc42
%dir %{_libexecdir}/%{hv_kvp_daemon}
269fc42
%{_libexecdir}/%{hv_kvp_daemon}/*
8e8f9a7
%dir %{_sharedstatedir}/hyperv
8e8f9a7
8e8f9a7
%files -n hypervvssd
8e8f9a7
%{_sbindir}/%{hv_vss_daemon}
8e8f9a7
%{_unitdir}/hypervvssd.service
8e8f9a7
8e8f9a7
%files license
8e8f9a7
%doc COPYING
8e8f9a7
8e8f9a7
%changelog
269fc42
* Fri Sep 20 2013 Tomas Hozza <thozza@redhat.com> - 0-0.2.20130826git
269fc42
- Use 'hypervkvpd' directory in libexec for KVP daemon scripts (#1010268)
269fc42
8e8f9a7
* Mon Aug 26 2013 Tomas Hozza <thozza@redhat.com> - 0-0.1.20130826git
8e8f9a7
- Initial package