2
0
mirror of https://github.com/mbusb/multibootusb synced 2024-11-01 15:40:16 +00:00

Small improvements and added a distro

1. Added syslinux.bin and an entry in grub.cfg so as to chainload to syslinux from grub2
2. Added grml
3. Kill windows explorer when writing ISO image to USB (This is reqired to prevent dd.exe from failing)
4. Load combobox with detected drive when loading GUI
5. File dialog remembers last opened file directory
6. Logging syslinux install command
This commit is contained in:
mbusb 2017-04-16 22:19:18 +05:30
parent 1c6cd4fff7
commit 704769a81c
8 changed files with 67 additions and 12 deletions

2
.gitignore vendored
View File

@ -103,4 +103,4 @@ multibootusb*.exe
*.swp
# Test file which I work on to test logic before committing to main file.
mbusb*py
mbusb_te*py

View File

@ -37,9 +37,14 @@ set color_highlight=white/light-blue
export color_normal
export color_highlight
menuentry "Boot Plop Boot Manager"{
if [ ${grub_platform} == "pc" ]; then
menuentry "Load Syslinux Boot Loader"{
chainloader /multibootusb/syslinux.bin
}
menuentry "Boot Plop Boot Manager"{
linux16 /multibootusb/plpbt
}
}
fi
# Load windows boot loaders from USB drive
source /multibootusb/grub/win.cfg

Binary file not shown.

View File

@ -60,6 +60,8 @@ def distro(iso_cfg_ext_dir, iso_link):
return "kaos"
elif re.search(r'boot=live', string, re.I) and isolinux_bin_exist(iso_link):
return "debian"
elif re.search(r'grml', string, re.I) and re.search(r'live-media-path=', string, re.I):
return "grml"
elif re.search(r'debian-installer', string, re.I) and not any("casper" in s.lower() for s in iso_file_list):
return "debian-install"
elif re.search(r'solydx', string, re.I):

View File

@ -292,8 +292,9 @@ def prepare_mbusb_host_dir():
os.makedirs(home)
else:
log("Cleaning old multibootusb directory...")
shutil.rmtree(home)
os.makedirs(home)
clean_iso_cfg_ext_dir(os.path.join(home, "iso_cfg_ext_dir"))
#shutil.rmtree(home)
#os.makedirs(home)
if not os.path.exists(os.path.join(home, "preference")):
os.makedirs(os.path.join(home, "preference"))
@ -356,6 +357,37 @@ def grub_efi_exist(grub_efi_path):
return True
return False
def process_exist(process_name):
"""
Detect if process exist/ running and kill it.
:param process_name: process name to check
:return: True if processis killed else False
"""
if platform.system() == 'Windows':
import signal
import wmi
c = wmi.WMI()
for process in c.Win32_Process():
if process_name in process.Name:
log(process_name + ' exist...')
log(process.ProcessId + ' ' + process.Name)
log("Having Windows explorer won't allow dd.exe to write ISO image properly."
"\nKilling the process..")
try:
os.kill(process.ProcessId, signal.SIGTERM)
return True
except:
log('Unable to kill process ' + process.ProcessId)
return False
def write_to_file(filepath, text):
if not os.path.exists(filepath):
with open(filepath, 'w') as f:
f.write(text.strip())
if __name__ == '__main__':
log(quote("""Test-string"""))
log(has_digit("test-string-with-01-digit"))

View File

@ -96,9 +96,11 @@ class AppGui(qemu.Qemu, Imager, QtWidgets.QMainWindow, Ui_MainWindow):
self.progress_thread_dd.finished.connect(self.dd_finished)
self.progress_thread_dd.status.connect(self.ui.statusbar.showMessage)
# FIXME
# self.add_device()
prepare_mbusb_host_dir()
self.onRefreshClick()
# def add_device(self):
# """
@ -134,7 +136,6 @@ class AppGui(qemu.Qemu, Imager, QtWidgets.QMainWindow, Ui_MainWindow):
about.exec_()
def onComboChange(self):
"""
Detects and updates GUI with populated USB device details.
@ -177,7 +178,6 @@ class AppGui(qemu.Qemu, Imager, QtWidgets.QMainWindow, Ui_MainWindow):
log("No USB disk found...")
def onRefreshClick(self):
"""
Calls function to detect USB devices.
@ -245,8 +245,17 @@ class AppGui(qemu.Qemu, Imager, QtWidgets.QMainWindow, Ui_MainWindow):
def browse_iso(self):
if str(self.ui.image_path.text()):
self.ui.image_path.clear()
config.image_path = QtWidgets.QFileDialog.getOpenFileName(self, 'Select an iso...', '', 'ISO Files (*.iso)')[0]
preference_file_path = os.path.join(multibootusb_host_dir(), "preference", "iso_dir.txt")
dir_path = ''
if os.path.exists(preference_file_path):
dir_path = open(preference_file_path, 'r').read()
config.image_path = QtWidgets.QFileDialog.getOpenFileName(self, 'Select an iso...', dir_path, 'ISO Files (*.iso)')[0]
if config.image_path:
default_dir_path = os.path.dirname(config.image_path)
gen.write_to_file(preference_file_path, default_dir_path)
if platform.system() == "Windows":
if "/" in config.image_path:
config.image_path = config.image_path.strip().replace("/", "\\")
@ -563,6 +572,11 @@ class AppGui(qemu.Qemu, Imager, QtWidgets.QMainWindow, Ui_MainWindow):
if self.iso_size >= usb_disk_size:
QtWidgets.QMessageBox.information(self, "No enough space on disk.", os.path.basename(config.image_path) +
" size is larger than the size of " + config.usb_disk)
elif gen.process_exist('explorer.exe') is not False:
# Check if windows explorer is running and inform user to close it.
QtWidgets.QMessageBox.information(self, "Windows Explorer", "Windows Explorer is running\n"
"You need to close it before writing ISO "
"image to disk...")
else:
reply = QtWidgets.QMessageBox.question \
(self, 'Review selection',

View File

@ -171,6 +171,7 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
else:
config.status_text = 'Failed to install syslinux on distro directory...'
log ("\nFailed to install syslinux on distro directory...\n")
elif platform.system() == "Windows":
syslinux_path = resource_path(os.path.join(multibootusb_host_dir(), "syslinux", "bin")) + \
"\syslinux" + config.syslinux_version + ".exe"
@ -178,7 +179,7 @@ def syslinux_distro_dir(usb_disk, iso_link, distro):
distro_sys_install_bs = distro_sys_install_bs.replace("/", "\\")
sys_cmd = syslinux_path + option + distro_syslinux_install_dir + ' ' + usb_disk + ' ' + \
distro_sys_install_bs
log("\nExecuting ==> " + sys_cmd, '\n')
log("\nExecuting ==> " + sys_cmd + '\n')
config.status_text = 'Installing distro specific syslinux...'
if subprocess.call(sys_cmd, shell=True) == 0:
config.status_text = 'Syslinux install on distro directory is success...'

View File

@ -62,7 +62,8 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
if not persistence == 0:
string = re.sub(r'boot=live', 'boot=live persistent persistent-path=/multibootusb/' +
iso_basename(iso_link) + "/", string)
elif distro == 'grml':
string = re.sub(r'live-media-path=', 'ignore_bootid live-media-path=', string)
elif distro == "ubuntu-server":
string = re.sub(r'file',
'cdrom-detect/try-usb=true floppy.allowed_drive_mask=0 ignore_uuid ignore_bootid root=UUID=' +