forked from Hybridmax/G92XF_Mystery_Kernel_Old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repack_edge.sh
executable file
·144 lines (117 loc) · 4.12 KB
/
repack_edge.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# Kernel Repack Script by Hybridmax ([email protected])
clear
echo
echo
# vars
export KERNEL_DIR=$(pwd)
export CURDATE=`date "+%Y.%m.%d"`
export IMAGE_DIR=arch/arm64/boot
export BUILD_IMG=build_image
export DTS=arch/arm64/boot/dts
export ZIP_DIR=zip_files
export MODULES_DIR=build_image/zip_files/system/lib/modules
export DEVELOPER="Mystery"
export DEVICE="S6-Edge"
export VERSION_NUMBER="$(cat $KERNEL_DIR/version)"
export HYBRIDVER="$DEVELOPER-Kernel-$DEVICE-$VERSION_NUMBER-($CURDATE)"
export KERNEL_NAME="$HYBRIDVER"
#########################################################################################
# Check Image
if [ -f "arch/arm64/boot/Image" ]; then
clear
echo "............................................."
echo "Repacking Boot.img, wait"
echo "............................................."
echo " "
sleep 3
else
echo "............................................."
echo "Exiting cause no Image was found!"
echo "............................................."
sleep 3
exit
fi
#########################################################################################
# Copy Modules & Image
echo "Copy Modules............................"
echo " "
find -name '*.ko' -exec cp -av {} $MODULES_DIR \;
#${CROSS_COMPILE}strip --strip-unneeded $MODULES_DIR/*
echo "Copy Image.............................."
echo " "
cp $IMAGE_DIR/Image $BUILD_IMG/G925F/Image
#########################################################################################
# DT.IMG Generation
#clear
#echo "Make DT.img............................"
#echo " "
#./tools/dtbtool -o $BUILD_IMG/G925F/dt.img -s 2048 -p ./scripts/dtc/ $DTS/ | sleep 1
#########################################################################################
# Calculate DTS size
#du -k "$BUILD_IMG/G925F/dt.img" | cut -f1 >sizT
#sizT=$(head -n 1 sizT)
#rm -rf sizT
#echo "dt.img: $sizT Kb"
#echo " "
#########################################################################################
# Ramdisk Generation
echo "Make Ramdisk............................"
echo " "
cd $BUILD_IMG
mkdir -p ramfs_tmp
cp -a G925F/ramdisk/* ramfs_tmp
cp ramdisk_fix_permissions.sh ramfs_tmp/ramdisk_fix_permissions.sh
chmod 0777 ramfs_tmp/ramdisk_fix_permissions.sh
cd ramfs_tmp
./ramdisk_fix_permissions.sh
rm -f ramdisk_fix_permissions.sh
# ADB Fix
if [ -f "../G925F/patch/adbd_5.1.1" ]; then
cp -r sbin/adbd sbin/adbd.bak
cp -r ../G925F/patch/adbd_5.1.1 sbin/adbd
fi
find . | fakeroot cpio -H newc -o | lzop -9 > ../ramdisk.cpio.lzo
cd ..
mv ramdisk.cpio.lzo G925F
rm -r ramfs_tmp
#########################################################################################
# Boot.img Generation
echo "Make boot.img..........................."
echo " "
cd G925F
./../mkbootimg --kernel Image --ramdisk ramdisk.cpio.lzo --dt dt.img --base 0x10000000 --pagesize 2048 --ramdisk_offset 0x01000000 --tags_offset 0x00000100 --second_offset 0x00f00000 -o boot.img
echo -n "SEANDROIDENFORCE" >> boot.img
# copy the final boot.img to output directory ready for zipping
cp boot.img ../$ZIP_DIR/boot.img
#########################################################################################
# Generate Odin Flashable Kernel
#echo "Make tar.md5..........................."
#echo " "
#tar -H ustar -cvf $KERNEL_NAME.tar boot.img
#md5sum -t $KERNEL_NAME.tar >> $KERNEL_NAME.tar
#mv $KERNEL_NAME.tar output_kernel
#########################################################################################
# ZIP Generation
echo "Make ZIP................................"
echo " "
cd ../$ZIP_DIR
zip -r $KERNEL_NAME.zip *
mv $KERNEL_NAME.zip ../output_kernel
#########################################################################################
# Cleaning Up
cd ../..
echo "Make Clean.............................."
echo " "
rm -rf $BUILD_IMG/G925F/Image
rm -rf $BUILD_IMG/G925F/kernel
rm -rf $BUILD_IMG/G925F/ramdisk.cpio.*
rm -rf $BUILD_IMG/G925F/boot.img
#rm -rf $BUILD_IMG/G925F/dt.img
rm -rf $BUILD_IMG/boot.img
rm -rf $BUILD_IMG/ramdisk-cpio.*
rm -rf $BUILD_IMG/zip_files/boot.img
rm -rf $BUILD_IMG/zip_files/hybridmax/boot.img
rm -rf $BUILD_IMG/zip_files/system/lib/modules/*
echo "Done, $KERNEL_NAME.zip is ready!"
echo " "