Compiling image with same kernel as the repos?

Hello all,

I am wondering what to do to compile an image in such a way that packages depending on the kernel work fine? Currently all my images fail to install any kernel-related packages through opkg as the kernel version doesn't match the one I've got.


Yes, in theory you can reproduce the version hash used for kernel and kernel depending packages (they are reproducable), you 'just' need to use the exact same git commits (easy) for master repo and feeds - and then use the exact same kernel config (not so easy, the kernel's version hash includes the kernel configuration), this implies building all packages which may indirectly select kernel symbols to be enabled.

In practice this makes very little sense, as you can't change anything remotely kernel related (as the hash must match) and need to build a lot of unnecessary packages which do influence the kernel configuration. This means your results will be (almost, at least as far as the kernel is involved) exactly as if you had taken a prebuilt image in the first place, at which point building it yourself (almost) becomes useless busy-work.

It usually makes more sense to build exactly what you (may) need for your image yourself, to include it directly into the image you're building. As a result you'd never need to use opkg (as everything is already part of your self-built image) and never get into version mismatches in the first place. Whenever you actually encounter a new kernel package you didn't know about while building your image, you just add it to your (diff)config and rebuild and sysupgrade to the new version.

If you don't actually want to change the source (kernel or userland), but just need a different package selection for your device, the imagebuilder might be a better option - as this just regenerates the firmware images from existing binaries (no change to version hash) according to your needs.


Yes, you can; but kernel must be compiled with exactly the same parameters. Any change in the configuration during the build will make them incompatible.