RFC: our kernel snap "build" easily packages the wrong kernel version
Kamal Mostafa
kamal at canonical.com
Fri Apr 21 18:47:25 UTC 2017
This version: string in snapcraft.yaml *looks* like a kernel version number
and it is what sets the version of the snap itself...
$ grep version snapcraft.yaml
version: 4.4.0-71.92
But it actually has no correlation to the actual kernel version which
gets downloaded (not actually "built" at all *cough*) and packaged into
the snap.
Our Makefile blindly fetches and apt-install's the "latest published" kernel
version from the archive. Thus, it is painfully easy to accidentally
produce a kernel snap with version 'A' but which actually contains kernel
version 'B'. If I simply git fetch the current snap repo[0] and build
it right now, I get this crazy result:
$ grep version snapcraft.yaml
version: 4.4.0-71.92
$ sudo snapcraft
[...] Unpacking linux-image-4.4.0-72-generic (4.4.0-72.93) ...
[...] Snapped pc-kernel_4.4.0-71.92_amd64.snap
The snap version is "4.4.0-71.92" but really contains the 72.93 kernel! If
I build this snap from the exact same SHA next week, then I'll get the 73.94
kernel!
I propose that we fix this by tweaking the Makefile to apt-install the
*specific* kernel version matching the snap version number. That's an easy
change to the PACKAGE line(s) in the Makefile, e.g.:
-PACKAGE := linux-signed-generic
+PACKAGE := linux-signed-generic=$(SNAPCRAFT_PROJECT_VERSION)
However -- because the $(PACKAGE) being installed there is the actually the
meta package -- that then also means that all of the snapcraft.yaml's
versions will need to be set to the desired kernel *meta* version
instead of the image version, e.g. "version: 4.4.0.72.78" instead of
"version: 4.4.0-72.93".
With that change in place, snapcraft will now (sanely!) fail if you try to
package a kernel (meta) version that it cannot download, instead of blindly
packaging some arbitrary kernel version du-jour.
Otherwise, the only change in the result is that the snap version number will
of course now match the kernel meta version instead of the the image version:
$ grep version snapcraft.yaml
version: 4.4.0.72.78
$ sudo snapcraft
[...] Unpacking linux-image-4.4.0-72-generic (4.4.0-72.93) ...
[...] Snapped pc-kernel_4.4.0.72.78_amd64.snap
Comments on this proposal?
-Kamal
[0] git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-snap/+git/xenial pc
More information about the kernel-team
mailing list