Skip to content

treewide: fix dangling SONAME symlinks when using ABI_VERSION#29415

Open
BKPepe wants to merge 1 commit into
openwrt:masterfrom
BKPepe:treewide-so-libraries
Open

treewide: fix dangling SONAME symlinks when using ABI_VERSION#29415
BKPepe wants to merge 1 commit into
openwrt:masterfrom
BKPepe:treewide-so-libraries

Conversation

@BKPepe
Copy link
Copy Markdown
Member

@BKPepe BKPepe commented May 10, 2026

A previous commit (from #28220) attempted to introduce proper SONAME symlinks for packages utilizing ABI_VERSION. However, it incorrectly copied only the symlink without the underlying physical library file, resulting in broken packages with dangling symlinks.

Before:

tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/oniguruma_6.9.9-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/lib/
lrwxrwxrwx  0 0      0           0 Feb  5  2024 ./usr/lib/libonig.so.5 -> libonig.so.5.4.0

After:

tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/oniguruma_6.9.9-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/lib/
lrwxrwxrwx  0 0      0           0 Feb  5  2024 ./usr/lib/libonig.so.5 -> libonig.so.5.4.0
-rwxr-xr-x  0 0      0      526493 Feb  5  2024 ./usr/lib/libonig.so.5.4.0

This properly standardizes shared library packaging, prevents shipping duplicate full-sized files (as seen previously in packages like libre2), and aligns the packages feed with core OpenWrt practices. As you could see in the previous commit (see it in the Fixes tag):

Before:

tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/re2_2023.02.01\~b025c6a3-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/lib/
-rw-r--r--  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so
-rw-r--r--  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so.10
-rw-r--r--  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so.10.0.0

After:

tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/re2_2023.02.01\~b025c6a3-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/lib/
lrwxrwxrwx  0 0      0           0 Aug 18  2024 ./usr/lib/libre2.so -> libre2.so.10
lrwxrwxrwx  0 0      0           0 Aug 18  2024 ./usr/lib/libre2.so.10 -> libre2.so.10.0.0
-rwxr-xr-x  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so.10.0.0

Fixes: 537c2a6 ("treewide: avoid deref symlinks when installing .so")
Fixes: #29387

Follow-up of the discussion in #29397

Copilot AI review requested due to automatic review settings May 10, 2026 21:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes packaging of shared libraries that use ABI_VERSION by ensuring both the SONAME symlink and its target library file are installed, preventing dangling symlinks in generated .ipk packages.

Changes:

  • Bump PKG_RELEASE for affected libraries.
  • Adjust install steps to copy lib*.so.$(ABI_VERSION) plus the corresponding versioned target(s) via a glob.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
libs/tinycdb/Makefile Copy libcdb.so.$(ABI_VERSION) plus its versioned target(s) to avoid dangling SONAME symlink.
libs/oniguruma/Makefile Copy libonig.so.$(ABI_VERSION) plus its versioned target(s) to ensure valid runtime library installation.
libs/libyaml-cpp/Makefile Copy libyaml-cpp.so.$(ABI_VERSION) plus its versioned target(s) so SONAME symlink resolves correctly.
libs/libmariadb/Makefile Copy libmariadb.so.$(ABI_VERSION) plus its versioned target(s) to prevent broken symlink packaging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GeorgeSapkin
Copy link
Copy Markdown
Member

GeorgeSapkin commented May 11, 2026

Something is weird with krb5-libs as well:

Library /usr/lib/krb5/plugins/kdb/db2.so has SONAME 'db2.so.0' but no corresponding symlink was found in /usr/lib/krb5/plugins/kdb

@BKPepe
Copy link
Copy Markdown
Member Author

BKPepe commented May 11, 2026 via email

@GeorgeSapkin
Copy link
Copy Markdown
Member

It's going to be ignored after this:

Not sure if that's actually a good idea, but 🤷

@BKPepe
Copy link
Copy Markdown
Member Author

BKPepe commented May 11, 2026 via email

@BKPepe
Copy link
Copy Markdown
Member Author

BKPepe commented May 11, 2026

oniguruma5: Use generic tests
WARNING: opening /ci/packages.adb: UNTRUSTED signature
oniguruma5: [pass] Symlink /usr/lib/libonig.so.5 points to an existing file
oniguruma5: [pass] Binary /usr/lib/libonig.so.5.5.0 does not contain any hardcoded build paths
oniguruma5: [pass] Binary /usr/lib/libonig.so.5.5.0 is stripped
oniguruma5: [pass] All linked libraries for /usr/lib/libonig.so.5.5.0 are present
oniguruma5: [pass] Library /usr/lib/libonig.so.5.5.0 has SONAME 'libonig.so.5'
oniguruma5: [pass] SONAME link for /usr/lib/libonig.so.5.5.0 is correct
oniguruma5: [skip] Version check override
oniguruma5: Generic tests passed

Okay. The output looks much better than this one #29397 (comment) :)

Comment thread libs/tinycdb/Makefile
Comment on lines 46 to 49
define Package/tinycdb/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcdb.so.$(ABI_VERSION) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcdb.so.$(ABI_VERSION)* $(1)/usr/lib
endef
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still CI/CD complains:

tinycdb1: Use generic tests
WARNING: opening /ci/packages.adb: UNTRUSTED signature
tinycdb1: [pass] Binary /usr/lib/libcdb.so.1 does not contain any hardcoded build paths
tinycdb1: [pass] Binary /usr/lib/libcdb.so.1 is stripped
tinycdb1: [pass] All linked libraries for /usr/lib/libcdb.so.1 are present
tinycdb1: [warn] Library /usr/lib/libcdb.so.1 has the same name as its SONAME 'libcdb.so.1'. The library file should have a more specific version.
tinycdb1: [pass] SONAME link for /usr/lib/libcdb.so.1 is correct
tinycdb1: [skip] Version check override
tinycdb1: Generic tests passed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part is bothering you?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That warning! 🤔 Nothing wrong about the CI/CD, though. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the idea is that a file matching the SONAME is a link to a more specific version. So this one is not bad, but sus 👀

Here's my gold standard:

root@OpenWrt:~# ls -lh /usr/lib/libsqlite3.so.*
lrwxrwxrwx    1 root     root          20 May 11 17:17 /usr/lib/libsqlite3.so.0 -> libsqlite3.so.3.53.0
-rwxr-xr-x    1 root     root     1004.6K May 10 12:59 /usr/lib/libsqlite3.so.3.53.0

root@OpenWrt:~# readelf -d /usr/lib/libsqlite3.so.3.53.0 | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [libsqlite3.so.0]

Comment thread libs/libmariadb/Makefile
$(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/sha256_password.so \
$(1)$(MARIADB_PLUGIN_DIR)
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmariadb.so.$(ABI_VERSION) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmariadb.so.$(ABI_VERSION)* $(1)/usr/lib
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libmariadb3: Use generic tests
WARNING: opening /ci/packages.adb: UNTRUSTED signature
libmariadb3: [pass] Binary /usr/lib/libmariadb.so.3 does not contain any hardcoded build paths
libmariadb3: [pass] Binary /usr/lib/libmariadb.so.3 is stripped
libmariadb3: [pass] All linked libraries for /usr/lib/libmariadb.so.3 are present
libmariadb3: [warn] Library /usr/lib/libmariadb.so.3 has the same name as its SONAME 'libmariadb.so.3'. The library file should have a more specific version.

This one is from CI/CD

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see from libsqlite3 example doing cp smth.so.$(ABI_VERSION)* might not always work, since the ABI might be a link to a different version. That is, be careful.

@GeorgeSapkin GeorgeSapkin force-pushed the treewide-so-libraries branch from b670333 to d44ac82 Compare May 13, 2026 22:03
A previous commit attempted to introduce proper SONAME symlinks for
packages utilizing ABI_VERSION. However, it incorrectly copied only
the symlink without the underlying physical library file, resulting
in broken packages with dangling symlinks.

Before:
```
tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/oniguruma_6.9.9-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/lib/
lrwxrwxrwx  0 0      0           0 Feb  5  2024 ./usr/lib/libonig.so.5 -> libonig.so.5.4.0
```

After:
```
tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/oniguruma_6.9.9-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/
drwxr-xr-x  0 0      0           0 Feb  5  2024 ./usr/lib/
lrwxrwxrwx  0 0      0           0 Feb  5  2024 ./usr/lib/libonig.so.5 -> libonig.so.5.4.0
-rwxr-xr-x  0 0      0      526493 Feb  5  2024 ./usr/lib/libonig.so.5.4.0
```

This properly standardizes shared library packaging, prevents shipping
duplicate full-sized files (as seen previously in packages like libre2),
and aligns the packages feed with core OpenWrt practices.
As you could see in the previous commit (see it in the ``Fixes`` tag):

Before:
```
tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/re2_2023.02.01\~b025c6a3-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/lib/
-rw-r--r--  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so
-rw-r--r--  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so.10
-rw-r--r--  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so.10.0.0
```

After:
```
tar -Oxzf bin/packages/arm_cortex-a9_vfpv3-d16/packages/re2_2023.02.01\~b025c6a3-r1_arm_cortex-a9_vfpv3-d16.ipk ./data.tar.gz | tar -tzvf -
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/
drwxr-xr-x  0 0      0           0 Aug 18  2024 ./usr/lib/
lrwxrwxrwx  0 0      0           0 Aug 18  2024 ./usr/lib/libre2.so -> libre2.so.10
lrwxrwxrwx  0 0      0           0 Aug 18  2024 ./usr/lib/libre2.so.10 -> libre2.so.10.0.0
-rwxr-xr-x  0 0      0      331875 Aug 18  2024 ./usr/lib/libre2.so.10.0.0
```

Fixes: 537c2a6 ("treewide: avoid deref symlinks when installing .so")

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
@GeorgeSapkin GeorgeSapkin force-pushed the treewide-so-libraries branch from d44ac82 to 285ba5d Compare May 13, 2026 22:04
@GeorgeSapkin
Copy link
Copy Markdown
Member

GeorgeSapkin commented May 13, 2026

Fixed conflicts and rebased.

@GeorgeSapkin
Copy link
Copy Markdown
Member

Is anything blocking this?

@BKPepe
Copy link
Copy Markdown
Member Author

BKPepe commented May 14, 2026

Nope, only missing a lot of time. Thanks for fixing conflicts, I will look at it once again today or tomorrow and merge it afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oniguruma5: .so file is missing

3 participants