File criu.spec of Package criu

%define realname criu
%define realver  4.1
%define srcext   tar.gz

%define so_ver   2

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       %{?extraver:0.}1%{?dist}
License:       GPL-2.0
Group:         Productivity/Other
URL:           http://criu.org/
Summary:       Checkpoint and Restore in Userspace

# Install-time parameters
Requires:      python3%{?suse_version:-base}

# Build-time parameters
BuildRequires: pkg-config
BuildRequires: python3%{?suse_version:-base} python3-pip python3-setuptools python3-wheel
BuildRequires: python3-protobuf
# See Makefile.config
BuildRequires: libbsd-devel
BuildRequires: pkgconfig(libselinux)
BuildRequires: pkgconfig(libbpf)
BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(gnutls)
BuildRequires: pkgconfig(libnftables)
BuildRequires: libprotobuf-c-devel protobuf-devel
BuildRequires: libnet-devel
BuildRequires: libnl3-devel
BuildRequires: libcap-devel
BuildRequires: libuuid-devel
# Tests
BuildRequires: libaio-devel
BuildRequires: python3-PyYAML
# Documentation
BuildRequires: asciidoc xmlto libxml2%{?suse_version:-tools}
%if 0%{?suse_version}
BuildRequires: docbook-xsl-stylesheets docbook_4
%else
BuildRequires: docbook-style-xsl
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       https://codeload.github.com/checkpoint-restore/criu/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
An utility to checkpoint/restore tasks. Using this tool, you can freeze a
running application (or part of it) and checkpoint it to a hard drive as a
collection of files. You can then use the files to restore and run the
application from the point it was frozen at. The distinctive feature of the CRIU
project is that it is mainly implemented in user space.

%package -n lib%{name}%{?so_ver}
License:       LGPL-2.1
Group:         System/Libraries
Summary:       Shared library for %{name}
Provides:      lib%{name}
Provides:      libcompel

%description -n lib%{name}%{?so_ver}
Shared library for %{name}

%package devel
License:       LGPL-2.1
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      lib%{name}%{?so_ver} = %{version}
Provides:      lib%{name}-devel

%description devel
Development files for %{name}

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
# Disable package checking
cat > criu/Makefile.packages <<EOF
check-packages:
	/bin/true

.PHONY:check-packages
EOF

%build
_CFLAGS='%{optflags} -DCONFIG_HAS_TCP_REPAIR_WINDOW -DCONFIG_HAS_TCP_REPAIR -DCONFIG_HAS_MEMFD_CREATE'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
%{__make} %{?_smp_mflags} V=1 \
 PREFIX=%{_prefix} \
 BINDIR=%{_bindir} \
 SBINDIR=%{_sbindir} \
 MANDIR=%{_mandir} \
 INCLUDEDIR=%{_includedir} \
 LIBEXECDIR=%{_libexecdir} \
 LIBDIR=%{_libdir} \
 PLUGINDIR=%{_libdir}/%{name} \
 RUNDIR=%{!?_rundir:/var/run} \
 SYSTEMDUNITDIR=%{_unitdir} \
 LOGROTATEDIR=%{_sysconfdir}/logrotate.d/ \
 \
 PYTHON=python3 \
 PIPFLAGS=--no-build-isolation \
 USERCFLAGS="$_CFLAGS" \
 LIBS_FEATURES="$_LDFLAGS -lprotobuf-c -lnet -lgnutls -lnl-3 -luuid -lbsd -lnftables -lbpf -lselinux" \
 WERROR=0

%install
%{__make} install DESTDIR=%{buildroot} V=1 \
 PREFIX=%{_prefix} \
 BINDIR=%{_bindir} \
 SBINDIR=%{_sbindir} \
 MANDIR=%{_mandir} \
 INCLUDEDIR=%{_includedir} \
 LIBEXECDIR=%{_libexecdir} \
 LIBDIR=%{_libdir} \
 PLUGINDIR=%{_libdir}/%{name} \
 RUNDIR=%{!?_rundir:/var/run} \
 SYSTEMDUNITDIR=%{_unitdir} \
 LOGROTATEDIR=%{_sysconfdir}/logrotate.d/ \
 \
 PYTHON=python3 \
 PIPFLAGS=--no-build-isolation
# Remove execute permission
%{__chmod} a-x %{buildroot}%{_libdir}/libcriu.a

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%license COPYING
%doc CREDITS README.md
%{_bindir}/crit
%{_bindir}/compel
%{_sbindir}/criu
%{_sbindir}/criu-ns
%dir %{_libexecdir}/compel/scripts
%dir %{_libexecdir}/compel
%dir %{_libexecdir}/criu/scripts
%dir %{_libexecdir}/criu
%{_libexecdir}/compel/scripts/compel-pack.lds.S
%{_libexecdir}/compel/*.lib.a
%{_libexecdir}/criu/scripts/systemd-autofs-restart.sh
%{python3_sitelib}/*
%doc %{_mandir}/man1/*
%doc %{_mandir}/man8/*

%files -n lib%{name}%{?so_ver}
%defattr(-,root,root)
%{_libdir}/lib%{name}.so.*
%{_libdir}/libcompel.so.*
%{_libdir}/%{name}/

# Development stuff
%files devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/compel/
%{_includedir}/criu/
%{_libdir}/lib%{name}.so
%{_libdir}/lib%{name}.a
%{_libdir}/libcompel.so
%{_libdir}/libcompel.a

%post   -n lib%{name}%{?so_ver} -p /sbin/ldconfig
%postun -n lib%{name}%{?so_ver} -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by