forked from OpenHD/OpenHD-KernelBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·137 lines (100 loc) · 3.77 KB
/
build.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
#!/bin/bash
PLATFORM=$1
DISTRO=$2
##############
### Config ###
##############
# Fixed at v5.2.20 until 5.3.4 works for injection
RTL_8812AU_REPO=https://github.com/OpenHD/rtl8812au.git
RTL_8812AU_BRANCH=20201214.1-new
RTL_8812BU_REPO=https://github.com/OpenHD/rtl88x2bu.git
RTL_8812BU_BRANCH=5.6.1_30362.20181109_COEX20180928-6a6a
RTL_8188EUS_REPO=https://github.com/OpenHD/rtl8188eus.git
RTL_8188EUS_BRANCH=v5.3.9-fix
V4L2LOOPBACK_REPO=https://github.com/OpenHD/v4l2loopback.git
V4L2LOOPBACK_BRANCH=openhd2
EXFAT_REPO=https://github.com/OpenHD/exfat-linux.git
EXFAT_BRANCH=openhd2
#####################
### BUILD HELPERS ###
#####################
SRC_DIR=$(pwd)
LINUX_DIR=$(pwd)/linux-${PLATFORM}
CONFIGS=$(pwd)/configs
J_CORES=$(nproc)
PACKAGE_DIR=$(pwd)/package
# load helper scripts
for File in scripts/*.sh; do
source ${File}
echo "LOAD ${File}"
done
# Remove previous build dir and recreate
init
################### Env's like $ARCH
### BUILD ENV's ### and $CROSS_COMPILE
################### are set here
setup_pi_env
build_pi_kernel() {
echo "Building pi kernel"
pushd ${LINUX_DIR}
echo "Set kernel config"
cp "${CONFIGS}/.config-${KERNEL_BRANCH}-${ISA}" ./.config || exit 1
make clean
yes "" | make oldconfig || exit 1
KERNEL=${KERNEL} KBUILD_BUILD_TIMESTAMP='' make -j $J_CORES zImage modules dtbs || exit 1
echo "Copy kernel"
cp arch/arm/boot/zImage "${PACKAGE_DIR}/usr/local/share/openhd/kernel/${KERNEL}.img" || exit 1
echo "Copy kernel modules"
make -j $J_CORES INSTALL_MOD_PATH="${PACKAGE_DIR}" modules_install || exit 1
echo "Copy DTBs"
cp arch/arm/boot/dts/*.dtb "${PACKAGE_DIR}/usr/local/share/openhd/kernel/dtb/" || exit 1
cp arch/arm/boot/dts/overlays/*.dtb* "${PACKAGE_DIR}/usr/local/share/openhd/kernel/overlays/" || exit 1
cp arch/arm/boot/dts/overlays/README "${PACKAGE_DIR}/usr/local/share/openhd/kernel/overlays/" || exit 1
# prevents the inclusion of firmware that can conflict with normal firmware packages, dpkg will complain. there
# should be a kernel config to stop installing this into the package dir in the first place
rm -r "${PACKAGE_DIR}/lib/firmware/*"
pushd tools/perf
#ARCH=${ARCH} KERNEL=${KERNEL} make perf || exit 1
#cp perf ${PACKAGE_DIR}/usr/local/bin/perf-${KERNEL_VERSION} || exit 1
popd
popd
# Build Realtek drivers
build_rtl8812au_driver
build_rtl8812bu_driver
build_rtl8188eus_driver
cp ${SRC_DIR}/overlay/boot/* "${PACKAGE_DIR}/usr/local/share/openhd/kernel/" || exit 1
depmod -b ${PACKAGE_DIR} ${KERNEL_VERSION}
}
prepare_build() {
check_time
fetch_pi_source
fetch_rtl8812au_driver
fetch_rtl8812bu_driver
fetch_rtl8188eus_driver
fetch_v4l2loopback_driver
# on the pi our kernel is new enough that we don't need to add the exfat driver anymore
if [[ ! "${PLATFORM}" == "pi" ]]; then
fetch_exfat_driver
fi
build_pi_kernel
}
if [[ "${PLATFORM}" == "pi" ]]; then
# a simple hack, we want 2 kernels in one package so we source 2 different configs and build them all.
# note that pi zero kernels are not being generated here because they are prepackaged with a specific
# kernel build. this is a temporary thing due to the unique issues with USB on the pi zero.
source $(pwd)/kernels/${PLATFORM}-${DISTRO}-v7
prepare_build
if [[ -f "$(pwd)/kernels/${PLATFORM}-${DISTRO}-v7l" ]]; then
source $(pwd)/kernels/${PLATFORM}-${DISTRO}-v7l
prepare_build
fi
if [[ -f "$(pwd)/kernels/${PLATFORM}-${DISTRO}-v6" ]]; then
source $(pwd)/kernels/${PLATFORM}-${DISTRO}-v6
prepare_build
fi
fi
copy_overlay
package
post_processing
# Show cache stats
ccache -s