File xen.spec of Package xen.15298

#
# spec file for package xen
#
# Copyright (c) 2020 SUSE LLC
#
# 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 http://bugs.opensuse.org/
#
# needssslcertforbuild


#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates
%endif

Name:           xen
ExclusiveArch:  %ix86 x86_64 %arm aarch64
%define changeset 35349
%define xen_build_dir xen-4.10.4-testing
#
%define with_gdbsx 0
%define with_dom0_support 0
%bcond_with    xen_oxenstored
%ifarch x86_64
%bcond_without xen_debug
%bcond_without xen_stubdom
%else
%bcond_with    xen_debug
%bcond_with    xen_stubdom
%endif
#
%ifarch x86_64
%define with_gdbsx 1
%define with_dom0_support 1
%endif
#
%ifarch %arm aarch64
%define with_dom0_support 1
%endif
#
%define xen_install_suffix %{nil}
%ifarch x86_64
%define xen_install_suffix .gz
%endif
# EFI requires gcc 4.6 or newer
# gcc46 is available in 12.1 or sles11sp2
# gcc47 is available in sles11sp3
# gcc48 is available in sles11sp4
# 12.2+ have gcc 4.7 as default compiler
%define with_gcc47 0
%define with_gcc48 0
%define _fwdefdir /etc/sysconfig/SuSEfirewall2.d/services
%systemd_requires
BuildRequires:  systemd-devel
%define with_systemd_modules_load %{_prefix}/lib/modules-load.d
PreReq:         %fillup_prereq
%ifarch %arm aarch64
%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120200 )
BuildRequires:  libfdt-devel
%else
BuildRequires:  libfdt1-devel
%endif
%endif
# JWF: Until Anthony's series to load BIOS via toolstack is merged,
# autoconf is needed by autogen.sh.
# http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01626.html
BuildRequires:  autoconf >= 2.67
BuildRequires:  bison
BuildRequires:  fdupes
%if 0%{?suse_version} > 1315
BuildRequires:  figlet
%endif
BuildRequires:  flex
BuildRequires:  glib2-devel
BuildRequires:  libaio-devel
BuildRequires:  libbz2-devel
BuildRequires:  libnl3-devel
BuildRequires:  libpixman-1-0-devel
BuildRequires:  libuuid-devel
BuildRequires:  libxml2-devel
BuildRequires:  libyajl-devel
%if %{with xen_stubdom}
%if 0%{?suse_version} < 1230
BuildRequires:  texinfo
%else
BuildRequires:  makeinfo
%endif
%endif
BuildRequires:  ncurses-devel
%if %{?with_dom0_support}0
%if %{with xen_oxenstored}
BuildRequires:  ocaml
BuildRequires:  ocaml-compiler-libs
BuildRequires:  ocaml-findlib
BuildRequires:  ocaml-ocamldoc
BuildRequires:  ocaml-runtime
%endif
%endif
BuildRequires:  acpica
BuildRequires:  openssl-devel
BuildRequires:  python3-devel
BuildRequires:  systemd
BuildRequires:  xz-devel
%ifarch x86_64
BuildRequires:  gcc-32bit
BuildRequires:  gcc-c++
%if %{?with_gcc47}0
BuildRequires:  gcc47
%endif
%if %{?with_gcc48}0
BuildRequires:  gcc48
%endif
BuildRequires:  glibc-32bit
BuildRequires:  glibc-devel-32bit
BuildRequires:  makeinfo
%endif
%ifarch x86_64
BuildRequires:  pesign-obs-integration
%endif

Version:        4.10.4_10
Release:        0
Summary:        Xen Virtualization: Hypervisor (aka VMM aka Microkernel)
License:        GPL-2.0
Group:          System/Kernel
Source0:        xen-4.10.4-testing-src.tar.bz2
Source1:        stubdom.tar.bz2
Source5:        ipxe.tar.bz2
Source6:        mini-os.tar.bz2
Source9:        xen.changes
Source10:       README.SUSE
Source11:       boot.xen
Source12:       boot.local.xenU
Source13:       xen-supportconfig
Source15:       logrotate.conf
Source21:       block-npiv-common.sh
Source22:       block-npiv
Source23:       block-npiv-vport
Source26:       init.xen_loop
Source29:       block-dmmd
# Xen API remote authentication sources
Source30:       etc_pam.d_xen-api
Source31:       xenapiusers
# Init script and sysconf file for pciback
Source34:       init.pciback
Source35:       sysconfig.pciback
Source36:       xnloader.py
Source37:       xen2libvirt.py
# Systemd service files
Source41:       xencommons.service
Source42:       xen-dom0-modules.service
Source57:       xen-utils-0.1.tar.bz2
# For xen-libs
Source99:       baselibs.conf
# Upstream patches
Patch1:         5a33a12f-domctl-improve-locking-during-domain-destruction.patch
Patch2:         5a79d7ed-libxc-packed-initrd-dont-fail-domain-creation.patch
Patch3:         5b0d2d91-x86-suppress-sync-when-XPTI-off.patch
Patch4:         5b9784ad-x86-HVM-drop-hvm_fetch_from_guest_linear.patch
Patch5:         5b9784d2-x86-HVM-add-known_gla-helper.patch
Patch6:         5b9784f2-x86-HVM-split-page-straddling-accesses.patch
Patch7:         5ba5188c-libxl-keep-assigned-pci-devices-across-domain-reboots.patch
Patch8:         5c0f786c-parse_size_and_unit-percent.patch
Patch9:         5c0f7894-x86-dom0_mem-variants.patch
Patch10:        5c6d7b01-x86-pmtimer-fix-hvm_acpi_sleep_button.patch
Patch11:        5c6d7b35-x86-shadow-dont-pass-wrong-L4-MFN.patch
Patch12:        5c75615a-viridian-fix-HvFlushVirtualAddress.patch
Patch13:        5c7561aa-x86-shadow-dont-use-map_domain_page_global.patch
Patch14:        5c77c30b-x86-hvm-increase-triple-fault-log-level.patch
Patch15:        5c77e5c8-x86-nmi-correctly-check-MSB-of-P6-perf-counter.patch
Patch16:        5c8fb92d-x86-HVM-split-linear-reads-and-writes.patch
Patch17:        5c8fb951-x86-HVM-finish-IOREQs-correctly-on-completion.patch
Patch18:        5cf0f6a4-x86-vhpet-resume-avoid-small-diff.patch
Patch19:        5cf16e51-x86-spec-ctrl-Knights-retpoline-safe.patch
Patch20:        5d08f651-x86-AMD-correct-Fam17-checks.patch
Patch21:        5d08f68b-x86-AMD-limit-C1E-disable.patch
Patch22:        5d160571-x86-cpuid-restrict-OSXSAVE-leak.patch
Patch23:        5d1b395a-x86-MSI-fix-loop-termination.patch
Patch24:        5d419d49-x86-spec-ctrl-report-proper-status.patch
Patch25:        5d43253c-x86-ucode-always-collect_cpu_info-at-boot.patch
Patch26:        5d4aa36f-x86-apic-enable-x2APIC-mode-earlier.patch
Patch27:        5d4d850a-introduce-bss-percpu-page-aligned.patch
Patch28:        5d516531-x86-xpti-dont-leak-TSS-adjacent-data.patch
Patch29:        5d6524ca-x86-mm-correctly-init-M2P-entries.patch
Patch30:        5d67ceaf-x86-properly-gate-PKU-clearing.patch
Patch31:        5d70bfba-x86-shadow-dont-enable-with-too-small-allocation.patch
Patch32:        5d779811-x86-fix-CPUID7-0-eax-levelling-MSR.patch
Patch33:        5d89d8d9-libxc-x86-avoid-overflow-in-CPUID-APIC-ID.patch
Patch34:        5d8b715f-ACPI-cpuidle-bump-max-num-of-states.patch
Patch35:        5d8ce179-sched-dont-leak-XEN_RUNSTATE_UPDATE.patch
Patch36:        5d947b01-x86-crash-force-unlock-console.patch
Patch37:        5d948bdb-IOMMU-add-missing-HVM-check.patch
Patch38:        5d9ef2a1-EFI-deref-pointer-in-set_color.patch
Patch39:        5d9ef2c5-EFI-gfx-mode-for-MB2-boot.patch
Patch40:        5d9ef2ef-PCI-clear-maskall-fields-on-assign.patch
Patch41:        5d9f454a-x86-EFI-pixel-reserved-0.patch
Patch42:        5db07974-x86-update-time-info-on-TSC-adjustments.patch
Patch43:        5db892ac-VT-x-correct-BDF93-workaround.patch
Patch44:        5db892ac-VT-x-fix-Haswell-Broadwell-LBR-TSX-errata.patch
Patch45:        5dbaf89f-dont-use-BUG-for-parameter-checking.patch
Patch46:        5dbaf8e0-x86-PV-check-GDT-LDT-limits-during-emulation.patch
Patch47:        5dbaf990-x86-mm-L1TF-checks-dont-leave-partial-entry.patch
Patch48:        5dbaf9b2-x86-mm-dont-re-set-PGT_pinned-on-partial-page.patch
Patch49:        5dbaf9ce-x86-mm-split-partial_pte-tristate.patch
Patch50:        5dbaf9f5-x86-mm-use-flags-for-_put_page_type.patch
Patch51:        5dbafa13-x86-mm-rework-get_page_and_type_from_mfn-conditional.patch
Patch52:        5dbafa46-x86-mm-alloc_lN_table-clear-partial_flags-when-preempting.patch
Patch53:        5dbafa5c-x86-mm-always-retain-general-ref-on-partial.patch
Patch54:        5dbafa7f-x86-mm-collapse-PTF_partial_.patch
Patch55:        5dbafaa4-x86-mm-properly-handle-linear-pt-promotion-failure.patch
Patch56:        5dbafabd-x86-mm-fix-nested-devalidation-on-error.patch
Patch57:        5dbafad5-x86-mm-dont-drop-type-ref-unless.patch
Patch58:        5dbafb0d-Arm-p2m-avoid-aliasing-guest-physical-frame.patch
Patch59:        5dbafb4e-Arm-p2m-avoid-off-by-1-check-on-max_mapped_gfn.patch
Patch60:        5dbafb72-Arm-p2m-dont-check-p2m_get_root_pointer-ret-with-BUG_ON.patch
Patch61:        5dbafba5-passthrough-quarantine-PCI-devices.patch
Patch62:        5dbafbda-Arm32-entry-Split-__DEFINE_ENTRY_TRAP.patch
Patch63:        5dbafbfd-Arm32-entry-fold-SAVE_ALL-into-vector-macro.patch
Patch64:        5dbafc3a-Arm32-dont-unmask-interrupts-on-trap-without-level-change.patch
Patch65:        5dbafc4f-Arm64-dont-unmask-interrupts-on-trap-without-level-change.patch
Patch66:        5dca846c-x86-fix-clear_IO_APIC_pin-raw-writes.patch
Patch67:        5dca84a2-AMD-IOMMU-dont-needlessly-trigger-errors-on-unmap.patch
Patch68:        5dcae816-VT-d-hide-superpages-for-SandyBridge.patch
Patch69:        5dcae816-VT-x-work-around-executable-EPT-superpages.patch
Patch70:        5dcae816-VT-x-runtime-modification-of-exec-sp.patch
Patch71:        5dcae816-x86-introduce-tsx-option.patch
Patch72:        5dcae816-x86-spec-ctrl-mitigate-TAA.patch
Patch73:        5dd8126b-x86-vLAPIC-allow-APIC_SPIV_FOCUS_DISABLED.patch
Patch74:        5dd93ce0-vVMX-fix-livelock-with-XSA-304-fix.patch
Patch75:        5ddbb3d3-x86-mm-adjust-linear-usage-accounting.patch
Patch76:        5ddd2555-IOMMU-always-quarantine-PCI-devs.patch
Patch77:        5e876b0f-tools-xenstore-fix-use-after-free-in-xenstored.patch
Patch78:        xsa307.patch
Patch79:        xsa308.patch
Patch80:        xsa309.patch
Patch81:        xsa310-1.patch
Patch82:        xsa310-2.patch
Patch83:        xsa310-3.patch
Patch84:        xsa311-2.patch
Patch85:        xsa313-1.patch
Patch86:        xsa313-2.patch
Patch87:        xsa314.patch
Patch88:        xsa316.patch
Patch89:        xsa318.patch
Patch90:        xsa320-1.patch
Patch91:        xsa320-2.patch
# Our platform specific patches
Patch400:       xen-destdir.patch
Patch401:       vif-bridge-no-iptables.patch
Patch402:       vif-bridge-tap-fix.patch
Patch403:       xl-conf-default-bridge.patch
Patch404:       xen-arch-kconfig-nr_cpus.patch
Patch405:       suse-xendomains-service.patch
Patch406:       replace-obsolete-network-configuration-commands-in-s.patch
Patch407:       disable-building-pv-shim.patch
# Needs to go upstream
Patch420:       suspend_evtchn_lock.patch
Patch421:       xenpaging.doc.patch
Patch422:       stubdom-have-iovec.patch
Patch423:       vif-route.patch
# Other bug fixes or features
Patch451:       xenconsole-no-multiple-connections.patch
Patch452:       hibernate.patch
Patch453:       stdvga-cache.patch
Patch454:       ipxe-enable-nics.patch
Patch455:       pygrub-netware-xnloader.patch
Patch456:       pygrub-boot-legacy-sles.patch
Patch457:       pygrub-handle-one-line-menu-entries.patch
Patch458:       aarch64-rename-PSR_MODE_ELxx-to-match-linux-headers.patch
Patch459:       aarch64-maybe-uninitialized.patch
Patch460:       CVE-2014-0222-blktap-qcow1-validate-l2-table-size.patch
Patch461:       blktap2-no-uninit.patch
Patch462:       libxc.sr.superpage.patch
Patch463:       libxl.add-option-to-disable-disk-cache-flushes-in-qdisk.patch
Patch464:       libxl.pvscsi.patch
Patch465:       xen.libxl.dmmd.patch
Patch466:       libxl.set-migration-constraints-from-cmdline.patch
Patch467:       xenstore-run-in-studomain.patch
Patch468:       libxl.LIBXL_DESTROY_TIMEOUT.patch
Patch469:       libxl.Add-a-version-check-of-QEMU-for-QMP-commands.patch
Patch470:       libxl.qmp-Tell-QEMU-about-live-migration-or-snapshot.patch
Patch471:       libxl.pv-qemu-migration.patch
Patch472:       libxl.prepare-environment-for-domcreate_stream_done.patch
Patch473:       libxl.LIBXL_HOTPLUG_TIMEOUT.patch
Patch474:       libxc.do_domctl.EFAULT-retry.patch
Patch475:       libxl.helper_done-crash.patch
# python3 conversion patches
Patch500:       build-python3-conversion.patch
Patch501:       pygrub-python3-conversion.patch
Patch502:       migration-python3-conversion.patch
Patch503:       bin-python3-conversion.patch
Patch504:       fix-xenpvnetboot.patch
# Hypervisor and PV driver Patches
Patch600:       xen.bug1026236.suse_vtsc_tolerance.patch
Patch601:       x86-ioapic-ack-default.patch
Patch602:       x86-cpufreq-report.patch
Patch620:       xenstore-launch.patch
Patch621:       xen.build-compare.doc_html.patch
Patch622:       xen.build-compare.man.patch
Patch623:       ipxe-no-error-logical-not-parentheses.patch
Patch624:       ipxe-use-rpm-opt-flags.patch
# Build patches
Patch99995:     xen.fuzz-_FORTIFY_SOURCE.patch
Patch99996:     xen.stubdom.newlib.patch
Patch99998:     tmp_build.patch
Url:            http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define pyver %(python3 -c "import sys; print(sys.version[:3])")

%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)

[Hypervisor is a trademark of IBM]

%package libs
Summary:        Xen Virtualization: Libraries
Group:          System/Kernel

%description libs
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 libraries used to interact with the Xen
virtual machine monitor.

In addition to this package you need to install kernel-xen, xen and
xen-tools to use Xen.


Authors:
--------
    Ian Pratt <ian.pratt@cl.cam.ac.uk>


%if %{?with_dom0_support}0

%package tools
Summary:        Xen Virtualization: Control tools for domain 0
Group:          System/Kernel
%ifarch x86_64
%if 0%{?suse_version} >= 1315
Requires:       grub2-x86_64-xen
%endif
# Uncomment when ovmf is supported
#Requires:       qemu-ovmf-x86_64
Requires:       qemu-x86
%endif
%ifarch %arm aarch64
Requires:       qemu-arm
%endif
Requires:       %{name}-libs = %{version}-%{release}
Requires:       multipath-tools
Requires:       python3
Requires:       python3-curses
Requires:       qemu-seabios
# subpackage existed in 10.3
Provides:       xen-tools-ioemu = %{version}
Obsoletes:      xen-tools-ioemu < %{version}
Conflicts:      libvirt < 1.0.5

%description tools
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 control tools that allow you to start, stop,
migrate, and manage virtual machines.

In addition to this package you need to install kernel-xen, xen and
xen-libs to use Xen.


Authors:
--------
    Ian Pratt <ian.pratt@cl.cam.ac.uk>


%endif

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

%description tools-domU
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 tools that allow unprivileged domains to query
the virtualized environment.



Authors:
--------
    Ian Pratt <ian.pratt@cl.cam.ac.uk>

%package devel
Summary:        Xen Virtualization: Headers and libraries for development
Group:          System/Kernel
Requires:       %{name}-libs = %{version}
Requires:       libuuid-devel

%description devel
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 libraries and header files needed to create
tools to control virtual machines.



Authors:
--------
    Ian Pratt <ian.pratt@cl.cam.ac.uk>

%if %{?with_dom0_support}0

%package doc-html
Summary:        Xen Virtualization: HTML documentation
Group:          Documentation/HTML

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

xen-doc-html contains the online documentation in HTML format. Point
your browser at file:/usr/share/doc/packages/xen/html/



Authors:
--------
    Ian Pratt <ian.pratt@cl.cam.ac.uk>
%endif

%prep
%setup -q -n %xen_build_dir -a 1 -a 5 -a 6 -a 57
# Upstream patches
%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
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%patch59 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch72 -p1
%patch73 -p1
%patch74 -p1
%patch75 -p1
%patch76 -p1
%patch77 -p1
%patch78 -p1
%patch79 -p1
%patch80 -p1
%patch81 -p1
%patch82 -p1
%patch83 -p1
%patch84 -p1
%patch85 -p1
%patch86 -p1
%patch87 -p1
%patch88 -p1
%patch89 -p1
%patch90 -p1
%patch91 -p1
# Our platform specific patches
%patch400 -p1
%patch401 -p1
%patch402 -p1
%patch403 -p1
%patch404 -p1
%patch405 -p1
%patch406 -p1
%patch407 -p1
# Needs to go upstream
%patch420 -p1
%patch421 -p1
%patch422 -p1
%patch423 -p1
# Other bug fixes or features
%patch451 -p1
%patch452 -p1
%patch453 -p1
%patch454 -p1
%patch455 -p1
%patch456 -p1
%patch457 -p1
%patch458 -p1
%patch459 -p1
%patch460 -p1
%patch461 -p1
%patch462 -p1
%patch463 -p1
%patch464 -p1
%patch465 -p1
%patch466 -p1
%patch467 -p1
%patch468 -p1
%patch469 -p1
%patch470 -p1
%patch471 -p1
%patch472 -p1
%patch473 -p1
%patch474 -p1
%patch475 -p1
# python3 conversion patches
%patch500 -p1
%patch501 -p1
%patch502 -p1
%patch503 -p1
%patch504 -p1
# Hypervisor and PV driver Patches
%patch600 -p1
%patch601 -p1
%patch602 -p1
%patch620 -p1
%patch621 -p1
%patch622 -p1
%patch623 -p1
%patch624 -p1
# Build patches
%patch99995 -p1
%patch99996 -p1
%patch99998 -p1

%build
# JWF: Anthony's series to load BIOS from toolstack requires autogen.sh.
# http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01626.html
./autogen.sh

# we control the version info of this package
# to gain control of filename of xen.gz
XEN_VERSION=%{version}
XEN_VERSION=${XEN_VERSION%%%%.*}
XEN_SUBVERSION=%{version}
XEN_SUBVERSION=${XEN_SUBVERSION#*.}
XEN_SUBVERSION=${XEN_SUBVERSION%%%%.*}
XEN_EXTRAVERSION="%version-%release"
XEN_EXTRAVERSION="${XEN_EXTRAVERSION#*.}"
XEN_EXTRAVERSION="${XEN_EXTRAVERSION#*.}"
# remove trailing B_CNT to reduce build-compare noise
XEN_EXTRAVERSION="${XEN_EXTRAVERSION%%.*}"
XEN_FULLVERSION="$XEN_VERSION.$XEN_SUBVERSION.$XEN_EXTRAVERSION"
XEN_BUILD_DATE="`date -u -d '1970-01-01'`"
XEN_BUILD_TIME="`date -u -d '1970-01-01' +%%T`"
SMBIOS_DATE="`date -u -d '1970-01-01' +%%m/%%d/%%Y`"
RELDATE="`date -u -d '1970-01-01' '+%%d %%b %%Y'`"
if test -r %{S:9}
then
	XEN_BUILD_DATE="` date -u -d \"$(sed -n '/@/{s/ - .*$//p;q}' %{S:9})\" `"
	XEN_BUILD_TIME="` date -u -d \"$(sed -n '/@/{s/ - .*$//p;q}' %{S:9})\" +%%T`"
	SMBIOS_DATE="` date -u -d \"$(sed -n '/@/{s/ - .*$//p;q}' %{S:9})\" +%%m/%%d/%%Y`"
	RELDATE="` date -u -d \"$(sed -n '/@/{s/ - .*$//p;q}' %{S:9})\" '+%%d %%b %%Y'`"
fi
cat > .our_xenversion <<_EOV_
export WGET=$(type -P false)
export FTP=$(type -P false)
export GIT=$(type -P false)
export EXTRA_CFLAGS_XEN_TOOLS="$RPM_OPT_FLAGS"
export EXTRA_CFLAGS_QEMU_TRADITIONAL="$RPM_OPT_FLAGS"
export SMBIOS_DATE="$SMBIOS_DATE"
export RELDATE="$RELDATE"
XEN_VERSION=$XEN_VERSION
XEN_SUBVERSION=$XEN_SUBVERSION
XEN_EXTRAVERSION=$XEN_EXTRAVERSION
XEN_FULLVERSION=$XEN_FULLVERSION
_EOV_
source ./.our_xenversion
echo "%{changeset}" > xen/.scmversion
sed -i~ "
s/XEN_VERSION[[:blank:]]*=.*/XEN_VERSION = $XEN_VERSION/
s/XEN_SUBVERSION[[:blank:]]*=.*/XEN_SUBVERSION = $XEN_SUBVERSION/
s/XEN_EXTRAVERSION[[:blank:]]*?=.*/XEN_EXTRAVERSION = .$XEN_EXTRAVERSION/
s/XEN_FULLVERSION[[:blank:]]*=.*/XEN_FULLVERSION = $XEN_FULLVERSION/
s/XEN_BUILD_DATE[[:blank:]]*?=.*/XEN_BUILD_DATE = $XEN_BUILD_DATE/
s/XEN_BUILD_TIME[[:blank:]]*?=.*/XEN_BUILD_TIME = $XEN_BUILD_TIME/
s/XEN_BUILD_HOST[[:blank:]]*?=.*/XEN_BUILD_HOST = buildhost/
s/XEN_DOMAIN[[:blank:]]*?=.*/XEN_DOMAIN = suse.de/
" xen/Makefile
if diff -u xen/Makefile~ xen/Makefile
then
	: no changes?
fi
configure_flags=
%if %{with xen_stubdom}
configure_flags=--enable-stubdom
%else
# change the/our default to daemon due to lack of stubdom
sed -i~ 's/ XENSTORETYPE=domain$/ XENSTORETYPE=daemon/' tools/hotplug/Linux/launch-xenstore.in
configure_flags=--disable-stubdom
%endif
export PYTHON="/usr/bin/python3"
configure_flags="${configure_flags} --disable-qemu-traditional"
./configure \
        --disable-xen \
        --enable-tools \
        --enable-docs \
        --prefix=/usr \
        --exec_prefix=/usr \
        --bindir=%{_bindir} \
        --sbindir=%{_sbindir} \
        --libdir=%{_libdir} \
        --libexecdir=%{_libexecdir} \
        --datadir=%{_datadir} \
        --mandir=%{_mandir} \
        --includedir=%{_includedir} \
        --docdir=%{_defaultdocdir}/xen \
	--with-initddir=%{_initddir} \
%if %{?with_dom0_support}0
%if %{with xen_oxenstored}
	--with-xenstored=oxenstored \
%endif
%endif
	--enable-systemd \
	--with-systemd=%{_unitdir} \
	--with-systemd-modules-load=%{with_systemd_modules_load} \
	--with-system-ovmf=%{_datadir}/qemu/ovmf-x86_64-ms.bin \
	--with-system-seabios=%{_datadir}/qemu/bios-256k.bin \
	--with-system-qemu=%{_bindir}/qemu-system-i386 \
        ${configure_flags}
make -C tools/include/xen-foreign %{?_smp_mflags}
make %{?_smp_mflags}
%if %{?with_dom0_support}0
make -C tools/xen-utils-0.1 XEN_INTREE_BUILD=yes XEN_ROOT=$PWD
%endif
#

%install
source ./.our_xenversion
# tools
make \
	DESTDIR=$RPM_BUILD_ROOT \
	SYSCONFIG_DIR=%{_fillupdir} \
	%{?_smp_mflags} \
	install
find $RPM_BUILD_ROOT -ls
for i in $RPM_BUILD_ROOT%{_fillupdir}/*
do
	mv -v $i ${i%/*}/sysconfig.${i##*/}
done

#
unitdir=$RPM_BUILD_ROOT%{_unitdir}
udev_rulesdir=$RPM_BUILD_ROOT%{_udevrulesdir}
tools_domU_dir=$RPM_BUILD_ROOT%{_libexecdir}/%{name}-tools-domU
mkdir -p ${udev_rulesdir}
mkdir -p ${tools_domU_dir}
#
tee ${unitdir}/xen-LIBXL_HOTPLUG_TIMEOUT.service <<'_EOS_'
[Unit]
Description=set global per-device LIBXL_HOTPLUG_TIMEOUT to 5 seconds
ConditionPathExists=/proc/xen/capabilities

Requires=xenstored.service
After=xenstored.service
Requires=xen-init-dom0.service
After=xen-init-dom0.service
Before=xencommons.service

[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities
ExecStart=%{_bindir}/xenstore-write '/libxl/suse/per-device-LIBXL_HOTPLUG_TIMEOUT' '5'

[Install]
WantedBy=multi-user.target
_EOS_
#
tee ${udev_rulesdir}/80-%{name}-tools-domU.rules <<'_EOR_'
# XenSource, Inc. Xen Platform Device
SUBSYSTEM=="pci", ATTR{modalias}=="pci:v00005853d00000001sv00005853sd00000001bcFFsc80i00", TAG+="systemd", ENV{SYSTEMD_WANTS}+="%{name}-vcpu-watch.service"
_EOR_
#
tee $RPM_BUILD_ROOT%{_unitdir}/%{name}-vcpu-watch.service <<'_EOS_'
[Unit]
Description=Listen to CPU online/offline events from dom0 toolstack

[Service]
Type=simple
ExecStart=%{_libexecdir}/%{name}-tools-domU/%{name}-vcpu-watch.sh
Restart=always
RestartSec=2
_EOS_
#
tee $RPM_BUILD_ROOT%{_libexecdir}/%{name}-tools-domU/%{name}-vcpu-watch.sh <<'_EOS_'
#!/bin/bash
unset LANG
unset ${!LC_*}
echo "$0 starting" >&2
xenstore-watch cpu | while read
do
  : xenstore event: ${REPLY}
  case "${REPLY}" in
    cpu)
      : just started
      ;;
    cpu/[0-9]/availability|cpu/[0-9][0-9]/availability)
      vcpu="${REPLY%/*}"
      vcpu="${vcpu#*/}"
      sysfs="/sys/devices/system/cpu/cpu${vcpu}/online"
      if test -f "${sysfs}"
      then
        availability="`xenstore-read \"${REPLY}\"`"
        case "${availability}" in
          online|offline)
            if test "${availability}" = "online"
            then
              new_sysfs_state=1
            else
              new_sysfs_state=0
            fi
            read cur_sysfs_state rest < "${sysfs}"
            if test "${cur_sysfs_state}" = "${new_sysfs_state}"
            then
              : the vcpu "${vcpu}" already has state "${availability}" via "${sysfs}"
            else
              : setting vcpu "${vcpu}" to "${availability}" via "${sysfs}"
              echo "setting vcpu ${vcpu} to ${availability}" >&2
              echo "${new_sysfs_state}" > "${sysfs}"
            fi
          ;;
        esac
      fi
    ;;
    *)
      : unhandled
    ;;
  esac
done
exit 1
_EOS_
chmod 755 $RPM_BUILD_ROOT%{_libexecdir}/%{name}-tools-domU/%{name}-vcpu-watch.sh
#
tee ${udev_rulesdir}/60-persistent-xvd.rules <<'_EOR_'
ACTION=="remove", GOTO="xvd_aliases_end"
SUBSYSTEM!="block", GOTO="xvd_aliases_end"
KERNEL=="xvd*[!0-9]", IMPORT{program}=="%{name}-tools-domU.sh --devpath %%p --devtype $env{DEVTYPE}"
KERNEL=="xvd*[0-9]",  IMPORT{program}=="%{name}-tools-domU.sh --devpath %%p --devtype $env{DEVTYPE}"
KERNEL=="xvd*[!0-9]", ENV{VBD_HD_SYMLINK}=="hd[a-d]", SYMLINK+="$env{VBD_HD_SYMLINK}"
KERNEL=="xvd*[0-9]",  ENV{VBD_HD_SYMLINK}=="hd[a-d]", SYMLINK+="$env{VBD_HD_SYMLINK}%%n"
LABEL="xvd_aliases_end"
_EOR_
#
tee ${udev_rulesdir}/80-%{name}-channel-setup.rules <<'_EOF_'
SUBSYSTEM=="xen", DEVPATH=="/devices/console-[0-9]", IMPORT{program}=="xen-channel-setup.sh $attr{nodename} %n"

SUBSYSTEM=="xen", DEVPATH=="/devices/console-[0-9]", ENV{XEN_CHANNEL_NAME}=="org.qemu.guest_agent.0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="qemu-ga@hvc%n.service"
_EOF_
#
dracut_moduledir=$RPM_BUILD_ROOT/usr/lib/dracut/modules.d/50%{name}-tools-domU
mkdir -p ${dracut_moduledir}
tee ${dracut_moduledir}/module-setup.sh <<'_EOS_'
#!/bin/bash
check() {
  require_binaries xenstore-read || return 1
  return 0
}

depends() {
  return 0
}
install() {
  inst_multiple xenstore-read
  inst_multiple ${udevdir}/%{name}-tools-domU.sh
  inst_rules 60-persistent-xvd.rules
}
_EOS_
chmod 755 ${dracut_moduledir}/module-setup.sh
#
udev_programdir=$RPM_BUILD_ROOT/usr/lib/udev
mkdir -p ${udev_programdir}
tee ${udev_programdir}/%{name}-tools-domU.sh <<'_EOS_'
#!/bin/bash
set -e
devpath=
devtype=
dev=
while test "$#" -gt 0
do
  : "$1"
  case "$1" in
    --devpath) devpath=$2 ; shift ;;
    --devtype) devtype=$2 ; shift ;;
    *) echo "$0: Unknown option $1" >&2 ; exit 1 ;;
  esac
  shift
done
test -n "${devpath}" || exit 1
test -n "${devtype}" || exit 1
cd "/sys/${devpath}"
case "${devtype}" in
  partition) cd .. ;;
esac
cd -P device
d="${PWD##*/}"
d="${d/-/\/}"
backend="`xenstore-read device/${d}/backend`"
dev="`xenstore-read \"${backend}\"/dev`"
test -n "${dev}" && echo "VBD_HD_SYMLINK=${dev}"
_EOS_
#
tee ${udev_programdir}/%{name}-channel-setup.sh <<'_EOF_'
#!/bin/bash

if test "$#" -ne 2; then
    exit 1
fi

channel_path="$1"
channel_num="$2"

name="`xenstore-read \"$channel_path\"/name`"
test -z "$name" && exit 1

if test $name != "org.qemu.guest_agent.0"; then
    exit 1
fi

mkdir -p /dev/xenchannel
devname=/dev/xenchannel/$name
# Xen's console devices are used for channels. See xen-pv-channel(7)
# for more details
ln -sfn /dev/hvc$channel_num $devname

echo "XEN_CHANNEL_NAME=$name"
_EOF_
chmod 755 ${udev_programdir}/*.sh

# EFI
%if %{?with_dom0_support}0
install_xen()
{
    local ext=""
    find $RPM_BUILD_ROOT/boot -ls
    if [ -n "$1" ]; then
        ext="-$1"
        mv $RPM_BUILD_ROOT/boot/xen-syms-${XEN_FULLVERSION} \
           $RPM_BUILD_ROOT/boot/xen-syms${ext}-${XEN_FULLVERSION}
        mv $RPM_BUILD_ROOT/boot/xen-${XEN_FULLVERSION}%{xen_install_suffix} \
           $RPM_BUILD_ROOT/boot/xen${ext}-${XEN_FULLVERSION}%{xen_install_suffix}
        if test -d $RPM_BUILD_ROOT%{_libdir}/efi; then
            mv $RPM_BUILD_ROOT%{_libdir}/efi/xen-${XEN_FULLVERSION}.efi $RPM_BUILD_ROOT%{_libdir}/efi/xen${ext}-${XEN_FULLVERSION}.efi
            ln -sf xen${ext}-${XEN_FULLVERSION}.efi $RPM_BUILD_ROOT%{_libdir}/efi/xen${ext}-$XEN_VERSION.$XEN_SUBVERSION.efi
            ln -sf xen${ext}-${XEN_FULLVERSION}.efi $RPM_BUILD_ROOT%{_libdir}/efi/xen${ext}-$XEN_VERSION.efi
            ln -sf xen${ext}-${XEN_FULLVERSION}.efi $RPM_BUILD_ROOT%{_libdir}/efi/xen${ext}.efi
        fi
    fi
    rm $RPM_BUILD_ROOT/boot/xen-$XEN_VERSION.$XEN_SUBVERSION%{xen_install_suffix}
    rm $RPM_BUILD_ROOT/boot/xen-$XEN_VERSION%{xen_install_suffix}
    rm $RPM_BUILD_ROOT/boot/xen%{xen_install_suffix}
    # Do not link to links; grub cannot follow.
    ln -s xen${ext}-${XEN_FULLVERSION}%{xen_install_suffix} $RPM_BUILD_ROOT/boot/xen${ext}-$XEN_VERSION.$XEN_SUBVERSION%{xen_install_suffix}
    ln -s xen${ext}-${XEN_FULLVERSION}%{xen_install_suffix} $RPM_BUILD_ROOT/boot/xen${ext}-$XEN_VERSION%{xen_install_suffix}
    ln -s xen${ext}-${XEN_FULLVERSION}%{xen_install_suffix} $RPM_BUILD_ROOT/boot/xen${ext}%{xen_install_suffix}
    if test -f xen-syms${ext}-${XEN_FULLVERSION}; then
        ln -sf xen-syms${ext}-${XEN_FULLVERSION} $RPM_BUILD_ROOT/boot/xen-syms${ext}
    fi
    find $RPM_BUILD_ROOT/boot -ls
}
export BRP_PESIGN_FILES="*.efi /lib/firmware"
CC=gcc
%if %{?with_gcc47}0
CC=gcc-4.7
%endif
%if %{?with_gcc48}0
CC=gcc-4.8
%endif
rm -fv xen/.config
%if %{with xen_debug}
echo CONFIG_DEBUG=y > xen/.config
yes '' | make -C xen oldconfig
make -C xen install DEBUG_DIR=/boot DESTDIR=$RPM_BUILD_ROOT CC=$CC %{?_smp_mflags}
install_xen dbg
make -C xen clean
%endif
echo CONFIG_DEBUG=n > xen/.config
yes '' | make -C xen oldconfig
make -C xen install DEBUG_DIR=/boot DESTDIR=$RPM_BUILD_ROOT CC=$CC %{?_smp_mflags}
install_xen
make -C xen clean
echo > xen.files.txt
# EFI depends on gcc47
if test -d $RPM_BUILD_ROOT%{_libdir}/efi
then
	echo %{_libdir}/efi >> xen.files.txt
fi
%endif

# On x86_64, qemu-xen was installed as /usr/lib/xen/bin/qemu-system-i386
# and advertised as the <emulator> in libvirt capabilities. Tool such as
# virt-install include <emulator> in domXML they produce, so we need to
# preserve the path. For x86_64, create a simple wrapper that invokes
# /usr/bin/qemu-system-i386
# Using qemu-system-x86_64 will result in an incompatible VM
%ifarch x86_64
cat > $RPM_BUILD_ROOT/usr/lib/xen/bin/qemu-system-i386 << 'EOF'
#!/bin/sh

exec %{_bindir}/qemu-system-i386 "$@"
EOF
chmod 0755 $RPM_BUILD_ROOT/usr/lib/xen/bin/qemu-system-i386
%endif

# Stubdom
%if %{?with_dom0_support}0
# Docs
mkdir -p $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/misc
for name in COPYING %SOURCE10 %SOURCE11 %SOURCE12; do
    install -m 644 $name $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/
done
for name in vtpm-platforms.txt crashdb.txt xenpaging.txt \
    xen-command-line.markdown xenstore-paths.markdown; do
    install -m 644 docs/misc/$name $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/misc/
done

mkdir -p $RPM_BUILD_ROOT/etc/modprobe.d
install -m644 %SOURCE26 $RPM_BUILD_ROOT/etc/modprobe.d/xen_loop.conf

# xen-utils
make -C tools/xen-utils-0.1 install DESTDIR=$RPM_BUILD_ROOT XEN_INTREE_BUILD=yes XEN_ROOT=$PWD
install -m755 %SOURCE37 $RPM_BUILD_ROOT/usr/sbin/xen2libvirt

rm -f $RPM_BUILD_ROOT/etc/xen/README*
# Example config
mkdir -p $RPM_BUILD_ROOT/etc/xen/{vm,examples,scripts}
mv $RPM_BUILD_ROOT/etc/xen/xlexample* $RPM_BUILD_ROOT/etc/xen/examples
rm -f $RPM_BUILD_ROOT/etc/xen/examples/*nbd
install -m644 tools/xentrace/formats $RPM_BUILD_ROOT/etc/xen/examples/xentrace_formats.txt

# Scripts
rm -f $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd
install -m755 %SOURCE21 %SOURCE22 %SOURCE23 %SOURCE29 $RPM_BUILD_ROOT/etc/xen/scripts/
mkdir -p $RPM_BUILD_ROOT/usr/lib/supportconfig/plugins
install -m 755 %SOURCE13 $RPM_BUILD_ROOT/usr/lib/supportconfig/plugins/xen

# Xen API remote authentication files
install -d $RPM_BUILD_ROOT/etc/pam.d
install -m644 %SOURCE30 $RPM_BUILD_ROOT/etc/pam.d/xen-api
install -m644 %SOURCE31 $RPM_BUILD_ROOT/etc/xen/

# Logrotate
install -m644 -D %SOURCE15 $RPM_BUILD_ROOT/etc/logrotate.d/xen

# Directories
mkdir -p $RPM_BUILD_ROOT/var/lib/xenstored
mkdir -p $RPM_BUILD_ROOT/var/lib/xen/images
mkdir -p $RPM_BUILD_ROOT/var/lib/xen/jobs
mkdir -p $RPM_BUILD_ROOT/var/lib/xen/save
mkdir -p $RPM_BUILD_ROOT/var/lib/xen/dump
mkdir -p $RPM_BUILD_ROOT/var/log/xen
mkdir -p $RPM_BUILD_ROOT/var/log/xen/console
ln -s /var/lib/xen/images $RPM_BUILD_ROOT/etc/xen/images

# Bootloader
install -m644 %SOURCE36 $RPM_BUILD_ROOT/%{_libdir}/python%{pyver}/site-packages

# Systemd
cp -bavL %{S:41} $RPM_BUILD_ROOT%{_unitdir}
bn=`basename %{S:42}`
cp -bavL %{S:42} $RPM_BUILD_ROOT%{_unitdir}/${bn}
mods="`
for conf in $(ls $RPM_BUILD_ROOT%{with_systemd_modules_load}/*.conf)
do
	grep -v ^# $conf
	echo -n > $conf
done
`"
for mod in $mods
do
	echo "ExecStart=-/bin/sh -c 'modprobe $mod || :'" >> $RPM_BUILD_ROOT%{_unitdir}/${bn}
done
rm -rfv $RPM_BUILD_ROOT%{_initddir}
install -m644 %SOURCE35 $RPM_BUILD_ROOT%{_fillupdir}/sysconfig.pciback

# Clean up unpackaged files
find $RPM_BUILD_ROOT \( \
	-name .deps -o \
	-name README.blktap -o \
	-name README.xenmon -o \
	-name target-x86_64.conf -o \
	-name xen-mfndump -o \
	-name qcow-create -o \
	-name img2qcow -o \
	-name qcow2raw -o \
	-name qemu-bridge-helper -o \
	-name qemu-img-xen -o \
	-name qemu-nbd-xen -o \
	-name palcode-clipper -o \
	-name "*.dtb" -o \
	-name "openbios-*" -o \
	-name "petalogix*" -o \
	-name "ppc*" -o \
	-name "*.pyc" -o \
	-name "s390*" -o \
	-name "slof*" -o \
	-name "spapr*" -o \
	-name "*.egg-info" \) \
	-print -delete
# Wipe empty directories
if find $RPM_BUILD_ROOT/usr -type d -print0 | xargs -0n1 rmdir -p 2>/dev/null
then
	:
fi

# "xl devd" has to be called manually in a driver domain
find $RPM_BUILD_ROOT -name xendriverdomain.service -print -delete

# Create symlinks for keymaps
%fdupes -s $RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -size 0 -delete

%else
# !with_dom0_support

# 32 bit hypervisor no longer supported.  Remove dom0 tools.
rm -rf $RPM_BUILD_ROOT/%{_datadir}/doc
rm -rf $RPM_BUILD_ROOT/%{_datadir}/man
rm -rf $RPM_BUILD_ROOT/%{_libdir}/xen
rm -rf $RPM_BUILD_ROOT/%{_libdir}/python*
rm -rf $RPM_BUILD_ROOT/%{_libdir}/ocaml*
rm -rf $RPM_BUILD_ROOT%{_unitdir}
rm -rf $RPM_BUILD_ROOT%{_fillupdir}
rm -rf $RPM_BUILD_ROOT%{with_systemd_modules_load}
rm -rf $RPM_BUILD_ROOT/usr/sbin
rm -rf $RPM_BUILD_ROOT/etc/xen
rm -rf $RPM_BUILD_ROOT/var
rm -f  $RPM_BUILD_ROOT/%{_sysconfdir}/bash_completion.d/xl.sh
rm -f  $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/xen*
rm -f  $RPM_BUILD_ROOT/%{_bindir}/*trace*
rm -f  $RPM_BUILD_ROOT/%{_bindir}/xenalyze*
rm -f  $RPM_BUILD_ROOT/%{_bindir}/xenco*
rm -f  $RPM_BUILD_ROOT/%{_bindir}/xen-cpuid
rm -f  $RPM_BUILD_ROOT/%{_bindir}/xenstore*
rm -f  $RPM_BUILD_ROOT/%{_bindir}/pygrub
rm -f  $RPM_BUILD_ROOT/%{_bindir}/remus
rm -f  $RPM_BUILD_ROOT/usr/etc/qemu/target-x86_64.conf
rm -f  $RPM_BUILD_ROOT/usr/libexec/qemu-bridge-helper
%endif

%if %{?with_dom0_support}0

%files -f xen.files.txt
%defattr(-,root,root)
/boot/*

%endif

%files libs
%defattr(-,root,root)
%{_libdir}/fs/
%{_libdir}/*.so.*

%if %{?with_dom0_support}0

%files tools
%defattr(-,root,root)
%ifarch %ix86 x86_64
/usr/bin/xenalyze
%endif
/usr/bin/xencons
/usr/bin/xenstore*
/usr/bin/pygrub
/usr/bin/xencov_split
/usr/bin/xentrace_format
%ifarch x86_64
/usr/bin/xen-cpuid
%endif
#/usr/sbin/tap*
/usr/sbin/xenbaked
/usr/sbin/xenconsoled
/usr/sbin/xencov
/usr/sbin/xenlockprof
/usr/sbin/xenmon.py
/usr/sbin/xenperf
/usr/sbin/xenpm
/usr/sbin/xenpmd
/usr/sbin/xen-ringwatch
/usr/sbin/xenstored
/usr/sbin/xen-tmem-list-parse
/usr/sbin/xentop
/usr/sbin/xentrace
/usr/sbin/xentrace_setsize
/usr/sbin/xentrace_setmask
/usr/sbin/xenwatchdogd
#/usr/sbin/lock-util
#/usr/sbin/td-util
#/usr/sbin/vhd-update
#/usr/sbin/vhd-util
/usr/sbin/flask-get-bool
/usr/sbin/flask-getenforce
/usr/sbin/flask-label-pci
/usr/sbin/flask-loadpolicy
/usr/sbin/flask-set-bool
/usr/sbin/flask-setenforce
%if %{?with_gdbsx}0
/usr/sbin/gdbsx
%endif
/usr/sbin/xl
/usr/sbin/xen2libvirt
%ifarch %ix86 x86_64
/usr/sbin/xen-hptool
/usr/sbin/xen-hvmcrash
/usr/sbin/xen-hvmctx
/usr/sbin/xen-lowmemd
/usr/sbin/kdd
%endif
/usr/sbin/xen-list
/usr/sbin/xen-destroy
/usr/sbin/xen-bugtool
/usr/sbin/xen-livepatch
/usr/sbin/xen-diag
%dir %attr(700,root,root) /etc/xen
%dir /etc/xen/scripts
/etc/xen/scripts/block*
/etc/xen/scripts/external-device-migrate
/etc/xen/scripts/hotplugpath.sh
/etc/xen/scripts/launch-xenstore
/etc/xen/scripts/locking.sh
/etc/xen/scripts/logging.sh
/etc/xen/scripts/vif2
/etc/xen/scripts/vif-*
/etc/xen/scripts/vscsi
/etc/xen/scripts/xen-hotplug-*
/etc/xen/scripts/xen-network-common.sh
/etc/xen/scripts/xen-script-common.sh
/etc/xen/scripts/colo-proxy-setup
/etc/xen/scripts/remus-netbuf-setup
%dir /usr/lib/supportconfig
%dir /usr/lib/supportconfig/plugins
/usr/lib/supportconfig/plugins/xen
%{_libexecdir}/xen
%exclude %{_libexecdir}/%{name}-tools-domU
%{_fillupdir}/sysconfig.pciback
%{_fillupdir}/sysconfig.xencommons
%{_fillupdir}/sysconfig.xendomains
%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 /var/log/xen
%dir /var/log/xen/console
%config /etc/logrotate.d/xen
/etc/xen/auto
%config /etc/xen/examples
/etc/xen/images
%config /etc/xen/cpupool
%config /etc/xen/vm
%config(noreplace) /etc/xen/xenapiusers
%config(noreplace) /etc/xen/xl.conf
%config /etc/pam.d/xen-api
%config /etc/modprobe.d/xen_loop.conf
%config %{_unitdir}
%exclude %{_unitdir}/%{name}-vcpu-watch.service
%config %{with_systemd_modules_load}
%dir /etc/modprobe.d
/etc/bash_completion.d/xl.sh
%dir %{_libdir}/python%{pyver}/site-packages/grub
%dir %{_libdir}/python%{pyver}/site-packages/xen
%dir %{_libdir}/python%{pyver}/site-packages/xen/lowlevel
%dir %{_libdir}/python%{pyver}/site-packages/xen/migration
%{_libdir}/python%{pyver}/site-packages/grub/*
%{_libdir}/python%{pyver}/site-packages/xen/__init__*
%{_libdir}/python%{pyver}/site-packages/xen/lowlevel/*
%{_libdir}/python%{pyver}/site-packages/xen/migration/*
%{_libdir}/python%{pyver}/site-packages/*.so
%{_libdir}/python%{pyver}/site-packages/xnloader.py
%dir %{_defaultdocdir}/xen
%{_defaultdocdir}/xen/COPYING
%{_defaultdocdir}/xen/README.SUSE
%{_defaultdocdir}/xen/boot.local.xenU
%{_defaultdocdir}/xen/boot.xen
%{_mandir}/man*/*

%if %{with xen_oxenstored}
/usr/sbin/oxenstored
/etc/xen/oxenstored.conf
%dir %{_libdir}/ocaml
%dir %{_libdir}/ocaml/xenbus
%dir %{_libdir}/ocaml/xenctrl
%dir %{_libdir}/ocaml/xeneventchn
%dir %{_libdir}/ocaml/xenlight
%dir %{_libdir}/ocaml/xenmmap
%dir %{_libdir}/ocaml/xenstore
%dir %{_libdir}/ocaml/xentoollog
%{_libdir}/ocaml/xenbus/META
%{_libdir}/ocaml/xenbus/*.so
%{_libdir}/ocaml/xenbus/*.cma
%{_libdir}/ocaml/xenbus/*.cmi
%{_libdir}/ocaml/xenbus/*.cmo
%{_libdir}/ocaml/xenctrl/META
%{_libdir}/ocaml/xenctrl/*.so
%{_libdir}/ocaml/xenctrl/*.cma
%{_libdir}/ocaml/xenctrl/*.cmi
%{_libdir}/ocaml/xeneventchn/META
%{_libdir}/ocaml/xeneventchn/*.so
%{_libdir}/ocaml/xeneventchn/*.cma
%{_libdir}/ocaml/xeneventchn/*.cmi
%{_libdir}/ocaml/xenlight/META
%{_libdir}/ocaml/xenlight/*.so
%{_libdir}/ocaml/xenlight/*.cma
%{_libdir}/ocaml/xenlight/*.cmi
%{_libdir}/ocaml/xenmmap/META
%{_libdir}/ocaml/xenmmap/*.so
%{_libdir}/ocaml/xenmmap/*.cma
%{_libdir}/ocaml/xenmmap/*.cmi
%{_libdir}/ocaml/xenstore/META
%{_libdir}/ocaml/xenstore/*.cma
%{_libdir}/ocaml/xenstore/*.cmi
%{_libdir}/ocaml/xenstore/*.cmo
%{_libdir}/ocaml/xentoollog/META
%{_libdir}/ocaml/xentoollog/*.so
%{_libdir}/ocaml/xentoollog/*.cma
%{_libdir}/ocaml/xentoollog/*.cmi
%endif

# with_dom0_support
%endif

%posttrans -n %{name}-tools-domU
%{?regenerate_initrd_posttrans}

%files tools-domU
%defattr(-,root,root)
%ifarch %ix86 x86_64
/usr/bin/xen-detect
%endif
/bin/domu-xenstore*
/bin/xenstore-*
%if %{?with_dom0_support}0
%config %{_unitdir}/%{name}-vcpu-watch.service
%endif
%{_libexecdir}/%{name}-tools-domU
/usr/lib/udev
/usr/lib/dracut

%files devel
%defattr(-,root,root)
%{_libdir}/*.a
%{_libdir}/*.so
%if %{?with_dom0_support}0
%if %{with xen_oxenstored}
%{_libdir}/ocaml/xenbus/*.a
%{_libdir}/ocaml/xenbus/*.cmx*
%{_libdir}/ocaml/xenctrl/*.a
%{_libdir}/ocaml/xenctrl/*.cmx*
%{_libdir}/ocaml/xeneventchn/*.a
%{_libdir}/ocaml/xeneventchn/*.cmx*
%{_libdir}/ocaml/xenlight/*.a
%{_libdir}/ocaml/xenlight/*.cmx*
%{_libdir}/ocaml/xenmmap/*.a
%{_libdir}/ocaml/xenmmap/*.cmx*
%{_libdir}/ocaml/xenstore/*.a
%{_libdir}/ocaml/xenstore/*.cmx*
%{_libdir}/ocaml/xentoollog/*.a
%{_libdir}/ocaml/xentoollog/*.cmx*
%endif
%endif
/usr/include/*
%{_datadir}/pkgconfig/xenlight.pc
%{_datadir}/pkgconfig/xlutil.pc
#%{_datadir}/pkgconfig/xenblktapctl.pc
%{_datadir}/pkgconfig/xencall.pc
%{_datadir}/pkgconfig/xencontrol.pc
%{_datadir}/pkgconfig/xendevicemodel.pc
%{_datadir}/pkgconfig/xenevtchn.pc
%{_datadir}/pkgconfig/xenforeignmemory.pc
%{_datadir}/pkgconfig/xengnttab.pc
%{_datadir}/pkgconfig/xenguest.pc
%{_datadir}/pkgconfig/xenstat.pc
%{_datadir}/pkgconfig/xenstore.pc
%{_datadir}/pkgconfig/xentoolcore.pc
%{_datadir}/pkgconfig/xentoollog.pc
%{_datadir}/pkgconfig/xenvchan.pc

%if %{?with_dom0_support}0

%files doc-html
%defattr(-,root,root)
%dir %{_defaultdocdir}/xen
%{_defaultdocdir}/xen/misc
%{_defaultdocdir}/xen/html

%post
if [ -x /sbin/update-bootloader ]; then
    /sbin/update-bootloader --refresh; exit 0
fi

%pre tools
%service_add_pre xencommons.service
%service_add_pre xendomains.service
%service_add_pre xen-watchdog.service
%service_add_pre xenstored.service
%service_add_pre xen-dom0-modules.service
%service_add_pre xenconsoled.service
%service_add_pre xen-init-dom0.service
%service_add_pre xen-qemu-dom0-disk-backend.service

%post tools
xen_tools_first_arg=$1
%{fillup_only -n xencommons xencommons}
%{fillup_only -n xendomains xendomains}
%service_add_post xencommons.service
%service_add_post xendomains.service
%service_add_post xen-watchdog.service
%service_add_post xenstored.service
%service_add_post xen-dom0-modules.service
%service_add_post xenconsoled.service
%service_add_post xen-init-dom0.service
%service_add_post xen-qemu-dom0-disk-backend.service

if [ -f /usr/bin/qemu-img ]; then
    if [ -f /usr/bin/qemu-img-xen ]; then
        rm /usr/bin/qemu-img-xen
    fi
    rm -f %{_libexecdir}/xen/bin/qemu-img-xen
    ln -s /usr/bin/qemu-img %{_libexecdir}/xen/bin/qemu-img-xen
fi
if [ -f /usr/bin/qemu-nbd ]; then
    if [ -f /usr/bin/qemu-nbd-xen ]; then
        rm /usr/bin/qemu-nbd-xen
    fi
    rm -f %{_libexecdir}/xen/bin/qemu-nbd-xen
    ln -s /usr/bin/qemu-nbd %{_libexecdir}/xen/bin/qemu-nbd-xen
fi
if [ -f /usr/bin/qemu-io ]; then
    rm -f %{_libexecdir}/xen/bin/qemu-io-xen
    ln -s /usr/bin/qemu-io %{_libexecdir}/xen/bin/qemu-io-xen
fi
if [ -f /etc/default/grub ] && ! (/usr/bin/grep GRUB_CMDLINE_XEN /etc/default/grub >/dev/null); then
    echo '# Xen boot parameters for all Xen boots' >> /etc/default/grub
    echo 'GRUB_CMDLINE_XEN=""' >> /etc/default/grub
    echo '# Xen boot parameters for non-recovery Xen boots (in addition to GRUB_CMDLINE_XEN)' >> /etc/default/grub
    echo 'GRUB_CMDLINE_XEN_DEFAULT=""' >> /etc/default/grub
fi
if [ -f /usr/lib/grub2/x86_64-xen/grub.xen -a ! -f /usr/lib/xen/boot/pvgrub64.bin ]; then
    ln -s /usr/lib/grub2/x86_64-xen/grub.xen /usr/lib/xen/boot/pvgrub64.bin
fi

%preun tools
%service_del_preun xencommons.service
%service_del_preun xendomains.service
%service_del_preun xen-watchdog.service
%service_del_preun xenstored.service
%service_del_preun xen-dom0-modules.service
%service_del_preun xenconsoled.service
%service_del_preun xen-init-dom0.service
%service_del_preun xen-qemu-dom0-disk-backend.service

%postun tools
export DISABLE_RESTART_ON_UPDATE=yes
%service_del_postun xencommons.service
%service_del_postun xendomains.service
%service_del_postun xen-watchdog.service
%service_del_postun xenstored.service
%service_del_postun xen-dom0-modules.service
%service_del_postun xenconsoled.service
%service_del_postun xen-init-dom0.service
%service_del_postun xen-qemu-dom0-disk-backend.service

%endif

%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by