Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpkg: allow filtering provided shlibs #2422

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ifreund
Copy link
Contributor

@ifreund ifreund commented Feb 17, 2025

This branch adds several useful ways to filter the shared libraries automatically added to shlibs_provided by a pkg based on parsing the ELF/Mach-O binary. These two commits are the most relevant:

libpkg: add SHLIB_PROVIDE_PATHS_* options

This allows limiting the files in a package that can affect
shlibs_provided when ELF files are scanned during e.g. pkg create.

The ports system will be able to populate these options automatically
based on the already existing USE_LDCONFIG variable.
libpkg: add SHLIB_PROVIDE_IGNORE_{GLOB,REGEX} options

These are quite simple to implement and nicely complement the
SHLIB_REQUIRE_IGNORE_{GLOB,REGEX} options.

Sponsored by:	The FreeBSD Foundation
Sponsored by:	The FreeBSD Foundation
This is consistent with the behavior for required shlibs and will make
the next commit simpler to implement correctly.

Sponsored by:	The FreeBSD Foundation
This allows limiting the files in a package that can affect
shlibs_provided when ELF files are scanned during e.g. pkg create.

The ports system will be able to populate these options automatically
based on the already existing USE_LDCONFIG variable.

Sponsored by:	The FreeBSD Foundation
These are quite simple to implement and nicely complement the
SHLIB_REQUIRE_IGNORE_{GLOB,REGEX} options.

Sponsored by:	The FreeBSD Foundation
@ifreund
Copy link
Contributor Author

ifreund commented Feb 17, 2025

Looks like the macos CI is broken due to some upstream homebrew? issue.

ATF_REQUIRE_EQ(tll_length(p->shlibs_provided), 0);
ATF_REQUIRE_EQ(pkg_analyse_elf(false, p, binpath), EPKG_OK);
ATF_REQUIRE_EQ(tll_length(p->shlibs_provided), 1);
ATF_REQUIRE_STREQ(tll_front(p->shlibs_provided), "libtestfbsd.so.1");
Copy link
Contributor

Choose a reason for hiding this comment

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

This test stopped checking if libtestfbsd.so.1 is provided, which changes its behavior. Is this intended?

Copy link
Contributor Author

@ifreund ifreund Feb 17, 2025

Choose a reason for hiding this comment

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

This is intended, the analyze_elf() function now works differently and does not directly add entries to p->shlibs_provided. Instead, the provided shlib is returned with an out parameter and pkg_analyze_files() decides whether or not it should be filtered out.

This filtering cannot be done in analyze_elf() directly as pkg_analyze_files() must be aware of all shlibs provided by the package including filtered shlibs so that it can eliminate redundant shlibs_required entries.

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.

2 participants