Make non-devel packages fully conforformant with FHS

This commit is contained in:
Mikhail Novosyolov 2019-12-03 00:44:07 +03:00
parent e789c7be69
commit 445ac1df85

View file

@ -65,7 +65,7 @@
Summary: LibreSSL utils and libs coexisting with OpenSSL
Name: libressl
Version: 3.0.2
Release: 2
Release: 3
# The code is distributed under ISC license except of original OpenSSL code
License: ISC and BSD-like
Group: System/Libraries
@ -108,20 +108,14 @@ GOST is supported out of the box.
# %%_obindir is /usr/bin
# %%_mandir is /opt/libressl/share/man
# %%_omandir is /usr/share/man
%{_bindir}/openssl
%{_bindir}/libressl
%{_obindir}/libressl
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_omandir}/*/*
%{_libdir}/*.so.*
%config(noreplace) %{_openssldir}/libressl.cnf
%config(noreplace) %{_openssldir}/x509v3.cnf
%{_omandir}/*/*
%exclude %{_omandir}/man3/*
%exclude %{_omandir}/*/nc.*
%exclude %{_omandir}/*/netcat.*
%exclude %{_omandir}/*/ocspcheck.*
%exclude %{_libdir}/*.so
#-------------------------------------------------------------------------------------
%package -n %{libcrypto_pkg}
@ -160,6 +154,10 @@ libtls library from LibreSSL
%package devel
Summary: LibreSSL devel package
Requires: %{name} = %{EVRD}
# symlinks /opt/libressl/lib/*.so.* -> /usr/lib(64)/*.so.*
Requires: %{libcrypto_pkg} = %{EVRD}
Requires: %{libtls_pkg} = %{EVRD}
Requires: %{libssl_pkg} = %{EVRD}
Autoreq: 1
%description devel
@ -175,9 +173,11 @@ remove RPATH/RUNPATH manually if needed.
%files devel
%doc ChangeLog COPYING
%{_libdir}/*.so
# symlinks to %%{_olibdir}/*.so.*, only for devel package
%{_libdir}/*.so.*
%{_olibdir}/pkgconfig/*.pc
%{_includedir}
%{_mandir}/man3/*
%{_mandir}/*/*
%{_omandir}/man3/*
#-------------------------------------------------------------------------------------
@ -293,26 +293,26 @@ cp -rv %{buildroot}%{_mandir}/* %{buildroot}%{_omandir}/
# We have put libressl_ prefixed mans to system man directory,
# now delete them from /opt/libressl/share/man to leave
# mans with original names in /opt/libressl/share/man
# Mans with original names will be included to devel package only
rm -fv %{buildroot}%{_mandir}/*/libressl_*
rm -fv %{buildroot}%{_omandir}/*/openssl.*
(cd %{buildroot}%{_omandir}/man3 ; rm -fv $(ls -1v | grep -v '^libressl_') )
( cd %{buildroot}%{_omandir}/man3 ; rm -fv $(ls -1v | grep -v '^libressl_') )
# Fully delete other mans from /opt
rm -fv %{buildroot}%{_mandir}/*/{nc,netcat,ocspcheck}*
# Manually compress man pages because we use both
# /usr/share/man and /opt/libressl/share/man,
# /usr/lib/rpm/brp-compress will not compress both of them
mkdir tmp
pushd tmp
( cd tmp
sed -e 's,./usr/share/man/man*,%{buildroot}%{_mandir}/man* %{buildroot}%{_omandir}/man*,g' \
%{_usrlibrpm}/brp-compress > ./brp-compress.sh
chmod +x ./brp-compress.sh
COMPRESS="%{_compress}" COMPRESS_EXT="%{_extension}" ./brp-compress.sh
popd
)
mkdir -p %{buildroot}%{_obindir}
mv -v %{buildroot}%{_bindir}/{nc,ocspcheck} %{buildroot}%{_obindir}/
( cd %{buildroot}%{_bindir} ; ln -s openssl libressl )
( cd %{buildroot}%{_obindir} ; ln -s %{_bindir}/openssl libressl )
mv -v %{buildroot}%{_bindir}/{nc,ocspcheck,openssl} %{buildroot}%{_obindir}/
mv -v %{buildroot}%{_obindir}/openssl %{buildroot}%{_obindir}/libressl
( cd %{buildroot}%{_obindir} ; ln -s nc netcat )
( cd %{buildroot}%{_includedir} ; ln -s openssl libressl )
# Remove static libs
@ -372,9 +372,20 @@ do
)
done
cp -v %{buildroot}/%{_libdir}/{libcrypto,libtls,libssl}.so.* %{buildroot}/%{_olibdir}/
mv -v %{buildroot}/%{_libdir}/{libcrypto,libtls,libssl}.so.* %{buildroot}/%{_olibdir}/
( cd %{buildroot}/%{_libdir}/
for i in %{buildroot}/%{_olibdir}/{libcrypto,libtls,libssl}.so.*
do
filename="$(basename "$i")"
ln -s "%{_olibdir}/${filename}" "$filename"
done
)
if [ "$(find %{buildroot}/%{_libdir}/ -iname '*.so.*' -type f | wc -l)" -gt 0 ]; then
echo "Some shared libraries were not relocated!"
exit 1
fi
chrpath --delete %{buildroot}/%{_olibdir}/*.so.*
chrpath --delete %{buildroot}/%{_obindir}/{nc,ocspcheck}
chrpath --delete %{buildroot}/%{_obindir}/{nc,ocspcheck,libressl}
# Stuff from system OpenSSL will be used
rm -fvr %{buildroot}/%{_openssldir}/{certs,cert.pem}
@ -386,14 +397,13 @@ _pcf(){
oflags="$(eval $@)"
nflags="$(echo "$oflags" | sed -e 's,%{_prefix},%{buildroot}%{_prefix},g')"
}
libressl="%{buildroot}/%{_bindir}/libressl"
libressl="%{buildroot}/%{_obindir}/libressl"
rflags="-Wl,-rpath=%{buildroot}%{_libdir},-rpath=%{buildroot}%{_olibdir}"
# These tests caught a lot of mistakes during first builds
export PKG_CONFIG_PATH=%{buildroot}/%{_olibdir}/pkgconfig
export LD_LIBRARY_PATH=%{buildroot}/%{_olibdir}
# (test 1) Check that openssldir is correct
export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}
$libressl version -d | awk '{print $NF}' | tr -d '""' | grep -q '^%{_openssldir}$'
unset LD_LIBRARY_PATH
# (test 2) Check that path to config file is correct
# and also check that pkg-config libressl points to libressl, not openssl
_pcf pkg-config --libs --cflags libressl