File virt-manager.spec of Package virt-manager

#
# spec file for package virt-manager
#
# Copyright (c) 2026 SUSE LLC and contributors
#
# 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 https://bugs.opensuse.org/
#


%global __python %{__python3}
%global with_guestfs               0
%global default_hvs                "qemu,xen,lxc"
%if 0%{?suse_version} < 1600 || 0%{?suse_version} >= 1699
    %define is_sles16 0
    %define have_spice 1
%else
    %define is_sles16 1
    %define have_spice 0
%endif

%global flavor @BUILD_FLAVOR@%{nil}
# No spice on SLES16 so no running check build
%if "%{flavor}" == "test" && %{have_spice}
%bcond_without test
%define psuffix -%{flavor}
%else
%bcond_with test
%define psuffix %{nil}
%endif

Name:           virt-manager%{psuffix}
Version:        5.1.0
Release:        0
Summary:        Virtual Machine Manager
License:        GPL-2.0-or-later
Group:          System/Monitoring
URL:            http://virt-manager.org/
Source0:        https://releases.pagure.org/virt-manager/virt-manager-%{version}.tar.xz
Source1:        virt-install.rb
Source2:        virt-install.desktop
Source3:        virt-manager-supportconfig
# Upstream Patches
Patch1:         001-ci-bump-actions-setup-python-from-5-to-6.patch
Patch2:         002-addhardware-network-adjust-supported-network-devices-for-bhyve.patch
Patch3:         003-virtinst-cloudinit-include-empty-meta-data-file.patch
Patch4:         004-xmlapi-split-out-xmlbase.py-and-xmllibxml2.py.patch
Patch5:         005-xmlbase-fix-parentnode-None-check.patch
Patch6:         006-xmllibxml2-lazily-import-libxml2.patch
Patch7:         007-xmlapi-add-xmletree.py-backend.patch
Patch8:         008-Fix-typo-in-virt-clone-documentation.patch
Patch9:         009-Calling-loader.close-before-pixbuf-assignment-to-avoid-NoneType-pixbuf.patch
Patch10:        010-Rename-AppStream-metadata-to-rDNS-format.patch
Patch11:        011-metainfo-Add-developer-tag.patch
Patch12:        012-virtManager-wrapped-details-hw-panel-with-GtkScrolledWindow.patch
Patch13:        013-virtinst-interface-add-support-for-backend.hostname-and-backend.fqdn.patch
Patch14:        014-virtinst-add-support-for-acpi-generic-initiator.patch
Patch15:        015-virtinst-add-support-for-pcihole64.patch
Patch16:        016-ci-bump-actions-checkout-from-5-to-6.patch
Patch17:        017-maint-use-constants-instead-of-strings-for-boot-devices.patch
Patch18:        018-virtinst-rework-get_boot_order.patch
Patch19:        019-virtinst-guest-introduce-can_use_device_boot_order.patch
Patch20:        020-virtinst-remove-legacy-attribute-from-set_boot_order-get_boot_order.patch
Patch21:        021-installer-add-support-to-use-device-boot-order.patch
Patch22:        022-ci-Fix-test-against-libvirt-git.patch
Patch23:        023-ci-Add-gobject-introspection-dep.patch
Patch24:        024-virtinst-Fix-XDG_DATA_HOME-handling.patch
Patch25:        025-Translated-using-Weblate-Czech.patch
Patch26:        026-Translated-using-Weblate-Romanian.patch
Patch27:        027-Translated-using-Weblate-Ukrainian.patch
Patch28:        028-Translated-using-Weblate-Georgian.patch
Patch29:        029-Translated-using-Weblate-Spanish.patch
Patch30:        030-Translated-using-Weblate-Swedish.patch
Patch31:        031-Translated-using-Weblate-Korean.patch
Patch32:        032-Translated-using-Weblate-Russian.patch
Patch33:        033-Translated-using-Weblate-Polish.patch
Patch34:        034-Translated-using-Weblate-German.patch
Patch35:        035-Translated-using-Weblate-Finnish.patch
Patch36:        036-Translated-using-Weblate-Chinese-Simplified-zh_CN.patch
Patch37:        037-Translated-using-Weblate-Kabyle.patch
Patch38:        038-Translated-using-Weblate-Chinese-Simplified-zh_CN.patch
Patch39:        039-Translated-using-Weblate-Chinese-Simplified-zh_CN.patch
Patch40:        040-Translated-using-Weblate-Turkish.patch
Patch41:        041-Translated-using-Weblate-Italian.patch
Patch42:        042-Translated-using-Weblate-English-United-Kingdom.patch
Patch43:        043-Translated-using-Weblate-Portuguese.patch
Patch44:        044-Translated-using-Weblate-Portuguese-Brazil.patch
Patch45:        045-Translated-using-Weblate-Chinese-Simplified-zh_CN.patch
Patch46:        046-Translated-using-Weblate-Romanian.patch
Patch47:        047-Translated-using-Weblate-Turkish.patch
Patch48:        048-Translated-using-Weblate-Estonian.patch
Patch49:        049-Translated-using-Weblate-Indonesian.patch
Patch50:        050-Translated-using-Weblate-Swedish.patch
Patch51:        051-addhardware-Add-usb-as-a-recommended-sound-device.patch
Patch52:        052-tests-port-pytest_ignore_collect-to-pathlib.patch
Patch53:        053-tests-handle-collection_path-and-path-for-pytest_ignore_collect.patch
Patch54:        054-tests-use-Node.path-when-available.patch
Patch55:        055-virtinst-Add-serial-controller-option-to-cli.patch
Patch56:        056-virtinst-Add-NVMe-Controller.patch
Patch57:        057-virtinst-implement-NVMe-disk-target-generation.patch
Patch58:        058-virtManager-Add-NVMe-disk-type.patch
Patch59:        059-ui-Show-NVMe-Controller-details.patch
Patch60:        060-virtinst-fix-locale-when-running-in-flatpak.patch
Patch61:        061-virtinst-add-support-for-iommufd.patch
Patch62:        062-cli-add--boot-secure-boot-option.patch
Patch63:        063-man-secure-boot-dont-mention-entrolled-keys.patch
Patch64:        064-uitests-fix-snapshot-name-validation-test.patch
Patch65:        065-uitests-relax-alert-lookup-naming.patch
Patch66:        066-testmock-add--test-options-disable-name-validation.patch
Patch67:        067-ui-add-USB-startup-policy-mnemonics.patch
Patch68:        068-uitests-cover-USB-startup-policy.patch
Patch69:        069-uitests-cover-NVME-disks-and-controller.patch
Patch70:        070-uitests-Add-coverage-exclusions.patch
Patch71:        071-tests-cli-fix-aarch64-win11-with-latest-osinfo-db.patch
Patch72:        072-details-Fix-TPM-label-from-Customize-wizard.patch
Patch73:        073-uitests-createvm-add-Customize-Add-Hardware-TPM-case.patch
Patch74:        074-testdriver-add-more-complete-zfs-XML.patch
Patch75:        075-ci-add-workflow_dispatch-to-more-workflows.patch
Patch76:        076-ci-Install-acl-to-get-more-code-coverage.patch
Patch77:        077-man-virt-install-change--boot-secure-boot--docs.patch
Patch78:        078-man-virt-install-remove-some-obscure--boot-scearios.patch
Patch79:        079-domain-os-add-set_firmware_feature-helper.patch
Patch80:        080-cli-add--boot-firmware.enrolled-keys--firmware.secure-boot-.patch
Patch81:        081-tests-properly-skip-win11-aarch64-test-on-old-osinfo.patch
# SUSE Only
Patch200:       virtman-dont-specify-vte-version.patch
# Features or Enhancements
# Bug Fixes

BuildArch:      noarch

%define verrel %{version}-%{release}
Requires:       dconf
Requires:       gtk3
Requires:       python3-gobject
Requires:       virt-manager-common = %{verrel}
Requires:       vte

Recommends:     gtksourceview4
Recommends:     libvirt-daemon-config-network
Recommends:     (libvirt-daemon-kvm or libvirt-daemon-qemu)

Suggests:       python3-libguestfs

BuildRequires:  gettext
BuildRequires:  meson
BuildRequires:  python3-devel
BuildRequires:  python3-docutils
BuildRequires:  pkgconfig(gobject-introspection-1.0)
%if %{is_sles16}
%define __requires_exclude typelib\\(AppIndicator3|SpiceClientGtk|SpiceClientGLib|GtkSource\\) = 3.0
%else
# GtkSource = 4 is available everywhere we run this version of virt-manager
%define __requires_exclude typelib\\(GtkSource\\) = 3.0
%endif
%if %{with test}
BuildRequires:  python3-argcomplete
BuildRequires:  python3-pytest
BuildRequires:  virt-install = %{version}
BuildRequires:  virt-manager = %{version}
BuildRequires:  pkgconfig(vte-2.91)
%endif

%description
Virtual Machine Manager provides a graphical tool for administering virtual
machines for KVM, Xen, and QEmu. Start, stop, add or remove virtual devices,
connect to a graphical or serial console, and see resource usage statistics
for existing VMs on local or remote machines. Uses libvirt as the backend
management API.

%package common
Summary:        Common files used by the different Virtual Machine Manager interfaces
Group:          System/Monitoring

# This version not strictly required: virt-manager should work with older,
# however varying amounts of functionality will not be enabled.
Requires:       libosinfo >= 0.2.10
Requires:       python3-argcomplete
Requires:       python3-gobject
Requires:       python3-libvirt-python >= 0.7.0
Requires:       python3-requests
Requires:       xorriso

%description common
Common files used by the different virt-manager interfaces, as well as
virt-install related tools.

%package -n virt-install
Summary:        Utilities for installing virtual machines
Group:          System/Monitoring

Requires:       libvirt-client
Requires:       virt-manager-common = %{verrel}

Provides:       python3-virtinst
Provides:       virt-clone
Provides:       virt-xml
Supplements:    virt-manager

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

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

%if !%{with test}
%build
%if %{default_hvs}
%global _default_hvs --default-hvs %{default_hvs}
%endif
%if %{have_spice}
%global _default_graphics -Ddefault-graphics=spice
%else
%global _default_graphics -Ddefault-graphics=vnc
%endif
%meson \
    -Ddefault-hvs=%{default_hvs} \
    %{?_default_graphics} \
    -Dupdate-icon-cache=false \
    -Dcompile-schemas=false \
    -Dtests=disabled
%meson_build

%install
%meson_install

# YaST is not used on SLES16
%if ! %{?is_sles16}
mkdir -p %{buildroot}/%{_datadir}/YaST2/clients/
install -m644 %SOURCE1 %{buildroot}/%{_datadir}/YaST2/clients/virt-install.rb
mkdir -p %{buildroot}/%{_datadir}/applications/YaST2/
install -m644 %SOURCE2 %{buildroot}/%{_datadir}/applications/YaST2/virt-install.desktop
%endif
# Oddly, supportconfig doesn't execute plugins with '-' in the name, so use 'virt_manager'
mkdir -p %{buildroot}/usr/lib/supportconfig/plugins
install -m 755 %SOURCE3 %{buildroot}/usr/lib/supportconfig/plugins/virt_manager
chmod -x %{buildroot}%{_datadir}/virt-manager/virtManager/virtmanager.py

%python3_fix_shebang

%find_lang %{name}
%endif

%if %{with test}
%check
export XDG_DATA_HOME="/tmp/.local/share"
pytest -v -rfEs
%endif

%post
/bin/touch --no-create %{_datadir}/icons/hicolor >/dev/null 2>&1 || :
/usr/bin/update-desktop-database > /dev/null 2>&1 || :

%postun
if [ $1 -eq 0 ] ; then
    /bin/touch --no-create %{_datadir}/icons/hicolor >/dev/null 2>&1
    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor >/dev/null 2>&1 || :
    /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas > /dev/null 2>&1 || :
fi
/usr/bin/update-desktop-database > /dev/null 2>&1 || :

%posttrans
/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor >/dev/null 2>&1 || :
/usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas > /dev/null 2>&1 || :

%if !%{with test}
%files
%defattr(-,root,root,-)
%{_bindir}/%{name}

%{_mandir}/man1/%{name}.1*

%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/ui
%{_datadir}/%{name}/ui/*.ui
%{_datadir}/%{name}/virtManager

%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/*/
%dir %{_datadir}/icons/hicolor/*/apps
%{_datadir}/%{name}/icons
%{_datadir}/icons/hicolor/*/apps/*

%{_datadir}/metainfo/org.virt_manager.virt-manager.metainfo.xml
%{_datadir}/applications/%{name}.desktop
%if ! %{?is_sles16}
%{_datadir}/applications/YaST2/virt-install.desktop
%endif
%dir %{_datadir}/glib-2.0
%dir %{_datadir}/glib-2.0/schemas
%{_datadir}/glib-2.0/schemas/org.virt-manager.virt-manager.gschema.xml
%dir /usr/lib/supportconfig
%dir /usr/lib/supportconfig/plugins
/usr/lib/supportconfig/plugins/virt_manager

%files common -f %{name}.lang
%defattr(-,root,root,-)
%dir %{_datadir}/%{name}

%{_datadir}/%{name}/virtinst

%files -n virt-install
%defattr(-,root,root,-)
%{_mandir}/man1/virt-install.1*
%{_mandir}/man1/virt-clone.1*
%{_mandir}/man1/virt-xml.1*

%{_bindir}/virt-install
%{_datadir}/bash-completion/completions/virt-install
%{_bindir}/virt-clone
%{_datadir}/bash-completion/completions/virt-clone
%{_bindir}/virt-xml
%{_datadir}/bash-completion/completions/virt-xml

%if ! %{?is_sles16}
%dir %{_datadir}/YaST2
%dir %{_datadir}/YaST2/clients
%dir %{_datadir}/applications/YaST2
%{_datadir}/YaST2/clients/virt-install.rb
%endif
%endif

%changelog
openSUSE Build Service is sponsored by