-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-kernel
executable file
·72 lines (63 loc) · 2.13 KB
/
build-kernel
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
#!/bin/bash
#
# Build-kernel builds a linux kernel with a specific version of GCC;
# It defaults to the version that was used to build your currently
# running kernel. It supports concurrency for SMP and multicore
# systems, nicing, and other niceties.
#
# Copyright (C) 2011-2016 Nicholas D Steeves <[email protected]>
# Distributed under the terms of the GPLv2 license.
#
# This script needs kernel-package and fakeroot
NICE="yes" # To nice kernel compilation, set to "yes"
EMAIL="username@domain"
TODAY=`date +%Y%m%d`
export CONCURRENCY_LEVEL=`grep -c ^processor /proc/cpuinfo | sed 's/^0$/1/'`
CCV=`cat /proc/version | sed 's/.*gcc version //' | cut -c 1-3`
# Alternatively, specifify a specific version as follows (gcc-4.9)
# CCV="4.9"
export MAKEFLAGS="CC=gcc-$CCV"
if [ ! -x "$(command -v gcc-$CCV)" ]; then
echo "A suitable gcc version was not found"
echo "Please install gcc-$CCV before continuing"
exit 1
fi
make oldconfig
grep CONFIG_IOSCHED_BFQ=y .config
if [ $? -eq 0 ]; then
BFQ='+bfq'
fi
if [ "$NICE" = "yes" ]; then
time nice fakeroot make-kpkg binary-arch --initrd --append-to-version=$BFQ."${TODAY}" || exit $?
else
time fakeroot make-kpkg binary-arch --initrd --append-to-version=$BFQ."${TODAY}" || exit $?
fi
for i in VERSION PATCHLEVEL SUBLEVEL; do
TMP=`grep ^$i Makefile | awk '{print $3}'`
export "${i}"=$TMP
done
echo "Linux kernel ${VERSION}.${PATCHLEVEL}.${SUBLEVEL}.${TODAY} is ready to be installed" \
| mail -s "New kernel is ready" $EMAIL
while true; do
printf "Would you like to install the new kernel? (yes/no) "
read choice
case "$choice" in
yes | y | Yes | YES )
break
;;
no | n | No | NO )
echo "If you say so . . . "
sleep 1
echo "Goodbye!"
exit 1
;;
* )
printf "Please answer yes or no\n\n"
;;
esac
done
sudo dpkg -i \
../linux-headers-${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${BFQ}.${TODAY}_*.deb \
../linux-image-${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${BFQ}.${TODAY}_*.deb \
|| exit $?
echo "Please reboot to activate new kernel"