This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
patch_driver.sh
executable file
·75 lines (68 loc) · 3.45 KB
/
patch_driver.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
#!/bin/bash
set -eu -o pipefail
BUILD_PATH=/tmp/build-kernel
### Apple T2 drivers commit hashes
# Patches
APPLE_SMC_DRIVER_GIT_URL=https://github.com/AdityaGarg8/mojave-patches.git
APPLE_SMC_DRIVER_BRANCH_NAME=main
APPLE_SMC_DRIVER_COMMIT_HASH=67f914af7b2c553534d7a27c99a4f69179586d35
## BCE
#APPLE_BCE_DRIVER_GIT_URL=https://github.com/aunali1/mbp2018-bridge-drv.git
#APPLE_BCE_DRIVER_BRANCH_NAME=aur
#APPLE_BCE_DRIVER_COMMIT_HASH=c884d9ca731f2118a58c28bb78202a0007935998
## SPI
#APPLE_IB_DRIVER_GIT_URL=https://github.com/roadrunner2/macbook12-spi-driver.git
#APPLE_IB_DRIVER_BRANCH_NAME=mbp15
#APPLE_IB_DRIVER_COMMIT_HASH=90cea3e8e32db60147df8d39836bd1d2a5161871
rm -rf "${BUILD_PATH}"
mkdir -p "${BUILD_PATH}"
cd "${BUILD_PATH}" || exit
### AppleSMC and BT aunali fixes
git clone --single-branch --branch ${APPLE_SMC_DRIVER_BRANCH_NAME} ${APPLE_SMC_DRIVER_GIT_URL} \
"${BUILD_PATH}/linux-mbp-arch"
cd "${BUILD_PATH}/linux-mbp-arch" || exit
git checkout ${APPLE_SMC_DRIVER_COMMIT_HASH}
while IFS= read -r file; do
echo "==> Adding ${file}"
cp -rfv "${file}" "${WORKING_PATH}"/patches/"${file##*/}"
done < <(find "${BUILD_PATH}/linux-mbp-arch" -type f -name "*.patch" | grep -vE '000[0-9]' | sort)
#### Add custom drivers to kernel
#echo -e "From: \"Kernel Builder (sita)\" <ubuntu-kernel-bot@canonical.com>\nSubject: patch custom drivers\n" >"${WORKING_PATH}/patches/custom-drivers.patch"
#
#git clone --depth 1 --single-branch --branch v"${KERNEL_VERSION}" \
# git://kernel.ubuntu.com/virgin/linux-stable.git "${BUILD_PATH}/linux-stable"
#cd "${BUILD_PATH}/linux-stable/drivers" || exit
#
#### apple-bce
#git clone --depth 1 --single-branch --branch "${APPLE_BCE_DRIVER_BRANCH_NAME}" \
# "${APPLE_BCE_DRIVER_GIT_URL}" "${BUILD_PATH}/linux-stable/drivers/apple-bce"
#cd "${BUILD_PATH}/linux-stable/drivers/apple-bce" || exit
#git checkout "${APPLE_BCE_DRIVER_COMMIT_HASH}" && rm -rf .git
#
#cd "${BUILD_PATH}/linux-stable/drivers"
#cp -rfv "${WORKING_PATH}/templates/Kconfig" "${BUILD_PATH}/linux-stable/drivers/apple-bce/Kconfig"
#sed -i "s/TEST_DRIVER/APPLE_BCE_DRIVER/g" "${BUILD_PATH}/linux-stable/drivers/apple-bce/Kconfig"
## shellcheck disable=SC2016
#sed -i 's/obj-m/obj-$(CONFIG_APPLE_BCE)/g' "${BUILD_PATH}/linux-stable/drivers/apple-bce/Makefile"
## shellcheck disable=SC2016
#echo 'obj-$(CONFIG_APPLE_BCE) += apple-bce/' >>"${BUILD_PATH}/linux-stable/drivers/Makefile"
#sed -i "\$i source \"drivers/apple-bce/Kconfig\"\n" "${BUILD_PATH}/linux-stable/drivers/Kconfig"
#
#### apple-ib
#git clone --single-branch --branch "${APPLE_IB_DRIVER_BRANCH_NAME}" \
# "${APPLE_IB_DRIVER_GIT_URL}" "${BUILD_PATH}/linux-stable/drivers/apple-touchbar"
#cd "${BUILD_PATH}/linux-stable/drivers/apple-touchbar" || exit
#git checkout "${APPLE_IB_DRIVER_COMMIT_HASH}" && rm -rf .git
#
#cd "${BUILD_PATH}/linux-stable/drivers"
#cp -rfv "${WORKING_PATH}/templates/Kconfig" "${BUILD_PATH}/linux-stable/drivers/apple-touchbar/Kconfig"
#sed -i "s/TEST_DRIVER/APPLE_TOUCHBAR_DRIVER/g" "${BUILD_PATH}/linux-stable/drivers/apple-touchbar/Kconfig"
## shellcheck disable=SC2016
#sed -i 's/obj-m/obj-$(CONFIG_APPLE_TOUCHBAR)/g' "${BUILD_PATH}/linux-stable/drivers/apple-touchbar/Makefile"
## shellcheck disable=SC2016
#echo 'obj-$(CONFIG_APPLE_TOUCHBAR) += apple-touchbar/' >>"${BUILD_PATH}/linux-stable/drivers/Makefile"
#sed -i "\$i source \"drivers/apple-touchbar/Kconfig\"\n" "${BUILD_PATH}/linux-stable/drivers/Kconfig"
#
### Prepare patch
#git add .
#git diff HEAD >> "${WORKING_PATH}/patches/custom-drivers.patch"