summaryrefslogtreecommitdiff
path: root/scripts/build-kernel
blob: e58d2d5aea039ecefa11816ce4b9138875222651 (plain)
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
#!/bin/bash
if [ ! -f "Makefile" ]; then
  echo "Makefile missing, This script needs to be executed inside the vyos-kernel package directory"
  exit 1
fi

if grep -Fxq "KBUILD_OUTPUT" Makefile; then
  echo "Wrong Makefile?, This script needs to be executed inside the vyos-kernel package directory"
  exit 1
fi


# newer Kernel versions come with a "# SPDX-License-Identifier: GPL-2.0" identifier
# as the first line in the file - use compatible approach with grep rather then sed
VERSION=$(grep "^VERSION" Makefile | grep -Eo '[0-9]{1,4}')
PATCHLEVEL=$(grep "^PATCHLEVEL" Makefile | grep -Eo '[0-9]{1,4}')
SUBLEVEL=$(grep "^SUBLEVEL" Makefile | grep -Eo '[0-9]{1,4}')
ARCH=$(dpkg --print-architecture)

case "$ARCH" in
    amd64)
        make x86_64_vyos_defconfig
        TARGETS="kernel_headers kernel_image"
        # the following targets are not supported for Linux Kernels > 4.14 as
        # they have been removed from the Makefile (commits 18afab8c1d3c2 &
        # 22cba31bae9dc).
        if [ ${PATCHLEVEL} -lt 14 ]; then
            TARGETS+=" kernel_manual kernel_doc"
        fi
        CONCURRENCY_LEVEL=4 LOCALVERSION="" make-kpkg --rootcmd fakeroot --initrd --append_to_version -amd64-vyos --revision=$VERSION.$PATCHLEVEL.$SUBLEVEL-1+vyos1+current1 -j$(cat /proc/cpuinfo | grep processor | wc -l) ${TARGETS}
    ;;

    armhf)
        make armhf_vyos_defconfig
    ;;
esac