@@ -1328,33 +1328,60 @@ def prepare_hvm_system_linux(self, vm, init_script, extra_files=None):
1328
1328
1329
1329
def create_bootable_iso (self ):
1330
1330
"""Create simple bootable ISO image.
1331
- Type 'poweroff ' to it to terminate that VM.
1331
+ Type 'halt ' to it to terminate that VM.
1332
1332
"""
1333
- isolinux_cfg = (
1334
- 'prompt 1\n '
1335
- 'label poweroff\n '
1336
- ' kernel poweroff.c32\n '
1337
- )
1338
1333
output_fd , output_path = tempfile .mkstemp ('.iso' )
1339
1334
with tempfile .TemporaryDirectory () as tmp_dir :
1335
+ f = os .open (tmp_dir , os .O_RDONLY | os .O_DIRECTORY )
1340
1336
try :
1341
- shutil .copy ('/usr/share/syslinux/isolinux.bin' , tmp_dir )
1342
- shutil .copy ('/usr/share/syslinux/ldlinux.c32' , tmp_dir )
1343
- shutil .copy ('/usr/share/syslinux/poweroff.c32' , tmp_dir )
1344
- with open (os .path .join (tmp_dir , 'isolinux.cfg' ), 'w' ) as cfg :
1345
- cfg .write (isolinux_cfg )
1346
- subprocess .check_call (['genisoimage' , '-o' , output_path ,
1347
- '-c' , 'boot.cat' ,
1348
- '-b' , 'isolinux.bin' ,
1337
+ os .mkdir ('os' , mode = 0o755 , dir_fd = f )
1338
+ os .mkdir ('iso' , mode = 0o755 , dir_fd = f )
1339
+ os .mkdir ('os/images' , mode = 0o755 , dir_fd = f )
1340
+ os .mkdir ('os/EFI' , mode = 0o755 , dir_fd = f )
1341
+ os .mkdir ('os/EFI/BOOT' , mode = 0o755 , dir_fd = f )
1342
+ with open (f'/proc/self/fd/{ f } /os/images/boot_hybrid.img' , 'wb' ) as v :
1343
+ subprocess .check_call (['grub2-mkimage' ,
1344
+ '-O' , 'i386-pc-eltorito' ,
1345
+ '-d' , '/usr/lib/grub/i386-pc' ,
1346
+ '-p' , '/boot/grub2' ,
1347
+ 'iso9660' , 'biosdisk' , 'halt' ], stdout = v )
1348
+ with open (f'/proc/self/fd/{ f } /os/EFI/BOOT/BOOTX64.EFI' , 'wb' ) as v :
1349
+ subprocess .check_call (['grub2-mkimage' ,
1350
+ '-O' , 'x86_64-efi' ,
1351
+ '-d' , '/usr/lib/grub/x86_64-efi' ,
1352
+ '-p' , '/boot/grub2' ,
1353
+ 'iso9660' , 'disk' , 'halt' ], stdout = v )
1354
+ graft_path = '.=' + os .path .join (tmp_dir , "os" ).replace ("\\ " , "\\ \\ " ).replace ("=" , "\\ =" )
1355
+ efiboot_img = os .path .join (tmp_dir , 'os/images/efiboot.img' )
1356
+ subprocess .check_call (['sudo' , 'mkefiboot' , '--label=ANACONDA' ,
1357
+ os .path .join (tmp_dir , 'os/EFI/BOOT' ),
1358
+ efiboot_img ])
1359
+ subprocess .check_call (['sudo' , 'chmod' , '-R' , 'go+rX' , tmp_dir ])
1360
+ subprocess .check_call (['xorrisofs' ,
1361
+ '-o' , output_path ,
1362
+ '--grub2-mbr' , 'os/images/boot_hybrid.img' ,
1363
+ '--mbr-force-bootable' ,
1364
+ '--gpt-iso-bootable' ,
1365
+ '-partition_offset' , '16' ,
1366
+ '-append_partition' , '2' , '0xef' , efiboot_img ,
1367
+ '-iso_mbr_part_type' , 'EBD0A0A2-B9E5-4433-87C0-68B6B72699C7' ,
1368
+ '-appended_part_as_gpt' ,
1369
+ '-c' , 'boot.cat' , '--boot-catalog-hide' ,
1370
+ '-eltorito-boot' , 'images/boot_hybrid.img' ,
1349
1371
'-no-emul-boot' ,
1350
1372
'-boot-load-size' , '4' ,
1351
1373
'-boot-info-table' ,
1352
- '-q' ,
1353
- tmp_dir ])
1354
- except FileNotFoundError :
1355
- self .skipTest ('syslinux or genisoimage not installed' )
1356
- os .close (output_fd )
1357
- self .addCleanup (os .unlink , output_path )
1374
+ '--grub2-boot-info' ,
1375
+ '-eltorito-alt-boot' ,
1376
+ '-e' , '--interval:appended_partition_2:all::' ,
1377
+ '-no-emul-boot' ,
1378
+ '-graft-points' , graft_path ,
1379
+ 'boot/grub2/i386-pc=/usr/lib/grub/i386-pc' ,
1380
+ 'boot/grub2/x86_64-efi=/usr/lib/grub/x86_64-efi' ],
1381
+ cwd = tmp_dir )
1382
+ self .addCleanup (os .unlink , output_path )
1383
+ finally :
1384
+ os .close (f )
1358
1385
return output_path
1359
1386
1360
1387
def create_local_file (self , filename , content , mode = 'w' ):
0 commit comments