hyper-v/hyper-v.spec

156 lines
4.5 KiB
RPMSpec

#
# spec file for package hyper-v
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define hv_kvp_daemon hv_kvp_daemon
%define hv_vss_daemon hv_vss_daemon
Name: hyper-v
ExclusiveArch: %ix86 x86_64
PreReq: %insserv_prereq
Requires(pre): coreutils
Summary: Microsoft Hyper-V tools
License: GPL-2.0
Group: System/Kernel
Supplements: modalias(dmi*:svn*MicrosoftCorporation*:pn*VirtualMachine*:rn*VirtualMachine*)
Supplements: modalias(pci:v00001414d00005353sv*sd*bc*sc*i*)
Url: http://www.kernel.org
# Arbitrary version number
Version: 5
Release: 0
Source5: hyper-v.kvptest.ps1.txt
Source9: hyper-v.include.linux.hyperv.h
Source10: hyper-v.tools.hv.hv_kvp_daemon.c
Source11: hyper-v.init.sh
Source12: hyper-v.tools.hv.hv_vss_daemon.c
Source13: hyper-v.init.vss.sh
Source20: hyper-v.tools.hv.hv_get_dhcp_info.sh
Source21: hyper-v.tools.hv.hv_get_dns_info.sh
Source22: hyper-v.tools.hv.hv_set_ifconfig.sh
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
This package contains the Microsoft Hyper-V tools.
%prep
%setup -Tc
cp -avL %{S:5} kvptest.ps1.txt
cp -vL %{S:9} %{hv_kvp_daemon}.h
cp -vL %{S:10} %{hv_kvp_daemon}.c
cp -vL %{S:12} %{hv_vss_daemon}.c
%build
sed -i~ '/#include <linux.hyperv.h>/d' %{hv_kvp_daemon}.c
sed -i~ '/#include <linux.hyperv.h>/d' %{hv_vss_daemon}.c
gcc \
$RPM_OPT_FLAGS \
-Wno-unused-variable \
-Wno-pointer-sign \
-D_GNU_SOURCE \
-g \
%{hv_kvp_daemon}.c \
-include %{hv_kvp_daemon}.h \
-DCN_KVP_IDX=0x9 \
-DCN_KVP_VAL=0x1 \
-o %{hv_kvp_daemon}
gcc \
$RPM_OPT_FLAGS \
-Wno-unused-variable \
-Wno-pointer-sign \
-D_GNU_SOURCE \
-g \
%{hv_vss_daemon}.c \
-include %{hv_kvp_daemon}.h \
-DCN_VSS_IDX=0xa \
-DCN_VSS_VAL=0x1 \
-o %{hv_vss_daemon}
%install
mkdir -p $RPM_BUILD_ROOT/usr/sbin
install -m755 %{hv_kvp_daemon} $RPM_BUILD_ROOT/usr/sbin
install -m755 %{hv_vss_daemon} $RPM_BUILD_ROOT/usr/sbin
mkdir -p $RPM_BUILD_ROOT/usr/lib/%{name}/bin
cp -avL %{S:20} $RPM_BUILD_ROOT/usr/lib/%{name}/bin/hv_get_dhcp_info
cp -avL %{S:21} $RPM_BUILD_ROOT/usr/lib/%{name}/bin/hv_get_dns_info
cp -avL %{S:22} $RPM_BUILD_ROOT/usr/lib/%{name}/bin/hv_set_ifconfig
chmod 755 $RPM_BUILD_ROOT/usr/lib/%{name}/bin/*
mkdir -p $RPM_BUILD_ROOT/etc/init.d
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}
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}
%files
%defattr (-,root,root)
%doc kvptest.ps1.txt
/etc/init.d/*
/usr/sbin/*
/usr/lib/%{name}
%pre
# hv_kvp_daemon in SLES11 SP2 stored temporary state files in /var/opt
# move them to /var/lib and remove old directory, if possible.
if test -d /var/opt/hyperv
then
if mkdir -p -v -m 0755 /var/lib/hyperv && pushd /var/lib/hyperv > /dev/null
then
for oldfile in /var/opt/hyperv/ifcfg-* /var/opt/hyperv/.kvp_pool_*
do
if test -e "${oldfile}"
then
mv -vfb "${oldfile}" . || :
fi
done
popd > /dev/null
fi
rmdir -v /var/opt/hyperv || :
fi
%post
board_vendor=
product_name=
if pushd /sys/class/dmi/id > /dev/null 2>/dev/null
then
if test -r board_vendor
then
board_vendor="`cat board_vendor`"
fi
if test -r product_name
then
product_name="`cat product_name`"
fi
popd > /dev/null
fi
if test "${board_vendor}" = "Microsoft Corporation" -a "${product_name}" = "Virtual Machine"
then
echo "Enabling %{hv_kvp_daemon} on '${product_name}' from '${board_vendor}'"
%{insserv_force_if_yast %{hv_kvp_daemon}}
echo "Enabling %{hv_vss_daemon} on '${product_name}' from '${board_vendor}'"
%{insserv_force_if_yast %{hv_vss_daemon}}
fi
%preun
%stop_on_removal %{hv_kvp_daemon}
%stop_on_removal %{hv_vss_daemon}
%postun
# no restart on update because the daemon can not be restarted
%insserv_cleanup
%changelog