Skip to content

Commit

Permalink
kernel plugin: properly generate Ubuntu kernel .config
Browse files Browse the repository at this point in the history
Recent Ubuntu kernels (>= Jammy) are now using a new format to store
their .config, called annotations [1].

The kernel plugin is trying to assemble a .config using the old config
chunks stored in `debian.<kernel>/config/*` that are not available
anymore in the kernels that are using this new annotations model.

Instead of trying to manually assemble the config we should rely on
`debian/rules genconfigs` that is more portable across different Ubuntu
kernels and releases.

[1] https://lists.ubuntu.com/archives/kernel-team/2023-June/140230.html

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed Jul 11, 2023
1 parent 4d0d751 commit cbf73b6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions snapcraft_legacy/plugins/v2/_kernel_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,20 @@ def _do_base_config_cmd(
logger.info("Using ubuntu config flavour %s", config_flavour)
conf_cmd = textwrap.dedent(
""" echo "Assembling Ubuntu config..."
branch=$(cut -d'.' -f 2- < ${{KERNEL_SRC}}/debian/debian.env)
baseconfigdir=${{KERNEL_SRC}}/debian.${{branch}}/config
archconfigdir=${{KERNEL_SRC}}/debian.${{branch}}/config/${{DEB_ARCH}}
ubuntuconfig=${{baseconfigdir}}/config.common.ubuntu
archconfig=${{archconfigdir}}/config.common.${{DEB_ARCH}}
flavourconfig=${{archconfigdir}}/config.flavour.{config_flavour}
cat ${{ubuntuconfig}} ${{archconfig}} ${{flavourconfig}} \
> {dest_dir}/.config 2>/dev/null || true
if [ -f ${{KERNEL_SRC}}/debian/rules ] && [ -x ${{KERNEL_SRC}}/debian/rules ]; then
# Generate Ubuntu kernel configs
pushd ${{KERNEL_SRC}}
fakeroot debian/rules clean genconfigs || true
popd
# Pick the right kernel .config for the target arch and flavour
ubuntuconfig=${{KERNEL_SRC}}/CONFIGS/${{DEB_ARCH}}-config.flavour.{config_flavour}
cat ${{ubuntuconfig}} > ${dest_dir}/.config
# Clean up kernel source directory
pushd ${{KERNEL_SRC}}
fakeroot debian/rules clean
rm -rf CONFIGS/
popd
fi""".format(
config_flavour=config_flavour, dest_dir=dest_dir
Expand Down

0 comments on commit cbf73b6

Please sign in to comment.