1 |
commit: 1079122ea0c1733024dbebadd2ae8ad2c88a9bee |
2 |
Author: Richard Yao <ryao <AT> cs <DOT> stonybrook <DOT> edu> |
3 |
AuthorDate: Wed Feb 1 03:20:49 2012 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 6 08:19:17 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=1079122e |
7 |
|
8 |
copy_binaries: utility function to pick up a binary and needed libs |
9 |
|
10 |
The existing multipath functionality manually picks up a binary and lots |
11 |
of needed libraries manually, and sometimes misses libraries if the |
12 |
binary was linked against something else. |
13 |
|
14 |
Use lddtree from app-misc/pax-utils to get all libraries with the |
15 |
binary. The only ones that will be missed are those that are dlopen()ed. |
16 |
cpio is used for copying to preserve directory structure. |
17 |
|
18 |
lddtree usage replaces a larger manual function from calling ldd, that |
19 |
was also vulnerable to injections. |
20 |
|
21 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
22 |
(commit message rewritten) |
23 |
|
24 |
--- |
25 |
ChangeLog | 4 ++++ |
26 |
gen_initramfs.sh | 9 +++++++++ |
27 |
2 files changed, 13 insertions(+), 0 deletions(-) |
28 |
|
29 |
diff --git a/ChangeLog b/ChangeLog |
30 |
index bc8be73..5115896 100644 |
31 |
--- a/ChangeLog |
32 |
+++ b/ChangeLog |
33 |
@@ -5,6 +5,10 @@ |
34 |
# Distributed under the GPL v2 |
35 |
# $Id$ |
36 |
|
37 |
+ 06 Feb 2012: Richard Yao <ryao@×××××××××××××.edu> gen_initramfs.sh: |
38 |
+ copy_binaries utility function for putting binaries and librares into |
39 |
+ initramfs (see git commit for full details). |
40 |
+ |
41 |
06 Feb 2012; Robin H. Johnson <robbat2@g.o> defaults/initrd.scripts: |
42 |
Support virtio devices, and provide fallback of all remaining devices. |
43 |
|
44 |
|
45 |
diff --git a/gen_initramfs.sh b/gen_initramfs.sh |
46 |
index 32a1b1e..b96e36e 100755 |
47 |
--- a/gen_initramfs.sh |
48 |
+++ b/gen_initramfs.sh |
49 |
@@ -3,6 +3,15 @@ |
50 |
|
51 |
CPIO_ARGS="--quiet -o -H newc" |
52 |
|
53 |
+copy_binaries() { |
54 |
+ |
55 |
+ local destdir=$1 files=$2 |
56 |
+ |
57 |
+ # Copy files |
58 |
+ lddtree $files | tr ')(' '\n' |awk '/=>/{ if($3 ~ /^\//){print $3}}' | sort | uniq | cpio -p --make-directories --dereference --quiet $destdir |
59 |
+ |
60 |
+} |
61 |
+ |
62 |
append_base_layout() { |
63 |
if [ -d "${TEMP}/initramfs-base-temp" ] |
64 |
then |