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

fix: Honor the ${pcfiledir} entries in pkgconfig #977

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions craft_parts/packages/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,14 @@ def fix_pkg_config(
f"^prefix=(?P<trim>{'|'.join(prefixes_to_trim)})(?P<prefix>.*)"
)
pattern = re.compile("^prefix=(?P<prefix>.*)")
pattern_pcfiledir = re.compile("^prefix *= *[$]{pcfiledir}.*")

# process .pc file
with fileinput.input(pkg_config_file, inplace=True) as input_file:
for line in input_file:
if pattern_pcfiledir.search(line) is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment here about why this is being checked would be useful for the future

print(line, end="")
continue
match = pattern.search(line)
match_trim = pattern_trim.search(line)

Expand Down
1 change: 1 addition & 0 deletions docs/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Bug fixes:

- Make sure the :ref:`uv plugin<craft_parts_uv_plugin>` is re-entrant on
source changes.
- Preserve the ``pcfiledir`` tag in ``pkgconfig`` files.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you merge main back into this and point this changelog entry to 2.3.1 instead?


Documentation:

Expand Down
12 changes: 12 additions & 0 deletions tests/unit/packages/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ def test_normalize_fix_pkg_config(
f"{tmpdir}/usr"
)

def test_normalize_fix_pkg_config_with_pcfiledir(
self, tmpdir, pkg_config_file, expected_pkg_config_content
):
"""Verify normalization fixes pkg-config files."""
pc_file = tmpdir / "my-file.pc"
pkg_config_file(pc_file, "${pcfiledir}/../../..")
normalize(tmpdir, repository=DummyRepository)

assert pc_file.read_text(encoding="utf-8") == expected_pkg_config_content(
"${pcfiledir}/../../.."
)

def test_fix_pkg_config_is_dir(self, tmpdir):
"""Verify directories ending in .pc do not raise an error."""
pc_file = tmpdir / "granite.pc"
Expand Down
Loading