#
# spec file for package libressl
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%undefine _missing_build_ids_terminate_build
%define _ssldir          /etc/pki/tls
%global _hardened_build 1

Name:           libressl
Version:        4.0.0
Release:        1%{dist}
Summary:        An SSL/TLS protocol implementation
License:        OpenSSL
Group:          Development/Libraries/C and C++
Url:            http://libressl.org/

Source:         http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/%{name}-%{version}.tar.gz
Patch1:         libressl-rename-config-file.patch
Patch2:         libressl-cmake-rename-binaries.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?rhel} == 7
BuildRequires:  devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-build devtoolset-8-binutils
%else
BuildRequires:  gcc gcc-c++
%endif
BuildRequires:  cmake
BuildRequires:  pkgconfig
Requires:      %{name}-libs = %{version}-%{release}


%description
LibreSSL is an open-source implementation of the Secure Sockets Layer
(SSL) and Transport Layer Security (TLS) protocols. It derives from
OpenSSL, with the aim of refactoring the OpenSSL code so as to
provide a more secure implementation.

%package libs
Summary:        LibreSSL libraries
Group:          Development/Libraries/C and C++


%description libs

LibreSSL is an open-source implementation of the Secure Sockets Layer
(SSL) and Transport Layer Security (TLS) protocols. It derives from
OpenSSL, with the aim of refactoring the OpenSSL code so as to
provide a more secure implementation.

This subpackage contains libraries for applications
that want to make use of libressl.

%package devel
Summary:        Development files for LibreSSL, an SSL/TLS protocol implementation
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}-%{release}
Conflicts:      openssl-devel
Conflicts:      openssl3-devel

%description devel
LibreSSL is an open-source implementation of the Secure Sockets Layer
(SSL) and Transport Layer Security (TLS) protocols. It derives from
OpenSSL, with the aim of refactoring the OpenSSL code so as to
provide a more secure implementation.

This subpackage contains libraries and header files for developing
applications that want to make use of libressl.


%prep
%autosetup -p1 -n %{name}-%{version}

%build
%if 0%{?rhel} == 7
# We build using the devtoolset-8 compilers
%enable_devtoolset8
%endif

%cmake \
    -DCMAKE_INSTALL_LIBDIR=%{_libdir}/libressl \
    -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir}/libressl \
    -DOPENSSLDIR=%{_ssldir} \
    -DLIBRESSL_TESTS=OFF \
    -DENABLE_NC=ON

%cmake_build

%install
%cmake_install

rm -f %{buildroot}/etc/pki/tls/cert.pem
rm -f %{buildroot}/%{_libdir}/libressl/*.a
rm -f %{buildroot}/%{_libdir}/libressl/*.la
mkdir -p %{buildroot}/%{_sysconfdir}/ld.so.conf.d
echo '%{_libdir}/libressl' > %{buildroot}/%{_sysconfdir}/ld.so.conf.d/libressl.conf
find %{buildroot}/%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) -exec chmod 755 {} +

mv %{buildroot}%{_libdir}/libressl/pkgconfig %{buildroot}%{_libdir}/pkgconfig
mv %{buildroot}%{_libdir}/libressl/cmake %{buildroot}%{_libdir}/
pushd %{buildroot}%{_libdir}/libressl
for lib in ssl tls crypto
do
    ln -sf %{_libdir}/libressl/$(readlink lib${lib}.so) %{buildroot}%{_libdir}/lib${lib}.so
    rm -f %{buildroot}/%{_libdir}/libressl/lib${lib}.so
done


%post  libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig


%files
%defattr(-,root,root)
%{_bindir}/*-libre
%{_mandir}/man1/*.1*
%{_mandir}/man5/*.*
%{_mandir}/man8/*.*
%doc COPYING VERSION README.md

%files libs
%config %{_sysconfdir}/ld.so.conf.d/libressl.conf
%attr(0644,root,root) %config(noreplace) %{_ssldir}/libressl.cnf
%attr(0644,root,root) %config(noreplace) %{_ssldir}/x509v3.cnf
%{_libdir}/libressl/lib*.so.*
%doc COPYING VERSION

%files devel
%defattr(-,root,root)
%{_includedir}/libressl/
%{_libdir}/libcrypto.so
%{_libdir}/libssl.so
%{_libdir}/libtls.so
%{_libdir}/pkgconfig/*.pc
%{_libdir}/cmake/LibreSSL/*.cmake
%{_mandir}/man3/*

%changelog
* Mon Jan  6 2025 Raven <raven@sysadmins.ws> - 4.0.0-1
- update to 4.0.0

* Thu Mar 28 2024 Raven <raven@sysadmins.ws> - 3.8.4-1
- update to 3.8.4

* Wed Feb 28 2024 Raven <raven@sysadmins.ws> - 3.8.2-1
- update to 3.8.2

* Tue Oct  3 2023 Raven <raven@sysadmins.ws> - 3.8.1-1
- update to 3.8.1

* Thu Mar 14 2019 Raven <raven@sysadmins.ws> - 2.8.3-1
- update to 2.8.3

* Tue Nov  6 2018 Raven <raven@sysadmins.ws> - 2.8.2-1
- update to 2.8.2

* Wed Aug  1 2018 Raven <raven@sysadmins.ws> - 2.6.5-1
- update to new upstream release 2.6.5

* Fri May  5 2017 Raven <raven@sysadmins.ws> - 2.5.4-1
- initial release