[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to create a kernel package



Hans wrote:
I want to create a kernel package, which I can install with dpkg. There was a
command doing it instead of "make && make install", and I could not find it
any more. Last time I did it is a long time ago. Does someone know?

I also don't remember the old command, but this has been obsoleted by
the kernel itself, that has now a bindeb-pkg target.

So you'd do "make oldconfig bindeb-pkg" and you should end up with some
deb packages in the parent directory. If the build fails, you need to
install some -devel packages.

Then install the linux-image-*.deb package using dpkg -i.

Second question: My kernel sources are pointing with a symlink to /usr/src/
linux-5.10/, but by default there was a symlink to the headers, which is /usr/
src/linux-headers-5.10-*/.

No need to set up these links yourself, let the kernel development
package do that for you, if/when you install it.

For my understanding: When do I need this? I suppose, only when I want to
build modules, right?

Yes

Anything else to take notice of, i.e. adding a versionstring, so that I get
not in conflict with the debian repo packages?

You can set the CONFIG_LOCALVERSION in the kernel config file to add
some string to the kernel version, so it is unlikely to clash with the
upstream kernel version. It's useful to leave the Debian kernel
installed, in case your compiled kernel fails to boot.

FWIW, here is my script to build a kernel:

------------
#!/bin/sh
set -e

prog_name=`basename $0`
concurrency=16
suffix=".`whoami`"

usage() {
    echo "$prog_name [OPTIONS]"
}

help() {
    usage
    echo
    echo "OPTIONS"
    echo "  -h      show this help page"
    echo "  -j      number of parallel make threads (default: $concurrency)"
    echo "  -s      add suffix (default: $suffix)"
}


while getopts hj:s: opt; do
    case "$opt" in
        h)  help
            exit 0;;
        j)  concurrency="$OPTARG";;
        s)  suffix="$OPTARG";;
        \?)     # unknown flag
            usage >&2
            exit 1;;
    esac
done
shift `expr $OPTIND - 1`

if [ -n "$date" ]; then
    echo >&2 "Extra argument"
    exit 1
fi


sed -i -e 's/^#*\<CONFIG_LOCALVERSION\>.*/CONFIG_LOCALVERSION="'"$suffix"'"/' .config
make -j "$concurrency" clean oldconfig savedefconfig bindeb-pkg
-----------------

Thomas


Reply to: