Change downstream .so version scheme

- Use the entire version number in the .so version to reflect the lack
  of an upstream ABI stability policy.
- Use a separate .so version macro in the spec file rather than
  deducing it from the package version. Having to manually change the
  .so version macro on updates is a valuable reminder of the need to
  rebuild dependent packages.
- Also support versioning shared libraries in non-monolithic builds.
This commit is contained in:
Benjamin A. Beasley 2022-03-30 08:21:16 -04:00
commit bdfba1880a
3 changed files with 69 additions and 19 deletions

View file

@ -1,11 +0,0 @@
diff -up USD-20.05/cmake/macros/Public.cmake.sover USD-20.05/cmake/macros/Public.cmake
--- USD-20.05/cmake/macros/Public.cmake.sover 2020-09-16 16:40:05.489056637 +0200
+++ USD-20.05/cmake/macros/Public.cmake 2020-09-16 16:38:43.784595457 +0200
@@ -926,6 +926,7 @@ function(pxr_toplevel_prologue)
FOLDER "${folder}"
PREFIX "${PXR_LIB_PREFIX}"
IMPORT_PREFIX "${PXR_LIB_PREFIX}"
+ SOVERSION ${PXR_MAJOR_VERSION}
)
_get_install_dir("lib" libInstallPrefix)
install(

35
USD-22.03-soversion.patch Normal file
View file

@ -0,0 +1,35 @@
diff -Naur USD-22.03-original/cmake/defaults/Version.cmake USD-22.03/cmake/defaults/Version.cmake
--- USD-22.03-original/cmake/defaults/Version.cmake 2022-02-18 16:49:09.000000000 -0500
+++ USD-22.03/cmake/defaults/Version.cmake 2022-03-30 08:25:52.278316816 -0400
@@ -27,3 +27,9 @@
set(PXR_PATCH_VERSION "3")
math(EXPR PXR_VERSION "${PXR_MAJOR_VERSION} * 10000 + ${PXR_MINOR_VERSION} * 100 + ${PXR_PATCH_VERSION}")
+
+set(PXR_DOWNSTREAM_SOVERSION "${PXR_MAJOR_VERSION}.${PXR_MINOR_VERSION}.${PXR_PATCH_VERSION}"
+ CACHE
+ STRING
+ "Downstream shared object version"
+)
diff -Naur USD-22.03-original/cmake/macros/Private.cmake USD-22.03/cmake/macros/Private.cmake
--- USD-22.03-original/cmake/macros/Private.cmake 2022-02-18 16:49:09.000000000 -0500
+++ USD-22.03/cmake/macros/Private.cmake 2022-03-30 08:25:52.279316828 -0400
@@ -1285,6 +1285,7 @@
PREFIX "${args_PREFIX}"
SUFFIX "${args_SUFFIX}"
PUBLIC_HEADER "${args_PUBLIC_HEADERS}"
+ SOVERSION ${PXR_DOWNSTREAM_SOVERSION}
)
set(pythonEnabled "PXR_PYTHON_ENABLED=1")
diff -Naur USD-22.03-original/cmake/macros/Public.cmake USD-22.03/cmake/macros/Public.cmake
--- USD-22.03-original/cmake/macros/Public.cmake 2022-02-18 16:49:09.000000000 -0500
+++ USD-22.03/cmake/macros/Public.cmake 2022-03-30 08:25:52.279316828 -0400
@@ -939,6 +939,7 @@
FOLDER "${folder}"
PREFIX "${PXR_LIB_PREFIX}"
IMPORT_PREFIX "${PXR_LIB_PREFIX}"
+ SOVERSION ${PXR_DOWNSTREAM_SOVERSION}
)
_get_install_dir("lib" libInstallPrefix)
install(

View file

@ -1,5 +1,10 @@
# We hard-code the ABI version here, even though it can be derived from the
# package version, as a reminder of the need to rebuild dependent packages on
# every update. See additional notes near the downstream ABI versioning patch.
# It should be 0.MAJOR.MINOR without leading zeros, e.g. 22.03 → 0.22.3.
%global downstream_so_version 0.22.3
%global __cmake_in_source_build 0
%global libmajor 0
%global srcname USD
%bcond_without alembic
%bcond_with documentation
@ -43,8 +48,31 @@ URL: http://www.openusd.org/
Source0: https://github.com/PixarAnimationStudios/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: org.open%{name}.%{name}view.desktop
# Upstream was asked about .so versioning and setting SONAME properly and
# seemed unprepared to handle the request:
# https://github.com/PixarAnimationStudios/USD/issues/1259#issuecomment-657120216
#
# A patch was offered:
# https://github.com/PixarAnimationStudios/USD/issues/1387
Patch1: %{srcname}-20.05-soversion.patch
# but it was not sufficient for the general case, since (1) it only handled the
# monolithic build, and (2) it derived the .so version from PXR_MAJOR_VERSION,
# which is *not* reliably bumped on API or ABI changes, and currently is still
# zero.
#
# We will therefore probably need to keep doing downstream .so versioning for
# the foreseeable future. Currently we are assuming that the ABI is likely to
# change on every release (an appropriate assumption for a large C++ project
# with no ABI stability policy), so we build the .so version from the project
# version. Note that the “hidden” major version is zero, so this complies with
# the “0.” prefix recommended in the packaging guidelines.
#
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_downstream_so_name_versioning
#
# A known defect of this patch is that it causes the hdTiny.so example plugin
# to be versioned as well, which is undesired. This is not a serious problem
# because we do not want to package the built plugin anyway. (It should not be
# built with -DPXR_BUILD_EXAMPLES=OFF, but it is.)
Patch1: %{srcname}-22.03-soversion.patch
# https://github.com/PixarAnimationStudios/USD/issues/1591
Patch2: USD-21.08-OpenEXR3.patch
@ -330,8 +358,9 @@ desktop-file-install \
--dir=%{buildroot}%{_datadir}/applications \
%{SOURCE1}
# Remove arch-specific code in /usr/share
find %{buildroot}%{_datadir}/%{name}/examples -name '*.so' -print -delete
# Remove examples that were built and installed even though we set
# -DPXR_BUILD_EXAMPLES=OFF.
rm -vrf '%{buildroot}%{_datadir}/%{name}/examples'
# Fix installation path for some files
mv %{buildroot}%{_prefix}/lib/python/pxr/*.* \
@ -346,9 +375,6 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/org.open%{name}.%{nam
%files
%doc NOTICE.txt README.md
%{_bindir}/*
%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/examples/
%{_datadir}/%{name}/examples/*
%if %{with python3}
%files -n python3-%{name}
@ -359,7 +385,7 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/org.open%{name}.%{nam
%files libs
%license LICENSE.txt
%doc NOTICE.txt README.md
%{_libdir}/lib%{name}_%{name}_ms.so.%{libmajor}
%{_libdir}/lib%{name}_%{name}_ms.so.%{downstream_so_version}
%{_libdir}/%{name}
%exclude %{_libdir}/%{name}/%{name}/resources/codegenTemplates