shadow: replace static linking with dynamic libraries in a custom location and bundled with shadow

Despite our efforts to make static linking work, there have
been new reports of bizarre build failures:
https://lists.openembedded.org/g/openembedded-core/message/194006
https://lists.openembedded.org/g/openembedded-core/message/193907

This commit changes back to dynamic linking, but places
the libraries in a custom location, per RP's suggestion.

(From OE-Core rev: b93562937737e97dbc8cb7c874e9913f6a285a34)

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexander Kanavin
2024-01-19 13:43:23 +01:00
committed by Richard Purdie
parent 4a126e3170
commit 4a61101478
2 changed files with 14 additions and 15 deletions

View File

@@ -21,11 +21,6 @@ DISABLE_STATIC:pn-libusb1-native = ""
# needed by rust
DISABLE_STATIC:pn-musl = ""
# needed by shadow-native to build static executables, particularly useradd
DISABLE_STATIC:pn-attr-native = ""
DISABLE_STATIC:pn-libbsd-native = ""
DISABLE_STATIC:pn-libmd-native = ""
EXTRA_OECONF:append = "${DISABLE_STATIC}"
EXTRA_OECMAKE:append:pn-libical = " -DSHARED_ONLY=True"

View File

@@ -47,16 +47,6 @@ EXTRA_OECONF += "--without-libcrack \
CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY"
# Force static linking of utilities so we can use from the sysroot/sstate for useradd
# without worrying about the dependency libraries being available
LDFLAGS:append:class-native = " -no-pie"
do_compile:prepend:class-native () {
sed -i -e 's#\(LIBS.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
-e 's#\(LIBBSD.*\)-lbsd#\1 ${STAGING_LIBDIR}/libbsd.a ${STAGING_LIBDIR}/libmd.a#g' \
-e 's#\(LIBATTR.*\)-lattr#\1 ${STAGING_LIBDIR}/libattr.a#g' \
${B}/lib/Makefile ${B}/src/Makefile
}
NSCDOPT = ""
NSCDOPT:class-native = "--without-nscd"
NSCDOPT:class-nativesdk = "--without-nscd"
@@ -161,6 +151,20 @@ do_install:append() {
touch ${D}${sysconfdir}/subgid
}
# Make executables look for dynamically linked libraries in a custom location, and install
# the needed libraries there. That way we can use them from sstate
# in setscene tasks without worrying about the dependency libraries being available.
do_install:append:class-native() {
binaries=$(find ${D}${base_bindir}/ ${D}${base_sbindir}/ ${D}${bindir}/ ${D}${sbindir}/ -executable -type f)
chrpath -k -r ${STAGING_DIR_NATIVE}/lib-shadow-deps $binaries
mkdir -p ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/
install ${STAGING_LIBDIR_NATIVE}/libattr.so.* ${STAGING_LIBDIR_NATIVE}/libbsd.so.* ${STAGING_LIBDIR_NATIVE}/libmd.so.* ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/
install ${D}${libdir}/*.so.* ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/
}
SYSROOT_DIRS:append:class-native = " ${STAGING_DIR_NATIVE}/lib-shadow-deps/"
INSANE_SKIP:${PN}:class-native = "already-stripped"
PACKAGES =+ "${PN}-base"
FILES:${PN}-base = "\
${base_bindir}/login.shadow \