Skip to content

Overridable debuginfo type #945

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

Open
wants to merge 1 commit 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
10 changes: 5 additions & 5 deletions pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ find_system_rpmbuild(name="rules_pkg_rpmbuild")
```
"""

load(
"@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl",
"DEBUGINFO_TYPE_FEDORA",
"DEBUGINFO_TYPE_NONE",
)
load(
"//pkg:providers.bzl",
"PackageDirsInfo",
Expand All @@ -39,6 +34,11 @@ load(
"PackageVariablesInfo",
)
load("//pkg/private:util.bzl", "setup_output_files", "substitute_package_variables")
load(
"//toolchains/rpm:rpmbuild_configure.bzl",
"DEBUGINFO_TYPE_FEDORA",
"DEBUGINFO_TYPE_NONE",
)

rpm_filetype = [".rpm"]

Expand Down
32 changes: 23 additions & 9 deletions toolchains/rpm/rpmbuild_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def _parse_release_info(release_info):

return os_name, os_version

DEBUGINFO_TYPE_DEFAULT = "default"
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should call this DEBUGINFO_TYPE_AUTODETECT?


# The below are also defined in `pkg/make_rpm.py`
DEBUGINFO_TYPE_NONE = "none"
DEBUGINFO_TYPE_CENTOS = "centos"
DEBUGINFO_TYPE_FEDORA = "fedora"
Expand All @@ -67,11 +70,25 @@ DEBUGINFO_TYPE_BY_OS_RELEASE = {
"fedora": DEBUGINFO_TYPE_FEDORA,
}

DEBUGINFO_VALID_VALUES = [
DEBUGINFO_TYPE_FEDORA,
DEBUGINFO_TYPE_CENTOS,
DEBUGINFO_TYPE_NONE,
DEBUGINFO_TYPE_DEFAULT,
]

def _build_repo_for_rpmbuild_toolchain_impl(rctx):
debuginfo_type = DEBUGINFO_TYPE_NONE
if rctx.path(RELEASE_PATH).exists:
os_name, _ = _parse_release_info(rctx.read(RELEASE_PATH))
debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE.get(os_name, debuginfo_type)
if rctx.attr.debuginfo_type not in DEBUGINFO_VALID_VALUES:
fail("debuginfo_type must be one of", DEBUGINFO_VALID_VALUES)

debuginfo_type = rctx.attr.debuginfo_type
if debuginfo_type == DEBUGINFO_TYPE_DEFAULT:
rctx.watch(RELEASE_PATH)
if rctx.path(RELEASE_PATH).exists:
os_name, _ = _parse_release_info(rctx.read(RELEASE_PATH))
debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE.get(os_name, debuginfo_type)
else:
debuginfo_type = DEBUGINFO_TYPE_NONE

rpmbuild_path = rctx.which("rpmbuild")
if rctx.attr.verbose:
Expand All @@ -80,9 +97,6 @@ def _build_repo_for_rpmbuild_toolchain_impl(rctx):
else:
print("No system rpmbuild found.") # buildifier: disable=print

if rctx.attr.debuginfo_type not in ["centos7", "fedora40", "none"]:
fail("debuginfo_type must be one of centos7, fedora40, or none")

version = "unknown"
if rpmbuild_path:
res = rctx.execute([rpmbuild_path, "--version"])
Expand Down Expand Up @@ -112,9 +126,9 @@ build_repo_for_rpmbuild_toolchain = repository_rule(
doc = """
The underlying debuginfo configuration for the system rpmbuild.

One of `centos`, `fedora`, and `none`
One of `centos`, `fedora`, `none`, and `default` (which looks up `/etc/os-release`)
""",
default = "none",
default = DEBUGINFO_TYPE_DEFAULT,
),
},
)
Expand Down