diff --git a/antlir/antlir2/antlir2_packager/src/rpm.rs b/antlir/antlir2/antlir2_packager/src/rpm.rs index 8dc2b8f5b7..489e7e74c8 100644 --- a/antlir/antlir2/antlir2_packager/src/rpm.rs +++ b/antlir/antlir2/antlir2_packager/src/rpm.rs @@ -82,6 +82,8 @@ pub struct Rpm { binary_payload: Option, disable_strip: bool, disable_build_id_links: bool, + #[serde(rename = "_strip")] + strip: Option>, } impl PackageFormat for Rpm { @@ -238,6 +240,17 @@ AutoProv: {autoprov} } if self.disable_strip { spec.push_str("%define __strip /usr/bin/true\n"); + } else if let Some(strip) = &self.strip { + spec.push_str("%define __strip "); + let mut strip = strip.iter(); + let path = strip.next().context("strip command is empty")?; + spec.push_str("/__antlir2__/working_directory/"); + spec.push_str(path); + for arg in strip { + spec.push_str(arg); + spec.push(' '); + } + spec.push('\n'); } if self.disable_build_id_links { spec.push_str("%define _build_id_links none\n"); @@ -342,6 +355,10 @@ AutoProv: {autoprov} .tmpfs(Path::new("/tmp")) .tmpfs(Path::new("/dev")) .inputs(Path::new("/dev/null")); + #[cfg(facebook)] + isol_context + .platform(Path::new("/usr/local/fbcode")) + .platform(Path::new("/mnt/gvfs")); let isol_context = isol_context.build(); run_cmd( diff --git a/antlir/antlir2/bzl/package/defs.bzl b/antlir/antlir2/bzl/package/defs.bzl index d0a54d51a3..4632512eb9 100644 --- a/antlir/antlir2/bzl/package/defs.bzl +++ b/antlir/antlir2/bzl/package/defs.bzl @@ -7,6 +7,7 @@ load("//antlir/antlir2/bzl:platform.bzl", "arch_select", "os_select") load("//antlir/antlir2/bzl:types.bzl", "BuildApplianceInfo", "LayerInfo") load("//antlir/antlir2/bzl/image:cfg.bzl", "attrs_selected_by_cfg") load("//antlir/buck2/bzl:ensure_single_output.bzl", "ensure_single_output") +load("//antlir/bzl:build_defs.bzl", "internal_external") load(":btrfs.bzl", "btrfs") load(":cfg.bzl", "layer_attrs", "package_cfg") load(":gpt.bzl", "GptPartitionSource", "gpt") @@ -56,7 +57,13 @@ def _generic_impl_with_layer( if uses_build_appliance: spec_opts["build_appliance"] = build_appliance[BuildApplianceInfo].dir for key in rule_attr_keys: - spec_opts[key] = getattr(ctx.attrs, key) + val = getattr(ctx.attrs, key) + if type(val) == "dependency": + if RunInfo in val: + val = val[RunInfo] + else: + val = ensure_single_output(val) + spec_opts[key] = val spec = ctx.actions.write_json( "spec.json", @@ -310,6 +317,10 @@ _rpm, _rpm_anon = _new_package_rule( "summary": attrs.option(attrs.string(), default = None), "supplements": attrs.list(attrs.string(), default = []), "version": attrs.option(attrs.string(), default = None, doc = "If unset, defaults to current datetime HHMMSS"), + "_strip": internal_external( + fb = attrs.default_only(attrs.exec_dep(default = "fbsource//third-party/binutils:strip")), + oss = attrs.option(attrs.exec_dep(), default = None), + ), }, format = "rpm", dot_meta = False, diff --git a/antlir/antlir2/test_images/package/rpm/BUCK b/antlir/antlir2/test_images/package/rpm/BUCK index 4908aecaae..343513e70b 100644 --- a/antlir/antlir2/test_images/package/rpm/BUCK +++ b/antlir/antlir2/test_images/package/rpm/BUCK @@ -37,7 +37,6 @@ image.layer( package.rpm( name = "add.rpm", # @oss-disable - disable_strip = True, # disable double stripping (fixed later in this stack to not be necessary) layer = ":layer", license = "none", rpm_name = "add",