Skip to content

Commit

Permalink
[antlir][rpm] disable_ldconfig attr
Browse files Browse the repository at this point in the history
Summary:
Add a `disable_ldconfig` attr so that RPMs that install `.so`s without knowing
all the aliases that `ldconfig` will create can still be packaged (just without
those aliases)

Test Plan:
```
❯ buck2 test fbcode//antlir/antlir2/test_images/package/rpm:test
Buck UI: https://www.internalfb.com/buck2/f7550864-0e14-401d-b48a-8996aef8f956
Test UI: https://www.internalfb.com/intern/testinfra/testrun/3377699974677660
Network: Up: 8.1KiB  Down: 279B  (reSessionID-cfe15ac7-3035-4ea0-bc53-f1609c1a01ec)
Jobs completed: 9. Time elapsed: 3.3s.
Cache hits: 0%. Commands: 2 (cached: 0, remote: 0, local: 2)
Tests finished: Pass 1. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Reviewed By: justintrudell

Differential Revision: D65483357

fbshipit-source-id: f3b920b1b5deddba47a46c84ab056d7a0e464f9a
  • Loading branch information
vmagro authored and facebook-github-bot committed Nov 6, 2024
1 parent eef4a76 commit eda5c50
Show file tree
Hide file tree
Showing 4 changed files with 19 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 @@ -82,6 +82,7 @@ pub struct Rpm {
binary_payload: Option<String>,
disable_strip: bool,
disable_build_id_links: bool,
disable_ldconfig: bool,
#[serde(rename = "_strip")]
strip: Option<Vec<String>>,
}
Expand Down Expand Up @@ -255,6 +256,9 @@ AutoProv: {autoprov}
if self.disable_build_id_links {
spec.push_str("%define _build_id_links none\n");
}
if self.disable_ldconfig {
spec.push_str("%define __brp_ldconfig %{nil}\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 @@ -291,6 +291,7 @@ _rpm, _rpm_anon = _new_package_rule(
"conflicts": attrs.list(attrs.string(), default = []),
"description": attrs.option(attrs.string(), default = None),
"disable_build_id_links": attrs.bool(default = False),
"disable_ldconfig": attrs.bool(default = False),
"disable_strip": attrs.bool(default = False),
"epoch": attrs.int(default = 0),
"extra_files": attrs.list(attrs.string(), default = []),
Expand Down
8 changes: 8 additions & 0 deletions antlir/antlir2/test_images/package/rpm/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ image.layer(
dst = "/usr/bin/add",
never_use_dev_binary_symlink = True,
),
feature.ensure_dirs_exist(dirs = "/usr/lib64"),
feature.install(
src = ":libadd[shared]",
# Install at a more specific version path, then ldconfig will
# symlink libadd.so.1 (SONAME) to this path during rpmbuild
dst = "/usr/lib64/libadd.so.1.2",
),
],
)

package.rpm(
name = "add.rpm",
# @oss-disable
disable_ldconfig = True,
layer = ":layer",
license = "none",
rpm_name = "add",
Expand Down
6 changes: 6 additions & 0 deletions antlir/antlir2/test_images/package/rpm/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ def test_stripped_binary(self):
# It should also include debugging stuff, keyed by build-id
self.assertIn("/usr/lib/.build-id", files)
self.assertIn("/usr/lib/debug/.build-id", files)

def test_no_ldconfig(self) -> None:
files = _files_in_rpm("/add.rpm")
self.assertIn("/usr/lib64/libadd.so.1.2", files)
# but ldconfig should not have been run, so the symlink should not exist
self.assertNotIn("/usr/lib64/libadd.so.1", files)

0 comments on commit eda5c50

Please sign in to comment.