@@ -63,8 +63,8 @@ type UkiKernelInfo struct {
6363 Initramfs string `json:"initramfs,omitempty"` // Optional: empty in modify mode
6464}
6565
66- func baseImageHasUkis (imageChroot * safechroot.Chroot ) (bool , error ) {
67- espDir := filepath .Join (imageChroot .RootDir (), EspDir )
66+ func baseImageHasUkis (imageChroot * safechroot.Chroot , distroHandler DistroHandler ) (bool , error ) {
67+ espDir := filepath .Join (imageChroot .RootDir (), distroHandler . GetEspDir () )
6868 ukiFiles , err := getUkiFiles (espDir )
6969 if err != nil {
7070 return false , fmt .Errorf ("failed to check for UKI files:\n %w" , err )
@@ -112,8 +112,8 @@ func baseImageHasUkiAddons(espPath string) (bool, error) {
112112// - mode: create: Extract and regenerate UKIs
113113// - mode: passthrough: Preserve existing UKIs without modification
114114// - mode: modify: Check for addon, modify addon only (preserve main UKI)
115- func validateUkiMode (imageConnection * imageconnection.ImageConnection , uki * imagecustomizerapi.Uki ) error {
116- hasUkis , err := baseImageHasUkis (imageConnection .Chroot ())
115+ func validateUkiMode (imageConnection * imageconnection.ImageConnection , uki * imagecustomizerapi.Uki , distroHandler DistroHandler ) error {
116+ hasUkis , err := baseImageHasUkis (imageConnection .Chroot (), distroHandler )
117117 if err != nil {
118118 return err
119119 }
@@ -157,7 +157,7 @@ func validateUkiMode(imageConnection *imageconnection.ImageConnection, uki *imag
157157
158158 // For modify mode, validate that base image has UKI addons
159159 if uki .Mode == imagecustomizerapi .UkiModeModify {
160- espDir := filepath .Join (imageConnection .Chroot ().RootDir (), EspDir )
160+ espDir := filepath .Join (imageConnection .Chroot ().RootDir (), distroHandler . GetEspDir () )
161161 hasAddons , err := baseImageHasUkiAddons (espDir )
162162 if err != nil {
163163 return fmt .Errorf ("failed to check for UKI addons:\n %w" , err )
@@ -173,8 +173,8 @@ func validateUkiMode(imageConnection *imageconnection.ImageConnection, uki *imag
173173}
174174
175175// extractAndSaveUkiCmdline extracts the kernel cmdline from existing UKI addons and saves them to uki-kernel-info.json.
176- func extractAndSaveUkiCmdline (buildDir string , imageChroot * safechroot.Chroot ) error {
177- espDir := filepath .Join (imageChroot .RootDir (), EspDir )
176+ func extractAndSaveUkiCmdline (buildDir string , imageChroot * safechroot.Chroot , distroHandler DistroHandler ) error {
177+ espDir := filepath .Join (imageChroot .RootDir (), distroHandler . GetEspDir () )
178178 ukiFiles , err := getUkiFiles (espDir )
179179 if err != nil {
180180 return fmt .Errorf ("failed to get UKI files:\n %w" , err )
@@ -307,13 +307,13 @@ func prepareUkiHelper(ctx context.Context, buildDir string, uki *imagecustomizer
307307 }
308308
309309 // Extract kernel command line arguments from either grub.cfg or UKI.
310- espDir := filepath .Join (imageChroot .RootDir (), EspDir )
310+ espDir := filepath .Join (imageChroot .RootDir (), distroHandler . GetEspDir () )
311311 kernelToArgs , err := extractKernelToArgs (espDir , bootDir , buildDir )
312312 if err != nil {
313313 return fmt .Errorf ("%w:\n %w" , ErrUKIKernelCmdlineExtract , err )
314314 }
315315
316- err = cleanBootDirectory (imageChroot )
316+ err = cleanBootDirectory (imageChroot , distroHandler )
317317 if err != nil {
318318 return fmt .Errorf ("%w:\n %w" , ErrUKICleanBootDir , err )
319319 }
@@ -965,13 +965,17 @@ func getKernelNameFromUki(ukiPath string) (string, error) {
965965 fileName := filepath .Base (ukiPath )
966966
967967 matches := ukiNamePattern .FindStringSubmatch (fileName )
968- if len (matches ) != 2 {
969- return "" , fmt .Errorf ("invalid UKI file name: (%s)" , fileName )
968+ if len (matches ) == 2 {
969+ // Standard UKI naming: vmlinuz-<version>.efi → vmlinuz-<version>
970+ return "vmlinuz-" + matches [1 ], nil
970971 }
971972
972- // Reconstruct kernel name (vmlinuz-<version>, e.g., vmlinuz-6.6.51.1-5.azl3)
973- kernelName := "vmlinuz-" + matches [1 ]
974- return kernelName , nil
973+ // Non-standard UKI naming (e.g., acl.efi): use filename without .efi extension
974+ if strings .HasSuffix (fileName , ".efi" ) {
975+ return strings .TrimSuffix (fileName , ".efi" ), nil
976+ }
977+
978+ return "" , fmt .Errorf ("invalid UKI file name: (%s)" , fileName )
975979}
976980
977981func extractSectionFromUkiWithObjcopy (ukiPath string , sectionName string , outputPath string , buildDir string ) error {
@@ -998,22 +1002,22 @@ func extractSectionFromUkiWithObjcopy(ukiPath string, sectionName string, output
9981002 return nil
9991003}
10001004
1001- func extractKernelAndInitramfsFromUkis (ctx context.Context , imageChroot * safechroot.Chroot , buildDir string ) error {
1002- err := extractKernelAndInitramfsFromUkisHelper (ctx , imageChroot , buildDir )
1005+ func extractKernelAndInitramfsFromUkis (ctx context.Context , imageChroot * safechroot.Chroot , buildDir string , distroHandler DistroHandler ) error {
1006+ err := extractKernelAndInitramfsFromUkisHelper (ctx , imageChroot , buildDir , distroHandler )
10031007 if err != nil {
10041008 return fmt .Errorf ("%w:\n %w" , ErrUKIExtractComponents , err )
10051009 }
10061010
10071011 return nil
10081012}
10091013
1010- func extractKernelAndInitramfsFromUkisHelper (ctx context.Context , imageChroot * safechroot.Chroot , buildDir string ) error {
1014+ func extractKernelAndInitramfsFromUkisHelper (ctx context.Context , imageChroot * safechroot.Chroot , buildDir string , distroHandler DistroHandler ) error {
10111015 logger .Log .Infof ("Extracting kernel and initramfs from existing UKIs for re-customization" )
10121016
10131017 _ , span := otel .GetTracerProvider ().Tracer (OtelTracerName ).Start (ctx , "extract_kernel_initramfs_from_ukis" )
10141018 defer span .End ()
10151019
1016- espDir := filepath .Join (imageChroot .RootDir (), EspDir )
1020+ espDir := filepath .Join (imageChroot .RootDir (), distroHandler . GetEspDir () )
10171021 ukiFiles , err := getUkiFiles (espDir )
10181022 if err != nil {
10191023 return err
@@ -1121,9 +1125,9 @@ func cleanUkiDirectory(ukiOutputDir string) error {
11211125 return nil
11221126}
11231127
1124- func cleanBootDirectory (imageChroot * safechroot.Chroot ) error {
1128+ func cleanBootDirectory (imageChroot * safechroot.Chroot , distroHandler DistroHandler ) error {
11251129 bootPath := filepath .Join (imageChroot .RootDir (), BootDir )
1126- espPath := filepath .Join (imageChroot .RootDir (), EspDir )
1130+ espPath := filepath .Join (imageChroot .RootDir (), distroHandler . GetEspDir () )
11271131
11281132 dirEntries , err := os .ReadDir (bootPath )
11291133 if err != nil {
0 commit comments