-
Notifications
You must be signed in to change notification settings - Fork 20
/
kernel-rebase.sh
executable file
·73 lines (56 loc) · 1.58 KB
/
kernel-rebase.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
#!/usr/bin/env bash
# Colours
RED='\033[0;31m'
GREEN='\033[0;32m'
NORMAL='\033[0m'
# Project Directory
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Variables
ACK_REPO="https://android.googlesource.com/kernel/common.git"
OEM_KERNEL=${1}
ACK_BRANCH=${2}
# Help Function
usage() {
echo -e "${0} \"link to oem kernel source (git)\" \"ack-branch\"
>> eg: ${0} \"https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git -b dandelion-q-oss\" \"android-4.9-q\""
}
# Abort Function
abort() {
[ ! -z "${@}" ] && echo -e ${RED}"${@}"${NORMAL}
exit 1
}
# Clone the OEM Kernel Source
git clone --depth=1 --single-branch $(echo ${OEM_KERNEL}) oem
# Clone the Android Common Kernel Source
git clone --single-branch -b ${ACK_BRANCH} ${ACK_REPO} kernel
# Get the OEM Kernel's Version
cd oem
OEM_KERNEL_VERSION=$(make kernelversion)
cd -
# Hard Reset ACK to ${OEM_KERNEL_VERSION}
cd kernel
OEM_KERNEL_VER_SHORT_SHA=$(git log --oneline ${ACK_BRANCH} Makefile | grep -i ${OEM_KERNEL_VERSION} | grep -i merge | cut -d ' ' -f1)
git reset --hard ${OEM_KERNEL_VER_SHORT_SHA}
cd -
# Get the list of Directories of the OEM Kernel
cd oem
OEM_DIR_LIST=$(find -type d -printf "%P\n" | grep -v / | grep -v .git)
cd -
# Start Rebasing
cd kernel
for i in ${OEM_DIR_LIST}; do
rm -rf ${i}
done
cd -
cp -r oem/* kernel/
cd kernel
for i in ${OEM_DIR_LIST}; do
git add ${i}
git commit -s -m "${i}: Import OEM Changes"
done
git add .
git commit -s -m "Import Remaining OEM Changes"
cd -
echo -e ${GREEN}"Your Kernel has been successfully rebased to ACK. Please check kernel/"${NORMAL}
# Exit
exit 0