diff --git a/antlir/antlir2/antlir2_packager/src/rpm.rs b/antlir/antlir2/antlir2_packager/src/rpm.rs index 489e7e74c8..e98e175461 100644 --- a/antlir/antlir2/antlir2_packager/src/rpm.rs +++ b/antlir/antlir2/antlir2_packager/src/rpm.rs @@ -82,6 +82,7 @@ pub struct Rpm { binary_payload: Option, disable_strip: bool, disable_build_id_links: bool, + disable_ldconfig: bool, #[serde(rename = "_strip")] strip: Option>, } @@ -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")); } diff --git a/antlir/antlir2/bzl/package/defs.bzl b/antlir/antlir2/bzl/package/defs.bzl index 4632512eb9..223fc0cbfb 100644 --- a/antlir/antlir2/bzl/package/defs.bzl +++ b/antlir/antlir2/bzl/package/defs.bzl @@ -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 = []), diff --git a/antlir/antlir2/test_images/package/rpm/BUCK b/antlir/antlir2/test_images/package/rpm/BUCK index 343513e70b..22eefef1e3 100644 --- a/antlir/antlir2/test_images/package/rpm/BUCK +++ b/antlir/antlir2/test_images/package/rpm/BUCK @@ -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", diff --git a/antlir/antlir2/test_images/package/rpm/test.py b/antlir/antlir2/test_images/package/rpm/test.py index b8b9ac6f4d..dd085e26d5 100644 --- a/antlir/antlir2/test_images/package/rpm/test.py +++ b/antlir/antlir2/test_images/package/rpm/test.py @@ -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)