This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
forked from corsicanu/android_kernel_samsung_universal8895
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_kernel.sh
executable file
·88 lines (87 loc) · 3.16 KB
/
build_kernel.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
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
commit=$(git rev-parse --short HEAD)
adb devices
kernel=$(adb shell uname -a)
device=$(adb shell su -c "cat /proc/cmdline" | sed 's/ /\n/g' | grep androidboot.bootloader)
tmpfolder=/sdcard/tmp
if echo $device | grep 'G950[FN]'; then
codename=dreamlte
elif echo $device | grep 'G955[FN]'; then
codename=dream2lte
elif echo $device | grep 'N950[FN]'; then
codename=greatlte
else
echo "Unknown device $device is not supported, make sure you only have 1 connected ADB device !"
exit
fi
bootdev=$(adb shell su -c find /dev/block/platform -iname boot) &&
bootimg=build_exynos8895-$codename-boot.img
defconfig=exynos8895-"$codename"_defconfig
echo ""
echo "**************************************************************************"
echo "Kernel : $kernel"
echo "Device : $codename ($device)"
echo "Boot : $bootdev"
echo "Kconfig : docker-$defconfig"
echo "Commit : $commit"
echo "**************************************************************************"
adb shell su -c "mkdir -p $tmpfolder" &&
adb shell su -c "dd if=$bootdev of=$tmpfolder/$bootimg bs=4096" &&
adb pull $tmpfolder/$bootimg ./android/pulled-$bootimg &&
echo ""
echo "Compiling kernel with docker-$defconfig ..."
echo "=========================================================================="
cp ./arch/arm64/configs/$defconfig ./arch/arm64/configs/docker-$defconfig &&
cat << EOF >> ./arch/arm64/configs/docker-$defconfig
# Fix freeze/reset
CONFIG_NETFILTER_XT_MATCH_QTAGUID=n
# Fix no network inside container
CONFIG_ANDROID_PARANOID_NETWORK=n
# Fix postgres shmem problem
CONFIG_SYSVIPC=y
# Overlay2 with Native Diff support
CONFIG_OVERLAY_FS=y
# Others required by Docker
CONFIG_BRIDGE=y
CONFIG_BRIDGE_NETFILTER=y
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
CONFIG_NETFILTER_XT_MATCH_IPVS=y
CONFIG_IP_VS=y
CONFIG_IP_VS_NFCT=y
CONFIG_IP_VS_PROTO_TCP=y
CONFIG_IP_VS_PROTO_UDP=y
CONFIG_IP_VS_RR=y
CONFIG_LOCALVERSION_AUTO=n
CONFIG_LOCALVERSION="-$commit-docker"
# Testing
CONFIG_BLK_CGROUP=y
CONFIG_CMDLINE="loop.max_part=7 cgroup_enable=blkio,cpu,cpuacct,devices,freezer,memory,pids,schedtune buildvariant=eng"
EOF
make mrproper &&
make docker-"$defconfig" &&
make -s -j $(nproc) || exit
echo ""
echo "Repacking kernel to compiled-$bootimg ..."
echo "=========================================================================="
mkdir -p ./android/magiskboot/tmp/ &&
cd ./android/magiskboot/tmp/ &&
chmod +x ../* &&
../magiskboot_x86 unpack -h ../../pulled-$bootimg &&
cp ../../../arch/arm64/boot/dtb.img ./extra &&
cp ../../../arch/arm64/boot/Image ./kernel &&
#sed -i '2s/.*/cmdline=androidboot.selinux=permissive/' header &&
../magiskboot_x86 repack ../../pulled-$bootimg ../../compiled-$bootimg &&
../magiskboot_x86 cleanup &&
cd ../../../ &&
echo ""
echo "Flashing new-$bootimg to $bootdev ..."
echo "=========================================================================="
adb push ./android/compiled-$bootimg $tmpfolder/compiled-$bootimg &&
adb shell su -c "dd if=$tmpfolder/compiled-$bootimg of=$bootdev bs=4096" &&
adb shell su -c "sync" &&
adb reboot
echo ""
echo "Done. Phone is rebooting!"
echo "=========================================================================="