File qemu-5.1.spec of Package qemu-5.1

#
# spec file for package qemu
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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/
#

%define _lto_cflags %nil
%global _buildshell /bin/bash
%bcond_without libnfs
%bcond_without librbd
%bcond_without qemu_gtk3_22
%bcond_without qemu_opengl
%bcond_without qemu_vte
%bcond_without spice
%bcond_without virglrenderer

Name:           qemu-5.1
Version:        0
Release:        0
Summary:        Upstream %name
ExclusiveArch:  x86_64
License:        BSD-3-Clause AND GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later AND MIT
Group:          System/Emulators/PC
Url:            https://www.qemu.org/
%define qemu_revision_full d0ed6a69d399ae193959225cdeaa9382746c91cc
%define qemu_revision_short d0ed6a69d3
%define qemu_date_unix 1597162023
%define qemu_date_commit 2020-08-11 17:07:03 +0100

%define seabios_revision_full d9c812dda519a1a73e8370e1b81ddf46eb22ed16
%define seabios_revision_short d9c812dd
%define seabios_date_unix 1595950578
%define seabios_date_commit 2020-07-28 11:36:18 -0400

%define ipxe_revision_full 7f75d320f6d8ac7ec5185b2145da87f698aec273
%define ipxe_revision_short 7f75d320
%define ipxe_date_unix 1725276297
%define ipxe_date_commit 2024-09-02 12:24:57 +0100

%define keycodemapdb_revision_full 6b3d716e2b6472eb7189d3220552280ef3d832ce
%define keycodemapdb_revision_short 6b3d716
%define keycodemapdb_date_unix 1515765463
%define keycodemapdb_date_commit 2018-01-12 13:57:43 +0000

%define btestfloat3_revision_full 5a59dcec19327396a011a17fd924aed4fec416b3
%define btestfloat3_revision_short 5a59dce
%define btestfloat3_date_unix 1547748698
%define btestfloat3_date_commit 2019-01-17 13:11:38 -0500

%define ovmf_revision_full 20d2e5a125e34fc8501026613a71549b2a1a3e54
%define ovmf_revision_short 20d2e5a125
%define ovmf_date_unix 1559796702
%define ovmf_date_commit 2019-06-06 12:51:42 +0800

Patch1607958578: qemu.bbd2d5a8120771ec59b86a80a1f51884e0a26e53.patch
Patch1689400309: qemu.230dfd9257e92259876c113e58b5f0d22b056d2e.patch
%if %suse_version > 1110
BuildRequires: python(abi) > 3.0
%endif
Patch1621549128: seabios.6eff8085980dba0938cea0193b8a0fd3c6b0c4ca.patch
Patch1683105390: seabios.be7e899350caa7b74d8271a34264c3b4aef25ab0.patch
%define seabios_version d9c812dda519a1a73e8370e1b81ddf46eb22ed16
Patch1484818598: ipxe.stable-build-id.patch
%define ipxe_version 7f75d320f6d8ac7ec5185b2145da87f698aec273
%define sgabios_version cbaee52287e5f32373181cff50a00b6c4ac9015a
Patch1519206414: keycodemapdb.16e5b0787687d8904dad2c026107409eb9bfcb95.patch
%define keycodemapdb_version 6b3d716e2b6472eb7189d3220552280ef3d832ce
%define btestfloat3_version 5a59dcec19327396a011a17fd924aed4fec416b3
%define bsoftfloat3_version b64af41c3276f97f0e181920400ee056b9c88037
Patch1648123474: ovmf.7b005f344e533cd913c3ca05b266f9872df886d1.patch
Patch1648123475: ovmf.85021f8cf22d1bd4114803c6c610dea5ef0059f1.patch
Patch1617269159: ovmf.Disable-brotli.patch
%define ovmf_version 20d2e5a125e34fc8501026613a71549b2a1a3e54
%define openssl_version 50eaac9f3337667259de725451f201e784599687
BuildRoot:      %_tmppath/%name-%version-build
BuildRequires:  acpica
BuildRequires:  bash
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libaio-devel
BuildRequires:  libattr-devel
BuildRequires:  libgcrypt-devel >= 1.5.0
BuildRequires:  libnuma-devel
%if %{with librbd}
BuildRequires:  librbd-devel
%endif
BuildRequires:  ovmf-tools
BuildRequires:  perl
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(bzip2)
%if %{with qemu_opengl}
BuildRequires:  pkgconfig(epoxy)
BuildRequires:  pkgconfig(gbm)
%endif
BuildRequires:  pkgconfig(glib-2.0) >= 2.48
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(gio-unix-2.0)
BuildRequires:  pkgconfig(gmodule-2.0)
BuildRequires:  pkgconfig(gmodule-export-2.0)
BuildRequires:  pkgconfig(gnutls) >= 3.1.18
BuildRequires:  pkgconfig(gthread-2.0)
%if %{with qemu_gtk3_22}
BuildRequires:  pkgconfig(gtk+-3.0) >= 3.22.0
BuildRequires:  pkgconfig(gtk+-x11-3.0)
%endif
BuildRequires:  pkgconfig(jack)
BuildRequires:  pkgconfig(libacl)
BuildRequires:  pkgconfig(libcap)
BuildRequires:  pkgconfig(libcap-ng)
BuildRequires:  pkgconfig(libcurl)
%if %{with libnfs}
BuildRequires:  pkgconfig(libnfs)
%endif
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libssh)
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  pkgconfig(libusbredirparser-0.5)
BuildRequires:  pkgconfig(liblzma)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(ncursesw)
BuildRequires:  pkgconfig(pixman-1)
BuildRequires:  python(abi) >= 3.5
%if %{with spice}
BuildRequires:  pkgconfig(spice-protocol)
BuildRequires:  pkgconfig(spice-server)
%endif
BuildRequires:  pkgconfig(vdeplug)
%if %{with virglrenderer}
BuildRequires:  pkgconfig(virglrenderer)
%endif
%if %{with qemu_vte}
BuildRequires:  pkgconfig(vte-2.91)
%endif
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xencontrol)
BuildRequires:  pkgconfig(xendevicemodel)
BuildRequires:  pkgconfig(xenevtchn)
BuildRequires:  pkgconfig(xenforeignmemory)
BuildRequires:  pkgconfig(xengnttab)
BuildRequires:  pkgconfig(xenguest)
BuildRequires:  pkgconfig(xenstore)
BuildRequires:  pkgconfig(xentoolcore)
BuildRequires:  pkgconfig(xkbcommon)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  xfsprogs-devel

%description

%prep
rm -rf %_builddir/%name-%version
mv %_sourcedir/%name-%version %_builddir/%name-%version
%setup -c -T -D
pushd '.'
%patch -P 1607958578 -p1
%patch -P 1689400309 -p1
popd

rm -rf './roms/seabios'
mkdir -vp './roms'
mv -v '%_sourcedir/seabios-%seabios_version' './roms/seabios'
pushd './roms/seabios'
%patch -P 1621549128 -p1
%patch -P 1683105390 -p1
popd

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

rm -rf './roms/sgabios'
mkdir -vp './roms'
mv -v '%_sourcedir/sgabios-%sgabios_version' './roms/sgabios'

rm -rf './ui/keycodemapdb'
mkdir -vp './ui'
mv -v '%_sourcedir/keycodemapdb-%keycodemapdb_version' './ui/keycodemapdb'
pushd './ui/keycodemapdb'
%patch -P 1519206414 -p1
popd

rm -rf './tests/fp/berkeley-testfloat-3'
mkdir -vp './tests/fp'
mv -v '%_sourcedir/btestfloat3-%btestfloat3_version' './tests/fp/berkeley-testfloat-3'

rm -rf './tests/fp/berkeley-softfloat-3'
mkdir -vp './tests/fp'
mv -v '%_sourcedir/bsoftfloat3-%bsoftfloat3_version' './tests/fp/berkeley-softfloat-3'

rm -rf './roms/edk2'
mkdir -vp './roms'
mv -v '%_sourcedir/ovmf-%ovmf_version' './roms/edk2'
pushd './roms/edk2'
%patch -P 1648123474 -p1
%patch -P 1648123475 -p1
%patch -P 1617269159 -p1
popd

rm -rf './roms/edk2/CryptoPkg/Library/OpensslLib/openssl'
mkdir -vp './roms/edk2/CryptoPkg/Library/OpensslLib'
mv -v '%_sourcedir/openssl-%openssl_version' './roms/edk2/CryptoPkg/Library/OpensslLib/openssl'

if pushd subprojects/packagefiles 2>/dev/null
then
  for prj in *
  do
    if pushd "${prj}" > /dev/null
    then
      for f in *
      do
        test -f "${f}" || continue
        ln -vt "../../${prj}/" *
        break
      done
      popd > /dev/null
    fi
  done
  popd > /dev/null
fi

%build
echo "%{seabios_revision_full}" > roms/seabios/.version
test -x "$(type -P gcc)"     && CC=$_
test -x "$(type -P gcc-4.6)" && CC=$_
test -x "$(type -P gcc-4.7)" && CC=$_
test -x "$(type -P gcc-4.8)" && CC=$_
test -x "$(type -P g++)"     && CXX=$_
test -x "$(type -P g++-4.6)" && CXX=$_
test -x "$(type -P g++-4.7)" && CXX=$_
test -x "$(type -P g++-4.8)" && CXX=$_
#
%ifarch %ix86 x86_64
target_list="
i386-softmmu
x86_64-softmmu
"
%endif
target_list="`echo ${target_list}| xargs`"
test -n "${target_list}"
PYTHON="$(type -P false)"
for i in \
	python3.7 \
	python3.6 \
	python3.5 \
	python3
do
	test -x "$(type -P $i)" || continue
	PYTHON="$_"
	break
done
tee .env.sh <<_EOF_
CC="`readlink -f $CC`"
CPP="`readlink -f $CC` -E"
CXX="`readlink -f $CXX`"
_EOF_
. ./.env.sh

if \
env \
CPP="${CPP}" \
bash \
./configure \
	--prefix=%_libdir/%name \
	--localstatedir=%_localstatedir \
	\
	--cc="${CC}" \
	--host-cc="${CC}" \
	--cxx="${CXX}" \
	--extra-cflags="%optflags" \
	--extra-cxxflags="%optflags" \
	--target-list="${target_list}" \
	--audio-drv-list=alsa \
	\
	--iasl="$(type -P iasl)" \
	--install="$(type -P install)" \
	--objcc="$(type -P false)" \
	--python="${PYTHON}" \
	--tls-priority=NORMAL \
	--with-git="$(type -P false)" \
	\
	\
	--disable-gtk \
	--disable-libnfs \
	--disable-opengl \
	--disable-rbd \
	--disable-spice \
	--disable-virglrenderer \
	--disable-vte \
	\
	\
	--enable-attr \
	--disable-auth-pam \
	--disable-brlapi \
	--disable-bsd-user \
	--enable-bzip2 \
	--enable-cap-ng \
	--disable-capstone \
	--disable-cocoa \
	--enable-coroutine-pool \
	--disable-crypto-afalg \
	--enable-curl \
	--enable-curses \
	--disable-debug-info \
	--disable-debug-mutex \
	--disable-debug-tcg \
	--with-default-devices \
	--disable-docs \
	--disable-fdt \
	--enable-gcrypt \
	--disable-git-update \
	--disable-glusterfs \
	--enable-gnutls \
%if %{with qemu_gtk3_22}
	--enable-gtk \
%endif
	--disable-guest-agent \
	--disable-guest-agent-msi \
	--disable-hax \
	--disable-hvf \
	--enable-iconv \
	--disable-jemalloc \
	--enable-kvm \
	--disable-libiscsi \
%if %{with libnfs}
	--enable-libnfs \
%endif
	--enable-libssh \
	--enable-libusb \
	--enable-libxml2 \
	--enable-linux-aio \
	--disable-linux-user \
	--enable-live-block-migration \
	--disable-lzo \
	--disable-lzfse \
	--disable-malloc-trim \
	--disable-membarrier \
	--enable-modules \
	--disable-mpath \
	--disable-netmap \
	--disable-nettle \
	--enable-numa \
%if %{with qemu_opengl}
	--enable-opengl \
%endif
	--enable-pie \
	--enable-plugins \
	--disable-qom-cast-debug \
	--enable-rng-none \
%if %{with librbd}
	--enable-rbd \
%endif
	--disable-rdma \
	--enable-replication \
	--disable-sanitizers \
	--disable-sdl \
	--disable-sdl-image \
	--disable-seccomp \
	--disable-slirp \
	--disable-smartcard \
	--disable-snappy \
	--disable-sparse \
%if %{with spice}
	--enable-spice \
%endif
	--enable-stack-protector \
	--disable-strip \
	--enable-system \
	--enable-tcg \
	--disable-tcg-interpreter \
	--disable-tcmalloc \
	--enable-tools \
	--disable-tpm \
	--enable-usb-redir \
	--disable-user \
	--enable-vde \
	--enable-vhost-crypto \
	--enable-vhost-net \
	--enable-vhost-scsi \
	--enable-vhost-user \
	--enable-vhost-user-fs \
	--enable-vhost-vsock \
%if %{with virglrenderer}
	--enable-virglrenderer \
%endif
	--enable-virtfs \
	--enable-vnc \
	--disable-vnc-jpeg \
	--enable-vnc-png \
	--disable-vnc-sasl \
%if %{with qemu_vte}
	--enable-vte \
%endif
	--disable-werror \
	--disable-whpx \
	--enable-xen \
	--enable-xen-pci-passthrough \
	--enable-xfsctl \
	%nil
then
	: success
else
	cat config.log
	exit 1
fi

V=V=1
make %{?_smp_mflags} ${V}

%ifarch x86_64
pushd pc-bios/optionrom
	cp --remove-destination -avt .. \
	kvmvapic.bin \
	linuxboot_dma.bin \
	linuxboot.bin \
	multiboot.bin \
	%nil
popd
nopie='-fno-pie'
make -C roms ${V} "CC=${CC}" "CPP=${CPP}" sgabios \
	'BUILD_DATE=\"date\"' \
	'BUILD_SHORT_DATE=\"short_date\"' \
	'BUILD_HOST=\"host\"' \
	'BUILD_USER=\"user\"' \
	%nil
make -C roms ${V} "CC=${CC}" "CPP=${CPP}" bios seavgabios pxerom efirom \
	%{?_smp_mflags} \
	"EDK2_BASETOOLS_OPTFLAGS=${nopie}" \
	"EDK2_BASETOOLS_LDFLAGS=${nopie}" \
	"EDK2_PYTHON_COMMAND=${PYTHON}" \
	"BUILD_CC=${CC}" \
	"BUILD_CXX=${CXX}" \
	"HOST_CC=${CC}" \
	'SEABIOS_EXTRAVERSION=-%_project/%name' \
	"PYTHON=${PYTHON}" \
	%nil
%endif

%install
. ./.env.sh
touch -r config-host.mak pc-bios
%make_install
find %buildroot -ls
find %buildroot -name "*.la" -print -delete
pushd %buildroot%_libdir/%name
rm -rfv \
	share/applications \
	share/icons \
	share/locale \
	%nil

	pushd share/qemu
		non_x86=(
		QEMU,cgthree.bin
		QEMU,tcx.bin
		bamboo.dtb
		canyonlands.dtb
		hppa-firmware.img
		npcm7xx_bootrom.bin
		openbios-ppc
		openbios-sparc32
		openbios-sparc64
		opensbi-riscv32-*.bin
		opensbi-riscv64-*.bin
		palcode-clipper
		petalogix-ml605.dtb
		petalogix-s3adsp1800.dtb
		qemu-nsis.bmp
		qemu_vga.ndrv
		s390-ccw.img
		s390-netboot.img
		skiboot.lid
		slof.bin
		u-boot-sam460-20100605.bin
		u-boot.e500
		vof*.bin
		edk2-licenses.txt
		*aarch64*.fd
		*arm*.fd
		firmware/*aarch64*.json
		firmware/*arm*.json
		)
		rm -fv "${non_x86[@]}"
	popd
popd
%fdupes %buildroot

%files
%_libdir/%name

%changelog
openSUSE Build Service is sponsored by