New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fallback kernel version scraper #32
Conversation
I can't see how this is correct. Versions need to be suitable for dropping into a file path to the module directory, but yours will include an irrelevant preamble of This pull request should be 1 commit, not 4. |
Nope - this is
It does not, though I don't see the problem there. The banner is in the compressed chunk, so grep won't see it. It should work if you run it on a This is
The x86 kver extraction procedure is much more efficient and there's no reason to replace it with mine. This PR targets architectures for which:
There might be edge cases like people disabling printk+procfs completely so maybe the banner doesn't end up in the image. Regardless of how likely this is, they'll get an error message just like before. I spent a good hour or two this morning to read header files and linker scripts to see if I could find a well-known pointer to the location of a version string, like on x86. I couldn't find any. If anyone has a better approach I'd be way happier to save that 1.8s of my life spent watching mkinitcpio scan the kernel image, but until then this approach should be quite reliable and I think it is a good compromise.
No problem, I can squash it into one when it's ready to merge. Update: squashed into one commit. |
To add more context on why I think this is helpful: As of now, linux packages on non-x86 derivates hardcode the kernel version in Cool, it works. But what if I want to change the preset to add, for instance, a fallback image? If were to do that, I'd have to remember every time I update the kernel to update the version number in the preset, because pacman is not going to touch it any more since I changed it. Every time I forget to do it (which That adds up to ~30m of work. I'd gladly trade that half hour with an extra 1.8s when I run mkinitcpio. With this patch you can just point it to the kernel image and have it scrape it for you just like on x86, and enjoy custom presets. Note that this does not imply alarm or whatever derivative's kernels should update their presets to use this. They can (and should IMHO, since it's faster), keep it hardcoded. This is just an additional way to scrape the kversion that users who want to make their custom presets can use. Let me know if you have any questions |
I'm going over this PR and I think it's somewhat complex for little added benefit. Also, testing this is hard, because I would have to setup an arm VM in order to test it. I'll consider this for a future release of mkinitcpio. |
If it can be helpful you can also test this on x86 using an ALARM aarch64/armv7h-generic rootfs and This is probably easier than bringing up an ARM VM since setting up the emulated hardware is not as straightforward as for x86 VMs. |
I'll try to test this, but for a future release of mkinitcpio |
Using PCREs makes this way more expensive than it needs to be. $ time command grep -aPo -m 1 'Linux version \d+(\.\d+)+.*' vmlinux > /dev/null
real 0m0.262s
user 0m0.255s
sys 0m0.006s
$ time command grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+' vmlinux > /dev/null
real 0m0.013s
user 0m0.006s
sys 0m0.007s |
Thanks, it is indeed much faster:
I'll add this change and rebase it on top of master while I'm at it |
The kernel version scraper included in mkinitcpio works only on x86 kernel images. This commit implements kernel version scraping on a generic architecture if an uncompressed image is provided. Signed-off-by: Davide Depau <davide@depau.eu>
Can we get this feature merged? I got a PR with similar modification: #45 The benefit will be that, all other Arch based distros (ALARM/ManjaroARM) can get a much simpler preset for their mkinicpio, no need to specify specific kernel version. |
Unfortunately this version is a little too strict, as it ignores the tailing |
The kernel version scraper included in mkinitcpio works only on x86 kernel images.
This commit implements kernel version scraping on a generic architecture if an uncompressed image is provided.
With this commit I'm mainly targeting ALARM. However, since I wasn't able to find a static offset for the kernel version like on x86, I decided to go for a generic scraper that greps over the entire uncompressed image.
This is definitely inefficient, it takes ~300ms on my laptop with an NVMe SSD, 1.8s on my Rock64 with eMMC storage. However, it's better than nothing in my opinion, and people can still hardcode the kernel version in the preset just as before.