Skip to content

Commit 1a89eb1

Browse files
committed
feat(rpm): add RPM debuginfo support on Ubuntu
1 parent 3bbfc0b commit 1a89eb1

4 files changed

Lines changed: 28 additions & 20 deletions

File tree

.bazelci/tests.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ default_tests: &default_tests
2929
- "//pkg/..."
3030
- "//tests/..."
3131
- "//toolchains/..."
32-
- "-//tests/rpm/..."
33-
- "-//pkg/legacy/tests/rpm/..."
34-
35-
default_tests_with_rpm: &default_tests_with_rpm
36-
test_targets:
37-
- "//pkg/..."
38-
- "//tests/..."
39-
- "//toolchains/..."
40-
# This has started to fail, even on CentOS.
41-
- "-//tests/rpm:test_golden_debuginfo_rpm_contents"
4232

4333
win_tests: &win_tests
4434
test_flags:
@@ -67,11 +57,14 @@ ubuntu2204: &ubuntu
6757
platform: ubuntu2204
6858
<<: *common
6959
<<: *default_tests
60+
shell_commands:
61+
- sudo apt-get update
62+
- sudo apt-get install -y rpm elfutils # rpmbuild, eu-strip
7063

7164
centos7: &centos
7265
platform: centos7_java11_devtoolset10
7366
<<: *common
74-
<<: *default_tests_with_rpm
67+
<<: *default_tests
7568

7669
macos: &macos
7770
platform: macos

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Intentionally blank
2+
common --test_output=errors

pkg/rpm_pfg.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ def _pkg_rpm_impl(ctx):
604604
if ctx.attr.architecture:
605605
preamble_pieces.append("BuildArch: " + ctx.attr.architecture)
606606

607+
# Tune debuginfo package generation if requested
608+
if ctx.attr.debuginfo:
609+
preamble_pieces.append("%{{!?_enable_debug_packages:%debug_package}}") # absent by default on Ubuntu
610+
preamble_pieces.append("%undefine _unique_debug_names") # set by default on Rocky, Ubuntu
611+
607612
preamble_file = ctx.actions.declare_file(
608613
"{}.spec.preamble".format(rpm_name),
609614
)

toolchains/rpm/rpmbuild_configure.bzl

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ def _build_repo_for_rpmbuild_toolchain_impl(rctx):
8181
if rctx.attr.debuginfo_type not in DEBUGINFO_VALID_VALUES:
8282
fail("debuginfo_type must be one of", DEBUGINFO_VALID_VALUES)
8383

84-
debuginfo_type = rctx.attr.debuginfo_type
85-
if debuginfo_type == DEBUGINFO_TYPE_AUTODETECT:
86-
if rctx.path(RELEASE_PATH).exists:
87-
rctx.watch(RELEASE_PATH)
88-
os_name, _ = _parse_release_info(rctx.read(RELEASE_PATH))
89-
debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE.get(os_name, debuginfo_type)
90-
else:
91-
debuginfo_type = DEBUGINFO_TYPE_NONE
92-
9384
rpmbuild_path = rctx.which("rpmbuild")
9485
if rctx.attr.verbose:
9586
if rpmbuild_path:
@@ -106,6 +97,24 @@ def _build_repo_for_rpmbuild_toolchain_impl(rctx):
10697
if parts[0] == "RPM" and parts[1] == "version":
10798
version = parts[2]
10899

100+
debuginfo_type = rctx.attr.debuginfo_type
101+
if debuginfo_type == DEBUGINFO_TYPE_AUTODETECT:
102+
version_parts = version.split(".")
103+
if len(version_parts) > 1 and version_parts[0].isdigit() and version_parts[1].isdigit():
104+
major = int(version_parts[0])
105+
minor = int(version_parts[1])
106+
if major < 4 or (major == 4 and minor < 18):
107+
debuginfo_type = DEBUGINFO_TYPE_CENTOS
108+
else:
109+
# https://rpm.org/wiki/Releases/4.18.0: Make %{buildsubdir} settable outside %setup
110+
debuginfo_type = DEBUGINFO_TYPE_FEDORA
111+
elif rctx.path(RELEASE_PATH).exists:
112+
rctx.watch(RELEASE_PATH)
113+
os_name, _ = _parse_release_info(rctx.read(RELEASE_PATH))
114+
debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE.get(os_name, debuginfo_type)
115+
else:
116+
debuginfo_type = DEBUGINFO_TYPE_NONE
117+
109118
_write_build(
110119
rctx = rctx,
111120
path = rpmbuild_path,

0 commit comments

Comments
 (0)