1 |
commit: 713b523abf4196ef97963cde973cccdce8609d46 |
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 03:51:02 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=713b523a |
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 smaller by approximately 240KB |
19 |
(post compression) on my system. In theory, this should make the |
20 |
initramfs load slightly faster. |
21 |
|
22 |
Signed-off-by: Richard Yao <ryao <AT> gentoo.org> |
23 |
|
24 |
--- |
25 |
gen_initramfs.sh | 14 ++++++++++++++ |
26 |
1 file changed, 14 insertions(+) |
27 |
|
28 |
diff --git a/gen_initramfs.sh b/gen_initramfs.sh |
29 |
index 745e15a..6ad51c1 100755 |
30 |
--- a/gen_initramfs.sh |
31 |
+++ b/gen_initramfs.sh |
32 |
@@ -796,6 +796,20 @@ create_initramfs() { |
33 |
append_data 'overlay' |
34 |
fi |
35 |
|
36 |
+ # Finalize cpio by removing duplicate files |
37 |
+ print_info 1 " >> Finalizing cpio" |
38 |
+ local TDIR="${TEMP}/initramfs-final" |
39 |
+ mkdir -p "${TDIR}" |
40 |
+ cd "${TDIR}" |
41 |
+ |
42 |
+ cpio --quiet -i -F "${CPIO}" 2> /dev/null \ |
43 |
+ || gen_die "extracting cpio for finalization" |
44 |
+ find . -print | cpio ${CPIO_ARGS} -F "${CPIO}" 2>/dev/null \ |
45 |
+ || gen_die "recompressing cpio" |
46 |
+ |
47 |
+ cd "${TEMP}" |
48 |
+ rm -r "${TDIR}" |
49 |
+ |
50 |
if isTrue "${INTEGRATED_INITRAMFS}" |
51 |
then |
52 |
# Explicitly do not compress if we are integrating into the kernel. |