-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
helpers.sh
executable file
·106 lines (86 loc) · 3 KB
/
helpers.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
# Interactive helpers for Android kernel development
# Copyright (C) 2019 Danny Lin <[email protected]>
# Copyright (C) 2019 kingbri <[email protected]>
# Copyright (C) 2019 celtare21 <[email protected]>
#
# This script must be *sourced* from a Bourne-compatible shell in order to
# function. Nothing will happen if you execute it.
#
# Source a compiler-specific setup script for proper functionality. This is
# only a base script and does not suffice for kernel building without the
# flags that compiler-specific scripts append to kmake_flags.
#
#### CONFIGURATION ####
# Kernel name
kernel_name="Artemis"
# Defconfig name
defconfig="artemis_coral_defconfig"
# Target architecture
arch="arm64"
# Base kernel compile flags (extended by compiler setup script)
kmake_flags=(
-j"$(nproc --all)"
ARCH="$arch"
O="out"
)
# Target device name to use in flashable package names
device_name="coral"
# Initialize kernel
function init_kernel() {
git submodule update --init
}
# Reset the current config to the committed defconfig
function mc() {
kmake "$defconfig"
}
# Open an interactive config editor
function cf() {
kmake nconfig
}
# Edit the raw text config
function ec() {
"${EDITOR:-vim}" "$kroot/out/.config"
}
# Get kernel repository root for later use
kroot="$PWD/$(dirname "$0")"
# Show an informational message
function msg() {
echo -e "\e[1;32m$1\e[0m"
}
# Go to the root of the kernel repository repository
function croot() {
cd "$kroot"
}
# Get the version of Clang in an user-friendly form
function get_clang_version() {
"$1" --version | head -n 1 | perl -pe 's/\((?:http|git).*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//' -e 's/^.*clang/clang/'
}
# Get the version of GCC in an user-friendly form
function get_gcc_version() {
"$1" --version | head -n 1 | cut -d'(' -f2 | tr -d ')' | sed -e 's/[[:space:]]*$//'
}
#### COMPILATION ####
# Make wrapper for kernel compilation
function kmake() {
make "${kmake_flags[@]}" "$@"
}
# Create a zipfile
function mkzip() {
echo "Copying new kernel files"
echo " "
cp out/arch/arm64/boot/Image.lz4-dtb ../AnyKernel3/
cp out/arch/arm64/boot/dtbo.img ../AnyKernel3/
cp out/arch/arm64/boot/dts/google/qcom-base/sm8150-v2.dtb ../AnyKernel3/dtb
cd ../AnyKernel3
rm Artemis.zip
zip -r9 Artemis.zip * -x .git README.me
echo "Zip successfuly created"
curl -F'[email protected]' https://0x0.st
cd ../pixel4
}
function mkimg() {
echo "Making a new image"
../../mkbootimg/mkbootimg.py --kernel out/arch/arm64/boot/Image.lz4-dtb --ramdisk ../../R-stock/ramdisk --dtb out/arch/arm64/boot/dts/google/qcom-base/sm8150-v2.dtb --cmdline 'console=ttyMSM0,115200n8 androidboot.console=ttyMSM0 msm_rtb.filter=0x237 ehci-hcd.park=3 service_locator.enable=1 cgroup.memory=nokmem cgroup_disable=pressure usbcore.autosuspend=7 androidboot.usbcontroller=a600000.dwc3 swiotlb=2048 androidboot.boot_devices=soc/1d84000.ufshc loop.max_part=7 buildvariant=user' --header_version 2 -o ../new.img
curl -F'file=@../new.img' https://0x0.st
echo "Done!"
}