@ -39,7 +39,6 @@ def gpt_part_table(usb_disk):
elif b ' gpt ' in _cmd_out :
return True
elif platform . system ( ) == ' Windows ' :
win_usb_disk_no = str ( usb . get_physical_disk_number ( config . usb_disk ) )
if config . usb_gpt is True :
return True
elif config . usb_gpt is False :
@ -107,10 +106,10 @@ def syslinux_default(usb_disk):
if platform . system ( ) == ' Linux ' :
mbr_install_cmd = ' dd bs=440 count=1 conv=notrunc if= ' + mbr_bin + ' of= ' + usb_disk [ : - 1 ]
else :
win_usb_disk_no = str ( usb . get_physical_disk_number ( config . usb_disk ) )
win_usb_disk_no = get_physical_disk_number ( config . usb_disk )
_windd = resource_path ( os . path . join ( " data " , " tools " , " dd " , " dd.exe " ) )
_input = " if= " + mbr_bin
_output = ' of= \\ \ . \\ physicaldrive ' + win_usb_disk_no
_output = ' of= \\ \ . \\ physicaldrive ' + str ( win_usb_disk_no )
mbr_install_cmd = _windd + ' ' + _input + ' ' + _output + ' count=1 '
if usb_fs in extlinux_fs :
@ -299,42 +298,32 @@ def replace_grub_binary():
Default binaries will work for msdos partition table and therefore need not be replaced .
: return :
"""
grub_efi_bin_path = os . path . join ( config . usb_mount , ' EFI ' , ' BOOT ' , ' bootx64.efi ' )
grub_efi_bin_gpt_path = os . path . join ( config . usb_mount , ' EFI ' , ' BOOT ' , ' bootx64-gpt.efi ' )
grub_efi_bin_msdos_path = os . path . join ( config . usb_mount , ' EFI ' , ' BOOT ' , ' bootx64-msdos.efi ' )
core_img_bin_path = os . path . join ( config . usb_mount , ' multibootusb ' , ' grub ' , ' core.img ' )
core_img_bin_msdos_path = os . path . join ( config . usb_mount , ' multibootusb ' , ' grub ' , ' core-msdos.img ' )
core_img_bin_gpt_path = os . path . join ( config . usb_mount , ' multibootusb ' , ' grub ' , ' core-gpt.img ' )
if platform . system ( ) in [ ' Linux ' , ' Windows ' ] :
if gpt_part_table ( config . usb_disk ) is True :
log ( ' Replacing efi binary with gpt compatible one... ' )
try :
shutil . copy ( grub_efi_bin_gpt_path , grub_efi_bin_path )
except Exception as e :
log ( e )
log ( ' Failed to replace efi binary... ' )
log ( ' Replacing core.img binary with gpt compatible one... ' )
try :
shutil . copy ( core_img_bin_gpt_path , core_img_bin_path )
except Exception as e :
log ( e )
log ( ' Failed to replace efi binary... ' )
else :
log ( ' Replacing efi binary with msdos compatible one... ' )
try :
# shutil.copy(core_img_bin_gpt_path, core_img_bin_path)
shutil . copy ( grub_efi_bin_msdos_path , grub_efi_bin_path )
except Exception as e :
log ( e )
log ( ' Failed to replace efi binary... ' )
# There used to be msdos/gpt specific files installed and relevant
# ones were copied to target files. But those specific files were
# removed by commit ec0f8d95f98f65541c8734623d97f4bd3cbecf0f.
# Therefore, as of commit d3c7aa7dc72b3d442c854a6a89071d3f5995ec27,
# code segment below is effectively no-op.
if platform . system ( ) not in [ ' Linux ' , ' Windows ' ] :
return
ptype = gpt_part_table ( config . usb_disk ) and ' -gpt. ' or ' -msdos. '
for dir_ , fname in [
( os . path . join ( config . usb_mount , ' EFI ' , ' BOOT ' ) , ' bootx64.efi ' ) ,
( os . path . join ( config . usb_mount , ' multibootusb ' , ' grub ' ) , ' grub.img ' )
] :
base , ext = fname . split ( ' . ' )
src = os . path . join ( dir_ , base + ptype + ext )
dst = os . path . join ( dir_ , fname )
if os . path . exists ( src ) :
try :
log ( ' Replacing core.img with msdos compatible one...' )
shutil . copy ( core_img_bin_msdos_path, core_img_bin_path )
log ( ' Replacing %s with %s ... ' % ( dst , src ) )
shutil . copy ( src , dst )
except Exception as e :
log ( e )
log ( ' Failed to replace core.img binary... ' )
log ( ' Failed to replace %s with %s ... ' % ( dst , src ) )
if __name__ == ' __main__ ' :
if os . geteuid ( ) != 0 :