%global gittag e2k-v1.2 %global e2k_target e2k-linux-user %global binfmt_dir %{_exec_prefix}/lib/binfmt.d Name: qemu-e2k Version: 1.2 Release: 1%{?dist} Summary: QEMU user-mode emulator for the Elbrus (e2k) architecture License: GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-2-Clause AND MIT URL: https://git.openelbrus.ru/mcst/qemu Source0: https://git.openelbrus.ru/mcst/qemu/-/archive/%{gittag}/qemu-%{gittag}.tar.bz2 BuildRequires: gcc BuildRequires: make BuildRequires: git BuildRequires: bison BuildRequires: flex BuildRequires: meson BuildRequires: ninja-build BuildRequires: pkgconfig BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip BuildRequires: python3-wheel BuildRequires: glib2-devel BuildRequires: pixman-devel BuildRequires: zlib-devel BuildRequires: libattr-devel BuildRequires: libcap-ng-devel BuildRequires: libseccomp-devel BuildRequires: glibc-static BuildRequires: glib2-static BuildRequires: zlib-static %description qemu-e2k is a linux-user-mode build of QEMU maintained by MCST (git.openelbrus.ru), providing emulation of Linux applications built for the Elbrus (e2k) instruction set, revisions elbrus-v2 through elbrus-v6 (elbrus-v7 support is incomplete upstream). %package -n qemu-user-e2k Summary: QEMU user mode emulation of Elbrus (e2k) %description -n qemu-user-e2k This package provides the user mode emulation of Elbrus (e2k). %package -n qemu-user-static-e2k Summary: Statically linked QEMU user-mode emulator for Elbrus (e2k) License: GPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-2-Clause AND MIT %description -n qemu-user-static-e2k This package provides a statically linked build of qemu-e2k, useful for copying into a chroot or container image without dragging in qemu-e2k's shared-library dependencies. %prep %autosetup -n qemu-%{gittag} %build run_configure() { ../configure \ --target-list=%{e2k_target} \ --prefix="%{_prefix}" \ --libdir="%{_libdir}" \ --datadir="%{_datadir}" \ --sysconfdir="%{_sysconfdir}" \ --interp-prefix=%{_prefix}/qemu-%%M \ --localstatedir="%{_localstatedir}" \ --docdir="%{_docdir}" \ --libexecdir="%{_libexecdir}" \ --extra-cflags="%{optflags}" \ --with-pkgversion="%{name}-%{version}-%{release}" \ --disable-docs \ "$@" \ || ( cat meson-logs/meson-log.txt 2>/dev/null; cat config.log 2>/dev/null; exit 1 ) } mkdir -p e2k_build pushd e2k_build run_configure %make_build popd mkdir -p e2k_static_build pushd e2k_static_build run_configure --static %make_build popd %install install -D -p -m 0755 e2k_build/qemu-e2k %{buildroot}%{_bindir}/qemu-e2k install -D -p -m 0755 e2k_static_build/qemu-e2k %{buildroot}%{_bindir}/qemu-e2k-static # binfmt_misc registration for the dynamic build: no F flag, since the # dynamic binary depends on the host's glibc/glib2 and cannot run inside # a chroot/container of another architecture that lacks them. This is # only useful for running e2k binaries directly on the host. mkdir -p %{buildroot}%{binfmt_dir} cat > %{buildroot}%{binfmt_dir}/qemu-e2k-dynamic.conf << 'EOF' :qemu-e2k-dynamic:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xaf\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-e2k:OC :qemu-e2k-old-dynamic:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x31\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-e2k:OC EOF # binfmt_misc registration for the static build: F flag, so the kernel # holds the interpreter's fd open at registration time — this is what # makes it usable inside chroots/containers of a foreign rootfs that # doesn't have the host's shared libraries (debootstrap, buildx, etc.). mkdir -p %{buildroot}%{binfmt_dir} cat > %{buildroot}%{binfmt_dir}/qemu-e2k-static.conf << 'EOF' :qemu-e2k-static:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xaf\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-e2k-static:OCF :qemu-e2k-old-static:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x31\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-e2k-static:OCF EOF %post -n qemu-user-e2k /bin/systemctl --system try-restart systemd-binfmt.service &>/dev/null || : %postun -n qemu-user-e2k /bin/systemctl --system try-restart systemd-binfmt.service &>/dev/null || : %post -n qemu-user-static-e2k /bin/systemctl --system try-restart systemd-binfmt.service &>/dev/null || : %postun -n qemu-user-static-e2k /bin/systemctl --system try-restart systemd-binfmt.service &>/dev/null || : %files -n qemu-user-e2k %license COPYING COPYING.LIB LICENSE %doc README.md %{_bindir}/qemu-e2k %{binfmt_dir}/qemu-e2k-dynamic.conf %files -n qemu-user-static-e2k %license COPYING COPYING.LIB LICENSE %{_bindir}/qemu-e2k-static %{binfmt_dir}/qemu-e2k-static.conf %changelog