fix(initrd): fix behavior quirk in module adding behavior
Variables modified within `while` loops are not usable outside of the loop. This results
in an interation for no Good Reason - the list of modules to add is empty at the end
anyways.
Instead, switch to a `for` loop and add the modules to a file.
Signed-off-by: Dilyn Corner <email address hidden>
fix(kernel): improve package version parsing (#6398)
Some kernels use different version strings independent of the Ubuntu
series. Modify the version string parsing function to normalise the
version string regardless of which Ubuntu series is being used.
This supports all version string formats:
- `x.y.z.a-b`
- `x.y.z-a-b`
- `x.y.z.a.b`
And converts them to the normalised format `x.y.z-a` which is used for
package names.
Additionally make the shell file testable by sourcing it with the
`SNAPCRAFT_TESTING` environment variable set.