Skip to content

Conversation

@rdesgroppes
Copy link
Contributor

@rdesgroppes rdesgroppes commented Jan 20, 2026

This enables RPM debuginfo package generation across different Linux distributions (tested on Rocky and Ubuntu in CI) by implementing RPM version-based detection if possible, and falling back to the existing OS release-based detection otherwise.

RPM 4.18.0 introduced changes to make %{buildsubdir} independent of the %setup macro:

While this change enabled setting buildsubdir as a regular macro rather than a spec object property, it had the side effect of altering the relative path handling in install scripts.

This requires different file path formats in the %install section:

  • RPM < 4.18, corresponding to the project's "centos" type:
    cp 'bazel-out/k8-fastbuild/bin/tests/rpm/test_debuginfo' '%{buildroot}/test_debuginfo'
    
  • RPM >= 4.18, corresponding to the project's "fedora" type:
    cp '../bazel-out/k8-fastbuild/bin/tests/rpm/test_debuginfo' '%{buildroot}/test_debuginfo'
    

Using the wrong "type" causes build failures:

  • "fedora" with RPM < 4.18:
    cp: cannot stat '../bazel-out/k8-fastbuild/bin/tests/rpm/test_debuginfo': No such file or directory
    
  • "centos" with RPM >= 4.18:
    rm: refusing to remove '.' or '..' directory: skipping '.'
    

The present change therefore implements version detection to automatically select the appropriate "type".

Additional fixes for cross-distribution compatibility

RedHat distros have redhat-rpm-config with %_enable_debug_packages that auto-invokes %debug_package (rpm-software-management/rpm#2204).
Debian/Ubuntu ship vanilla upstream RPM without this configuration:

output 'tests/rpm/test_debuginfo_rpm-debuginfo-1-0..rpm' was not created

That's why the change adds %debug_package only when applicable:

  • %{!?_enable_debug_packages:%debug_package}.

Also, since RPM 4.14, unique debug package filenames are enabled by default, leading to variadic filenames being generated:

Executing tests from //tests/rpm:test_golden_debuginfo_rpm_contents
-----------------------------------------------------------------------------
29c29
< /usr/lib/debug/test_debuginfo-1-0.x86_64.debug
---
> /usr/lib/debug/test_debuginfo.debug
FAIL: files "tests/rpm/test_debuginfo_rpm_contents.txt" and "tests/rpm/test_debuginfo_rpm_contents.txt.golden" differ

That's why the change makes debug package filenames consistent across distributions by means of:

  • %undefine _unique_debug_names (safe no-op on older RPM versions).

Note: I also verified the change locally with:

  • RPM 4.17.1 on Fedora 35 ("centos" type)
  • RPM 4.18.2 on Ubuntu 24.04.3 ("fedora" type)
  • RPM 4.19.1.1 on Fedora 40 ("fedora" type)

@rdesgroppes rdesgroppes force-pushed the fix-rpm-debuginfo-on-ubuntu branch 12 times, most recently from 2056729 to 1a89eb1 Compare January 20, 2026 17:29
@rdesgroppes rdesgroppes changed the title feat(rpm): add RPM debuginfo support on Ubuntu fix(rpm): debuginfo support on more distributions Jan 20, 2026
@rdesgroppes rdesgroppes force-pushed the fix-rpm-debuginfo-on-ubuntu branch 2 times, most recently from 5dbe86a to d618ca4 Compare January 20, 2026 22:13
@rdesgroppes rdesgroppes marked this pull request as ready for review January 20, 2026 22:15
@rdesgroppes rdesgroppes force-pushed the fix-rpm-debuginfo-on-ubuntu branch from d618ca4 to 85bada1 Compare January 21, 2026 10:07
Copy link
Collaborator

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

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

The change looks reasonable to me. However, there appear to be some CI failures.

@rdesgroppes rdesgroppes force-pushed the fix-rpm-debuginfo-on-ubuntu branch from b358709 to 15c0143 Compare January 24, 2026 23:22
Copy link
Collaborator

@cgrindel cgrindel left a comment

Choose a reason for hiding this comment

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

LGTM. @aiuto Would you like to take a look?

@aiuto
Copy link
Collaborator

aiuto commented Jan 26, 2026

@kellyma2 IIRC, you're the only one who knows about rpm debug.

@rdesgroppes rdesgroppes changed the title fix(rpm): debuginfo support on more distributions fix(rpm): debuginfo support on some distributions Jan 29, 2026
@rdesgroppes rdesgroppes force-pushed the fix-rpm-debuginfo-on-ubuntu branch from 15c0143 to b3cfb2a Compare January 29, 2026 11:49
This enables RPM debuginfo package generation across different Linux
distributions (tested on Rocky and Ubuntu in CI) by implementing RPM
version-based detection if possible, and falling back to the existing OS
release-based detection otherwise.

RPM 4.18.0 introduced changes to make `%{buildsubdir}` independent of
the `%setup` macro:
- commit: `Make %{buildsubdir} more independent of %setup`
  (rpm-software-management/rpm@6caca84c904423)
- since: `rpm-4.18.0-alpha1`
- release: https://rpm.org/wiki/Releases/4.18.0

While this change enabled setting `buildsubdir` as a regular macro
rather than a `spec` object property, it had the side effect of altering
the relative path handling in install scripts.

This requires different file path formats in the `%install` section:
- RPM < 4.18, corresponding to the project's "centos" type:
  ```
  cp 'bazel-out/k8-fastbuild/bin/tests/rpm/test_debuginfo' '%{buildroot}/test_debuginfo'
  ```
- RPM >= 4.18, corresponding to the project's "fedora" type:
  ```
  cp '../bazel-out/k8-fastbuild/bin/tests/rpm/test_debuginfo' '%{buildroot}/test_debuginfo'
  ```

Using the wrong "type" causes build failures:
- "fedora" with RPM < 4.18:
  ```
  cp: cannot stat '../bazel-out/k8-fastbuild/bin/tests/rpm/test_debuginfo': No such file or directory
  ```
- "centos" with RPM >= 4.18:
  ```
  rm: refusing to remove '.' or '..' directory: skipping '.'
  ```

The present change therefore implements version detection to
automatically select the appropriate "type".

**Additional fixes for cross-distribution compatibility**

RedHat distros have redhat-rpm-config with `%_enable_debug_packages`
that auto-invokes `%debug_package` (rpm-software-management/rpm#2204).
Debian/Ubuntu ship vanilla upstream RPM without this configuration:
```
output 'tests/rpm/test_debuginfo_rpm-debuginfo-1-0..rpm' was not created
```

That's why the change adds `%debug_package` only when applicable:
- `%{!?_enable_debug_packages:%debug_package}`.

Also, since RPM [4.14](https://rpm.org/wiki/Releases/4.14.0), unique
debug package filenames are enabled by default, leading to variadic
filenames being generated:
```
Executing tests from //tests/rpm:test_golden_debuginfo_rpm_contents
-----------------------------------------------------------------------------
29c29
< /usr/lib/debug/test_debuginfo-1-0.x86_64.debug
---
> /usr/lib/debug/test_debuginfo.debug
FAIL: files "tests/rpm/test_debuginfo_rpm_contents.txt" and "tests/rpm/test_debuginfo_rpm_contents.txt.golden" differ
```

That's why the change makes debug package filenames consistent across
distributions by means of:
- `%undefine _unique_debug_names` (safe no-op on older RPM versions).

Note: I also verified the change locally with:
- RPM 4.17.1 on Fedora 35 ("centos" type)
- RPM 4.18.2 on Ubuntu 24.04.3 ("fedora" type)
- RPM 4.19.1.1 on Fedora 40 ("fedora" type)
@rdesgroppes rdesgroppes force-pushed the fix-rpm-debuginfo-on-ubuntu branch from b3cfb2a to 46c531f Compare January 29, 2026 12:34
@aiuto
Copy link
Collaborator

aiuto commented Jan 29, 2026

@meteorcloudy Can you make @kellyma2 part of the project so we can more accurately assign things to him.
He's the defacto rpm expert

@kellyma2
Copy link
Contributor

@kellyma2 IIRC, you're the only one who knows about rpm debug.

I in touch with @rdesgroppes to get some understanding of the details. Will re-look at this.

Copy link
Contributor

@kellyma2 kellyma2 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@meteorcloudy
Copy link
Member

Should we move rules_pkg to bazel-contrib?

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.

5 participants