## Build Dragon Kernel

This page will describe how to easily build the Dragon Kernel.

The majority of users that are interested in building their own kernel are doing so because they have installed Ubuntu on their system and they wish to make a small change to the kernel for that system. In many cases the user just wants to make a kernel configuration change.

The purpose of this page is to give that user a minimum amount of information for them to meet the goal of making a simple change to the kernel, building it and installing their kernel. It is not intended to be the definitive guide to doing Ubuntu kernel development.

### Obtaining the source for an Dragon Kernel release

There are a number of different ways of getting the kernel sources. The two main ways will be documented here.

If you have installed a version of Ubuntu Disco and you want to make changes to the kernel that is installed on your system, use the apt method (described below) to obtain the sources.

However, if you wish to get the most up to date sources for the Ubuntu release you are running and make changes to that, use the git method (described below) to obtain the sources.

The source code which generated a specific binary package may be obtained using the apt source <package> command. For example to obtain the source for the currently running kernel you can use the command:

For default kernel:

# apt source linux-image-$(uname -r) For Dragon Kernel: # sudo add-apt-repository ppa:wip-kernel/genv5 # sudo apt update # apt source linux-source-5.2.15 From git: For example to obtain the precise tree All of the Dragon Kernel source is maintained under git. The source for each release is maintained in its own git repository on Dragon Team. To obtain a local copy you can simply git clone the repository for the release you are interested in as shown below. # git clone https://github.com/Dragon-Team/dragon-v5.git ### Build Environment If you have not built a kernel on your system before, there are some packages needed before you can successfully build. You can get these installed with: For default kernel: # sudo apt build-dep linux-image-$(uname -r)

For Dragon Kernel:

# sudo apt build-dep linux-source-5.2.15

The above command requires your system to have the correct deb-src lines in /etc/apt/sources.list.

For example, on default Disco you should have:

deb-src http://archive.ubuntu.com/ubuntu disco main
deb-src http://archive.ubuntu.com/ubuntu disco-updates main

For example, on Dragon Kernel (GENERIC) you should have:

deb-src http://ppa.launchpad.net/wip-kernel/genv5/ubuntu disco main

### Modifying the configuration

This step can be skipped if no configuration changes are wanted. The build process will use a configuration that is put together from various sub-config files. The simplest way to modify anything here is to run:

# chmod a+x debian/rules
# chmod a+x debian/scripts/*
# chmod a+x debian/scripts/misc/*
# fakeroot debian/rules clean
# fakeroot debian/rules editconfigs

You need to go through each (Y, Exit, Y, Exit..) or get a complaint about config later

This takes the current configuration for each architecture/flavour supported and calls menuconfig to edit its config file. The chmod is needed because the way the source package is created, it loses the executable bits on the scripts.

In order to make your kernel “newer” than the stock Dragon Kernel from which you are based you should add a local version modifier. Add something like “+test1” to the end of the first version number in the debian.master/changelog file, before building. This will help identify your kernel when running as it also appears in uname -a. Note that when a new Dragon Kernel is released that will be newer than your kernel (which needs regenerating), so care is needed when upgrading. NOTE: do not attempt to use CONFIG_LOCALVERSION as this will break the build.

### Building the kernel

Building the kernel is quite easy. Change your working directory to the root of the kernel source tree and then type the following commands:

Quicker build

# fakeroot debian/rules clean
# AUTOBUILD=1 fakeroot debian/rules binary-headers binary-arch-headers binary-generic binary-perarch skipdbg=true skipabi=false

If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version “5.2.15-dragon” on an amd64 system, these three (or four) .deb packages would be produced:

# cd ..
# ls *.deb
linux-buildinfo-5.2.15-dragon-sandybridge_5.2.15-dragon.201905210067_amd64.deb
linux-cloud-tools-5.2.15-dragon_5.2.15-dragon.201905210067_amd64.deb
linux-cloud-tools-5.2.15-dragon-sandybridge_5.2.15-dragon.201905210067_amd64.deb
linux-libc-dev_5.2.15-dragon.201905210067_amd64.deb
linux-image-unsigned-5.2.15-dragon-sandybridge_5.2.15-dragon.201905210067_amd64.deb
linux-modules-extra-5.2.15-dragon-sandybridge_5.2.15-dragon.201905210067_amd64.deb
linux-modules-5.2.15-dragon-sandybridge_5.2.15-dragon.201905210067_amd64.deb
linux-tools-5.2.15-dragon_5.2.15-dragon.201905210067_amd64.deb
linux-tools-5.2.15-dragon-sandybridge_5.2.15-dragon.201905210067_amd64.deb

### Testing and install the new kernel

Install the package set (on your build system, or on a different target system) with dpkg -i and then reboot:

# sudo dpkg -i *.deb
# sudo reboot

### Debug Symbols

Sometimes it is useful to have debug symbols built as well. Two additional steps are needed. First pkg-config-dbgsym needs to be installed. Second when executing the binary-* targets you need to add ‘skipdbg=false’.

# sudo apt install pkg-config-dbgsym
# fakeroot debian/rules clean
# AUTOBUILD=1 fakeroot debian/rules binary-headers binary-arch-headers binary-generic binary-perarch skipdbg=false skipabi=false