File xen.spec of Package xen

# norootforbuild
%define python_basename_xen   python3
%define python_basename_ovmf  python3
%define python_basename_qemuu python3.11
%define _lto_cflags %nil
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates
%endif
Name:           xen
Version:        0
Release:        0
ExclusiveArch:  %ix86 x86_64 %arm aarch64
#
%define with_hypervisor 0
#
%define xen_install_suffix %nil
%ifarch x86_64
%define xen_install_suffix .gz
%endif
#
%ifarch x86_64
%define with_hypervisor 1
%else
%endif
#
%bcond_without fdupes
%bcond_without xen_docs
%bcond_without xen_ovmf
%bcond_without xen_stubdom
%bcond_without xen_systemd
Requires(pre): %fillup_prereq
%if %{without xen_systemd}
Requires(pre): %insserv_prereq
%else
%systemd_requires
%endif
#
BuildRequires: xen-buildreq-qemu-xen
BuildRequires: xen-buildreq-tools-staging
BuildRequires: python(abi) = 3.11
%if %{with xen_docs}
BuildRequires: xen-buildreq-docs
%endif
%if %{with xen_ovmf}
BuildRequires: xen-buildreq-ovmf
%endif
%if %{with xen_stubdom}
BuildRequires: xen-buildreq-stubdom
%endif

License:        GPL-2.0+
Group:          System/Kernel
Summary:        Xen Hypervisor
Source1000:     stubdom.tar.xz
##
Url:            https://www.xenproject.org/
%define xen_revision_full 321b74f29d76569efbc50cbf38ec5341d672c7b7
%define xen_revision_short 321b74f29d
%define xen_date_unix 1749204446
%define xen_date_commit 2025-06-06 12:07:26 +0200

%define qemu_xen_revision_full e064f42c80be6f6ff8c12dcb2a663bdf70f965f6
%define qemu_xen_revision_short e064f42c80
%define qemu_xen_date_unix 1745484677
%define qemu_xen_date_commit 2025-04-24 10:51:17 +0200

%define btestfloat3_revision_full e7af9751d9f9fd3b47911f51a5cfd08af256a9ab
%define btestfloat3_revision_short e7af975
%define btestfloat3_date_unix 1689946593
%define btestfloat3_date_commit 2023-07-21 15:36:33 +0200

%define keycodemapdb_revision_full f5772a62ec52591ff6870b7e8ef32482371f22c6
%define keycodemapdb_revision_short f5772a6
%define keycodemapdb_date_unix 1677604609
%define keycodemapdb_date_commit 2023-02-28 18:16:49 +0100

%define seabios_revision_full a6ed6b701f0a57db0569ab98b0661c12a6ec3ff8
%define seabios_revision_short a6ed6b70
%define seabios_date_unix 1699879799
%define seabios_date_commit 2023-11-13 13:49:59 +0100

%define minios_revision_full d273a44cec90dad5d3f0bc361a6fea41e0288a56
%define minios_revision_short d273a44
%define minios_date_unix 1741268255
%define minios_date_commit 2025-03-06 14:37:35 +0100

%define ovmf_revision_full ba91d0292e593df8528b66f99c1b0b14fadc8e16
%define ovmf_revision_short ba91d0292e
%define ovmf_date_unix 1684933194
%define ovmf_date_commit 2023-05-24 12:59:54 +0000

%define ipxe_revision_full 5b3ebf8b24ae40a6f9f9f78491702d508f843e56
%define ipxe_revision_short 5b3ebf8b
%define ipxe_date_unix 1748870355
%define ipxe_date_commit 2025-06-02 14:19:15 +0100

Patch1607528400: xen.bitmap-long.patch
Patch1603987219: xen.xl-migration-debug.patch
Patch1603883256: xen.sr-readv_exact.patch
Patch1603460399: xen.sr-save-show_transfer_rate.patch
Patch1603444836: xen.sr-save-mfns.patch
Patch1603445031: xen.sr-save-types.patch
Patch1603445165: xen.sr-save-errors.patch
Patch1603445441: xen.sr-save-iov.patch
Patch1603445640: xen.sr-save-rec_pfns.patch
Patch1603446045: xen.sr-save-guest_data.patch
Patch1603450076: xen.sr-save-local_pages.patch
Patch1603456770: xen.sr-restore-pfns.patch
Patch1603456771: xen.sr-restore-types.patch
Patch1603456939: xen.sr-restore-mfns.patch
Patch1603457049: xen.sr-restore-map_errs.patch
Patch1603457933: xen.sr-restore-populate_pfns-pfns.patch
Patch1603457652: xen.sr-restore-populate_pfns-mfns.patch
Patch1603711157: xen.sr-restore-read_record.patch
Patch1603822910: xen.sr-restore-handle_buffered_page_data.patch
Patch1603984390: xen.sr-restore-handle_incoming_page_data.patch
Patch1610030034: xen.sr-LIBXL_API_VERSION.patch
Patch1610031510: xen.sr-LIBXL_HAVE_DOMAIN_SUSPEND_PROPS.patch
Patch1610126389: xen.sr-precopy_policy.patch
Patch1610188337: xen.sr-max_iters.patch
Patch1610044768: xen.sr-min_remaining.patch
Patch1610047528: xen.sr-abort_if_busy.patch
Patch1612551003: xen.sr-xg_sr_bitmap.patch
Patch1612552562: xen.sr-xg_sr_bitmap-populated_pfns.patch
Patch1502110682: xen.sr-restore-hvm-legacy-superpage.patch
Patch1612467233: xen.sr-track-migration-time.patch
Patch1691700133: xen.sr-save-stats.patch
Patch1625225456: xen.xl-save-pc.patch
Patch1685621743: xen.xenalyze-EXIT_REASONS.patch
Patch1685306001: xen.xenalyze-hvm_emul.patch
Patch1686918680: xen.xentrace-next_record.patch
Patch1687169893: xen.xentrace-74584a367051bc0d6f4b96fd360fa7bc6538fc39.patch
Patch1685443534: xen.xentrace-num_present_cpus.patch
Patch1687441939: xen.XENTRACE_OUTPUT.patch
Patch1687448544: xen.profile.d.patch
Patch1686911696: xen.trc-packed.patch
Patch1686815077: xen.trc-TRACE_trc.patch
Patch1686815150: xen.trc-trc.patch
Patch1686815208: xen.trc-do_sysctl.patch
Patch1686817681: xen.trc-ioreq_request_mapcache_invalidate.patch
Patch1686817742: xen.trc-ioreq_signal_mapcache_invalidate.patch
Patch1686817814: xen.trc-set_ioreq_server.patch
Patch1686817831: xen.trc-get_ioreq_server.patch
Patch1686817883: xen.trc-get_ioreq.patch
Patch1686817941: xen.trc-domain_has_ioreq_server.patch
Patch1686817949: xen.trc-get_pending_vcpu.patch
Patch1686818436: xen.trc-vcpu_ioreq_pending.patch
Patch1686818446: xen.trc-wait_for_io.patch
Patch1686818465: xen.trc-vcpu_ioreq_handle_completion.patch
Patch1686818476: xen.trc-ioreq_server_alloc_mfn.patch
Patch1686818486: xen.trc-ioreq_server_free_mfn.patch
Patch1686818495: xen.trc-is_ioreq_server_page.patch
Patch1686818506: xen.trc-ioreq_server_add_vcpu.patch
Patch1686818510: xen.trc-ioreq_server_remove_vcpu.patch
Patch1686818513: xen.trc-ioreq_server_remove_all_vcpus.patch
Patch1686818516: xen.trc-ioreq_server_alloc_pages.patch
Patch1686818519: xen.trc-ioreq_server_free_pages.patch
Patch1686818522: xen.trc-ioreq_server_free_rangesets.patch
Patch1686818525: xen.trc-ioreq_server_alloc_rangesets.patch
Patch1686818528: xen.trc-ioreq_server_enable.patch
Patch1686818531: xen.trc-ioreq_server_disable.patch
Patch1686818535: xen.trc-ioreq_server_init.patch
Patch1686818564: xen.trc-ioreq_server_deinit.patch
Patch1686818579: xen.trc-ioreq_server_create.patch
Patch1686818586: xen.trc-ioreq_server_destroy.patch
Patch1686818589: xen.trc-ioreq_server_get_info.patch
Patch1686818593: xen.trc-ioreq_server_get_frame.patch
Patch1686818596: xen.trc-ioreq_server_map_io_range.patch
Patch1686818600: xen.trc-ioreq_server_unmap_io_range.patch
Patch1686818603: xen.trc-ioreq_server_map_mem_type.patch
Patch1686818605: xen.trc-ioreq_server_set_state.patch
Patch1686818607: xen.trc-ioreq_server_add_vcpu_all.patch
Patch1686818609: xen.trc-ioreq_server_remove_vcpu_all.patch
Patch1686818612: xen.trc-ioreq_server_destroy_all.patch
Patch1686818614: xen.trc-ioreq_server_select.patch
Patch1686818616: xen.trc-ioreq_send_buffered.patch
Patch1686818619: xen.trc-ioreq_send.patch
Patch1686818622: xen.trc-ioreq_broadcast.patch
Patch1686818628: xen.trc-ioreq_domain_init.patch
Patch1686818649: xen.trc-ioreq_server_dm_op.patch
Patch1686838740: xen.trc-xenalyze-ioreq.patch
Patch1687430858: xen.xentrace-uneven-extra.patch
Patch1703581419: xen.DOC_HTML.patch
%if %suse_version > 1110
BuildRequires: python(abi) > 3.0
%endif
%define qemu_xen_version e064f42c80be6f6ff8c12dcb2a663bdf70f965f6
%define bsoftfloat3_version b64af41c3276f97f0e181920400ee056b9c88037
%define btestfloat3_version e7af9751d9f9fd3b47911f51a5cfd08af256a9ab
%define keycodemapdb_version f5772a62ec52591ff6870b7e8ef32482371f22c6
%define seabios_version a6ed6b701f0a57db0569ab98b0661c12a6ec3ff8
%define minios_version d273a44cec90dad5d3f0bc361a6fea41e0288a56
Patch1631262140: ovmf.QemuLoadKernelImage.patch
Patch1637751000: ovmf.mBusMasterOperationName.patch
Patch1617269159: ovmf.Disable-brotli.patch
Patch1687260117: ovmf.OVMF_PYTHON_COMMAND.patch
Patch1687262739: ovmf.MemoryStateToGhcbOp.patch
Patch1687263779: ovmf.ShellCommandRunDisconnect.patch
Patch1687284143: ovmf.SetOrClearSharedBit.patch
Patch1687286330: ovmf.AmdSevDxeEntryPoint.patch
Patch1687289375: ovmf.CoreOpenProtocol.patch
%define ovmf_version ba91d0292e593df8528b66f99c1b0b14fadc8e16
%define openssl_version 830bf8e1e4749ad65c51b6a1d0d769ae689404ba
Patch1484818598: ipxe.stable-build-id.patch
%define ipxe_version 5b3ebf8b24ae40a6f9f9f78491702d508f843e56
BuildRoot:      %_tmppath/%name-%version-build

%description
Xen is a virtual machine monitor for x86 that supports execution of
multiple guest operating systems with unprecedented levels of
performance and resource isolation.

This package contains the Xen Hypervisor. (tm)

%package libs
Summary:        Xen Virtualization: Libraries
Group:          System/Kernel
%if 0%{with_hypervisor}
Requires:       %name = %version-%release
%endif

%description libs

%package tools
Summary:        Xen Virtualization: Control tools for domain 0
Group:          System/Kernel
Requires:       %name-libs = %version-%release
Requires:       iproute2
Provides:       xen-doc-html = %version-%release
Obsoletes:      xen-doc-html

%description tools

%ifarch  %ix86 x86_64
%package tools-domU
Summary:        Xen Virtualization: Control tools for domain U
Group:          System/Kernel
Requires:       %name-libs = %version-%release
Conflicts:      %name-tools

%description tools-domU
%endif

%package devel
Summary:        Xen Virtualization: Headers and libraries for development
Group:          System/Kernel
Requires:       %name-libs = %version-%release
Requires:       pkgconfig(uuid)

%description devel

%prep
rm -rf %_builddir/%name-%version
mv %_sourcedir/%name-%version %_builddir/%name-%version
%setup -c -T -D
pushd '.'
%patch -P 1607528400 -p1
%patch -P 1603987219 -p1
%patch -P 1603883256 -p1
%patch -P 1603460399 -p1
%patch -P 1603444836 -p1
%patch -P 1603445031 -p1
%patch -P 1603445165 -p1
%patch -P 1603445441 -p1
%patch -P 1603445640 -p1
%patch -P 1603446045 -p1
%patch -P 1603450076 -p1
%patch -P 1603456770 -p1
%patch -P 1603456771 -p1
%patch -P 1603456939 -p1
%patch -P 1603457049 -p1
%patch -P 1603457933 -p1
%patch -P 1603457652 -p1
%patch -P 1603711157 -p1
%patch -P 1603822910 -p1
%patch -P 1603984390 -p1
%patch -P 1610030034 -p1
%patch -P 1610031510 -p1
%patch -P 1610126389 -p1
%patch -P 1610188337 -p1
%patch -P 1610044768 -p1
%patch -P 1610047528 -p1
%patch -P 1612551003 -p1
%patch -P 1612552562 -p1
%patch -P 1502110682 -p1
%patch -P 1612467233 -p1
%patch -P 1691700133 -p1
%patch -P 1625225456 -p1
%patch -P 1685621743 -p1
%patch -P 1685306001 -p1
%patch -P 1686918680 -p1
%patch -P 1687169893 -p1
%patch -P 1685443534 -p1
%patch -P 1687441939 -p1
%patch -P 1687448544 -p1
%patch -P 1686911696 -p1
%patch -P 1686815077 -p1
%patch -P 1686815150 -p1
%patch -P 1686815208 -p1
%patch -P 1686817681 -p1
%patch -P 1686817742 -p1
%patch -P 1686817814 -p1
%patch -P 1686817831 -p1
%patch -P 1686817883 -p1
%patch -P 1686817941 -p1
%patch -P 1686817949 -p1
%patch -P 1686818436 -p1
%patch -P 1686818446 -p1
%patch -P 1686818465 -p1
%patch -P 1686818476 -p1
%patch -P 1686818486 -p1
%patch -P 1686818495 -p1
%patch -P 1686818506 -p1
%patch -P 1686818510 -p1
%patch -P 1686818513 -p1
%patch -P 1686818516 -p1
%patch -P 1686818519 -p1
%patch -P 1686818522 -p1
%patch -P 1686818525 -p1
%patch -P 1686818528 -p1
%patch -P 1686818531 -p1
%patch -P 1686818535 -p1
%patch -P 1686818564 -p1
%patch -P 1686818579 -p1
%patch -P 1686818586 -p1
%patch -P 1686818589 -p1
%patch -P 1686818593 -p1
%patch -P 1686818596 -p1
%patch -P 1686818600 -p1
%patch -P 1686818603 -p1
%patch -P 1686818605 -p1
%patch -P 1686818607 -p1
%patch -P 1686818609 -p1
%patch -P 1686818612 -p1
%patch -P 1686818614 -p1
%patch -P 1686818616 -p1
%patch -P 1686818619 -p1
%patch -P 1686818622 -p1
%patch -P 1686818628 -p1
%patch -P 1686818649 -p1
%patch -P 1686838740 -p1
%patch -P 1687430858 -p1
%patch -P 1703581419 -p1
popd

rm -rf './tools/qemu-xen-dir-remote'
mkdir -vp './tools'
mv -v '%_sourcedir/qemu_xen-%qemu_xen_version' './tools/qemu-xen-dir-remote'

rm -rf './tools/qemu-xen-dir-remote/subprojects/berkeley-softfloat-3'
mkdir -vp './tools/qemu-xen-dir-remote/subprojects'
mv -v '%_sourcedir/bsoftfloat3-%bsoftfloat3_version' './tools/qemu-xen-dir-remote/subprojects/berkeley-softfloat-3'

rm -rf './tools/qemu-xen-dir-remote/subprojects/berkeley-testfloat-3'
mkdir -vp './tools/qemu-xen-dir-remote/subprojects'
mv -v '%_sourcedir/btestfloat3-%btestfloat3_version' './tools/qemu-xen-dir-remote/subprojects/berkeley-testfloat-3'

rm -rf './tools/qemu-xen-dir-remote/subprojects/keycodemapdb'
mkdir -vp './tools/qemu-xen-dir-remote/subprojects'
mv -v '%_sourcedir/keycodemapdb-%keycodemapdb_version' './tools/qemu-xen-dir-remote/subprojects/keycodemapdb'

rm -rf './tools/firmware/seabios-dir-remote'
mkdir -vp './tools/firmware'
mv -v '%_sourcedir/seabios-%seabios_version' './tools/firmware/seabios-dir-remote'
pushd './tools/firmware/seabios-dir-remote'
popd

rm -rf './extras/mini-os-remote'
mkdir -vp './extras'
mv -v '%_sourcedir/minios-%minios_version' './extras/mini-os-remote'

rm -rf './tools/firmware/ovmf-dir-remote'
mkdir -vp './tools/firmware'
mv -v '%_sourcedir/ovmf-%ovmf_version' './tools/firmware/ovmf-dir-remote'
pushd './tools/firmware/ovmf-dir-remote'
%patch -P 1631262140 -p1
%patch -P 1637751000 -p1
%patch -P 1617269159 -p1
%patch -P 1687260117 -p1
%patch -P 1687262739 -p1
%patch -P 1687263779 -p1
%patch -P 1687284143 -p1
%patch -P 1687286330 -p1
%patch -P 1687289375 -p1
popd

rm -rf './tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib/openssl'
mkdir -vp './tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib'
mv -v '%_sourcedir/openssl-%openssl_version' './tools/firmware/ovmf-dir-remote/CryptoPkg/Library/OpensslLib/openssl'

rm -rf './tools/firmware/etherboot/ipxe'
mkdir -vp './tools/firmware/etherboot'
mv -v '%_sourcedir/ipxe-%ipxe_version' './tools/firmware/etherboot/ipxe'
pushd './tools/firmware/etherboot/ipxe'
%patch -P 1484818598 -p1
popd

find . -path '*/subprojects/packagefiles' | while read
do
  if pushd "${REPLY}" 2>/dev/null
  then
    for prj in *
    do
      if pushd "${prj}" > /dev/null
      then
        for f in *
        do
          test -f "${f}" || continue
          test -d "../../${prj}/" || continue
          ln -vft "../../${prj}/" *
          break
        done
        popd > /dev/null
      fi
    done
    popd > /dev/null
  fi
done

%build
pushd './tools/firmware/ovmf-dir-remote'
mkdir -vp MdePkg/Library/MipiSysTLib/mipisyst/library/include
popd
python_basename_xen='%{python_basename_xen}'
python_basename_ovmf='%{python_basename_ovmf}'
python_basename_qemuu='%{python_basename_qemuu}'
%include %_datadir/xen-buildreq/build.txt

%install
%include %_datadir/xen-buildreq/install.txt
(
pushd %buildroot > /dev/null
test -f etc/profile.d/xen.sh && echo "%%config /$_"
test -f var/lib/xen/xentrace.bin && echo "%%config /$_"
) >> xen-tools.python.files.txt

%clean
: %buildroot preserved

%if 0%{with_hypervisor}
%files -f xen.files.txt
%defattr(-,root,root)
/boot/*
%endif

%files libs
%defattr(-,root,root)
%_libdir/xenfsimage/
%_libdir/*.so.*

%files tools -f xen-tools.python.files.txt
%defattr(-,root,root)
%if %{with xen_docs}
%{_defaultdocdir}/%name/html
%endif
/usr/bin/xen[!-]*
/usr/bin/vchan-socket-proxy
%ifarch  %ix86 x86_64
/usr/bin/xen-cpuid
%endif
/usr/sbin/*
%_libexecdir/xen
%if %{with xen_docs}
%_mandir/man*/*.gz
%endif
%_fillupdir/*
%dir /var/lib/xen
%dir %attr(700,root,root) /var/lib/xen/images
%dir %attr(700,root,root) /var/lib/xen/save
%dir %attr(700,root,root) /var/lib/xen/dump
%ifarch  %ix86 x86_64
%dir %attr(700,root,root) /var/lib/xen/xenpaging
%endif
%dir /var/lib/xenstored
%dir %attr(700,root,root) /etc/xen
%config /etc/xen/*
%dir /var/log/xen
%if %{with xen_systemd}
%config %_unitdir/*
%else
%if %{?with_rc_d}0
%config /etc/rc.d
%endif
%config %{_initddir}/*
%endif
%dir %{_defaultdocdir}/%name
%{_defaultdocdir}/%name/misc
%dir %_libdir/python*/site-packages/xen
%dir %_libdir/python*/site-packages/grub
%_datadir/bash-completion
%_datadir/qemu-xen
%_libdir/python*/site-packages/*.so

%ifarch  %ix86 x86_64
%files tools-domU
%defattr(-,root,root)
/usr/bin/xen-detect
%endif

%files devel
%defattr(-,root,root)
%_libdir/*.a
%_libdir/*.so
/usr/include/*
%_libdir/pkgconfig/*

%include %_datadir/xen-buildreq/scriptlets.txt
openSUSE Build Service is sponsored by