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 <ryao@gentoo.org>

Conflicts:
	gen_initramfs.sh
master v17
Richard Yao 12 years ago committed by Fabio Erculiani
parent 755798b933
commit 363d10ae48

@ -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.

Loading…
Cancel
Save