%global __python %{__python3}
Name:                virt-manager
Version:             2.1.0
Release:             3
Summary:             The manage virtual machines tool which via libvirt.
License:             GPLv2+
BuildArch:           noarch
URL:                 https://virt-manager.org/
Source0:             https://virt-manager.org/download/sources/virt-manager/virt-manager-%{version}.tar.gz
Patch0001:           0001-initrdinject-Use-full-option-versions-for-cpio.patch
Patch0002:           0002-initrdinject-Force-added-files-to-be-owned-as-root-b.patch
Requires:            virt-manager-common = %{version}-%{release} python3-gobject gtk3 libvirt-glib >= 0.0.9
Requires:            gtk-vnc2 spice-gtk3 dconf vte291
Recommends:          (libvirt-daemon-kvm or libvirt-daemon-qemu) libvirt-daemon-config-network
BuildRequires:       intltool pod2man python3-devel

%description
The virtual machine management tool uses libvirt as the management API and provides
graphical tools for managing KVM,Xen and LXC.Used to start, stop, add or delete
virtual devices, Connect to the console via graphics or serial to view and count the
resource usage and provide it to the virtual machine.

%package             common
Summary:             Files used for Virtual Machine Manager interfaces
Requires:            python3-argcomplete python3-libvirt python3-libxml2 python3-requests
Requires:            libosinfo >= 0.2.10 python3-gobject-base genisoimage

%description         common
The files used by virt-manager interfaces, as virt-install related tools.

%package -n virt-install
Summary:             Utilities for installing virtual machines
Requires:            virt-manager-common = %{version}-%{release} libvirt-client
Provides:            virt-install virt-clone virt-convert virt-xml

%description -n virt-install
Package provides several command line utilities, including virt-clone (clone an
existing virtual machine) and virt-install (build and install new VMs).

%package             help
Summary:             Documentation for user of virt-manager.
Requires:            virt-manager = %{version}-%{release}

%description         help
Documentation for user of virt-manager.

%prep
%autosetup -n virt-manager-%{version} -p1 -S git

%build
./setup.py configure --default-hvs "qemu,xen,lxc"

%install
./setup.py --no-update-icon-cache --no-compile-schemas install -O1 --root=%{buildroot}
%find_lang virt-manager
for f in $(find %{buildroot} -type f -executable -print); do
    sed -i "1 s|^#!/usr/bin/env python3|#!%{__python3}|" $f || :
done

%files
%doc README.md COPYING NEWS.md
%{_bindir}/virt-manager
%{_datadir}/virt-manager/ui/*.ui
%{_datadir}/virt-manager/{virt-manager,virtManager,icons}
%{_datadir}/icons/hicolor/*/apps/*
%{_datadir}/appdata/virt-manager.appdata.xml
%{_datadir}/applications/virt-manager.desktop
%{_datadir}/glib-2.0/schemas/org.virt-manager.virt-manager.gschema.xml

%files common -f virt-manager.lang
%dir %{_datadir}/virt-manager
%{_datadir}/virt-manager/{virtcli,virtconv,virtinst}

%files -n virt-install
%{_datadir}/virt-manager/{virt-install,virt-clone,virt-convert,virt-xml}
%{_datadir}/bash-completion/completions/{virt-install,virt-clone,virt-convert,virt-xml}
%{_bindir}/{virt-install,virt-clone,virt-convert,virt-xml}

%files               help
%{_mandir}/man1/virt-manager.1*
%{_mandir}/man1/{virt-install.1*,virt-clone.1*,virt-convert.1*,virt-xml.1*}

%changelog
* Wed Apr 22 2020 Jeffery.Gao <gaojianxing@huawei.com> - 2.1.0-3
- Package init
