sys-kernel/mkinitcpio: resolve encrypt hook libraries at image build time

因为 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 <zakk@gentoozh.org>
This commit is contained in:
Zakk committed 2026-09-12 19:19:28 +10:00
1 parent 1db4d76194
commit bb763ec8d2
2 files changed
+27 -6

No files matched your search

@@ -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
}
@@ -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() {