Rebuild VyOS kernel Step

From VyOS Wiki
Revision as of 14:24, 2 October 2018 by C-po (talk | contribs) (VyOS 1.2.x)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Rebuild VyOS kernel Step

VyOS 1.1.x

First clone build-iso.

git clone git://
cd build-iso

Update submodule. $branch is branch name (eg. helium)

Available flavors.

  • amd64-vyos
  • amd64-vyos-virt
  • 586-vyos
  • 586-vyos-virt

git submodule update --init pkgs/linux-image
cd pkgs/linux-image
git checkout $branch

Execute to generate control file. and ignore last error.

./debian/bin/ $flavor

make[1]: *** [debian/control-real] Error 1
make[1]: Leaving directory `/home/arch/build-iso/pkgs/linux-image'
make: *** [debian/control] Error 2

Make sure you have required tools installed

apt-get install devscripts kernel-package bc

Finally, execute make

cd ../../ # Top directory in build-iso.
make linux-image

VyOS 1.2.x

Please use the steps below when working with VyOS 1.2.x.

Clone the repository

shell> git clone

Initialize submodule

shell> cd vyos-build
shell> git submodule update --init packages/vyos-kernel

Checkout current branch

shell> cd packages/vyos-kernel
shell> git checkout current

Load VyOS Kernel configuration

shell> make x86_64_vyos_defconfig

Compile the Kernel

shell> LOCALVERSION="" make-kpkg --rootcmd fakeroot --initrd --append_to_version -amd64-vyos --revision=4.4.95-1+vyos1+current1 kernel_source kernel_debug kernel_headers kernel_manual kernel_doc kernel_image

Embedded Shell Script

This is actually the command which runs on the Jenkins Server to build the Kernel:

cd vyos-kernel
RELEASE=`echo $GIT_BRANCH | sed 's/origin\//* /g' |sed -n 's/^\* \(.*\)$/\1/p'`

if [ "${RELEASE}" = "helium" ]; then
    rm -f ../*.deb
    make -f debian/rules clean
    make -f debian/rules source-all
    dpkg-buildpackage -b -us -uc
    # 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)
    rm -f ../*.deb

    case "$ARCH" in
            make x86_64_vyos_defconfig
            TARGETS="kernel_source kernel_debug 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"
            CONCURRENCY_LEVEL=4 LOCALVERSION="" make-kpkg --rootcmd fakeroot --initrd --append_to_version -amd64-vyos --revision=$VERSION.$PATCHLEVEL.$SUBLEVEL-1+vyos1+current1 -j4 ${TARGETS}

            make armhf_vyos_defconfig