commit: 5f1a9eaf1e5b3ec654905e7149fe1f8ff7d01159
parent a8247cc1fb16e7378cce0be287da555d9d189f08
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 22 Mar 2019 10:47:18 +0100
make-initrd: Improve dynamic-lib copying
Diffstat:
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/make-initrd.bash b/make-initrd.bash
@@ -8,23 +8,6 @@ out_base=initramfs-${kv}
elves="lvm busybox blkid lsblk cryptsetup mksh zfs zpool"
WORKDIR="$(pwd)"
-function docp() {
- local link=${1} prefix
- [[ -n ${link} ]] || return
- cp -a {,.}${link}
-
- [[ -h ${link} ]] &&
- while true; do
- prefix=${link%/*}
- link=$(readlink ${link})
- [[ ${link%/*} == ${link} ]] && link=${prefix}/${link}
- cp -a {,.}${link} || die
- [[ -h ${link} ]] || break
- done
-
- return 0
-}
-
test -e $out_base && rm -fr $out_base
mkdir -p $out_base && pushd $out_base
mkdir -p {usr/,}{bin,lib$arc} dev proc sys newroot etc
@@ -61,12 +44,14 @@ ln bin/mksh bin/sh
bin/busybox --install usr/bin
for bin in $(find bin); do
- ldd $bin >/dev/null || continue
- for lib in $(ldd $bin | sed -nre 's,.* (/.*lib.*/.*.so.*) .*,\1,p' \
- -e 's,.*(/lib.*/ld.*.so.*) .*,\1,p')
- do
- mkdir -p ${lib%/*} && docp {,.}$lib
- done
+ if ldd "$bin" >/dev/null
+ then
+ for lib in $(ldd "$bin" | sed -nre 's,.* (/.*lib.*/.*.so.*) .*,\1,p')
+ do
+ filename=$(basename "$lib")
+ test -e "/lib/${filename}" || cp "$lib" lib
+ done
+ fi
done
if find . -print0 | cpio --null -ov --format=newc | xz -9 --check=crc32 > ../${out_base}.cpio.xz; then