Build libcurl-gnutls

This commit is contained in:
Mikhail Novosyolov 2021-03-09 20:12:34 +03:00
parent 0623c4430a
commit dca161e63b

119
curl.spec
View file

@ -1,8 +1,10 @@
%define major 4 %define major 4
%define libname %mklibname %{name} %{major} %define libname %mklibname %{name} %{major}
%define libname_libressl %mklibname %{name}-libressl %{major} %define libname_libressl %mklibname %{name}-libressl %{major}
%define libname_gnutls %mklibname %{name}-gnutls %{major}
%define devname %mklibname %{name} -d %define devname %mklibname %{name} -d
%define devname_libressl %mklibname %{name}-libressl -d %define devname_libressl %mklibname %{name}-libressl -d
%define devname_gnutls %mklibname %{name}-gnutls -d
%define ssh2 0 %define ssh2 0
@ -11,6 +13,15 @@
# Building a separate curl with libressl # Building a separate curl with libressl
%bcond_without libressl %bcond_without libressl
# Quite a lot of third-party software is compiled on Debian/Ubuntu
# and is linked with libcurl dynamically, Debian's invention libcurl-gnutls.so
# becomes a runtime dependency. Build the same crap to satisfy runtime dependencies.
# Examples of such software:
# - OnlyOffice DesktopEditors (and probably R7 Office)
# - SberPro https://www.sberbank.ru/ru/legal/new/sbrfbusiness
# GnuTLS, btw, is also capable of GOST.
%bcond_without gnutls
# Important! We perform autoreconf, then change resulting 'configure' # Important! We perform autoreconf, then change resulting 'configure'
# script, this prevents if from regenerating after we have changed it. # script, this prevents if from regenerating after we have changed it.
%define _disable_rebuild_configure 1 %define _disable_rebuild_configure 1
@ -28,11 +39,8 @@
%doc _docs/docs/*.md %doc _docs/docs/*.md
} }
%if %{with libressl} %define ssl_list openssl %{?with_libressl:libressl} %{?with_gnutls:gnutls}
%define ssl_list openssl libressl
%else
%define ssl_list openssl
%endif
%define shell_begin %{expand:for SSL in %%{ssl_list} ; \ %define shell_begin %{expand:for SSL in %%{ssl_list} ; \
do \ do \
mkdir -p "$SSL" ;\ mkdir -p "$SSL" ;\
@ -42,7 +50,7 @@
Summary: Gets a file from a FTP, GOPHER or HTTP server Summary: Gets a file from a FTP, GOPHER or HTTP server
Name: curl Name: curl
Version: 7.75.0 Version: 7.75.0
Release: 1 Release: 2
Epoch: 1 Epoch: 1
License: BSD-like License: BSD-like
Group: Networking/Other Group: Networking/Other
@ -70,6 +78,9 @@ BuildRequires: pkgconfig(libssh)
%if %{with libressl} %if %{with libressl}
BuildRequires: pkgconfig(libressl) BuildRequires: pkgconfig(libressl)
%endif %endif
%if %{with gnutls}
BuildRequires: pkgconfig(gnutls)
%endif
BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(krb5-gssapi) BuildRequires: pkgconfig(krb5-gssapi)
@ -112,6 +123,25 @@ This version is compiled with LibreSSL and is capable of GOST TLS.
%endif %endif
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%if %{with gnutls}
%package -n curl-gnutls
Summary: Gets a file from a FTP, GOPHER or HTTP server
Group: Networking/Other
%description -n curl-gnutls
curl is a client to get documents/files from servers, using any of the
supported protocols. The command is designed to work without user interaction
or any kind of interactivity.
It offers a busload of useful tricks like proxy support, user authentication,
ftp upload, HTTP post, file transfer resume and more.
This version is compiled with GnuTLS library.
%files -n curl-gnutls
%_docs
%{_bindir}/curl-gnutls
%endif
#----------------------------------------------------------------------------
%package -n %{libname} %package -n %{libname}
Summary: A library of functions for file transfer Summary: A library of functions for file transfer
Group: Networking/Other Group: Networking/Other
@ -147,6 +177,25 @@ libcurl-libressl is linked with LibreSSL and is capable of GOST TLS.
%endif %endif
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%if %{with gnutls}
%package -n %{libname_gnutls}
Summary: A library of functions for file transfer
Group: Networking/Other
Requires: rootcerts
%description -n %{libname_gnutls}
libcurl is a library of functions for sending and receiving files through
various protocols, including http and ftp.
You should install this package if you plan to use any applications that
use libcurl.
libcurl-gnutls is linked with GnuTLS library.
%files -n %{libname_gnutls}
%_docs
%{_libdir}/libcurl-gnutls.so.%{major}*
%endif
#----------------------------------------------------------------------------
%package -n %{devname} %package -n %{devname}
Summary: Header files and static libraries for libcurl Summary: Header files and static libraries for libcurl
Group: Development/C Group: Development/C
@ -195,6 +244,29 @@ use libcurl linked with LibreSSL and capable of GOST.
%endif %endif
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
%if %{with gnutls}
%package -n %{devname_gnutls}
Summary: Header files and devel libraries for libcurl with gnutls
Group: Development/C
Requires: %{libname_gnutls} = %{EVRD}
Provides: %{name}-gnutls-devel = %{EVRD}
%description -n %{devname_gnutls}
libcurl is a library of functions for sending and receiving files through
various protocols, including http and ftp.
You should install this package if you wish to develop applications that
use libcurl linked with gnutls and capable of GOST.
%files -n %{devname_gnutls}
%_docs
%{_includedir}/curl-gnutls
%{_libdir}/pkgconfig/libcurl-gnutls.pc
%{_libdir}/libcurl-gnutls.so
%endif
#----------------------------------------------------------------------------
%package examples %package examples
Summary: Example files for %{name} development Summary: Example files for %{name} development
Group: Development/C Group: Development/C
@ -240,6 +312,7 @@ rm -fr $(ls -1v | grep -vE "${regexp}|docs|COPYING|CHANGES")
ADD_CONF_OPTS="" ADD_CONF_OPTS=""
case "$SSL" in case "$SSL" in
libressl ) libressl )
with_gnutls=without
cp libcurl.pc.in.1 libcurl.pc.in cp libcurl.pc.in.1 libcurl.pc.in
# validate that correct file is being used # validate that correct file is being used
grep -q LIBRESSL_ libcurl.pc.in grep -q LIBRESSL_ libcurl.pc.in
@ -260,12 +333,23 @@ case "$SSL" in
" "
;; ;;
openssl ) openssl )
with_gnutls=without
cp libcurl.pc.in.0 libcurl.pc.in cp libcurl.pc.in.0 libcurl.pc.in
! grep -q LIBRESSL_ libcurl.pc.in ! grep -q LIBRESSL_ libcurl.pc.in
new_libname=libcurl new_libname=libcurl
export LIBS="$(pkg-config --cflags-only-I --libs-only-L openssl)" export LIBS="$(pkg-config --cflags-only-I --libs-only-L openssl)"
export CFLAGS="$LIBS" export CFLAGS="$LIBS"
export PREFIX_OPENSSL=%{_prefix} export PREFIX_OPENSSL=%{_prefix}
ADD_CONF_OPTS=""
;;
gnutls )
with_gnutls=with
new_libname=libcurl-gnutls
# It will be /usr/include/curl-libressl/gnutls
# to allow '#include <curl/xxx.h> to work with -I/usr/include/curl-gnuttls
ADD_CONF_OPTS="\
--includedir=%{_includedir}/curl-gnutls \
"
;; ;;
esac esac
@ -277,7 +361,7 @@ sed -i configure \
%configure \ %configure \
--disable-static \ --disable-static \
--with-ssl=off \ --with-ssl=off \
--without-gnutls \ --${with_gnutls}-gnutls \
--without-bearssl \ --without-bearssl \
--with-zlib \ --with-zlib \
--with-lber-lib=lber \ --with-lber-lib=lber \
@ -317,7 +401,7 @@ case "$SSL" in
%makeinstall_std %makeinstall_std
;; ;;
libressl ) libressl )
tmp="$(mktemp -d -p $(pwd))" tmp="$(mktemp -d -p $PWD)"
mkdir -p "$tmp" mkdir -p "$tmp"
make DESTDIR="${tmp}" install make DESTDIR="${tmp}" install
mv -v ${tmp}%{_bindir}/curl %{buildroot}%{_bindir}/curl-libressl mv -v ${tmp}%{_bindir}/curl %{buildroot}%{_bindir}/curl-libressl
@ -333,6 +417,20 @@ case "$SSL" in
> %{buildroot}%{_libdir}/pkgconfig/libcurl-libressl.pc > %{buildroot}%{_libdir}/pkgconfig/libcurl-libressl.pc
#rm -fr "$tmp" #rm -fr "$tmp"
;; ;;
gnutls )
tmp="$(mktemp -d -p $PWD)"
mkdir -p "$tmp"
make DESTDIR="${tmp}" install
mv -v ${tmp}%{_bindir}/curl %{buildroot}%{_bindir}/curl-gnutls
mv -v ${tmp}%{_libdir}/libcurl-gnutls* %{buildroot}%{_libdir}
mv -v ${tmp}%{_includedir}/curl-gnutls %{buildroot}%{_includedir}/
cat ${tmp}%{_libdir}/pkgconfig/libcurl.pc | \
sed -r \
-e 's,^Name:.+,Name: libcurl-gnutls,g' \
-e 's,-lcurl,-lcurl-gnutls,g' \
-e 's,-I$\{includedir\},-I$\{includedir\} -I$\{includedir\}/curl-gnutls,' \
> %{buildroot}%{_libdir}/pkgconfig/libcurl-gnutls.pc
;;
* ) echo 'Unknown $SSL' && exit 1 ;; * ) echo 'Unknown $SSL' && exit 1 ;;
esac esac
@ -359,9 +457,13 @@ readelf -a %{buildroot}%{_bindir}/curl-libressl | grep NEEDED | grep -q libcurl-
readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep SONAME | grep -q libcurl-libressl readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep SONAME | grep -q libcurl-libressl
readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep NEEDED | grep -q 'libssl.so.%{libressl_libssl_sover}' readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep NEEDED | grep -q 'libssl.so.%{libressl_libssl_sover}'
readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep NEEDED | grep -q 'libcrypto.so.%{libressl_libcrypto_sover}' readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep NEEDED | grep -q 'libcrypto.so.%{libressl_libcrypto_sover}'
readelf -a %{buildroot}%{_libdir}/libcurl-gnutls.so | grep NEEDED | grep -q 'libgnutls.so.'
! readelf -a %{buildroot}%{_libdir}/libcurl.so | grep SONAME | grep -q libcurl-libressl ! readelf -a %{buildroot}%{_libdir}/libcurl.so | grep SONAME | grep -q libcurl-libressl
readelf -a %{buildroot}%{_libdir}/libcurl-gnutls.so | grep SONAME | grep -q libcurl-gnutls
# Check that GSS-API has been enabled # Check that GSS-API has been enabled
readelf -a %{buildroot}%{_libdir}/libcurl.so | grep NEEDED | grep -q libgssapi
readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep NEEDED | grep -q libgssapi readelf -a %{buildroot}%{_libdir}/libcurl-libressl.so | grep NEEDED | grep -q libgssapi
readelf -a %{buildroot}%{_libdir}/libcurl-gnutls.so | grep NEEDED | grep -q libgssapi
# This test will not fail if there is no connection with internet # This test will not fail if there is no connection with internet
# --insecure to ignore missing SSL certificate # --insecure to ignore missing SSL certificate
if %{buildroot}%{_bindir}/curl-libressl --insecure \ if %{buildroot}%{_bindir}/curl-libressl --insecure \
@ -372,4 +474,3 @@ then
exit 1 exit 1
fi fi
%endif %endif
readelf -a %{buildroot}%{_libdir}/libcurl.so | grep NEEDED | grep -q libgssapi