forked from dsixda/Android-Kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_boot_img
More file actions
executable file
·99 lines (78 loc) · 2.02 KB
/
extract_boot_img
File metadata and controls
executable file
·99 lines (78 loc) · 2.02 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
############################################################################
#
# Copyright (c) 2012 - dsixda ([email protected])
#
# Android Kitchen is 100% free. This script file is intended for personal
# and/or educational use only. It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################
#
# This scripts extracts the contents of the boot.img from any folder
#
clear
date_str=`date '+%m%d%y_%H%M%S'`
boot_dir=bootimg_$date_str
echo
echo "Creating folder `pwd`/$boot_dir ..."
mkdir $boot_dir
echo
echo "---> Place boot.img/recovery.img into the folder mentioned above <--"
scripts/press_enter
cd $boot_dir
if [ -e boot.img ] || [ -e recovery.img ]
then
if [ -e recovery.img ]
then
echo "Renaming recovery.img to boot.img (for convenience of scripts)"
mv -f recovery.img boot.img
fi
cd ..
scripts/check_bootimg_header $boot_dir
scripts/check_kernel_offset $boot_dir
res=$?
if [ "$res" == "0" ]
then
kernel_file=extract-kernel.pl
ramdisk_file=extract-ramdisk.pl
else
rm -rf $boot_dir
exit 0
fi
cd $boot_dir
cp ../tools/extract_boot_files/$kernel_file extract-kernel.pl
cp ../tools/extract_boot_files/$ramdisk_file extract-ramdisk.pl
echo
echo Extracting kernel ...
./extract-kernel.pl boot.img 2>/dev/null
if [ ! -e zImage ]
then
echo "Error: No zImage found!"
else
test_z=`od -A n -j 1 -N 4 zImage | sed 's/ //g'`
if [ "$test_z" == "" ]
then
echo "Error: zImage is empty!"
fi
fi
echo Extracting ramdisk ...
./extract-ramdisk.pl boot.img 2>/dev/null
if [ ! -d boot.img-ramdisk ]
then
echo "Error: No ramdisk folder found!"
fi
rm boot.img
rm extract-*.pl
cd ..
echo
echo "Contents of $boot_dir:"
echo
echo "`ls -l $boot_dir`"
else
echo "Error: boot.img or recovery.img not found!"
echo
cd ..
echo "Removing $boot_dir folder"
rm -rf $boot_dir
exit 0
fi