File virt-v2v.spec of Package virt-v2v

# spec file for package virt-v2v
# Copyright (c) 2014 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

Name:           virt-v2v
Version:        0.9.1
Release:        1%{?dist}%{?extra_release}
Summary:        Convert a virtual machine to run on KVM
License:        GPL-2.0+ and LGPL-2.1+
Group:          System/Management

Source0:        %{name}-%{version}-441cf090.tar.gz
Source1:        %{name}-rpmlintrc
Patch0:         remove_ide_iface.patch
Patch1:         add_verbose_messaging.patch
Patch2:         mask_unused_hv_features.patch
Patch3:         win_convert_on_suse.patch
Patch4:         fix_manifest.patch
Patch5:         remove_rhev_help.patch
Patch6:         suppress_warnings.patch
Patch7:         add_sles12_win7-2012.patch
Patch8:         catch_invalid_initrd_path.patch
Patch9:         remove-duplicate-btrfs-roots.patch
Patch10:        preallocate-if-lvm.patch
Patch11:        catch_sles12_pkg_not_found.patch
Patch12:        rename_vb_examples.patch
Patch13:        reset_virtio_after_config.patch
Patch14:        handle_ova_files.patch
Patch99:        remove_esx_examples.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

# Backported upstream patches
# Naming scheme: <name>-<version>-<local sequence number>-<git commit>.patch
#  name:         virt-v2v
#  version:      the version of virt-v2v the patch was originally rebased to
#  local seq no: the order the patches should be applied in
#  git commit:   the first 8 characters of the git commit hash

# Unfortunately, despite really being noarch, we have to make virt-v2v arch
# dependent to avoid build failures on architectures where libguestfs isn't
# available.
ExclusiveArch:  x86_64 ppc64 ppc64le s390x

# Build system direct requirements
BuildRequires:  gettext
BuildRequires:  perl
BuildRequires:  perl(ExtUtils::Manifest)
BuildRequires:  perl(Module::Build)
BuildRequires:  perl(Module::Find)
BuildRequires:  perl(Test::More)
BuildRequires:  perl(Test::Pod)
BuildRequires:  perl(Test::Pod::Coverage)

# Runtime perl modules also required at build time for use_ok test
BuildRequires:  perl(Archive::Extract)
BuildRequires:  perl(DateTime)
BuildRequires:  perl(Digest::SHA1)
BuildRequires:  perl(IO::String)
BuildRequires:  perl(Locale::TextDomain)
BuildRequires:  perl(Module::Pluggable)
BuildRequires:  perl(Net::HTTPS)
BuildRequires:  perl(Net::SSL)
BuildRequires:  perl(Sys::Guestfs)
BuildRequires:  perl(Sys::Virt)
BuildRequires:  perl(Term::ProgressBar)
BuildRequires:  perl(URI)
BuildRequires:  perl(XML::DOM)
BuildRequires:  perl(XML::DOM::XPath)

BuildRequires:  perl-Sys-Guestfs >= 1.14.0
BuildRequires:  perl-Win-Hivex >= 1.2.2

Requires:       perl-base
# Required for the name optional argument to add_drive_opts
Requires:       perl-Sys-Guestfs >= 1.14.0

# Undocumented from antiquity
Requires:       perl-Win-Hivex >= 1.2.2

# Required for passing flags to get_xml_description
Requires:       perl(Sys::Virt) >= 0.2.4

# Net::SSL and Net::HTTPS are loaded with require rather than use, which
# rpmbuild doesn't seem to discover automatically.
Requires:       perl(Net::HTTPS)
Requires:       perl(Net::SSL)

# The perl(Sys::Virt) requirement should satisfy the libvirt requirement
# Need >= 0.8.1 for rpc fix talking to RHEL 5 libvirt
#Requires:       libvirt >= 0.8.1

# For GuestOS transfer image
Requires:       /usr/bin/mkisofs

# For guest image inspection
Requires:       /usr/bin/qemu-img

# For ssh transfers
Requires:       /usr/bin/ssh

# For libvirt and ESX connections and transfers
Requires:       perl(URI)

# For Windows conversions 
Requires:       perl(IO::String)

# For OVA conversions 
Requires:       perl(Archive::Extract)
Requires:       perl(Digest::SHA1)

#Additional requirements to run on openSUSE 12.3
Requires:       guestfs-tools >= 1.22
Requires:       perl-DateTime >= 0.72
Requires:       perl-Term-ProgressBar >= 2.10
Requires:       perl-XML-DOM >= 1.44
Requires:       perl-XML-DOM-XPath >= 0.14
Requires:       perl-XML-XPathEngine >= 0.13

# For building rhsrvany
#BuildRequires:  autoconf
#BuildRequires:  automake
#BuildRequires:  mingw32-cross-gcc
#BuildRequires:  mingw32-filesystem
#BuildRequires:  mingw32-gcc

virt-v2v is a tool for converting and importing virtual machines to
libvirt-managed KVM, or Red Hat Enterprise Virtualization. It can import a
variety of guest operating systems from libvirt-managed hosts and VMware ESX.

%setup -q -n %{name}-%{version}

%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
# Apply remove_esx_example.patch only under SLES12
%if 0%{?suse_version} == 1315
%patch99 -p1

%{__perl} Build.PL
#./Build rhsrvany

# perl doesn't need debuginfo
%define debug_package %{nil}

rm -rf %{buildroot}
./Build install \
    --destdir %{buildroot} \
    --installdirs vendor \
    --install_path locale=%{_datadir}/locale \
    --install_path confdoc=%{_mandir}/man5

# Create lib directory, used for holding software to be installed in guests
mkdir -p $statedir/software

# Copy Windows dependencies into place
mkdir -p $windir

# Copy built rhsrvany.exe into place. There's no need for it to be executable
#cp rhsrvany/RHSrvAny/rhsrvany.exe $windir/
#chmod 0644 $windir/rhsrvany.exe

mkdir -p %{buildroot}%{_sysconfdir}
cp v2v/virt-v2v.conf %{buildroot}%{_sysconfdir}/
cp v2v/virt-v2v.db $statedir/

%find_lang %{name}

# Not clear why this is being created as there is nothing arch-specific in
# virt-v2v. It isn't packaged, though, so we need to delete it.
find %{buildroot} -name .packlist -type f | xargs rm

# Remove virt-p2v-server as it has a runtime requirement of YAML::Tiny, and 
# virt-p2v is not yet available on SUSE
rm %{buildroot}%{_bindir}/virt-p2v-server
rm %{buildroot}%{_mandir}/man1/virt-p2v-server.*

./Build test

rm -rf %{buildroot}

%files -f %{name}.lang

%doc TODO.txt
%doc META.yml

# For noarch packages: vendorlib

# Man pages

# Executables
%attr(0755,root,root) %{_bindir}/virt-v2v

%dir %{_localstatedir}/lib/virt-v2v

%config(noreplace) %{_sysconfdir}/virt-v2v.conf
%config %{_localstatedir}/lib/virt-v2v/virt-v2v.db
%config(noreplace) %{_localstatedir}/lib/virt-v2v/software