-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmake_new_device_patch
executable file
·133 lines (120 loc) · 3.63 KB
/
make_new_device_patch
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
workdir=`pwd`
toolpath=$workdir/unpack-bootimg-tools/mkboot
patchrootdir=$workdir/patch_device
rawrec=$1
newdevname=$2
patchdevdir=$patchrootdir/$newdevname
androidmk=$patchdevdir/Android.mk
exampledeviceconf=$patchrootdir/example/device.conf
exampleinitconf=$patchrootdir/example/init.conf
pout() {
printf "${C_OUT}${*}${C_CLEAR}\n"
}
perr() {
printf "${C_ERR}${*}${C_CLEAR}\n"
}
clean()
{
rm -rf $patchdevdir
pout "......"
exit
}
function usage()
{
pout " Usage: $0 recovery_path new_device_name"
pout " $0 ./i9300-recovery.img i9300"
clean
}
function unpack_bootimg()
{
pout ">>> unpacking $rawrecpath ..."
$toolpath $rawrec $patchdevdir
pout ">>> unpack recovery image done!"
}
function generate_androidmk()
{
pout ""
pout ""
pout ""
echo "--------------------------------------------------------"
echo "Get img_info:"
echo "--------------------------------------------------------"
cat $patchdevdir/img_info
echo "--------------------------------------------------------"
pout ""
eval $(cat $patchdevdir/img_info)
if [ -z $kernel ]|| [ -z $ramdisk ] || [ -z $base_addr ]; then
pout "img_info file have not enough parameters."
clean
fi
pout "LOCAL_PATH := \$(call my-dir)" > $androidmk
pout "include \$(DD_CLEAR)" >> $androidmk
pout "DD_PRODUCT := $newdevname" >> $androidmk
pout "DD_KERNEL := \$(LOCAL_PATH)/kernel" >> $androidmk
if [ -f $patchdevdir/dt.img ] && [ -n $dtb_size ];then
pout "DD_DTIMG := \$(LOCAL_PATH)/dt.img" >> $androidmk
fi
pout "" >> $androidmk
pout "DD_KERNEL_BASE := $base_addr" >> $androidmk
pout "DD_KERNEL_PAGESIZE := $page_size" >> $androidmk
pout "DD_KERNEL_CMDLINE := $cmd_line" >> $androidmk
if [ -n $ramdisk_offset ];then
pout "DD_RAMDISK_OFFSET := $ramdisk_offset" >> $androidmk
fi
if [ -n $tags_offset ];then
pout "DD_TAGS_OFFSET := $tags_offset" >> $androidmk
fi
pout ""
pout "Please enter screen type:"
pout "MDPI: resolution < 480p"
pout "HDPI: 480p <= resolution < 720p"
pout "XHDPI: 720p <= resolution < 1080p"
pout "XXHDPI: resolution >= 1080p"
pout ""
read -p "Enter screen type (MDPI/HDPI/XHDPI/XXHDPI): " screentype
case $screentype in
MDPI | HDPI | XHDPI | XXHDPI)
pout "DD_DEVICE_SCREEN_TYPE := \"$screentype\"" >> $androidmk
;;
*)
pout "Invalid screen type: $screentype, please check it. Exit!"
clean
;;
esac
pout "" >> $androidmk
pout "DD_PRODUCT_ROOT := \$(LOCAL_PATH)/root" >> $androidmk
pout "DD_DEVICE_CONFIG := \$(LOCAL_PATH)/*.conf" >> $androidmk
pout "include \$(DD_RECOVERY)" >> $androidmk
pout ""
pout ""
echo "--------------------------------------------------------"
pout "Generate Android.mk:"
echo "--------------------------------------------------------"
cat $androidmk
echo "--------------------------------------------------------"
pout ""
pout ""
}
function handle_patch_device()
{
generate_androidmk
mv $patchdevdir/ramdisk $patchdevdir/root
mv $patchdevdir/zImage $patchdevdir/kernel
rm -rf $patchdevdir/ramdisk.gz
rm -rf $patchdevdir/img_info
echo "cp -f $exampledeviceconf $patchdevdir/device.conf"
echo "cp -f $exampleinitconf $patchdevdir/init.conf"
cp -f $exampledeviceconf $patchdevdir/device.conf
cp -f $exampleinitconf $patchdevdir/init.conf
}
if [[ "$#" == "2" ]] && [[ -f $1 ]];then
pout "RAW recovery: $rawrec"
pout "NEW device name: $newdevname"
pout "Patch device path: $patchdevdir"
else
usage
fi
unpack_bootimg;
handle_patch_device;
pout "FINISHED!"