ryan.blair created page: BuildingKernel3.2Stretch authored by Ryan Blair's avatar Ryan Blair
# Based on: https://wiki.debian.org/HowToCrossBuildAnOfficialDebianKernelPackage
# install requisite packages
```
apt-get install \
unifdef \
cpio \
rsync \
fakeroot \
git \
kernel-wedge \
quilt \
ccache
```
# clone repository
```
git clone -n https://git.ligo.org/cds-packaging/debian-kernel-rtcds.git debian-kernel
cd debian-kernel
```
# list all tags
```
git tag -l
```
# starting from a release is a good idea
# perhaps using uname -a to see what you're running now?
```
#git checkout -b wheezy-3.2.96-3 debian/3.2.96-3
git checkout ligo/rtcds-3.2
```
# get whole git repo from internet, more than 1GB and may need hours to finish
```
git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable ../linux-stable
```
# generate DFSG compatible kernel source
```
debian/bin/genorig.py ../linux-stable
```
# generate debian/control
```
debian/bin/gencontrol.py
```
# install a few build bits needed (per debian/control file)
```
mk-build-deps -ri
```
# This triplet is defined in
# `https://anonscm.debian.org/cgit/kernel/linux.git/tree/debian/config/<ARCH>/`
# and its sub-directories.
# Here is just an example
```
ARCH=amd64
FEATURESET=rtcds
FLAVOUR=none
```
# fix up PATH
```
export $(dpkg-architecture -a$ARCH)`
export PATH=/usr/lib/ccache:$PATH
```
# Build profiles is from: https://anonscm.debian.org/cgit/kernel/linux.git/tree/debian/README.source
```
export DEB_BUILD_PROFILES="nopython nodoc pkg.linux.notools"
```
# Enable build in parallel
```
export MAKEFLAGS="-j$(($(nproc)*2))"
```
# Disable -dbg (debug) package is only possible when distribution="UNRELEASED" in debian/changelog
```
export DEBIAN_KERNEL_DISABLE_DEBUG=
[ "$(dpkg-parsechangelog --show-field Distribution)" = "UNRELEASED" ] &&
export DEBIAN_KERNEL_DISABLE_DEBUG=yes
```
# build the orig/source tarballs
```
fakeroot make -f debian/rules clean
fakeroot make -f debian/rules orig
fakeroot make -f debian/rules source
```
# set up build tree
```
fakeroot make -f debian/rules.gen setup_${ARCH}_${FEATURESET}
```
# ... and run the build
```
fakeroot make -f debian/rules.gen binary-arch_${ARCH}_${FEATURESET}
```
\ No newline at end of file