#
# Copyright (C) 2010 Oracle. All rights reserved.
#
-diff -ur xen-4.13.1/tools/pygrub/src/pygrub xen-4.13.1.py/tools/pygrub/src/pygrub
---- xen-4.13.1/tools/pygrub/src/pygrub 2020-06-07 19:59:07.463276639 +0200
-+++ xen-4.13.1.py/tools/pygrub/src/pygrub 2020-06-07 19:58:48.203256360 +0200
-@@ -1,4 +1,4 @@
--#! /usr/bin/env python
-+#!/usr/bin/python2
- #
- # pygrub - simple python-based bootloader for Xen
- #
-diff -ur xen-4.13.1/tools/python/scripts/convert-legacy-stream xen-4.13.1.py/tools/python/scripts/convert-legacy-stream
---- xen-4.13.1/tools/python/scripts/convert-legacy-stream 2020-05-14 14:19:32.000000000 +0200
-+++ xen-4.13.1.py/tools/python/scripts/convert-legacy-stream 2020-06-07 19:58:48.203256360 +0200
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/python2
- # -*- coding: utf-8 -*-
-
- """
-diff -ur xen-4.13.1/tools/python/scripts/verify-stream-v2 xen-4.13.1.py/tools/python/scripts/verify-stream-v2
---- xen-4.13.1/tools/python/scripts/verify-stream-v2 2020-05-14 14:19:32.000000000 +0200
-+++ xen-4.13.1.py/tools/python/scripts/verify-stream-v2 2020-06-07 19:58:48.203256360 +0200
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/python2
- # -*- coding: utf-8 -*-
-
- """ Verify a v2 format migration stream """
-diff -ur xen-4.13.1/tools/xenmon/xenmon.py xen-4.13.1.py/tools/xenmon/xenmon.py
---- xen-4.13.1/tools/xenmon/xenmon.py 2020-05-14 14:19:32.000000000 +0200
-+++ xen-4.13.1.py/tools/xenmon/xenmon.py 2020-06-07 19:58:48.203256360 +0200
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!/usr/bin/python2
-
- #####################################################################
- # xenmon is a front-end for xenbaked.
diff -ur xen-4.13.1/tools/xentrace/xentrace_format xen-4.13.1.py/tools/xentrace/xentrace_format
--- xen-4.13.1/tools/xentrace/xentrace_format 2020-05-14 14:19:32.000000000 +0200
+++ xen-4.13.1.py/tools/xentrace/xentrace_format 2020-06-07 19:58:48.203256360 +0200
%bcond_without brlapi # brlapi support in Xen qemu
%bcond_with golang # Go library
%bcond_without ocaml # Ocaml libraries for Xen tools
+%bcond_with python2 # CPython 2.x module instead of 3.x
%bcond_without efi # EFI hypervisor
%bcond_without hypervisor # Xen hypervisor build
%bcond_without stubdom # stubdom build
Source59: vif-openvswitch
Source60: xen-init-list
Source61: xen-toolstack
+# shebang patch for python2-only scripts
Patch0: %{name}-python_scripts.patch
Patch1: %{name}-symbols.patch
Patch2: %{name}-link.patch
BuildRequires: perl-base
BuildRequires: perl-tools-pod
BuildRequires: pkgconfig
+%if %{with python2}
BuildRequires: python-devel >= 1:2.7
BuildRequires: python-markdown
+%else
+BuildRequires: python3-devel >= 1:3.2
+BuildRequires: python3-markdown
+%endif
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.647
BuildRequires: seabios
Requires: iptables
Requires: losetup
Requires: net-tools
+%if %{with python2}
Requires: python-%{name} = %{version}-%{release}
+%else
+Requires: python3-%{name} = %{version}-%{release}
+%endif
Requires: rc-scripts
Requires: sed
Requires: systemd-units >= 38
%description -n python-xen-guest -l pl.UTF-8
Moduły Pythona dla maszyn wirtualnych dom0 i domU.
+%package -n python3-xen
+Summary: Xen Python 3 modules
+Summary(pl.UTF-8): Moduły Pythona 3 dla Xena
+Group: Libraries
+Requires: %{name}-libs = %{version}-%{release}
+Obsoletes: python-xen < %{version}-%{release}
+
+%description -n python3-xen
+Xen Python 3 modules.
+
+%description -n python3-xen -l pl.UTF-8
+Moduły Pythona 3 dla Xena.
+
+%package -n python3-xen-guest
+Summary: Xen Python 3 modules for virtual machines
+Summary(pl.UTF-8): Moduły Pythona 3 dla maszyn wirtualnych Xena
+Group: Libraries
+Requires: %{name}-libs-guest = %{version}-%{release}
+Obsoletes: python-xen-guest < %{version}-%{release}
+
+%description -n python3-xen-guest
+Xen Python 3 modules for both dom0 and domU virtual machines.
+
+%description -n python3-xen-guest -l pl.UTF-8
+Moduły Pythona 3 dla maszyn wirtualnych dom0 i domU.
+
%package -n bash-completion-%{name}
Summary: bash-completion for Xen (xl)
Summary(pl.UTF-8): Bashowe dopełnianie poleceń dla Xena (xl)
ln -s %{SOURCE17} %{SOURCE18} %{SOURCE19} stubdom
ln -s %{SOURCE15} tools/firmware/etherboot/ipxe.tar.gz
+
+%if %{with python2}
+%{__sed} -i -e '1s,/usr/bin/env python$,%{__python},' \
+%else
+%{__sed} -i -e '1s,/usr/bin/env python$,%{__python3},' \
+%endif
+ tools/pygrub/src/pygrub \
+ tools/python/scripts/{convert-legacy-stream,verify-stream-v2} \
+ tools/xenmon/xenmon.py
+
# do not allow fetching anything via git
echo GIT=/bin/false >> Config.mk
%configure \
CPPFLAGS="%{rpmcppflags} -I/usr/include/ncurses" \
- PYTHON=%{__python} \
+ %{?with_python2:PYTHON=%{__python}} \
ac_cv_lib_gcrypt_gcry_md_hash_buffer=no \
ac_cv_lib_iconv_libiconv_open=no \
--disable-debug \
install -d _doc
cp -p tools/pygrub/README _doc/README.pygrub
+%if %{with python2}
%py_comp $RPM_BUILD_ROOT%{py_sitedir}
%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
%py_postclean
+%else
+%py3_comp $RPM_BUILD_ROOT%{py3_sitedir}
+%py3_ocomp $RPM_BUILD_ROOT%{py3_sitedir}
+%endif
# remove unneeded files
%if %{with hypervisor}
%{_libdir}/ocaml/xentoollog/*.cm[aixo]*
%endif
+%if %{with python2}
%files -n python-xen
%defattr(644,root,root,755)
%attr(755,root,root) %{py_sitedir}/xenfsimage.so
%files -n python-xen-guest
%defattr(644,root,root,755)
%dir %{py_sitedir}/xen
-%{py_sitedir}/xen/__init__.py*
+%{py_sitedir}/xen/__init__.py[co]
%dir %{py_sitedir}/xen/lowlevel
-%{py_sitedir}/xen/lowlevel/__init__.py*
+%{py_sitedir}/xen/lowlevel/__init__.py[co]
%attr(755,root,root) %{py_sitedir}/xen/lowlevel/xs.so
+%else
+
+%files -n python3-xen
+%defattr(644,root,root,755)
+%attr(755,root,root) %{py3_sitedir}/xenfsimage.cpython-*.so
+%dir %{py3_sitedir}/xen
+%dir %{py3_sitedir}/xen/__pycache__
+%{py3_sitedir}/xen/util.py
+%{py3_sitedir}/xen/__pycache__/util.cpython-*.py[co]
+%dir %{py3_sitedir}/xen/lowlevel
+%attr(755,root,root) %{py3_sitedir}/xen/lowlevel/xc.cpython-*.so
+%{py3_sitedir}/xen/migration
+%{py3_sitedir}/grub
+%{py3_sitedir}/pygrub-*-py*.egg-info
+%{py3_sitedir}/xen-*-py*.egg-info
+
+%files -n python3-xen-guest
+%defattr(644,root,root,755)
+%dir %{py3_sitedir}/xen
+%dir %{py3_sitedir}/xen/__pycache__
+%{py3_sitedir}/xen/__init__.py*
+%{py3_sitedir}/xen/__pycache__/__init__.cpython-*.py[co]
+%dir %{py3_sitedir}/xen/lowlevel
+%{py3_sitedir}/xen/lowlevel/__init__.py
+%{py3_sitedir}/xen/lowlevel/__pycache__
+%attr(755,root,root) %{py3_sitedir}/xen/lowlevel/xs.cpython-*.so
+%endif
+
%files -n bash-completion-%{name}
%defattr(644,root,root,755)
/etc/bash_completion.d/xl.sh