diff --git a/cmd/driver/printenv/printenv.go b/cmd/driver/printenv/printenv.go index b580c111..474c0b10 100644 --- a/cmd/driver/printenv/printenv.go +++ b/cmd/driver/printenv/printenv.go @@ -64,9 +64,6 @@ func (o *driverPrintenvOptions) RunDriverPrintenv(_ context.Context) error { if err != nil { return err } - fmt.Printf("ARCH=%s\n", kr.Architecture.ToNonDeb()) - fmt.Printf("KERNEL_RELEASE=%s\n", kr.String()) - fmt.Printf("KERNEL_VERSION=%s\n", kr.KernelVersion) d, err := driverdistro.DiscoverDistro(kr, driver.HostRoot) if err != nil { @@ -74,5 +71,10 @@ func (o *driverPrintenvOptions) RunDriverPrintenv(_ context.Context) error { } fmt.Printf("TARGET_ID=%s\n", d.String()) + fixedKr := d.FixupKernel(kr) + fmt.Printf("ARCH=%s\n", fixedKr.Architecture.ToNonDeb()) + fmt.Printf("KERNEL_RELEASE=%s\n", fixedKr.String()) + fmt.Printf("KERNEL_VERSION=%s\n", fixedKr.KernelVersion) + return nil } diff --git a/pkg/driver/distro/bottlerocket.go b/pkg/driver/distro/bottlerocket.go index 0abb0998..7638b5c5 100644 --- a/pkg/driver/distro/bottlerocket.go +++ b/pkg/driver/distro/bottlerocket.go @@ -52,7 +52,7 @@ func (b *bottlerocket) init(kr kernelrelease.KernelRelease, id string, cfg *ini. } //nolint:gocritic // the method shall not be able to modify kr -func (b *bottlerocket) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (b *bottlerocket) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { kr.KernelVersion = fmt.Sprintf("1_%s-%s", b.versionID, b.variantID) return kr } diff --git a/pkg/driver/distro/debian.go b/pkg/driver/distro/debian.go index 8b5b7480..4166bf86 100644 --- a/pkg/driver/distro/debian.go +++ b/pkg/driver/distro/debian.go @@ -42,7 +42,7 @@ func (d *debian) check(hostRoot string) bool { } //nolint:gocritic // the method shall not be able to modify kr -func (d *debian) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (d *debian) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { // Workaround: debian kernelreleases might not be actual kernel running; // instead, they might be the Debian kernel package // providing the compatible kernel ABI diff --git a/pkg/driver/distro/distro.go b/pkg/driver/distro/distro.go index cc2ce560..ac1e9889 100644 --- a/pkg/driver/distro/distro.go +++ b/pkg/driver/distro/distro.go @@ -50,7 +50,7 @@ var ErrUnsupported = fmt.Errorf("failed to determine distro") // Most of the distro-specific only partially override the default `generic` implementation. type Distro interface { init(kr kernelrelease.KernelRelease, id string, cfg *ini.File) error // private - fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease // private + FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease // private customizeBuild(printer *output.Printer, driverType drivertype.DriverType, kr kernelrelease.KernelRelease, hostRoot string) (map[string]string, error) PreferredDriver(kr kernelrelease.KernelRelease) drivertype.DriverType fmt.Stringer @@ -126,7 +126,7 @@ func toLocalPath(driverVer, fileName, arch string) string { func toFilename(d Distro, kr *kernelrelease.KernelRelease, driverName string, driverType drivertype.DriverType) string { // Fixup kernel information before attempting to download - fixedKR := d.fixupKernel(*kr) + fixedKR := d.FixupKernel(*kr) return fmt.Sprintf("%s_%s_%s_%s%s", driverName, d, fixedKR.String(), fixedKR.KernelVersion, driverType.Extension()) } @@ -158,7 +158,7 @@ func Build(d Distro, if err != nil { return "", err } - path, err := driverType.Build(printer, d.fixupKernel(kr), driverName, driverVer, env) + path, err := driverType.Build(printer, d.FixupKernel(kr), driverName, driverVer, env) if err != nil { return "", err } diff --git a/pkg/driver/distro/flatcar.go b/pkg/driver/distro/flatcar.go index 2a90816a..e4f3a9ea 100644 --- a/pkg/driver/distro/flatcar.go +++ b/pkg/driver/distro/flatcar.go @@ -74,7 +74,7 @@ func (f *flatcar) init(kr kernelrelease.KernelRelease, id string, cfg *ini.File) } //nolint:gocritic // the method shall not be able to modify kr -func (f *flatcar) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (f *flatcar) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { kr.Version = semver.MustParse(f.versionID) return kr } diff --git a/pkg/driver/distro/generic.go b/pkg/driver/distro/generic.go index 8500fbe5..34acc71d 100644 --- a/pkg/driver/distro/generic.go +++ b/pkg/driver/distro/generic.go @@ -39,7 +39,7 @@ func (g *generic) String() string { } //nolint:gocritic // the method shall not be able to modify kr -func (g *generic) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (g *generic) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { return kr } diff --git a/pkg/driver/distro/minikube.go b/pkg/driver/distro/minikube.go index afbf7778..48a5581d 100644 --- a/pkg/driver/distro/minikube.go +++ b/pkg/driver/distro/minikube.go @@ -67,7 +67,7 @@ func (m *minikube) check(hostRoot string) bool { } //nolint:gocritic // the method shall not be able to modify kr -func (m *minikube) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (m *minikube) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { kr.KernelVersion = fmt.Sprintf("1_%s", m.version) return kr } diff --git a/pkg/driver/distro/talos.go b/pkg/driver/distro/talos.go index 1ad6b692..adbde48f 100644 --- a/pkg/driver/distro/talos.go +++ b/pkg/driver/distro/talos.go @@ -44,7 +44,7 @@ func (t *talos) init(kr kernelrelease.KernelRelease, id string, cfg *ini.File) e } //nolint:gocritic // the method shall not be able to modify kr -func (t *talos) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (t *talos) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { kr.KernelVersion = fmt.Sprintf("1_%s", t.versionID) return kr } diff --git a/pkg/driver/distro/ubuntu.go b/pkg/driver/distro/ubuntu.go index 0d52da0c..b7710acc 100644 --- a/pkg/driver/distro/ubuntu.go +++ b/pkg/driver/distro/ubuntu.go @@ -47,7 +47,7 @@ func (u *ubuntu) init(kr kernelrelease.KernelRelease, _ string, f *ini.File) err } //nolint:gocritic // the method shall not be able to modify kr -func (u *ubuntu) fixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { +func (u *ubuntu) FixupKernel(kr kernelrelease.KernelRelease) kernelrelease.KernelRelease { // In the case that the kernelversion isn't just a number // we keep also the remaining part excluding `-Ubuntu`. // E.g.: