File openssl-ibmca.spec of Package openssl-ibmca.22259
#
# spec file for package openssl-ibmca
#
# Copyright (c) 2018-2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global enginesdir %(pkg-config --variable=enginesdir libcrypto)
Name: openssl-ibmca
Version: 2.1.1
Release: 0
Summary: The IBMCA OpenSSL dynamic engine
License: Apache-2.0
Group: Hardware/Other
URL: https://github.com/opencryptoki/openssl-ibmca
Source: https://github.com/opencryptoki/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: baselibs.conf
Source2: init_section.txt
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libica-devel >= 3.1.1
BuildRequires: libica-tools >= 2.4.0
BuildRequires: libtool
BuildRequires: openssl-devel
Requires: libica3
Requires: openssl
ExclusiveArch: s390x
%description
This package contains a shared object OpenSSL dynamic engine for the
IBM eServer Cryptographic Accelerator (ICA).
%prep
%autosetup
./bootstrap.sh
%build
export CFLAGS="%{optflags}"
export CPPFLAGS="%{optflags}"
%configure \
--libdir=%{enginesdir}
%make_build
%install
# Update the sample config file so that the dynamic path points
# to the correct version of the engines directory.
sed -i -e "/^dynamic_path/s, = .*/, = %{enginesdir}/," src/openssl.cnf.sample
%make_install
rm %{buildroot}%{enginesdir}/ibmca.la
# This file contains the first part of the changes that need to be
# inserted into /etc/ssl/openssl.cnf, so it needs to be on the "real"
# file system when the postinstall scriptlet is run.
mkdir -p %{buildroot}%{_datadir}/%{name}
cp -p %{SOURCE2} %{buildroot}%{_datadir}/%{name}/openssl-ibmca.sectiondef.txt
# This will create an openssl configuration file that will be usable
# by the .include directive of openSSL. That include will be inserted during
# the postinstall phase of the package installation.
grep -v "^#" src/openssl.cnf.sample | \
sed -n -e '/^\[engine_section\]/,$ p' | \
sed -e '/^$/ {N;N;s/\n\n/\n/g;}' > %{buildroot}%{_datadir}/%{name}/openssl-ibmca.cnf
%post
#Original fix for bsc#942839 was to update on first install
#For bsc#966139 update if openssl_def not found
SSLCNF=%{_sysconfdir}/ssl/openssl.cnf
SSLSMP=%{_datadir}/%{name}/openssl-ibmca.cnf
# If the openssl.cnf file has already been modified to point to our configuration file,
# don't re-modify it, just exit.
if ! grep -q openssl-ibmca/openssl-ibmca.cnf ${SSLCNF} ; then
cp -p ${SSLCNF} ${SSLCNF}.orig
# Insert the openssl init section
sed -i -e '/^HOME/ r %{_datadir}/%{name}/openssl-ibmca.sectiondef.txt' %{_sysconfdir}/ssl/openssl.cnf
# Insert the engine section declaration and the .include directive
sed -i -e '/^oid_section/ a \
engines = engine_section\
\
.include %{_datadir}/%{name}/openssl-ibmca.cnf' %{_sysconfdir}/ssl/openssl.cnf
fi
%postun
if [ $1 -eq 0 ]; then # last uninstall, modify %%{_sysconfdir}/openssl.cnf (bsc#942839)
SSLCNF=%{_sysconfdir}/ssl/openssl.cnf
if [ -f ${SSLCNF}.orig ]; then
mv ${SSLCNF}.orig ${SSLCNF}
fi
fi
%files
%license LICENSE
%doc README.md
%doc src/openssl.cnf.sample
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/openssl-ibmca.cnf
%{_datadir}/%{name}/openssl-ibmca.sectiondef.txt
%{enginesdir}/ibmca.*
%{_mandir}/man5/ibmca.5%{?ext_man}
%changelog