From bb763ec8d2b371673bd53bfce15bbd12bda558cf Mon Sep 17 00:00:00 2001 From: Zakk Date: Sat, 12 Sep 2026 19:15:12 +1000 Subject: [PATCH] sys-kernel/mkinitcpio: resolve encrypt hook libraries at image build time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 因为 42-r1 用 gcc-config -L 找 libgcc_s.so.1,只装 sys-libs/libgcc 的 clang 系统上没有这个路径,所以改问 ldconfig -p;legacy.so 改问 openssl version -m 的 MODULESDIR,不再猜 libdir。两处做成 patch 文件,去掉多层引号的 sed。 Signed-off-by: Zakk --- .../mkinitcpio-42-encrypt-gentoo-paths.patch | 23 +++++++++++++++++++ ...o-42-r1.ebuild => mkinitcpio-42-r2.ebuild} | 10 ++++---- 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 sys-kernel/mkinitcpio/files/mkinitcpio-42-encrypt-gentoo-paths.patch rename sys-kernel/mkinitcpio/{mkinitcpio-42-r1.ebuild => mkinitcpio-42-r2.ebuild} (84%) diff --git a/sys-kernel/mkinitcpio/files/mkinitcpio-42-encrypt-gentoo-paths.patch b/sys-kernel/mkinitcpio/files/mkinitcpio-42-encrypt-gentoo-paths.patch new file mode 100644 index 0000000000..d34cfa241d --- /dev/null +++ b/sys-kernel/mkinitcpio/files/mkinitcpio-42-encrypt-gentoo-paths.patch @@ -0,0 +1,23 @@ +install/encrypt: resolve libgcc_s and the OpenSSL modules dir at build time + +Gentoo keeps libgcc_s.so.1 under the active gcc's libdir (or in +/usr/lib64 from sys-libs/libgcc on clang systems) and the OpenSSL +providers under /usr/$(get_libdir)/ossl-modules, so the /usr/lib paths +hardcoded here are never found. Ask the dynamic loader cache and openssl +itself instead, which also follows toolchain and libdir changes. + +--- a/install/encrypt ++++ b/install/encrypt +@@ -20,10 +20,10 @@ build() { + '95-dm-notify.rules' + + # cryptsetup calls pthread_create(), which dlopen()s libgcc_s.so.1 +- add_binary '/usr/lib/libgcc_s.so.1' ++ add_binary "$(ldconfig -p | awk '/[[:space:]]libgcc_s\.so\.1 \(/ { print $NF; exit }')" /usr/lib/libgcc_s.so.1 + + # cryptsetup loads the legacy provider which is required for whirlpool +- add_binary '/usr/lib/ossl-modules/legacy.so' ++ add_binary "$(openssl version -m | sed 's/.*"\(.*\)"/\1/')/legacy.so" + + add_runscript + } diff --git a/sys-kernel/mkinitcpio/mkinitcpio-42-r1.ebuild b/sys-kernel/mkinitcpio/mkinitcpio-42-r2.ebuild similarity index 84% rename from sys-kernel/mkinitcpio/mkinitcpio-42-r1.ebuild rename to sys-kernel/mkinitcpio/mkinitcpio-42-r2.ebuild index e532701c3d..da8244a0d7 100644 --- a/sys-kernel/mkinitcpio/mkinitcpio-42-r1.ebuild +++ b/sys-kernel/mkinitcpio/mkinitcpio-42-r2.ebuild @@ -46,18 +46,16 @@ BDEPEND=" QA_PREBUILT="/usr/lib/initcpio/busybox" +PATCHES=( + "${FILESDIR}"/${PN}-42-encrypt-gentoo-paths.patch +) + src_prepare() { default # tools/dist.sh reads the version from git describe, which the tarball lacks sed -i "s|run_command('tools/dist.sh', 'get-version', check: true).stdout().strip()|'${PV}'|" \ meson.build || die sed -i "s:/usr/lib/libkmod.so.2:/usr/$(get_libdir)/libkmod.so.2:" install/udev || die - # libgcc_s lives under the active gcc's libdir, resolve it when the image is built - local libgcc='add_binary "$(gcc-config -L | cut -d: -f1)/libgcc_s.so.1" /usr/lib/libgcc_s.so.1' - sed -i \ - -e "/add_binary.*libgcc_s\.so\.1/s#.*# ${libgcc}#" \ - -e "s:/usr/lib/ossl-modules/legacy.so:/usr/$(get_libdir)/ossl-modules/legacy.so:" \ - install/encrypt || die } src_configure() {