-
Notifications
You must be signed in to change notification settings - Fork 24
/
rebuild_ramdisk.sh
executable file
·127 lines (109 loc) · 3.23 KB
/
rebuild_ramdisk.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
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
#!/bin/bash
# idleKernel ramdisk rebuild script by jcadduono
# This rebuild script is for Touchwiz Lollipop only
################### BEFORE STARTING ################
#
# Run ./build.sh first to generate kernel zImage!
#
# Run this file to automatically rebuild the ramdisk and boot.img
# with the contents in ik.ramdisk/ - used for testing ramdisk
# modifications only. There is no need to run this file otherwise.
#
###################### CONFIG ######################
# root directory of idleKernel git repo (default is this script's location)
RDIR=$(pwd)
[ -z $VARIANT ] && \
# device variant/carrier, possible options:
# att = N900A (AT&T)
# can = N900W8 (Canadian, same as T-Mobile)
# eur = N9005 (Snapdragon International / hltexx / Europe)
# spr = N900P (Sprint)
# tmo = N900T (T-Mobile, same as Canadian)
# usc = N900R4 (US Cellular)
# vzw = N900V (Verizon)
# korean variants:
# ktt = N900K (KT Corporation)
# lgt = N900L (LG Telecom)
# skt = N900S (South Korea Telecom)
# japanese variants:
# dcm = N900D / SC-01F (NTT Docomo)
# kdi = N900J / SCL22 (au by KDDI)
VARIANT=can
[ -z $VER ] && \
# version number
VER=$(cat $RDIR/VERSION)
# kernel version string appended to 3.4.x-idleKernel-hlte-
# (shown in Settings -> About device)
KERNEL_VERSION=$VARIANT-$VER
# output directory of flashable kernel
OUT_DIR=$RDIR
# output filename of flashable kernel
OUT_NAME=idleKernel-hlte-$KERNEL_VERSION
# should we make a TWRP flashable zip? (1 = yes, 0 = no)
MAKE_ZIP=1
# should we make an Odin flashable tar.md5? (1 = yes, 0 = no)
MAKE_TAR=1
############## SCARY NO-TOUCHY STUFF ###############
if ! [ -f $RDIR"/arch/arm/configs/variant_hlte_"$VARIANT ] ; then
echo "Device variant/carrier $VARIANT not found in arm configs!"
exit -1
fi
if ! [ -d $RDIR"/ik.ramdisk/variant/$VARIANT/" ] ; then
echo "Device variant/carrier $VARIANT not found in ik.ramdisk/variant!"
exit -1
fi
KDIR=$RDIR/build/arch/arm/boot
CLEAN_BUILD()
{
echo "Removing old boot.img..."
rm -f ik.zip/boot.img
echo "Removing old zip/tar.md5 files..."
rm -f $OUT_DIR/$OUT_NAME.zip
rm -f $OUT_DIR/$OUT_NAME.tar.md5
}
BUILD_RAMDISK()
{
VARIANT=$VARIANT $RDIR/setup_ramdisk.sh
cd $RDIR/build/ramdisk
echo "Building ramdisk.img..."
find | fakeroot cpio -o -H newc | gzip -9 > $KDIR/ramdisk.cpio.gz
cd $RDIR
}
BUILD_BOOT_IMG()
{
echo "Generating boot.img..."
$RDIR/scripts/mkqcdtbootimg/mkqcdtbootimg --kernel $KDIR/zImage \
--ramdisk $KDIR/ramdisk.cpio.gz \
--dt_dir $KDIR \
--cmdline "quiet console=null androidboot.hardware=qcom user_debug=23 msm_rtb.filter=0x37 ehci-hcd.park=3" \
--base 0x00000000 \
--pagesize 2048 \
--ramdisk_offset 0x02000000 \
--tags_offset 0x01E00000 \
--output $RDIR/ik.zip/boot.img
}
CREATE_ZIP()
{
echo "Compressing to TWRP flashable zip file..."
cd $RDIR/ik.zip
zip -r -9 - * > $OUT_DIR/$OUT_NAME.zip
cd $RDIR
}
CREATE_TAR()
{
echo "Compressing to Odin flashable tar.md5 file..."
cd $RDIR/ik.zip
tar -H ustar -c boot.img > $OUT_DIR/$OUT_NAME.tar
cd $OUT_DIR
md5sum -t $OUT_NAME.tar >> $OUT_NAME.tar
mv $OUT_NAME.tar $OUT_NAME.tar.md5
cd $RDIR
}
if CLEAN_BUILD && BUILD_RAMDISK && BUILD_BOOT_IMG; then
if [ $MAKE_ZIP -eq 1 ]; then CREATE_ZIP; fi
if [ $MAKE_TAR -eq 1 ]; then CREATE_TAR; fi
echo "Finished!"
else
echo "Error!"
exit -1
fi