libkcapi/libkcapi.spec

515 lines
16 KiB
RPMSpec
Raw Normal View History

2018-01-16 17:47:27 +00:00
# Shared object version of libkcapi.
%global vmajor 1
%global vminor 0
%global vpatch 3
# Do we build the replacements packages?
%bcond_with replace_coreutils
%bcond_with replace_fipscheck
%bcond_with replace_hmaccalc
%if %{with replace_coreutils} || %{with replace_fipscheck} || %{with replace_hmaccalc}
%global need_hasher 1
%else
%global need_hasher 0
%endif
2018-01-16 17:47:27 +00:00
# This package needs at least Linux Kernel v4.10.0.
%global min_kernel_ver 4.10.0
# Do we need to tweak sysctl.d? In newer versions of the Linux
# Kernel the default ancillary buffer size is set high enough.
# TODO: Adapt this when the patch for net/core/sock.c is merged.
%if %{lua:print(rpm.vercmp('99.0.0', posix.uname('%r')));} >= 0
%global with_sysctl_tweak 1
%else
%global with_sysctl_tweak 0
%endif
%if %{with_sysctl_tweak}
2018-01-16 17:47:27 +00:00
# Priority for the sysctl.d preset.
%global sysctl_prio 50
# Value used for the sysctl.d preset.
2018-02-26 09:22:36 +00:00
%global sysctl_optmem_max 81920
# Extension for the README.distro file.
%global distroname_ext %{?fedora:fedora}%{?rhel:redhat}
%endif
2018-01-16 17:47:27 +00:00
# Lowest limit to run the testsuite. If we cannot obtain this
# value, we asume the testsuite cannot be run.
%global test_optmem_max %(%{__cat} /proc/sys/net/core/optmem_max || echo 0)
# For picking patches from upstream commits or pull requests.
%global giturl https://github.com/smuellerDD/%{name}
# Do we replace some coreutils?
%if %{with replace_coreutils}
# TODO: Adapt this when replacing some coreutils initially.
%global coreutils_evr 8.29-1%{?dist}
2018-01-16 17:47:27 +00:00
%endif
# Do we replace fipscheck?
%if %{with replace_fipscheck}
# TODO: Adapt this when replacing fipscheck initially.
%global fipscheck_evr 1.5.0-3%{?dist}
2018-01-16 17:47:27 +00:00
%endif
# Do we replace hmaccalc?
%if %{with replace_hmaccalc}
# TODO: Adapt this when replacing hmaccalc initially.
%global hmaccalc_evr 0.9.14-10%{?dist}
2018-01-16 17:47:27 +00:00
%endif
# Add generation of HMAC checksums of the final stripped
# binaries. %%define with lazy globbing is used here
# intentionally, because using %%global does not work.
%define __spec_install_post \
%{?__debug_package:%{__debug_install_post}} \
%{__arch_install_post} \
%{__os_install_post} \
%{_bindir}/fipshmac %{buildroot}%{_bindir}/* \
%{_sbindir}/hardlink -cfv %{buildroot}%{_bindir} \
%{_bindir}/fipshmac %{buildroot}/%{_lib}/libkcapi.so.%{version} \
%{__ln_s} .libkcapi.so.%{version}.hmac \\\
%{buildroot}/%{_lib}/.libkcapi.so.%{vmajor}.hmac \
%{nil}
Name: libkcapi
Version: %{vmajor}.%{vminor}.%{vpatch}
Release: 10%{?dist}
2018-01-16 17:47:27 +00:00
Summary: User space interface to the Linux Kernel Crypto API
License: BSD or GPLv2
URL: http://www.chronox.de/%{name}.html
Source0: http://www.chronox.de/%{name}/%{name}-%{version}.tar.xz
Source1: http://www.chronox.de/%{name}/%{name}-%{version}.tar.xz.asc
Patch0: %{giturl}/compare/v1.0.3...master.patch#/%{name}-1.0.3-to_master.patch
Patch1: %{giturl}/pull/48.patch#/%{name}-1.0.3-Makefile_Do_not_clobber_pkgconfig-dir_from_configure.patch
2018-01-16 17:47:27 +00:00
BuildRequires: clang
BuildRequires: coreutils
BuildRequires: cppcheck
BuildRequires: docbook-utils-pdf
BuildRequires: fipscheck
BuildRequires: gcc
BuildRequires: git
2018-01-16 17:47:27 +00:00
BuildRequires: hardlink
BuildRequires: hmaccalc
BuildRequires: libtool
BuildRequires: openssl
BuildRequires: systemd
BuildRequires: xmlto
# To make sure this is not buildable nor installable if the
# available Linux Kernel does not support the Linux Kernel
# Crypto API User Space Interface.
BuildRequires: kernel-headers >= %{min_kernel_ver}
Requires: kernel >= %{min_kernel_ver}
2018-01-16 17:47:27 +00:00
# For ownership of %%{_sysctldir}.
Requires: systemd
Obsoletes: %{name}-replacements <= %{version}-%{release}
2018-01-16 17:47:27 +00:00
%description
libkcapi allows user-space to access the Linux kernel crypto API.
This library uses the netlink interface and exports easy to use APIs
so that a developer does not need to consider the low-level netlink
interface handling.
The library does not implement any cipher algorithms. All consumer
requests are sent to the kernel for processing. Results from the
kernel crypto API are returned to the consumer via the library API.
The kernel interface and therefore this library can be used by
unprivileged processes.
%package devel
Summary: Development files for the %{name} package
Requires: %{name}%{?_isa} == %{version}-%{release}
%description devel
Header files for applications that use %{name}.
%package doc
Summary: User documentation for the %{name} package
BuildArch: noarch
%description doc
User documentation for %{name}.
%if %{need_hasher}
%package hasher
Summary: Common utility for replacement packages
2018-01-16 17:47:27 +00:00
Requires: %{name}%{?_isa} == %{version}-%{release}
%description hasher
Provides a common binary used by the drop-in %{name} replacements for hashing/HMAC tools.
%endif
2018-01-16 17:47:27 +00:00
%if %{with replace_coreutils}
%package checksum
Summary: Drop-in replacement for *sum utils provided by the %{name} package
Requires: %{name}-hasher%{?_isa} == %{version}-%{release}
Requires: coreutils%{?_isa} >= %{coreutils_evr}
2018-01-16 17:47:27 +00:00
Conflicts: coreutils < %{coreutils_evr}
Conflicts: coreutils-single
%description checksum
Provides drop-in replacements for sha*sum tools (from package coreutils) using %{name}.
2018-01-16 17:47:27 +00:00
%endif
2018-01-16 17:47:27 +00:00
%if %{with replace_fipscheck}
%package fipscheck
Summary: Drop-in replacements for fipscheck/fipshmac provided by the %{name} package
Requires: %{name}-hasher%{?_isa} == %{version}-%{release}
2018-01-16 17:47:27 +00:00
Obsoletes: fipscheck <= %{fipscheck_evr}
Provides: fipscheck == %{fipscheck_evr}.1
Provides: fipscheck%{?_isa} == %{fipscheck_evr}.1
%description fipscheck
Provides drop-in replacements for fipscheck and fipshmac tools (from package fipscheck)
using %{name}.
2018-01-16 17:47:27 +00:00
%endif
2018-01-16 17:47:27 +00:00
%if %{with replace_hmaccalc}
%package hmaccalc
Summary: Drop-in replacements for hmaccalc provided by the %{name} package
Requires: %{name}-hasher%{?_isa} == %{version}-%{release}
2018-01-16 17:47:27 +00:00
Obsoletes: hmaccalc <= %{hmaccalc_evr}
Provides: hmaccalc == %{hmaccalc_evr}.1
Provides: hmaccalc%{?_isa} == %{hmaccalc_evr}.1
%description hmaccalc
Provides drop-in replacements for sha*hmac tools (from package hmaccalc) using %{name}.
2018-01-16 17:47:27 +00:00
%endif
%package static
Summary: Static library for -static linking with %{name}
Requires: %{name}-devel%{?_isa} == %{version}-%{release}
%description static
This package contains the %{name} static libraries for -static
linking. You don't need this, unless you link statically, which
is highly discouraged.
%package tools
Summary: Utility applications for the %{name} package
Requires: %{name}%{?_isa} == %{version}-%{release}
%description tools
Utility applications that are provided with %{name}. This includes
tools to use message digests, symmetric ciphers and random number
generators implemented in the Linux kernel from command line.
%prep
%autosetup -p 1 -S git
2018-01-16 17:47:27 +00:00
%if %{with_sysctl_tweak}
%{__cat} << EOF > README.%{distroname_ext}
2018-01-16 17:47:27 +00:00
This package increases the default limit of the ancillary buffer size
per kernel socket defined in \`net.core.optmem_max\` to %{sysctl_optmem_max} bytes.
For this preset to become active it requires a reboot after the
installation of this package. You can also manually increase this
limit by invocing \`sysctl net.core.optmem_max=%{sysctl_optmem_max}\` as the
super-user, e.g. using \`su\` or \`sudo\` on the terminal.
This is done to provide consumers of the new Linux Kernel Crypto API
User Space Interface a well sufficient and reasonable maximum limit
by default, especially when using AIO with a larger amount of IOVECs.
For further information about the AF_ALG kernel socket and AIO, see
the discussion at the kernel-crypto mailing-list:
https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg30417.html
See the instructions given in '%{_sysctldir}/50-default.conf',
if you need or want to override the preset made by this package.
EOF
%{__cat} << EOF > %{sysctl_prio}-%{name}-optmem_max.conf
# See the 'README.%{distroname_ext}' file shipped in %%doc
2018-01-16 17:47:27 +00:00
# with the %{name} package.
#
# See '%{_sysctldir}/50-default.conf',
# if you need or want to override this preset.
# Increase the ancillary buffer size per socket.
net.core.optmem_max = %{sysctl_optmem_max}
EOF
%endif
2018-01-16 17:47:27 +00:00
%ifarch %{power64}
%{__sed} -i -e 's!exit \$failures!#&!' test/kcapi-enc-test.sh
%endif
2018-01-16 17:47:27 +00:00
%{_bindir}/autoreconf -fiv
%build
%configure \
--libdir=/%{_lib} \
--disable-silent-rules \
--enable-kcapi-encapp \
--enable-kcapi-dgstapp \
--enable-kcapi-hasher \
--enable-kcapi-rngapp \
--enable-kcapi-speed \
--enable-kcapi-test \
--enable-shared \
--enable-static \
--with-pkgconfigdir=%{_libdir}/pkgconfig
%make_build all doc
%install
%make_install
# Install sysctl.d preset.
%{__mkdir_p} %{buildroot}%{_sysctldir}
2018-01-16 17:47:27 +00:00
%{__install} -Dpm 0644 -t %{buildroot}%{_sysctldir} \
%{sysctl_prio}-%{name}-optmem_max.conf
# Install into proper location for inclusion by %%doc.
%{__mkdir_p} %{buildroot}%{_pkgdocdir}
2018-01-16 17:47:27 +00:00
%{__install} -Dpm 0644 -t %{buildroot}%{_pkgdocdir} \
%if %{with_sysctl_tweak}
README.%{distroname_ext} \
%endif
README.md CHANGES TODO doc/%{name}.p{df,s}
2018-01-16 17:47:27 +00:00
%{__cp} -pr lib/doc/html %{buildroot}%{_pkgdocdir}
2018-03-31 10:35:32 +00:00
# Install replacement tools, if enabled.
%if !%{need_hasher}
%{__rm} -f %{buildroot}%{_bindir}/kcapi-hasher
%endif
%if !%{with replace_coreutils}
2018-01-16 17:47:27 +00:00
%{__rm} -f \
%{buildroot}%{_bindir}/md5sum \
%{buildroot}%{_bindir}/sha*sum
%endif
%if !%{with replace_fipscheck}
%{__rm} -f %{buildroot}%{_bindir}/fips*
%endif
%if !%{with replace_hmaccalc}
%{__rm} -f %{buildroot}%{_bindir}/sha*hmac
%endif
2018-01-16 17:47:27 +00:00
# We don't ship autocrap dumplings.
%{_bindir}/find %{buildroot} -type f -name '*.la' -print -delete
# HMAC checksums are generated during __spec_install_post.
%{_bindir}/find %{buildroot} -type f -name '*.hmac' -print -delete
# Remove 0-size files.
%{_bindir}/find %{buildroot} -type f -size 0 -print -delete
# Make sure all docs have non-exec permissions, except for the dirs.
%{_bindir}/find %{buildroot}%{_pkgdocdir} -type f -print | \
%{_bindir}/xargs %{__chmod} -c 0644
%{_bindir}/find %{buildroot}%{_pkgdocdir} -type d -print | \
%{_bindir}/xargs %{__chmod} -c 0755
# Possibly save some space by hardlinking.
for d in %{_mandir} %{_pkgdocdir}; do
%{_sbindir}/hardlink -cfv %{buildroot}$d
done
%check
# Some basic sanity checks.
for t in cppcheck scan; do
%make_build $t
done
# On some arches `/proc/sys/net/core/optmem_max` is lower than 20480,
# which is the lowest limit needed to run the testsuite. If that limit
# is not met, we do not run it.
%if %{test_optmem_max} >= 20480
# Real testsuite.
pushd test
ENABLE_FUZZ_TEST=1 \
NO_32BIT_TEST=1 \
./test-invocation.sh
popd
%endif
2018-02-04 12:43:23 +00:00
%ldconfig_scriptlets
2018-01-16 17:47:27 +00:00
%files
%doc %dir %{_pkgdocdir}
%doc %{_pkgdocdir}/README.md
%license COPYING*
/%{_lib}/%{name}.so.%{vmajor}
/%{_lib}/%{name}.so.%{version}
/%{_lib}/.%{name}.so.%{vmajor}.hmac
/%{_lib}/.%{name}.so.%{version}.hmac
%if %{with_sysctl_tweak}
%doc %{_pkgdocdir}/README.%{distroname_ext}
2018-01-16 17:47:27 +00:00
%{_sysctldir}/%{sysctl_prio}-%{name}-optmem_max.conf
%endif
2018-01-16 17:47:27 +00:00
%files devel
%doc %{_pkgdocdir}/CHANGES
%doc %{_pkgdocdir}/TODO
%{_includedir}/kcapi.h
%{_mandir}/man3/kcapi_*.3.*
/%{_lib}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%files doc
%doc %{_pkgdocdir}
%license %{_datadir}/licenses/%{name}*
%if %{need_hasher}
%files hasher
2018-01-16 17:47:27 +00:00
%{_bindir}/kcapi-hasher
%{_bindir}/.kcapi-hasher.hmac
%endif
2018-01-16 17:47:27 +00:00
%if %{with replace_coreutils}
%files checksum
2018-01-16 17:47:27 +00:00
%{_bindir}/md5sum
%{_bindir}/.md5sum.hmac
%{_bindir}/sha*sum
%{_bindir}/.sha*sum.hmac
%endif
2018-01-16 17:47:27 +00:00
%if %{with replace_fipscheck}
%files fipscheck
2018-01-16 17:47:27 +00:00
%{_bindir}/fips*
%{_bindir}/.fips*.hmac
%endif
2018-01-16 17:47:27 +00:00
%if %{with replace_hmaccalc}
%files hmaccalc
2018-01-16 17:47:27 +00:00
%{_bindir}/sha*hmac
%{_bindir}/.sha*hmac.hmac
%endif
%files static
/%{_lib}/%{name}.a
%files tools
%if %{need_hasher}
2018-01-16 17:47:27 +00:00
%exclude %{_bindir}/kcapi-hasher
%exclude %{_bindir}/.kcapi-hasher.hmac
%endif
%{_bindir}/kcapi*
%{_bindir}/.kcapi*.hmac
%{_mandir}/man1/kcapi*.1.*
%changelog
* Sat Mar 31 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-10
- Replace single patches with a monolitic one from upstream
2018-04-01 12:27:52 +00:00
- Obsolete replacements subpackage
- Ignore failing tests on %%{power64} temporarily
* Thu Mar 08 2018 Ondrej Mosnáček <omosnace@redhat.com> - 1.0.3-9
- Split up the replacements subpackage
2018-02-26 09:22:36 +00:00
* Mon Feb 26 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-8
- Increase optmem_max preset to 81920
* Mon Feb 26 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-7
- Obsoletes work by package name, not by provides (rhbz#1537225)
2018-02-25 13:12:04 +00:00
* Sun Feb 25 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-6
- Add patch to fix a copy-paste typo
2018-02-17 10:01:56 +00:00
* Sat Feb 17 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-5
- Add patch to fix build with -Werror
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org>
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
2018-02-04 12:43:23 +00:00
* Sun Feb 04 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-3
2018-02-17 08:48:03 +00:00
- Switch to %%ldconfig_scriptlets
2018-02-04 12:43:23 +00:00
* Wed Jan 17 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-2
- Decrease optmem_max preset to 40960
- Let the build fail, if the minimum kernel version cannot be met
- Conditionalize the sysctl.d tweak on version of the kernel
- Conditionalize the name of README.distro on the distro
2018-01-16 17:47:27 +00:00
* Tue Jan 16 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-1
- Initial import (rhbz#1533929)
* Tue Jan 16 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.13
- Increase optmem_max preset to 81920
* Tue Jan 16 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.12
- Add sysctl.d preset and README.fedora
* Mon Jan 15 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.11
- Make the contents of the -replacements package configurable
* Mon Jan 15 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.10
- Fix Obsoletes of the -replacements package
* Sun Jan 14 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.9
- Disable the -replacements package until we have a plan for it
* Sun Jan 14 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.8
- Move the kcapi-hasher binary to -replacements package, since it is
not of much use without the linked invocation names and saves the
extra Requires on the -tools package
* Sun Jan 14 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.7
- Fix internal Requires of sub-packages
- Hardlink files in %%{_bindir}
* Sun Jan 14 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.6
- Add patches from upstream
* Sat Jan 13 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.5
- Add patches from upstream
* Sat Jan 13 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.4
- Asume the testsuite cannot be run, if the value of optmem_max cannot
be obtained
* Sat Jan 13 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.3
- Move libraries to /%%{_lib} instead of %%{_libdir}, which is useful
during boot when the library might be needed before a potentially
seperate /usr partition is mounted
* Sat Jan 13 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.2
- Asume optmem_max is at least 20480, if the real value cannot be obtained
* Fri Jan 12 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.3-0.1
- New upstream release
* Wed Jan 10 2018 Björn Esser <besser82@fedoraproject.org> - 1.0.2-0.1
- Initial rpm release (rhbz#1533929)