2
0
mirror of https://github.com/mbusb/multibootusb synced 2024-11-01 15:40:16 +00:00
This commit is contained in:
mbusb 2017-04-20 19:50:20 +05:30
commit cb3bd559e2
9 changed files with 47 additions and 46 deletions

View File

@ -162,7 +162,7 @@ def detect_iso_from_file_list(iso_link):
elif any("dban" in s.lower() for s in iso_file_list): elif any("dban" in s.lower() for s in iso_file_list):
return "slitaz" return "slitaz"
elif any("memtest.img" in s.lower() for s in iso_file_list): elif any("memtest.img" in s.lower() for s in iso_file_list):
return "mentest" return "memtest"
elif any("mt86.png" in s.lower() for s in iso_file_list) and any("isolinux" in s.lower() for s in iso_file_list): elif any("mt86.png" in s.lower() for s in iso_file_list) and any("isolinux" in s.lower() for s in iso_file_list):
return 'raw_iso' return 'raw_iso'
elif any("menu.lst" in s.lower() for s in iso_file_list): elif any("menu.lst" in s.lower() for s in iso_file_list):

View File

@ -81,7 +81,7 @@ def mbusb_update_grub_cfg():
elif config.distro == 'ReactOS': elif config.distro == 'ReactOS':
f.write(' menuentry ' + iso.iso_basename(config.image_path) + f.write(' menuentry ' + iso.iso_basename(config.image_path) +
' {multiboot /loader/setupldr.sys}' + "\n") ' {multiboot /loader/setupldr.sys}' + "\n")
elif config.distro == 'mentest': elif config.distro == 'memtest':
f.write(' menuentry ' + iso.iso_basename(config.image_path) + f.write(' menuentry ' + iso.iso_basename(config.image_path) +
' {linux16 ' + '/multibootusb/' + iso.iso_basename(config.image_path) + '/BISOLINUX/MEMTEST}' + "\n") ' {linux16 ' + '/multibootusb/' + iso.iso_basename(config.image_path) + '/BISOLINUX/MEMTEST}' + "\n")
elif syslinux_menu is not None: elif syslinux_menu is not None:

View File

@ -101,8 +101,8 @@ def install_distro():
os.system('sync') os.system('sync')
if config.persistence != 0: if config.persistence != 0:
log('Creating Persistence...') log('Creating persistence...')
config.status_text = 'Creating Persistence...' config.status_text = 'Creating persistence...'
persistence.create_persistence() persistence.create_persistence()
install_patch() install_patch()

View File

@ -642,9 +642,9 @@ class ISO9660:
########################################################################### ###########################################################################
def dump_dir_record(dirs): def dump_dir_record(dirs):
""" Dump all the file dirctory records contained in desc_buf """ """ Dump all the file directory records contained in desc_buf """
gen.log("Dump file/deirectory record") gen.log("Dump file/directory record")
gen.log("===========================", end="\n") gen.log("===========================", end="\n")
if dirs != None: if dirs != None:
for f in dirs: for f in dirs:
@ -705,7 +705,7 @@ def dump_boot_record(volume_dsc):
gen.log("boot system identifier(%s)" %bootsys_identifier) gen.log("boot system identifier(%s)" %bootsys_identifier)
boot_identifier = volume_dsc[39:71] boot_identifier = volume_dsc[39:71]
gen.log("boot identifier(%s)" %boot_identifier) gen.log("boot identifier(%s)" %boot_identifier)
def usage(): def usage():
""" Prompt user how to use """ """ Prompt user how to use """

View File

@ -277,9 +277,9 @@ Are you SURE you want to enable it?",
log("File not selected...") log("File not selected...")
def ui_update_persistence(self): def ui_update_persistence(self):
log("===== config.persistence_available = " + str(config.persistence_available)) # log("===== config.persistence_available = " + str(config.persistence_available))
log("===== config.persistence_max_size = " + str(config.persistence_max_size)) # log("===== config.persistence_max_size = " + str(config.persistence_max_size))
log("===== config.persistence = " + str(config.persistence)) # log("===== config.persistence = " + str(config.persistence))
if config.persistence_available and config.persistence_max_size: if config.persistence_available and config.persistence_max_size:
self.ui.label_persistence_value.setVisible(True) self.ui.label_persistence_value.setVisible(True)
self.ui.label_persistence.setVisible(True) self.ui.label_persistence.setVisible(True)
@ -457,17 +457,17 @@ Are you SURE you want to enable it?",
# extract_cfg_file(config.image_path) # Extract files from ISO # extract_cfg_file(config.image_path) # Extract files from ISO
# config.distro = distro(iso_cfg_ext_dir(), config.image_path) # Detect supported distro # config.distro = distro(iso_cfg_ext_dir(), config.image_path) # Detect supported distro
usb_details = usb.details(config.usb_disk) usb_details = usb.details(config.usb_disk)
log("MultiBoot Install: USB Disk is " + config.usb_disk) log("MultiBoot Install: USB Disk: " + config.usb_disk)
log("MultiBoot Install: USB Label is " + config.usb_label) log("MultiBoot Install: USB Label: " + config.usb_label)
log("MultiBoot Install: USB UUID is " + config.usb_uuid) log("MultiBoot Install: USB UUID: " + config.usb_uuid)
log("MultiBoot Install: USB Mount path is " + config.usb_mount) log("MultiBoot Install: USB mount path: " + config.usb_mount)
log("MultiBoot Install: Total size of the disk is " + str(usb.bytes2human(usb_details['size_total']))) log("MultiBoot Install: Disk total size: " + str(usb.bytes2human(usb_details['size_total'])))
log("MultiBoot Install: Total used size is " + str(usb.bytes2human(usb_details['size_used']))) log("MultiBoot Install: Disk used size: " + str(usb.bytes2human(usb_details['size_used'])))
log("MultiBoot Install: Total size left on the disk is " + str(usb.bytes2human(usb_details['size_free']))) log("MultiBoot Install: Disk free size: " + str(usb.bytes2human(usb_details['size_free'])))
log("MultiBoot Install: FileSystem is " + usb_details['file_system']) log("MultiBoot Install: Filesystem: " + usb_details['file_system'])
log("MultiBoot Install: Vendor is " + usb_details['vendor']) log("MultiBoot Install: Disk vendor: " + usb_details['vendor'])
log("MultiBoot Install: Model is " + usb_details['model']) log("MultiBoot Install: Disk model: " + usb_details['model'])
log("MultiBoot Install: Name of the ISO file is " + iso_name(config.image_path)) log("MultiBoot Install: ISO file: " + iso_name(config.image_path))
if os.path.exists(config.image_path): if os.path.exists(config.image_path):
self.ui.image_path.clear() self.ui.image_path.clear()
@ -476,7 +476,7 @@ Are you SURE you want to enable it?",
copy_mbusb_dir_usb(config.usb_disk) copy_mbusb_dir_usb(config.usb_disk)
if not os.path.exists(os.path.join(config.usb_mount, "multibootusb", iso_basename(config.image_path))): if not os.path.exists(os.path.join(config.usb_mount, "multibootusb", iso_basename(config.image_path))):
config.persistence = self.ui.slider_persistence.value() * 1024 * 1024 config.persistence = self.ui.slider_persistence.value() * 1024 * 1024
log("Persistence chosen is " + str(bytes2human(config.persistence)) + " MB") log("Persistence chosen is " + str(bytes2human(config.persistence)))
install_size = iso_size(config.image_path) + config.persistence install_size = iso_size(config.image_path) + config.persistence
if install_size >= disk_usage(config.usb_mount).free: if install_size >= disk_usage(config.usb_mount).free:
log("ERROR: Not enough space available on " + config.usb_disk) log("ERROR: Not enough space available on " + config.usb_disk)

View File

@ -67,23 +67,23 @@ def create_persistence():
if platform.system() == 'Linux': if platform.system() == 'Linux':
mkfs = 'mkfs.ext3' mkfs = 'mkfs.ext3'
dd = 'dd' dd = 'dd'
persistence_mkfs_cmd = mkfs + ' -F ' + os.path.join(config.usb_mount, 'multibootusb', persistence_mkfs_cmd = mkfs + ' -F ' + gen.quote(os.path.join(config.usb_mount, 'multibootusb',
iso.iso_basename(config.image_path), iso.iso_basename(config.image_path),
fs_name) fs_name))
elif platform.system() == 'Windows': elif platform.system() == 'Windows':
mkfs = gen.quote(gen.resource_path(os.path.join("data", "tools", "mkfs", "mke2fs.exe"))) mkfs = gen.quote(gen.resource_path(os.path.join("data", "tools", "mkfs", "mke2fs.exe")))
dd = gen.quote(gen.resource_path(os.path.join("data", "tools", "dd", "dd.exe"))) dd = gen.quote(gen.resource_path(os.path.join("data", "tools", "dd", "dd.exe")))
persistence_mkfs_cmd = 'echo y|' + mkfs + ' -b 1024 -L ' + fs_name + ' ' + os.path.join(config.usb_mount, 'multibootusb', persistence_mkfs_cmd = 'echo y|' + mkfs + ' -b 1024 -L ' + fs_name + ' ' + gen.quote(os.path.join(config.usb_mount, 'multibootusb',
iso.iso_basename(config.image_path), fs_name) iso.iso_basename(config.image_path), fs_name))
if config.distro == 'fedora': if config.distro == 'fedora':
persistence_dd_cmd = dd + ' if=/dev/zero ' \ persistence_dd_cmd = dd + ' if=/dev/zero ' \
'of=' + os.path.join(config.usb_mount, 'multibootusb', 'of=' + gen.quote(os.path.join(config.usb_mount, 'multibootusb',
iso.iso_basename(config.image_path), 'LiveOS', fs_name) + \ iso.iso_basename(config.image_path), 'LiveOS', fs_name)) + \
' bs=1M count=' + str(int(persistence)) ' bs=1M count=' + str(int(persistence))
else: else:
persistence_dd_cmd = dd + ' if=/dev/zero of=' + os.path.join(config.usb_mount, 'multibootusb', persistence_dd_cmd = dd + ' if=/dev/zero of=' + gen.quote(os.path.join(config.usb_mount, 'multibootusb',
iso.iso_basename(config.image_path), fs_name) +\ iso.iso_basename(config.image_path), fs_name)) +\
' bs=1M count=' + str(int(persistence)) ' bs=1M count=' + str(int(persistence))
gen.log('Executing ==>' + persistence_dd_cmd) gen.log('Executing ==>' + persistence_dd_cmd)

View File

@ -63,7 +63,7 @@ def syslinux_default(usb_disk, version=4):
config.status_text = 'Installing mbr...' config.status_text = 'Installing mbr...'
log ('\nExecuting ==> ' + mbr_install_cmd) log ('\nExecuting ==> ' + mbr_install_cmd)
if subprocess.call(mbr_install_cmd, shell=True) == 0: if subprocess.call(mbr_install_cmd, shell=True) == 0:
config.status_text = 'mbr install is success...' config.status_text = 'mbr install is successful...'
log("\nmbr install is success...\n") log("\nmbr install is success...\n")
if set_boot_flag(usb_disk) is True: if set_boot_flag(usb_disk) is True:
return True return True
@ -158,13 +158,13 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
log ("Executing ==> " + sys_cmd) log ("Executing ==> " + sys_cmd)
config.status_text = 'Installing distro specific syslinux...' config.status_text = 'Installing distro specific syslinux...'
if subprocess.call(sys_cmd, shell=True) == 0: if subprocess.call(sys_cmd, shell=True) == 0:
config.status_text = 'Syslinux install on distro directory is success...' config.status_text = 'Syslinux install on distro directory is successful...'
log ("\nSyslinux install on distro directory is success...\n") log ("\nSyslinux install on distro directory is successful...\n")
log ('Executing ==> ' + dd_cmd + '\n') log ('Executing ==> ' + dd_cmd + '\n')
config.status_text = 'Copying boot sector...' config.status_text = 'Copying boot sector...'
if subprocess.call(dd_cmd, shell=True) == 0: if subprocess.call(dd_cmd, shell=True) == 0:
config.status_text = 'Bootsector copy is success...' config.status_text = 'Bootsector copy is successful...'
log ("\nBootsector copy is success...\n") log ("\nBootsector copy is successful...\n")
else: else:
config.status_text = 'Failed to copy boot sector...' config.status_text = 'Failed to copy boot sector...'
log ("\nFailed to copy boot sector...\n") log ("\nFailed to copy boot sector...\n")
@ -182,7 +182,7 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
log("\nExecuting ==> " + sys_cmd + '\n') log("\nExecuting ==> " + sys_cmd + '\n')
config.status_text = 'Installing distro specific syslinux...' config.status_text = 'Installing distro specific syslinux...'
if subprocess.call(sys_cmd, shell=True) == 0: if subprocess.call(sys_cmd, shell=True) == 0:
config.status_text = 'Syslinux install on distro directory is success...' config.status_text = 'Syslinux install on distro directory is successful...'
log ("\nSyslinux install was successful on distro directory...\n") log ("\nSyslinux install was successful on distro directory...\n")
else: else:
config.status_text = 'Failed to install syslinux on distro directory...' config.status_text = 'Failed to install syslinux on distro directory...'
@ -197,10 +197,10 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
subprocess.call('chmod +x ' + syslinux_path, shell=True) == 0 subprocess.call('chmod +x ' + syslinux_path, shell=True) == 0
log ("Executing ==> " + ext_cmd) log ("Executing ==> " + ext_cmd)
if subprocess.call(ext_cmd, shell=True) == 0: if subprocess.call(ext_cmd, shell=True) == 0:
log ("\nSyslinux install on distro directory is success...\n") log ("\nSyslinux install on distro directory is successful...\n")
log ('Executing ==> ' + dd_cmd, '\n') log ('Executing ==> ' + dd_cmd, '\n')
if subprocess.call(dd_cmd, shell=True) == 0: if subprocess.call(dd_cmd, shell=True) == 0:
log ("\nBootsector copy is success...\n") log ("\nBootsector copy is successful...\n")
else: else:
log ("\nFailed to install syslinux on distro directory...\n") log ("\nFailed to install syslinux on distro directory...\n")

View File

@ -327,7 +327,7 @@ def update_mbusb_cfg_file(iso_link, usb_uuid, usb_mount, distro):
"fromusb root=UUID=" + usb_uuid + " bootfromiso=/multibootusb/" + "fromusb root=UUID=" + usb_uuid + " bootfromiso=/multibootusb/" +
iso_basename(iso_link) + "/" + iso_name(iso_link) + " initrd=/multibootusb/" iso_basename(iso_link) + "/" + iso_name(iso_link) + " initrd=/multibootusb/"
+ iso_basename(iso_link) + '/isolinux/initrd.gz' + "\n") + iso_basename(iso_link) + '/isolinux/initrd.gz' + "\n")
elif distro == "mentest": elif distro == "memtest":
config_file.write("kernel " + '/multibootusb/' + iso_basename(iso_link) + '/BOOT/MEMTEST.IMG\n') config_file.write("kernel " + '/multibootusb/' + iso_basename(iso_link) + '/BOOT/MEMTEST.IMG\n')
elif distro == "sgrubd2" or config.distro == 'raw_iso': elif distro == "sgrubd2" or config.distro == 'raw_iso':

View File

@ -98,15 +98,16 @@ def list_devices(partition=1, fixed=False):
import pyudev import pyudev
context = pyudev.Context() context = pyudev.Context()
for device in context.list_devices(subsystem='block', ID_BUS="usb"):
devices.append(str(device['DEVNAME']))
gen.log("\t" + device['DEVNAME'])
if fixed is True: if fixed is True:
for device in context.list_devices(subsystem='block'): for device in context.list_devices(subsystem='block'):
if device.get('ID_BUS') in ("usb", "scsi", "ata") and device['DEVTYPE'] in ['disk', 'partition']: if device.get('DEVTYPE') in ['disk', 'partition'] and device.get('ID_PART_TABLE_TYPE'):
devices.append(str(device['DEVNAME'])) if device['DEVNAME'] not in devices:
gen.log("\t" + device['DEVNAME']) devices.append(str(device['DEVNAME']))
else: gen.log("\t" + device['DEVNAME'])
for device in context.list_devices(subsystem='block', ID_BUS="usb"):
devices.append(str(device['DEVNAME']))
gen.log("\t" + device['DEVNAME'])
except: except:
import dbus import dbus