From 299ad81febc024a74decb9c73fae778ccfd88cec Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hugly Date: Thu, 31 Oct 2024 18:17:58 +0100 Subject: [PATCH] Upgade rule_pkg by 1 version and work around rpmbuild bug 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. --- WORKSPACE | 9 ++++----- dist/package.bzl | 1 + dist/rpm/rpm_rules.patch | 27 ++++----------------------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 03dde70ab0..36d82328ff 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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") diff --git a/dist/package.bzl b/dist/package.bzl index e643f23d90..20ff361b66 100644 --- a/dist/package.bzl +++ b/dist/package.bzl @@ -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 diff --git a/dist/rpm/rpm_rules.patch b/dist/rpm/rpm_rules.patch index ce854cc14c..a00fd61248 100644 --- a/dist/rpm/rpm_rules.patch +++ b/dist/rpm/rpm_rules.patch @@ -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, @@ -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.