@@ -5,8 +5,10 @@ import (
55 "os"
66 "path"
77
8+ "github.com/FascodeNet/alterlinux/alteriso5/utils"
89 "github.com/FascodeNet/alterlinux/alteriso5/work/boot"
910 "github.com/Hayao0819/nahi/cputils"
11+ "github.com/Hayao0819/nahi/exutils"
1012 osutils "github.com/Hayao0819/nahi/futils"
1113)
1214
@@ -23,18 +25,18 @@ var makeCommonSystemdBoot *BuildTask = NewBuildTask("makeCommonSystemdBoot", fun
2325 // For UEFI x64
2426 if w .profile .HasBootMode (boot .UefiX64SystemdBootEsp ) || w .profile .HasBootMode (boot .UefiX64SystemdBootElTorito ) {
2527 efiboot_files = append (efiboot_files ,
26- path . Join (w .Dirs .Pacstrap , "usr" , " lib" , " systemd" , " boot" , " efi" , " systemd-bootx64.efi" ),
27- path . Join (w .Dirs .Pacstrap , "usr" , " share" , " edk2-shell" , " x64" , " Shell_Full.efi" ),
28- path . Join (w .Dirs .Pacstrap , "boot" , " memtest86+" , " memtest.efi" ),
29- path . Join (w .Dirs .Pacstrap , "usr" , " share" , " licenses" , " spdx" , " GPL-2.0-only.txt" ),
28+ utils . Slash (w .Dirs .Pacstrap , "/ usr/ lib/ systemd/ boot/ efi/ systemd-bootx64.efi" ),
29+ utils . Slash (w .Dirs .Pacstrap , "/ usr/ share/ edk2-shell/ x64/ Shell_Full.efi" ),
30+ utils . Slash (w .Dirs .Pacstrap , "/ boot/ memtest86+/ memtest.efi" ),
31+ utils . Slash (w .Dirs .Pacstrap , "/ usr/ share/ licenses/ spdx/ GPL-2.0-only.txt" ),
3032 )
3133 }
3234
3335 // For UEFI ia32
3436 if w .profile .HasBootMode (boot .UefiIa32SystemdBootEsp ) || w .profile .HasBootMode (boot .UefiIa32SystemdBootElTorito ) {
3537 efiboot_files = append (efiboot_files ,
36- path . Join (w .Dirs .Pacstrap , "usr" , " lib" , " systemd" , " boot" , " efi" , " systemd-bootia32.efi" ),
37- path . Join (w .Dirs .Pacstrap , "usr" , " share" , " edk2-shell" , " ia32" , " Shell_Full.efi" ),
38+ utils . Slash (w .Dirs .Pacstrap , "/ usr/ lib/ systemd/ boot/ efi/ systemd-bootia32.efi" ),
39+ utils . Slash (w .Dirs .Pacstrap , "/ usr/ share/ edk2-shell/ ia32/ Shell_Full.efi" ),
3840 )
3941 }
4042
@@ -70,10 +72,10 @@ var makeCommonSystemdBoot *BuildTask = NewBuildTask("makeCommonSystemdBoot", fun
7072 }
7173
7274 // For efiboot files
73- if err := os .MkdirAll (path . Join ( w . Base , w . target . Arch , "efiboot" ) , 0755 ); err != nil {
75+ if err := os .MkdirAll (w . Dirs . Efiboot , 0755 ); err != nil {
7476 return err
7577 }
76- sizes , err := osutils .GetFileSizesInDir (path . Join ( w . Base , w . target . Arch , "efiboot" ) )
78+ sizes , err := osutils .GetFileSizesInDir (w . Dirs . Efiboot )
7779 if err != nil {
7880 return err
7981 }
@@ -118,7 +120,8 @@ var makeCommonSystemdBootConfigIsofs *BuildTask = NewBuildTask("makeCommonSystem
118120var makeCommonSystemdBootConfigEsp * BuildTask = NewBuildTask ("makeCommonSystemdBootConfigEsp" , func (w Work ) error {
119121
120122 // mcopy -i "${efibootimg}" -s "${work_dir}/loader" ::/
121- return nil
123+ cmd := exutils .CommandWithStdio ("mcopy" , "-i" , w .Files .EfibootImg , "-s" , path .Join (w .Dirs .WorkArch , "loader" ), "::/" )
124+ return cmd .Run ()
122125})
123126
124127var makeUefiX64SystemdBootEsp * BuildTask = NewBuildTask ("makeUefiX64SystemdBootEsp" , func (w Work ) error {
@@ -135,15 +138,27 @@ var makeUefiX64SystemdBootEsp *BuildTask = NewBuildTask("makeUefiX64SystemdBootE
135138 }
136139
137140 // Copy systemd-boot EFI binary to the default/fallback boot path
138- // mcopy -i "${efibootimg}" \
139- // "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" ::/EFI/BOOT/BOOTx64.EFI
141+ {
142+ systemdBootEfi := utils .Slash (w .Dirs .Pacstrap , "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" )
143+ err := exutils .CommandWithStdio ("mcopy" , "-i" , w .Files .EfibootImg , systemdBootEfi , "::/EFI/BOOT/BOOTx64.EFI" ).Run ()
144+ if err != nil {
145+ return err
146+ }
147+ }
140148
141149 // Copy systemd-boot configuration files
142150 if err := w .RunOnce (makeCommonSystemdBootConfigEsp ); err != nil {
143151 return err
144152 }
145153
146154 // shellx64.efi is picked up automatically when on /
155+ {
156+ shellEfi := utils .Slash (w .Dirs .Pacstrap , "/usr/share/edk2-shell/x64/Shell_Full.efi" )
157+ err := exutils .CommandWithStdio ("mcopy" , "-i" , w .Files .EfibootImg , shellEfi , "::/shellx64.efi" ).Run ()
158+ if err != nil {
159+ return err
160+ }
161+ }
147162
148163 return nil
149164})
@@ -158,14 +173,23 @@ var makeUefiX64SystemdBootElTorito *BuildTask = NewBuildTask("makeUefiX64Systemd
158173 }
159174
160175 // Additionally set up systemd-boot in ISO 9660. This allows creating a medium for the live environment by using
161- // manual partitioning and simply copying the ISO 9660 file system contents.
162- // This is not related to El Torito booting and no firmware uses these files.
163- // _msg_info "Preparing an /EFI directory for the ISO 9660 file system..."
164- // install -d -m 0755 -- "${isofs_dir}/EFI/BOOT"
165-
166- // Copy systemd-boot EFI binary to the default/fallback boot path
167- // install -m 0644 -- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \
168- // "${isofs_dir}/EFI/BOOT/BOOTx64.EFI"
176+ // manual partitioning and simply copying the ISO 9660 file system contents.
177+ // This is not related to El Torito booting and no firmware uses these files.
178+ slog .Info ("Preparing an /EFI directory for the ISO 9660 file system..." )
179+ if err := os .MkdirAll (path .Join (w .Dirs .Iso , "EFI" , "BOOT" ), 0755 ); err != nil {
180+ return err
181+ }
182+
183+ // Copy systemd-boot EFI binary to the default/fallback boot path
184+ systemdBootEfi := utils .Slash (w .Dirs .Pacstrap , "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" )
185+ t := cputils.CopyTask {
186+ Source : systemdBootEfi ,
187+ Dest : path .Join (w .Dirs .Iso , "EFI" , "BOOT" , "BOOTx64.EFI" ),
188+ Perm : 0644 ,
189+ }
190+ if err := cputils .CopyAll (t ); err != nil {
191+ return err
192+ }
169193
170194 if err := w .RunOnce (makeCommonSystemdBootConfigIsofs ); err != nil {
171195 return err
0 commit comments