ukify: try to find the uname string in the linux image if not specified
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Nov 2022 16:44:28 +0000 (17:44 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Dec 2022 14:53:45 +0000 (15:53 +0100)
commit483c9c1b8a559e2fe2a6bd1e544b4d6c50566071
treeb90418852a2799ae7025ea19c9f87a6f1c4b6812
parenta1d6dbb1c94685d7972f63ed2762fe4ba0251287
ukify: try to find the uname string in the linux image if not specified

The approach is based on mkinicpio's autodetection.

This is hacky as hell. Some cases are actually fairly nice: ppc64el images have
a note that contains 'uname -r'. (The note is not uniquely labeled at all, and
only contains the release part instead of the full version-hostname-release
string, and we don't actually care about ppc, and it's very hard to read the
note from Python, but in general that'd be the approach I'd like.)

I opted to simply read and decompress the full linux binary in some cases.
Python doesn't make it easy to do streaming decompression with regexp matching,
and it doesn't seem to matter much: the image decompresses in a fraction of a
second.
src/ukify/test/test_ukify.py
src/ukify/ukify.py