forked from fmarier/user-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_kernel
executable file
·37 lines (30 loc) · 981 Bytes
/
compile_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
#!/bin/bash
#
# Used to compile a custom vanilla kernel into a Debian package
#
if [ ! -r .config ] ; then
echo "You must be in the source directory of a configured kernel."
exit 1
fi
VERSION=$(git log --oneline | head | cut -d' ' -f2,3 | grep "^Linux" | head -1 | cut -d' ' -f2)
if [ "z$VERSION" = "z" ] ; then
echo "Could not extract kernel version from the git log."
exit 2;
fi
# Set the number of parallel runs of gcc
export CONCURRENCY_LEVEL=$1
if [ "z$1" = "z" ] ; then
export CONCURRENCY_LEVEL=3
fi
# Prime sudo for later
sudo -v
# Compile the kernel into a Debian package
sudo ionice -c3 fakeroot make-kpkg clean
nice eatmydata fakeroot make-kpkg --revision=1.0+custom kernel_image &
BACKGROUND_BUILD=$!
sudo ionice -c3 -p "$BACKGROUND_BUILD"
wait "$BACKGROUND_BUILD" || exit 1
# Install the package
sudo mount -o remount,exec /dev/mapper/ctmp
sudo dpkg -i "../linux-image-$VERSION-grsec+_1.0+custom_"*.deb
sudo mount -o remount /dev/mapper/ctmp