feat: support zImage and bzImage in linux-kernel-cataloger (#4751)

Signed-off-by: Nadim Zubidat <nadimz@users.noreply.github.com>
This commit is contained in:
nadimz 2026-04-14 16:02:20 +02:00 committed by GitHub
parent 19b4f41270
commit c09f42e024
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 0 deletions

View File

@ -31,6 +31,10 @@ catalogers:
- '**/vmlinux-*'
- '**/vmlinuz'
- '**/vmlinuz-*'
- '**/bzImage'
- '**/bzImage-*'
- '**/zImage'
- '**/zImage-*'
- '**/lib/modules/**/*.ko'
metadata_types: # AUTO-GENERATED
- pkg.LinuxKernel

View File

@ -39,6 +39,10 @@ var kernelArchiveGlobs = []string{
"**/vmlinux-*",
"**/vmlinuz",
"**/vmlinuz-*",
"**/bzImage",
"**/bzImage-*",
"**/zImage",
"**/zImage-*",
}
var kernelModuleGlobs = []string{

View File

@ -0,0 +1,37 @@
package kernel
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseLinuxKernelMetadata_bzImage_PositiveCase(t *testing.T) {
magicType := []string{
"Linux kernel",
"x86 boot executable",
"bzImage",
"version 4.12.29-17011406-standard (oe-user@oe-host) #1 SMP Tue Apr 20 22:18:27 UTC 2021",
}
got := parseLinuxKernelMetadata(magicType)
assert.Equal(t, "x86", got.Architecture)
assert.Equal(t, "bzImage", got.Format)
assert.Equal(t, "4.12.29-17011406-standard", got.Version)
assert.NotEmpty(t, got.ExtendedVersion)
}
func TestParseLinuxKernelMetadata_bzImage_EmptyVersion(t *testing.T) {
magicType := []string{
"Linux kernel",
"x86 boot executable",
"bzImage",
// no "version ..." token
}
got := parseLinuxKernelMetadata(magicType)
assert.Equal(t, "bzImage", got.Format)
assert.Empty(t, got.Version, "version should be empty when no version token is present")
}