Skip to content

Commit

Permalink
Upgade rule_pkg by 1 version and work around rpmbuild bug
Browse files Browse the repository at this point in the history
There's a bug in some earlier rpmbuild versions that needs to be
given a default value for _smp_build_cpus. Hence the "defines" parameter
and hence the upgrade by 1 version and hence the update to the patch.
  • Loading branch information
jiceatscion committed Oct 31, 2024
1 parent ffd4dd3 commit 299ad81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
9 changes: 4 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ install_python_doc_deps()

http_archive(
name = "rules_pkg",
sha256 = "8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8",
patch_args = ["-p1"],
patches = ["@//dist:rpm/rpm_rules.patch"],
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.10.1/rules_pkg-0.10.1.tar.gz",
],
sha256 = "d250924a2ecc5176808fc4c25d5cf5e9e79e6346d79d5ab1c493e289e722d1d0",
patch_args = ["-p1"],
patches = ["@//dist:rpm/rpm_rules.patch"],
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
Expand Down
1 change: 1 addition & 0 deletions dist/package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def scion_pkg_rpm(name, package, executables = {}, systemds = [], configs = [],
package_name = package,
release = "%autorelease",
version_file = ":%s_version" % name,
defines = {"_smp_build_ncpus" : "1" },
requires = deps,
post_scriptlet_file = post,
**kwargs
Expand Down
27 changes: 4 additions & 23 deletions dist/rpm/rpm_rules.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl
index 1e3450c1..596dc26d 100644
--- a/pkg/rpm_pfg.bzl
+++ b/pkg/rpm_pfg.bzl
@@ -142,7 +142,7 @@ def _make_absolute_if_not_already_or_is_macro(path):
# this can be inlined easily.
return path if path.startswith(("/", "%")) else "/" + path

-#### Input processing helper functons.
+#### Input processing helper functions.

# TODO(nacl, #459): These are redundant with functions and structures in
# pkg/private/pkg_files.bzl. We should really use the infrastructure provided
@@ -251,7 +251,7 @@ def _pkg_rpm_impl(ctx):
rpm_name,
ctx.attr.version,
Expand All @@ -83,26 +74,16 @@ index 1e3450c1..596dc26d 100644
+ ctx.attr.architecture if ctx.attr.architecture else ctx.attr.target_architecture,
)

outputs, output_file, output_name = setup_output_files(
@@ -432,6 +432,9 @@ def _pkg_rpm_impl(ctx):
_, output_file, _ = setup_output_files(
@@ -454,5 +454,8 @@ def _pkg_rpm_impl(ctx):

args.append("--out_file=" + output_file.path)

+ if ctx.attr.target_architecture:
+ args.append("--target_arch=" + ctx.attr.target_architecture)
+
# Add data files.
if ctx.file.changelog:
files.append(ctx.file.changelog)
@@ -666,7 +669,7 @@ def _pkg_rpm_impl(ctx):
output_groups = {
"out": [default_file],
"rpm": [output_file],
- "changes": changes
+ "changes": changes,
}
return [
OutputGroupInfo(**output_groups),
# Add data files
files += ctx.files.srcs
@@ -791,20 +794,29 @@ pkg_rpm = rule(
# funny if it's not provided. The contents of the RPM are believed to
# be set as expected, though.
Expand Down

0 comments on commit 299ad81

Please sign in to comment.