forked from Liliniser/Kernel-repack-util
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathextracter.sh
executable file
·47 lines (39 loc) · 1.23 KB
/
extracter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# initramfs extracter
# parse command line options
while getopts "s:d:" opt
do
case "$opt" in
s) source_zImage=`readlink -f "$OPTARG"`;;
d) dest_initramfs_directory=`readlink -f "$OPTARG"`;;
esac
done
i_am=`readlink -f $0`
cur_space=`dirname $i_am`
Image_here=$cur_space'/out/Image'
original_initramfs_image=$cur_space'/out/original.cpio'
temp=$cur_space'/out/dd_cache'
if [ ! -f "$source_zImage" ]; then
echo "****** You must specify a valid zImage file as input ******"
exit 1
fi
if [ ! -n "$dest_initramfs_directory" ]; then
echo "****** You must specify a directory name where to extract the initramfs ******"
exit 1
fi
cd $cur_space
mkdir -p out
# load functions
. ./lib.sh
analyze_initramfs
echo "##### reading initramfs from the uncompressed Image file #####"
# original version
# dd if=$Image_here bs=1 skip=$start count=$count > $original_initramfs_image
# speed-optimized version
dd if=$Image_here ibs=$start skip=1 of=$temp
dd if=$temp bs=$count count=1 of=$original_initramfs_image
rm -r $dest_initramfs_directory
mkdir -p $dest_initramfs_directory || exit 1
cd $dest_initramfs_directory
echo "##### extracting the initramfs in $dest_initramfs_directory #####"
cpio -i --no-absolute-filenames < $original_initramfs_image