From e6f609ad01a58948d9d6162395af1a3549ee6f4b Mon Sep 17 00:00:00 2001 From: desert-sailor Date: Wed, 15 May 2024 16:52:13 +0800 Subject: [PATCH] Refactor openldap-compat package to support the transition from 2.4 --- openldap.spec | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/openldap.spec b/openldap.spec index 6d68e6c..1f1e76a 100644 --- a/openldap.spec +++ b/openldap.spec @@ -1,8 +1,11 @@ %global systemctl_bin /usr/bin/systemctl +%global so_ver 2 +%global so_ver_compat 2 + Name: openldap Version: 2.6.5 -Release: 4 +Release: 5 Summary: LDAP support libraries License: OLDAP-2.8 URL: https://www.openldap.org/ @@ -50,6 +53,20 @@ protocols for enabling directory services over the Internet. Install this package only if you plan to develop or will need to compile customized LDAP clients. +%package compat +Summary: Package providing legacy non-threaded libldap +Requires: openldap%{?_isa} = %{version}-%{release} +# since libldap is manually linked from libldap_r, the provides is not generated automatically +Provides: liblber-2.4.so.%{so_ver_compat}(OPENLDAP_2.4_%{so_ver_compat})(%{__isa_bits}bit) +Provides: libldap-2.4.so.%{so_ver_compat}(OPENLDAP_2.4_%{so_ver_compat})(%{__isa_bits}bit) +Provides: libldap_r-2.4.so.%{so_ver_compat}(OPENLDAP_2.4_%{so_ver_compat})(%{__isa_bits}bit) + +%description compat +The openldap-compat package contains shared libraries named as libldap-2.4.so, +libldap_r-2.4.so, liblber-2.4.so and libslapi-2.4.so. +The libraries are just links to the current version shared libraries, +and are available for compatibility reasons. + %package servers Summary: LDAP server License: OpenLDAP @@ -226,6 +243,37 @@ for lib in liblber libldap libldap_r libslapi; do rm -f ${lib}.so ln -s ${lib}.so.2 ${lib}.so done + +for lib in $(ls | grep libldap); do + IFS='.' + read -r -a libsplit <<< "$lib" + if [[ -z "${libsplit[3]}" && -n "${libsplit[2]}" ]] + then + so_ver_short_2_4="%{so_ver_compat}" + elif [ -n "${libsplit[3]}" ] + then + so_ver_full_2_4="%{so_ver_compat}.${libsplit[3]}.${libsplit[4]}" + fi + unset IFS +done + +echo ${so_ver_short_2_4} "->" ${so_ver_full_2_4} + +# Provide only libldap and copy it to libldap_r for both 2.4 and 2.6+ versions, make a versioned lib link +# We increase it by 2 because libldap-2.4 has the 'so.2' major version on 2.4.59 (one of the last versions which is EOF) +gcc -shared -o "%{buildroot}%{_libdir}/libldap-2.4.so.${so_ver_short_2_4}" -Wl,--no-as-needed \ + -Wl,-soname -Wl,libldap-2.4.so.${so_ver_short_2_4} -L "%{buildroot}%{_libdir}" -lldap +gcc -shared -o "%{buildroot}%{_libdir}/libldap_r-2.4.so.${so_ver_short_2_4}" -Wl,--no-as-needed \ + -Wl,-soname -Wl,libldap_r-2.4.so.${so_ver_short_2_4} -L "%{buildroot}%{_libdir}" -lldap +gcc -shared -o "%{buildroot}%{_libdir}/liblber-2.4.so.${so_ver_short_2_4}" -Wl,--no-as-needed \ + -Wl,-soname -Wl,liblber-2.4.so.${so_ver_short_2_4} -L "%{buildroot}%{_libdir}" -llber +gcc -shared -o "%{buildroot}%{_libdir}/libslapi-2.4.so.${so_ver_short_2_4}" -Wl,--no-as-needed \ + -Wl,-soname -Wl,libslapi-2.4.so.${so_ver_short_2_4} -L "%{buildroot}%{_libdir}" -lslapi +ln -s libldap-2.4.so.{${so_ver_short_2_4},${so_ver_full_2_4}} +ln -s libldap_r-2.4.so.{${so_ver_short_2_4},${so_ver_full_2_4}} +ln -s liblber-2.4.so.{${so_ver_short_2_4},${so_ver_full_2_4}} +ln -s libslapi-2.4.so.{${so_ver_short_2_4},${so_ver_full_2_4}} + popd chmod 0755 %{buildroot}%{_libdir}/lib*.so.* @@ -376,6 +424,12 @@ popd %{_includedir}/* %{_libdir}/pkgconfig/*.pc +%files compat +%{_libdir}/libldap-2.4*.so.* +%{_libdir}/libldap_r-2.4*.so.* +%{_libdir}/liblber-2.4*.so.* +%{_libdir}/libslapi-2.4*.so.* + %files help %defattr(-,root,root) %{_mandir}/man*/* @@ -391,6 +445,9 @@ popd %doc ltb-project-openldap-ppolicy-check-password-1.1/README.check_pwd %changelog +* Wed May 15 2024 Dongxing Wang - 2.6.5-5 +- Refactor openldap-compat package to support the transition from 2.4 + * Thu Jul 27 2023 zhangchenglin - 2.6.5-1 - update to version 2.6.5 -- Gitee