Skip to content

Commit

Permalink
[antlir][rpm.builder] Disable rpm stripping for debuginfo/stripped rp…
Browse files Browse the repository at this point in the history
…m subtragets

Summary:
rpmbuild implicitly strips, so let's disable it for:
- stripped RPM as it would be redundant
- debuginfo RPM as we don't want to strip debuginfo files. Packman does something similar
https://www.internalfb.com/code/fbsource/[c4111eae6a5a12e517bff5e6e4b827a8fd7f8dfa]/fbcode/oscore/lib/packman/build/rpmbuild.py?lines=245-248

Test Plan:
```name="Before, double strip error",counterexample
[[email protected] /data/users/naveedgol/fbsource/fbcode (bd049959b)]$ buck2 run fbcode//registry/builder/rpm/tests:fb-rpm-builder-test.base -- --no-publish
Error: Failed to build rpm

Caused by:
    failed to run command env -i PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" TERM="xterm-256color" USER="root" container="antlir2" "/bin/rpmbuild" "-bb" "--target" "aarch64" "--define" "_rpmdir /__antlir2__/out" "--define" "_topdir /tmp/rpmbuild/top" "--define" "_tmppath /tmp/rpmbuild/tmp" "/tmp/rpmspec" (ExitStatus(unix_wait_status(256))): Building target platforms: aarch64
    Building for target aarch64
    Executing(%install): /bin/sh -e /tmp/rpmbuild/tmp/rpm-tmp.wHHysc

    RPM build errors:

    warning: Could not canonicalize hostname: antlir2
    + umask 022
    + cd /tmp/rpmbuild/top/BUILD
    + '[' /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-20240625-081814.aarch64 '!=' / ']'
    + rm -rf /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-20240625-081814.aarch64
    ++ dirname /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-20240625-081814.aarch64
    + mkdir -p /tmp/rpmbuild/top/BUILDROOT
    + mkdir /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-20240625-081814.aarch64
    + cp -rp /__antlir2__/root/cpp_bin /__antlir2__/root/py_bin /__antlir2__/root/usr /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-20240625-081814.aarch64/
    + /usr/lib/rpm/check-buildroot
    + /usr/lib/rpm/redhat/brp-ldconfig
    + /usr/lib/rpm/brp-compress
    + /usr/lib/rpm/brp-strip /usr/bin/strip
    /usr/bin/strip: Unable to recognise the format of the input file `/tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-20240625-081814.aarch64/cpp_bin'
    error: Bad exit status from /tmp/rpmbuild/tmp/rpm-tmp.wHHysc (%install)
        Could not canonicalize hostname: antlir2
        Bad exit status from /tmp/rpmbuild/tmp/rpm-tmp.wHHysc (%install)

```

```name="Before, stripping debuginfo files error",counterexample
[[email protected] /data/users/naveedgol/fbsource/fbcode (bd049959b)]$ buck2 run fbcode//registry/builder/rpm/tests:fb-rpm-builder-test.base -- --no-publish
Error: Failed to build rpm

Action failed: fbcode//registry/builder/rpm/tests:fb-rpm-builder-test.base--rpm-debuginfo (antlir2_package)
Local command returned non-zero exit code 1
Reproduce locally: `env -- 'BUCK_SCRATCH_PATH=buck-out/v2/tmp/fbcode/1ccf2cb8bbccdd32/antlir2_package' buck-out/v2/gen/f ...<omitted>... /__fb-rpm-builder-test.base--rpm-debuginfo__/fb-rpm-builder-test.base--rpm-debuginfo.rpm' --rootless (run `buck2 log what-failed` to get the full command)`
stdout:
stderr:
Error: Failed to build rpm
Caused by:
    failed to run command env -i PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" TERM="xterm-256color" USER="root" container="antlir2" "/bin/rpmbuild" "-bb" "--target" "aarch64" "--define" "_rpmdir /__antlir2__/out" "--define" "_topdir /tmp/rpmbuild/top" "--define" "_tmppath /tmp/rpmbuild/tmp" "/tmp/rpmspec" (ExitStatus(unix_wait_status(256))): Building target platforms: aarch64
    Building for target aarch64
    Executing(%install): /bin/sh -e /tmp/rpmbuild/tmp/rpm-tmp.CZDbhR

    RPM build errors:

    warning: Could not canonicalize hostname: antlir2
    + umask 022
    + cd /tmp/rpmbuild/top/BUILD
    + '[' /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64 '!=' / ']'
    + rm -rf /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64
    ++ dirname /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64
    + mkdir -p /tmp/rpmbuild/top/BUILDROOT
    + mkdir /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64
    + cp -rp /__antlir2__/root/debug /tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64/
    + /usr/lib/rpm/check-buildroot
    + /usr/lib/rpm/redhat/brp-ldconfig
    + /usr/lib/rpm/brp-compress
    + /usr/lib/rpm/brp-strip /usr/bin/strip
    /usr/bin/strip: Unable to recognise the format of the input file `/tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64/debug/.build-id/b3/1f1a0641e3d4b9273184057c9c140d977ec80f.debug.dwp'
    /usr/bin/strip: Unable to recognise the format of the input file `/tmp/rpmbuild/top/BUILDROOT/fb-rpm-builder-test.base-debuginfo-20240625-081814.aarch64/debug/.build-id/b3/1f1a0641e3d4b9273184057c9c140d977ec80f.debug'
    error: Bad exit status from /tmp/rpmbuild/tmp/rpm-tmp.CZDbhR (%install)
        Could not canonicalize hostname: antlir2
        Bad exit status from /tmp/rpmbuild/tmp/rpm-tmp.CZDbhR (%install)

```

```
[[email protected] /data/users/naveedgol/fbsource/fbcode (18fa6d67e)]$ buck2 run fbcode//registry/builder/rpm/tests:fb-rpm-builder-test.base -- --no-publish
Buck UI: https://www.internalfb.com/buck2/9458e424-fbd9-44e9-bf8e-906f04279833
Network: Up: 0B  Down: 0B
Jobs completed: 377258. Time elapsed: 39.9s.
BUILD SUCCEEDED
2024-06-25T08:47:15.974194675-07:00  INFO registry_build_utils::build_utils: Using repo found at cwd: /data/users/naveedgol/fbsource
Buck UI: https://www.internalfb.com/buck2/8692ea93-fdde-4c9b-a527-7cf7af80800c
Network: Up: 395KiB  Down: 1.2KiB  (reSessionID-6a29f659-3e89-4757-bffc-f966d2741b0f)
Jobs completed: 221993. Time elapsed: 33.0s.
Cache hits: 8%. Commands: 25 (cached: 2, remote: 0, local: 23)
BUILD SUCCEEDED
Buck UI: https://www.internalfb.com/buck2/69ed4b7f-9fdf-4c46-8ec9-3aac9afc2c9a
Network: Up: 394KiB  Down: 1.2KiB  (reSessionID-24fdb06b-6b0a-4a39-adf4-fdbbe378469c)
Jobs completed: 239177. Time elapsed: 31.3s.
Cache hits: 8%. Commands: 25 (cached: 2, remote: 0, local: 23)
BUILD SUCCEEDED
{
  "aarch64": {
    "primary": "/data/users/naveedgol/fbsource/buck-out/v2/gen/fbcode/fce66e7cd0c18d42/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-stripped__/fb-rpm-builder-test.base--rpm-stripped.rpm",
    "debug": "/data/users/naveedgol/fbsource/buck-out/v2/gen/fbcode/fce66e7cd0c18d42/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-debuginfo__/fb-rpm-builder-test.base--rpm-debuginfo.rpm"
  },
  "x86_64": {
    "primary": "/data/users/naveedgol/fbsource/buck-out/v2/gen/fbcode/4fe0497eaed377d7/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-stripped__/fb-rpm-builder-test.base--rpm-stripped.rpm",
    "debug": "/data/users/naveedgol/fbsource/buck-out/v2/gen/fbcode/4fe0497eaed377d7/registry/builder/rpm/tests/__fb-rpm-builder-test.base--rpm-debuginfo__/fb-rpm-builder-test.base--rpm-debuginfo.rpm"
  }
}
```

Reviewed By: vmagro

Differential Revision: D59009302

fbshipit-source-id: 2685685c92ceffaa9127582efd54446a73e581c0
  • Loading branch information
Naveed Golafshani authored and facebook-github-bot committed Jun 25, 2024
1 parent a671479 commit 4de5c36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions antlir/antlir2/antlir2_packager/src/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub struct Rpm {
#[serde(default)]
autoprov: bool,
binary_payload: Option<String>,
disable_strip: bool,
}

impl PackageFormat for Rpm {
Expand Down Expand Up @@ -178,6 +179,9 @@ AutoProv: {autoprov}
if !self.python_bytecompile {
spec.push_str("%define __brp_python_bytecompile %{nil}\n");
}
if self.disable_strip {
spec.push_str("%define __strip /usr/bin/true\n");
}
if let Some(binary_payload) = &self.binary_payload {
spec.push_str(&format!("%define _binary_payload {binary_payload}\n"));
}
Expand Down
1 change: 1 addition & 0 deletions antlir/antlir2/bzl/package/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ _rpm, _rpm_anon = _new_package_rule(
"changelog": attrs.option(attrs.string(), default = None),
"conflicts": attrs.list(attrs.string(), default = []),
"description": attrs.option(attrs.string(), default = None),
"disable_strip": attrs.bool(default = False),
"epoch": attrs.int(default = 0),
"extra_files": attrs.list(attrs.string(), default = []),
"license": attrs.string(),
Expand Down

0 comments on commit 4de5c36

Please sign in to comment.