File qemu-6.2.spec of Package qemu-6.2

#
# 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-6.2
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 44f28df24767cf9dca1ddc9b23157737c4cbb645
%define qemu_revision_short 44f28df247
%define qemu_date_unix 1639514101
%define qemu_date_commit 2021-12-14 12:35:01 -0800

%define seabios_revision_full 2dd4b9b3f84019668719344b40dba79d681be41c
%define seabios_revision_short 2dd4b9b3
%define seabios_date_unix 1638495800
%define seabios_date_commit 2021-12-02 20:43:20 -0500

%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 d21009b1c9f94b740ea66be8e48a1d8ad8124023
%define keycodemapdb_revision_short d21009b
%define keycodemapdb_date_unix 1624871780
%define keycodemapdb_date_commit 2021-06-28 09:16:20 +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 06dc822d045c2bb42e497487935485302486e151
%define ovmf_revision_short 06dc822d04
%define ovmf_date_unix 1599144491
%define ovmf_date_commit 2020-09-03 14:48:11 +0000

Patch1603198935: qemu.ec87b5daca761039bbcf781eedbe4987f790836f.patch
Patch1689400309: qemu.230dfd9257e92259876c113e58b5f0d22b056d2e.patch
Patch1626679059: qemu.GCRYPT_VERSION_NUMBER.patch
Patch1641636465: qemu.gnutls.patch
Patch1641636664: qemu.glib.patch
%if %suse_version > 1110
BuildRequires: python(abi) > 3.0
%endif
Patch1683105390: seabios.be7e899350caa7b74d8271a34264c3b4aef25ab0.patch
%define seabios_version 2dd4b9b3f84019668719344b40dba79d681be41c
Patch1484818598: ipxe.stable-build-id.patch
%define ipxe_version 7f75d320f6d8ac7ec5185b2145da87f698aec273
%define sgabios_version cbaee52287e5f32373181cff50a00b6c4ac9015a
%define keycodemapdb_version d21009b1c9f94b740ea66be8e48a1d8ad8124023
%define btestfloat3_version 5a59dcec19327396a011a17fd924aed4fec416b3
%define bsoftfloat3_version b64af41c3276f97f0e181920400ee056b9c88037
Patch1648123474: ovmf.7b005f344e533cd913c3ca05b266f9872df886d1.patch
Patch1648123475: ovmf.85021f8cf22d1bd4114803c6c610dea5ef0059f1.patch
Patch1617269159: ovmf.Disable-brotli.patch
%define ovmf_version 06dc822d045c2bb42e497487935485302486e151
%define openssl_version e2e09d9fba1187f8d6aafaa34d4172f56f1ffb72
%define meson_version 12f9f04ba0decfda425dbbf9a501084c153a2d18
BuildRoot:      %_tmppath/%name-%version-build
BuildRequires:  acpica
BuildRequires:  bash
BuildRequires:  fdupes
%if %suse_version < 1500
BuildRequires:  gcc8
BuildRequires:  gcc8-c++
%else
BuildRequires:  gcc-c++
%endif
BuildRequires:  gettext-tools
BuildRequires:  libaio-devel
BuildRequires:  libattr-devel
BuildRequires:  libfdt-devel
BuildRequires:  libgcrypt-devel
BuildRequires:  libnuma-devel
%if %{with librbd}
BuildRequires:  librbd-devel
%endif
BuildRequires:  ninja >= 1.8.2
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)
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)
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(libpulse)
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 1603198935 -p1
%patch -P 1689400309 -p1
%patch -P 1626679059 -p1
%patch -P 1641636465 -p1
%patch -P 1641636664 -p1
popd

rm -rf './roms/seabios'
mkdir -vp './roms'
mv -v '%_sourcedir/seabios-%seabios_version' './roms/seabios'
pushd './roms/seabios'
%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'

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'

rm -rf './meson'
mkdir -vp '.'
mv -v '%_sourcedir/meson-%meson_version' './meson'

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 gcc-7)"   && CC=$_
test -x "$(type -P gcc-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=$_
test -x "$(type -P g++-7)"   && CXX=$_
test -x "$(type -P g++-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="$(readlink -f $_)"
	break
done
tee .env.sh <<_EOF_
CC="`readlink -f $CC`"
CPP="`readlink -f $CC` -E"
CXX="`readlink -f $CXX`"
_EOF_
. ./.env.sh
find * -type f -exec grep -lZ '%_bindir/python$' '{}' + | sort -z | tr '\0' '\n' | while read
do
	i="${REPLY}"
	sed -i~ "
	s@%_bindir/python[.0-9]*@$PYTHON@
	" "$i"
	diff -u "$i"~ "$i" && exit 1
	touch --reference="$i"~ "$i"
	rm -fv "$i"~
done
find * -type f -exec grep -lZ '%_bindir/env python' '{}' + | sort -z | tr '\0' '\n' | while read
do
	i="${REPLY}"
	sed -i~ "
	s@%_bindir/env python[.0-9]*@$PYTHON@
	" "$i"
	diff -u "$i"~ "$i" && exit 1
	touch --reference="$i"~ "$i"
	rm -fv "$i"~
done
if \
env \
CPP="${CPP}" \
"CFLAGS=%optflags -I%_includedir/ncursesw" \
"CXXFLAGS=%optflags -I%_includedir/ncursesw" \
bash \
./configure \
	--prefix=%_libdir/%name \
	--localstatedir=%_localstatedir \
	\
	--cc="${CC}" \
	--host-cc="${CC}" \
	--cxx="${CXX}" \
	--target-list="${target_list}" \
	\
	--iasl="$(type -P iasl)" \
	--install="$(type -P install)" \
	--objcc="$(type -P false)" \
	--python="${PYTHON}" \
	--ninja='%_bindir/ninja' \
	--tls-priority=NORMAL \
	--with-git="$(type -P false)" \
	\
	\
	--disable-docs \
	--disable-gtk \
	--disable-libnfs \
	--disable-opengl \
	--disable-rbd \
	--disable-spice \
	--disable-virglrenderer \
	--disable-vte \
	\
	\
	--enable-alsa \
	--enable-attr \
	--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 \
	--enable-fdt \
	--enable-gettext \
	--enable-gcrypt \
	--with-git-submodules=ignore \
	--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 \
	--enable-jack \
	--disable-keyring \
	--enable-kvm \
	--disable-libdaxctl \
	--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-oss \
	--enable-pie \
	--enable-plugins \
	--disable-qom-cast-debug \
%if %{with librbd}
	--enable-rbd \
%endif
	--disable-rdma \
	--enable-replication \
	--enable-rng-none \
	--disable-safe-stack \
	--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 \
	--enable-tools \
	--enable-tpm \
	--disable-tsan \
	--disable-u2f \
	--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 \
	--disable-virtiofsd \
	--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
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
ls -ld '--time-style=full-iso' 'pc-bios' 'build/config-host.mak'
touch -r 'build/config-host.mak' 'pc-bios'

%install
. ./.env.sh
%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