-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile-kernel
More file actions
executable file
·62 lines (51 loc) · 1.52 KB
/
compile-kernel
File metadata and controls
executable file
·62 lines (51 loc) · 1.52 KB
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
#!/bin/sh
set -e
while getopts 'b:k:ch' arg
do
case "$arg" in
'b') kbranch="$OPTARG";;
'k') kver="$OPTARG";;
'c') cleanup_after_build=true;;
'h') echo "Usage: $(basename $0) [-b KERNEL_BRANCH] [-k KERNEL_VERSION] [-c] {-h}"; exit 1;;
?) echo "Type '$(basename $0) -h' for a list of available options."; exit 1;;
esac
done
if test -z "${kbranch}"
then
echo "error: kernel branch not specified"
exit 1
fi
if test -z "${kver}"
then
echo "Error: kernel version not specified"
exit 1
fi
if test -z "${cleanup_after_build}"
then
cleanup_after_build="false"
fi
if test "$(whoami)" != "root"
then
echo "You must execute this script as root"
exit 1
fi
if test ! "$(command -v apt)"
then
echo "error: apt: could not find such package manager"
fi
if test ! -d "linux-${kbranch}.${kver}"
then
echo "Downloading file linux-${kbranch}.${kver}.tar.xz..."
curl -fSLO "https://cdn.kernel.org/pub/linux/kernel/v${kbranch}.x/linux-${kbranch}.${kver}.tar.xz"
echo "Extracting linux-${kbranch}.${kver}.tar.xz..."
tar xf "linux-${kbranch}.${kver}.tar.xz"
fi
cd "linux-${kbranch}.${kver}"
apt install -y build-essential flex bison libssl-dev libelf-dev debhelper-compat libdw-dev
make ARCH=$(uname -m) defconfig && LOCALVERSION=-custom nice make -j $(nproc --all) bindeb-pkg
if test "${cleanup_after_build}" == "true"
then
apt purge -y --autoremove build-essential dpkg-dev flex bison libssl-dev libelf-dev debhelper-compat libdw-dev
else
echo "Not cleaning up"
fi