Gentoo Archives: gentoo-commits

From: Richard Yao <ryao@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:ryao commit in: /
Date: Thu, 06 Jun 2013 05:54:18
Message-Id: 1370497977.0b4aae54598b05e25049093077e1a1e8c74754d1.ryao@gentoo
1 commit: 0b4aae54598b05e25049093077e1a1e8c74754d1
2 Author: Richard Yao <ryao <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jun 6 03:14:18 2013 +0000
4 Commit: Richard Yao <ryao <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 6 05:52:57 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=0b4aae54
7
8 Remove duplicate files from initramfs
9
10 genkernel's initramfs image is built incrementally by appending to the
11 cpio file. The introduction of copy_binaries resulted in copying
12 libraries from the host system, which causes the cpio to include certain
13 libraries multiple times whenever different stages depended upon the
14 same library. We address this by extracting the cpio to a temporary
15 directory and then compressing it again to "finalize" it. The extraction
16 eliminates the duplicate files.
17
18 This makes generated initramfs images slightly smaller and in theory,
19 should make the initramfs load slightly faster.
20
21 Signed-off-by: Richard Yao <ryao <AT> gentoo.org>
22
23 ---
24 gen_initramfs.sh | 14 ++++++++++++++
25 1 file changed, 14 insertions(+)
26
27 diff --git a/gen_initramfs.sh b/gen_initramfs.sh
28 index 745e15a..6ad51c1 100755
29 --- a/gen_initramfs.sh
30 +++ b/gen_initramfs.sh
31 @@ -796,6 +796,20 @@ create_initramfs() {
32 append_data 'overlay'
33 fi
34
35 + # Finalize cpio by removing duplicate files
36 + print_info 1 " >> Finalizing cpio"
37 + local TDIR="${TEMP}/initramfs-final"
38 + mkdir -p "${TDIR}"
39 + cd "${TDIR}"
40 +
41 + cpio --quiet -i -F "${CPIO}" 2> /dev/null \
42 + || gen_die "extracting cpio for finalization"
43 + find . -print | cpio ${CPIO_ARGS} -F "${CPIO}" 2>/dev/null \
44 + || gen_die "recompressing cpio"
45 +
46 + cd "${TEMP}"
47 + rm -r "${TDIR}"
48 +
49 if isTrue "${INTEGRATED_INITRAMFS}"
50 then
51 # Explicitly do not compress if we are integrating into the kernel.