The existing multipath functionality manually picks up a binary and lots
of needed libraries manually, and sometimes misses libraries if the
binary was linked against something else.
Use lddtree from app-misc/pax-utils to get all libraries with the
binary. The only ones that will be missed are those that are dlopen()ed.
cpio is used for copying to preserve directory structure.
lddtree usage replaces a larger manual function from calling ldd, that
was also vulnerable to injections.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
(commit message rewritten)
# Distributed under the GPL v2
# $Id$
+ 06 Feb 2012: Richard Yao <ryao@cs.stonybrook.edu> gen_initramfs.sh:
+ copy_binaries utility function for putting binaries and librares into
+ initramfs (see git commit for full details).
+
06 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> defaults/initrd.scripts:
Support virtio devices, and provide fallback of all remaining devices.
CPIO_ARGS="--quiet -o -H newc"
+copy_binaries() {
+
+ local destdir=$1 files=$2
+
+ # Copy files
+ lddtree $files | tr ')(' '\n' |awk '/=>/{ if($3 ~ /^\//){print $3}}' | sort | uniq | cpio -p --make-directories --dereference --quiet $destdir
+
+}
+
append_base_layout() {
if [ -d "${TEMP}/initramfs-base-temp" ]
then