File crun.spec of Package crun
%define realname crun
%define realver 1.21
%define srcext tar.gz
%define imgspecver 1.1.1
%define rtspecver 1.2.1
%define so_ver 0
%bcond_without bpf
%if 0%{?rhel} == 8
%define python3_pkg platform-python
%define python3 %{_libexecdir}/platform-python
%else
%define python3_pkg python3
%define python3 %{_bindir}/python3
%endif
# Common info
Name: %{realname}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: GPL-3.0+
Group: System/Management
URL: https://github.com/containers/crun
Summary: A fast and lightweight fully featured OCI runtime running containers
# Install-time parameters
%if 0%{?rhel}
Provides: oci-runtime
%endif
# Build-time parameters
BuildRequires: autoconf automake libtool
BuildRequires: pkg-config
BuildRequires: %{python3_pkg}
BuildRequires: pkgconfig(yajl) >= 2.0.0
BuildRequires: libcap-devel
BuildRequires: libseccomp-devel
BuildRequires: systemd-devel
BuildRequires: pkgconfig(criu) >= 3.15
BuildRequires: libprotobuf-c-devel
%if %{with bpf}
BuildRequires: libbpf-devel
%endif
# manpage
BuildRequires: go-md2man
BuildRoot: %{_tmppath}/%{name}-root
Source0: https://codeload.github.com/containers/crun/%{srcext}/refs/tags/%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}
Source1: https://codeload.github.com/containers/libocispec/%{srcext}/refs/heads/main#/libocispec-main.%{srcext}
Source2: https://codeload.github.com/opencontainers/image-spec/%{srcext}/refs/tags/v%{imgspecver}#/image-spec-%{imgspecver}.%{srcext}
Source3: https://codeload.github.com/opencontainers/runtime-spec/%{srcext}/refs/tags/v%{rtspecver}#/runtime-spec-%{rtspecver}.%{srcext}
%description
A fast and low-memory footprint OCI Container Runtime fully written in C.
crun conforms to the OCI Container Runtime specifications.
%package -n libcrun%{so_ver}
Group: System/Libraries
Summary: A fast and lightweight library for running containers
License: LGPL-3.0+
%description -n libcrun%{so_ver}
A fast and low-memory footprint OCI Container Runtime library.
%package devel
Group: Development/Libraries/C and C++
Summary: Development stuff for %{name}
License: LGPL-3.0+
Requires: libcrun%{so_ver} = %{version}-%{release}
Requires: pkgconfig(yajl) >= 2.1.0
Provides: libcrun%{so_ver}-devel = %{version}-%{release}
Provides: libcrun-devel = %{version}-%{release}
%description devel
crun is a fast and lightweight fully featured OCI runtime and C library for
running containers.
This package contains headers and libraries required to build software
using libcrun.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a1 -a2 -a3
%{__rm } -rf libocispec
%{__ln_s} libocispec-main libocispec
%{__mv} image-spec-%{imgspecver}/* libocispec/image-spec/
%{__mv} runtime-spec-%{rtspecver}/* libocispec/runtime-spec/
%{__sed} -ri '/SUBDIRS\s*=/ s/yajl//' libocispec/Makefile.am
test -x configure || autoreconf --install
# Build step (compile/build binaries, documentation, etc)
%build
_CFLAGS='%{optflags} -I%{_includedir}/libseccomp -I%(pwd -P)'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
printf "/* autogenerated. */\n#ifndef GIT_VERSION\n# define GIT_VERSION \"%s\"\n#endif\n" %{version} > git-version.h
(
cd libocispec-main
test -x configure || autoreconf --install
%configure \
--disable-embedded-yajl \
CFLAGS="$_CFLAGS" \
LDFLAGS="$_LDFLAGS" \
PYTHON="%{python3}"
)
%configure \
--enable-shared \
--disable-silent-rules \
--disable-embedded-yajl \
%if %{without bpf}
--disable-bpf \
%endif
CFLAGS="$_CFLAGS" \
LDFLAGS="$_LDFLAGS" \
PYTHON="%{python3}"
%{__make} %{?_smp_mflags}
# Install built stuff
%install
%{__make} install DESTDIR=%{buildroot}
HEADERS_TO_INSTALL=(
config.h
src/libcrun/container.h
src/libcrun/status.h
src/libcrun/utils.h
src/libcrun/error.h
)
%{__install} -d -m0755 %{buildroot}%{_includedir}/libcrun
for HEADER_TO_INSTALL in "${HEADERS_TO_INSTALL[@]}"; do
%{__install} -m0644 "$HEADER_TO_INSTALL" %{buildroot}%{_includedir}/libcrun/
done
# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
# Files list for the main package
%files
%defattr(-,root,root)
%license COPYING
%doc NEWS README.md SECURITY.md crun.1.md
%{_bindir}/crun
%{_mandir}/man1/crun.1*
%files -n libcrun%{so_ver}
%defattr(-,root,root)
%license COPYING.libcrun
%doc NEWS README.md SECURITY.md
%{_libdir}/libcrun.so.%{so_ver}*
%files devel
%defattr(-,root,root)
%license COPYING.libcrun
%doc NEWS README.md SECURITY.md
%{_includedir}/libcrun/
%{_libdir}/libcrun.so
%{_libdir}/libcrun.a
%exclude %{_libdir}/libcrun.la
%post -n libcrun%{so_ver} -p /sbin/ldconfig
%postun -n libcrun%{so_ver} -p /sbin/ldconfig
%changelog