1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

rpm: Introduce with_native

The new _without_native knob makes it possible to skip the native
build completely and build for MinGW only.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Andrea Bolognani 2023-11-02 16:56:54 +01:00
parent 3c840e50d9
commit eb6552d98b

View File

@ -203,6 +203,9 @@
%define qemu_moddir %{_libdir}/qemu %define qemu_moddir %{_libdir}/qemu
%define qemu_datadir %{_datadir}/qemu %define qemu_datadir %{_datadir}/qemu
# Native / MinGW builds
%define with_native 0%{!?_without_native:1}
%define with_mingw32 0 %define with_mingw32 0
%define with_mingw64 0 %define with_mingw64 0
@ -218,6 +221,13 @@
%define mingw_build_win64 %{with_mingw64} %define mingw_build_win64 %{with_mingw64}
%endif %endif
%if !%{with_native}
# Building the debugsource package apparently only works if the
# native build is enabled. debuginfo packages don't have this
# problem and setting this doesn't disable them
%global debug_package %{nil}
%endif
# RHEL releases provide stable tool chains and so it is safe to turn # RHEL releases provide stable tool chains and so it is safe to turn
# compiler warning into errors without being worried about frequent # compiler warning into errors without being worried about frequent
# changes in reported warnings # changes in reported warnings
@ -306,6 +316,7 @@ BuildRequires: systemd-rpm-macros
BuildRequires: rpcgen BuildRequires: rpcgen
# Fedora build root suckage # Fedora build root suckage
BuildRequires: gawk BuildRequires: gawk
%if %{with_native}
BuildRequires: gcc BuildRequires: gcc
%if %{with_libxl} %if %{with_libxl}
BuildRequires: xen-devel BuildRequires: xen-devel
@ -410,10 +421,11 @@ BuildRequires: wireshark-devel
BuildRequires: libssh-devel >= 0.8.1 BuildRequires: libssh-devel >= 0.8.1
%endif %endif
BuildRequires: libtirpc-devel BuildRequires: libtirpc-devel
# Needed for the firewalld_reload macro
%if %{with_firewalld_zone} %if %{with_firewalld_zone}
# Needed for the firewalld_reload macro
BuildRequires: firewalld-filesystem BuildRequires: firewalld-filesystem
%endif %endif
%endif
%if %{with_mingw32} %if %{with_mingw32}
BuildRequires: mingw32-filesystem BuildRequires: mingw32-filesystem
@ -451,6 +463,7 @@ Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). The main package includes of recent versions of Linux (and other OSes). The main package includes
the libvirtd server exporting the virtualization support. the libvirtd server exporting the virtualization support.
%if %{with_native}
%package docs %package docs
Summary: API reference and website documentation Summary: API reference and website documentation
@ -1075,6 +1088,7 @@ Requires: libvirt-daemon-driver-network = %{version}-%{release}
%description nss %description nss
Libvirt plugin for NSS for translating domain names into IP addresses. Libvirt plugin for NSS for translating domain names into IP addresses.
%endif
%if %{with_mingw32} %if %{with_mingw32}
%package -n mingw32-libvirt %package -n mingw32-libvirt
@ -1266,6 +1280,7 @@ exit 1
export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
%if %{with_native}
%meson \ %meson \
-Drunstatedir=%{_rundir} \ -Drunstatedir=%{_rundir} \
-Dinitconfdir=%{_sysconfdir}/sysconfig \ -Dinitconfdir=%{_sysconfdir}/sysconfig \
@ -1341,6 +1356,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
%{?arg_login_shell} %{?arg_login_shell}
%meson_build %meson_build
%endif
%if %{with_mingw32} || %{with_mingw64} %if %{with_mingw32} || %{with_mingw64}
%mingw_meson \ %mingw_meson \
@ -1425,6 +1441,7 @@ rm -fr %{buildroot}
export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
%if %{with_native}
%meson_install %meson_install
# We don't want to install /etc/libvirt/qemu/networks in the main %%files list # We don't want to install /etc/libvirt/qemu/networks in the main %%files list
@ -1487,6 +1504,7 @@ mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes.stp \
$RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes-64.stp $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes-64.stp
%endif %endif
%endif %endif
%endif
%if %{with_mingw32} || %{with_mingw64} %if %{with_mingw32} || %{with_mingw64}
%mingw_ninja_install %mingw_ninja_install
@ -1516,9 +1534,12 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
%endif %endif
%check %check
%if %{with_native}
# Building on slow archs, like emulated s390x in Fedora copr, requires # Building on slow archs, like emulated s390x in Fedora copr, requires
# raising the test timeout # raising the test timeout
VIR_TEST_DEBUG=1 %meson_test --no-suite syntax-check --timeout-multiplier 10 VIR_TEST_DEBUG=1 %meson_test --no-suite syntax-check --timeout-multiplier 10
%endif
%define libvirt_rpmstatedir %{_localstatedir}/lib/rpm-state/libvirt %define libvirt_rpmstatedir %{_localstatedir}/lib/rpm-state/libvirt
@ -1664,6 +1685,7 @@ VIR_TEST_DEBUG=1 %meson_test --no-suite syntax-check --timeout-multiplier 10
%define libvirt_systemd_config_pre() %libvirt_systemd_schedule_restart %1.service %define libvirt_systemd_config_pre() %libvirt_systemd_schedule_restart %1.service
%define libvirt_systemd_config_posttrans() %libvirt_systemd_perform_restart %1.service %define libvirt_systemd_config_posttrans() %libvirt_systemd_perform_restart %1.service
%if %{with_native}
%pre daemon %pre daemon
%libvirt_sysconfig_pre libvirtd %libvirt_sysconfig_pre libvirtd
%libvirt_systemd_inet_pre libvirtd %libvirt_systemd_inet_pre libvirtd
@ -1932,7 +1954,9 @@ done
getent group virtlogin >/dev/null || groupadd -r virtlogin getent group virtlogin >/dev/null || groupadd -r virtlogin
exit 0 exit 0
%endif %endif
%endif
%if %{with_native}
%files %files
%files docs %files docs
@ -2409,6 +2433,7 @@ exit 0
%{_datadir}/libvirt/api/libvirt-admin-api.xml %{_datadir}/libvirt/api/libvirt-admin-api.xml
%{_datadir}/libvirt/api/libvirt-qemu-api.xml %{_datadir}/libvirt/api/libvirt-qemu-api.xml
%{_datadir}/libvirt/api/libvirt-lxc-api.xml %{_datadir}/libvirt/api/libvirt-lxc-api.xml
%endif
%if %{with_mingw32} %if %{with_mingw32}
%files -n mingw32-libvirt -f mingw32-libvirt.lang %files -n mingw32-libvirt -f mingw32-libvirt.lang