LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File microsoft-hyper-v.spec of Package RHEL6 (Project isv:microsoft)

#
# spec file for package microsoft-hyper-v
#
# Copyright (c) 2010 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.
#
#

# nodebuginfo
# norootforbuild

%ifarch i386
Buildarch: i686
%endif

%ifarch i686
%define MODULES vmbus netvsc storvsc hv_timesource hid
%endif
%ifarch x86_64
%define MODULES vmbus netvsc storvsc hv_timesource hid
%endif
%define releasetag beta
%define my_release 3.%(date +%Y%m%d).%{releasetag}
Name:			microsoft-hyper-v

BuildRequires:          %kernel_module_package_buildreqs
Requires:               microsoft-hyper-v-kmod = rhel63.3
License:		GPLv2+
Group:			System/Kernel
Summary:		Microsoft hyper-v drivers and utilities
Version:		rhel63.3
Release:		%{release}
Source0:		microsoft-hyper-v-rhel63.3.3-beta2.tar.gz
Source1:		hypervkvpd
Source2:		Makefile.rh
BuildRoot:		%{_tmppath}/%{name}-%{version}-build

%kernel_module_package

%description
This package and subpackage contain drivers and utilities for the Microsoft Hyper-V environment.

%prep
%setup -n hv
cp %_sourcedir/Makefile.rh Makefile
cp hyperv_pvdrivers.conf %_sourcedir/
cp tools/hv_kvp_daemon.c %_sourcedir/
set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
for flavor in %flavors_to_build; do
        rm -rf obj/$flavor
        cp -r source obj/$flavor
        make -C %{kernel_source $flavor} M=$PWD/obj/$flavor modules
done
pushd source/tools
gcc $RPM_OPT_FLAGS -g hv_kvp_daemon.c -o hv_kvp_daemon
popd

%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=extra/%{name}
for flavor in %flavors_to_build; do
        make -C %{kernel_source $flavor} M=$PWD/obj/$flavor modules_install
done
install -d -m0755 $RPM_BUILD_ROOT/etc/modprobe.d
install    -m0644 source/hyperv_pvdrivers.conf $RPM_BUILD_ROOT/etc/modprobe.d/
install -d -m0755 $RPM_BUILD_ROOT/usr/sbin
install    -m0755 source/tools/hv_kvp_daemon $RPM_BUILD_ROOT/usr/sbin/
install -d -m0755 $RPM_BUILD_ROOT/etc/init.d
install    -m0755 %{S:1} $RPM_BUILD_ROOT/etc/init.d/hv_kvp_daemon

%pre
%ifarch i686
if [ `uname -i` == "x86_64" ]; then
  echo "This system supports 64-bit; please install the x86_64 versions of the Hyper-V modules.  Exiting now..."
  exit 1
fi
%endif

%ifarch x86_64
if [ `uname -i` == "i686" ]; then
  echo "This system supports 32-bit; please install the x86 versions of the Hyper-V modules.  Exiting now..."
  exit 1
fi
%endif


%post
# Update initrd
dracut --force "initramfs-$(uname -r).img" $(uname -r)
echo "Saving old initramfs"
if [ ! -e /boot/"initramfs-$(uname -r).img-old" ]
then
  cp -f /boot/"initramfs-$(uname -r).img" /boot/"initramfs-$(uname -r).img-old"
fi
echo "Installing new initramfs"
cp -f "initramfs-$(uname -r).img" /boot/"initramfs-$(uname -r).img"
/sbin/chkconfig --add hv_kvp_daemon
/etc/init.d/hv_kvp_daemon start >/dev/null

%preun
if [ $1 -eq 0 ]; then # package is being erased, not upgraded
    /sbin/service hv_kvp_daemon stop > /dev/null 2>&1
    /sbin/chkconfig --del hv_kvp_daemon
fi

%postun
echo "Create and install initramfs without Hyper-V drivers"
dracut --force "initramfs-$(uname -r).img" $(uname -r)
cp -f "initramfs-$(uname -r).img" /boot/"initramfs-$(uname -r).img"
if [ "$1" -ge "1" ]; then # Upgrade
    /sbin/service vmbus condrestart > /dev/null 2>&1
fi
echo "Linux Integration Services for Hyper-V has been removed.  Please reboot your system."

%files
%defattr(0755,root,root)
/etc/modprobe.d/hyperv_pvdrivers.conf
/etc/init.d/hv_kvp_daemon
/usr/sbin/hv_kvp_daemon

%changelog
* Sun Apr 25 2010 - andavis@novell.com
- Initial PLDP packages from code version 2.1.25.