-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_kernel.sh
98 lines (72 loc) · 2.77 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
88
89
90
91
92
93
94
95
96
97
98
#! /bin/bash -e
work_dir=$(pwd)
echo "Script Working Dir: $work_dir"
# Prepare Raspberry-Linux
echo "\n============================ ! Prepare System APT ! ============================\n"
sudo dpkg --add-architecture arm64
sudo dpkg --print-foreign-architectures
sudo apt update
sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev crossbuild-essential-arm64 -y
sudo apt install zlib1g-dev:arm64 libblkid-dev:arm64 uuid-dev:arm64 libtirpc-dev:arm64 libudev-dev:arm64 libcrypt-dev:arm64 libssl-dev:arm64 libaio-dev:arm64 libattr1-dev:arm64 libelf-dev:arm64 libffi-dev:arm64 libcurl4-openssl-dev:arm64 libtool-bin -y
sudo apt install build-essential autoconf automake libtool gawk alien fakeroot dkms libblkid-dev uuid-dev libudev-dev libssl-dev zlib1g-dev libaio-dev libattr1-dev libelf-dev linux-headers-generic python3 python3-dev python3-setuptools python3-cffi libffi-dev python3-packaging git debhelper-compat dh-python po-debconf python3-all-dev python3-sphinx parallel rsync -y
# Prepare Raspberry-Linux
sleep 10
echo "\n============================ ! Prepare Raspberry-Linux ! ============================\n"
cd $work_dir/linux
git reset --hard
git clean -d --force
make clean -j$(nproc)
KERNEL=kernel8
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux-gnu- \
CC=aarch64-linux-gnu-gcc \
make -s -j$(nproc) bcm2711_defconfig
sleep 2
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux-gnu- \
CC=aarch64-linux-gnu-gcc \
make prepare scripts -j$(nproc)
# Build zfs
sleep 10
echo "\n============================ ! Build ZFS ! ============================\n"
cd $work_dir/zfs
git reset --hard
git clean -d --force
make clean -j$(nproc)
./autogen.sh
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux-gnu- \
CC=aarch64-linux-gnu-gcc \
./configure \
--build=x86_64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu \
--enable-linux-builtin=yes \
--with-linux=$work_dir/linux \
--with-linux-obj=$work_dir/linux
./copy-builtin $work_dir/linux
make -j$(nproc)
make install -j$(nproc)
# Build raspberry-pve-linux
sleep 10
echo "\============================ ! Build Raspberry-Linux ! ============================\n"
cd $work_dir/linux
# Only for Debugging
#cp $work_dir/.config ./.config
while true; do
read -p "Do you wish to copy the existing Kernel Configuration? (y/n)" yn
case $yn in
[Yy]* ) cp $work_dir/.config ./.config; break;;
[Nn]* ) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CC=aarch64-linux-gnu-gcc make menuconfig; break;;
* ) echo "Please answer yes or no.";;
esac
done
# Only for Debugging
#ARCH=arm64 \
#CROSS_COMPILE=aarch64-linux-gnu- \
#CC=aarch64-linux-gnu-gcc \
#make menuconfig
ARCH=arm64 \
CROSS_COMPILE=aarch64-linux-gnu- \
CC=aarch64-linux-gnu-gcc \
make deb-pkg -j$(nproc)
sleep 10
echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Build Successfull * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"