From 363d10ae48ef1a2f1169db40756fdd9506952f79 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Wed, 5 Jun 2013 23:14:18 -0400 Subject: [PATCH] Remove duplicate files from initramfs genkernel's initramfs image is built incrementally by appending to the cpio file. The introduction of copy_binaries resulted in copying libraries from the host system, which causes the cpio to include certain libraries multiple times whenever different stages depended upon the same library. We address this by extracting the cpio to a temporary directory and then compressing it again to "finalize" it. The extraction eliminates the duplicate files. This makes generated initramfs images slightly smaller and in theory, should make the initramfs load slightly faster. Signed-off-by: Richard Yao Conflicts: gen_initramfs.sh --- gen_initramfs.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index a3e03d0..6a26465 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -869,6 +869,20 @@ create_initramfs() { # keep this at the very end, generates /etc/ld.so.conf* and cache append_data 'ld_so_conf' + # Finalize cpio by removing duplicate files + print_info 1 " >> Finalizing cpio..." + local TDIR="${TEMP}/initramfs-final" + mkdir -p "${TDIR}" + cd "${TDIR}" + + cpio --quiet -i -F "${CPIO}" 2> /dev/null \ + || gen_die "extracting cpio for finalization" + find . -print | cpio ${CPIO_ARGS} -F "${CPIO}" 2>/dev/null \ + || gen_die "recompressing cpio" + + cd "${TEMP}" + rm -r "${TDIR}" + if isTrue "${INTEGRATED_INITRAMFS}" then # Explicitly do not compress if we are integrating into the kernel.