| 1 | #!/bin/sh -e |
|---|
| 2 | |
|---|
| 3 | # build-debirf-kernel: script to build debianized linux kernel package with |
|---|
| 4 | # the inittmpfs patch from Kent Robotti |
|---|
| 5 | # |
|---|
| 6 | # The debirf scripts were written by |
|---|
| 7 | # Jameson Rollins <jrollins@fifthhorseman.net> |
|---|
| 8 | # and |
|---|
| 9 | # Daniel Kahn Gillmor <dkg-debian.org@fifthhorseman.net>. |
|---|
| 10 | # |
|---|
| 11 | # They are Copyright 2007, and are all released under the GPL, |
|---|
| 12 | # version 3 or later. |
|---|
| 13 | |
|---|
| 14 | CMD=$(basename $0) |
|---|
| 15 | |
|---|
| 16 | BUILDDIR=${BUILDDIR:-~/src/linux} |
|---|
| 17 | KVERS=$(uname -r | cut -f1 -d-) |
|---|
| 18 | KAPPEND=$(uname -r | cut -f1 -d- --complement) |
|---|
| 19 | PKGREV=${KVERS}-${1:-1} |
|---|
| 20 | |
|---|
| 21 | usage() { |
|---|
| 22 | cat <<EOF |
|---|
| 23 | usage: $CMD [N] |
|---|
| 24 | N is package revision number (defaults to 1) |
|---|
| 25 | |
|---|
| 26 | Build a kernel for debirf. |
|---|
| 27 | |
|---|
| 28 | 'man build-debirf-kernel' for more information. |
|---|
| 29 | EOF |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | die() { |
|---|
| 33 | echo "$1" >&2 |
|---|
| 34 | exit $2 |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | # check for the proper packages: |
|---|
| 38 | if (! dpkg -l "linux-source-$KVERS" kernel-package fakeroot linux-patch-inittmpfs >/dev/null ); then |
|---|
| 39 | die "Not continuing until you have the right packages installed." 1 |
|---|
| 40 | fi |
|---|
| 41 | |
|---|
| 42 | # create a build directory |
|---|
| 43 | mkdir -p "$BUILDDIR" |
|---|
| 44 | cd "$BUILDDIR" |
|---|
| 45 | tar xjf "/usr/src/linux-source-$KVERS.tar.bz2" |
|---|
| 46 | cd "linux-source-$KVERS" |
|---|
| 47 | |
|---|
| 48 | # copy in your current config file: |
|---|
| 49 | cp "/boot/config-${KVERS}-${KAPPEND}" .config |
|---|
| 50 | # pre-answer "y" to "Unpack the early userspace onto tmpfs": |
|---|
| 51 | echo 'CONFIG_EARLYUSERSPACE_ON_TMPFS=y' >> .config |
|---|
| 52 | make-kpkg --rootcmd fakeroot --initrd --append_to_version "-${KAPPEND}+inittmpfs" --revision "$PKGREV" --added_patches inittmpfs kernel_image |
|---|
| 53 | |
|---|
| 54 | # now you should have a .deb in |
|---|
| 55 | # $BUILDDIR/linux-image-${KVERS}-${KAPPEND}_${PKGREV}_*.deb |
|---|