Introduced more strict distro detection for those which fail

to be correctly identified. (grml64-full_2017.05.iso,
salixlive-xfce-14.2.1.iso, wifislax64-1.1-final.iso).
Fixed installer to make up for the fixed detection.
Removed a dead code block.
pull/328/head
Shinji Suzuki 6 years ago
parent 80c5a47381
commit e4ac1a0139

@ -38,7 +38,9 @@ def distro(iso_cfg_ext_dir, iso_link, expose_exception=False):
# of a false positive.
if iso_file_list:
distro = perform_strict_detections(iso_cfg_ext_dir, iso_file_list)
if distro:
return distro
distro = detect_iso_from_file_list(iso_file_list)
if distro:
return distro
@ -72,6 +74,10 @@ def distro(iso_cfg_ext_dir, iso_link, expose_exception=False):
def not_(predicate):
return partial(run_not, predicate)
# contains(X) predicates that X is contained in an examined text file.
# Multiple keywords can be concatenated by '|'. Predicates gets aaserted
# if anyone of the keywords is found in the text file.
# Sorry you can't include | in a keyword for now.
test_vector = [
('ubcd', contains('ubcd')),
('sgrubd2', contains('Super Grub Disk')),
@ -211,6 +217,44 @@ def detect_iso_from_file_list(iso_file_list):
# % (len(filenames), len(filenames)==1 and 'filename' or 'filenames'))
return None
def perform_strict_detections(iso_cfg_ext_dir, iso_file_list):
def run_contains(filepath, keyword, cfg_dir=iso_cfg_ext_dir):
fullpath = os.path.join(cfg_dir, filepath.replace('/', os.sep))
try:
with open(fullpath, 'rb') as f:
data = f.read().lower()
return keyword in data
except UnicodeDecodeError:
log("Couldn't decode %s" % fullpath)
return False
except (IOError, OSError):
log("Failed to open %s" % fullpath)
return False
def contains(relataive_filepath, keyword):
return partial(run_contains, relataive_filepath,
bytes(keyword.lower(),'us-ascii'))
# contains(P, K) predicates that file P contains the specified
# string K. The predicate get never asserted if P has not been
# extracted into the staging area (iso_cfg_ext_dir).
test_vector = [
('wifislax', contains('boot/syslinux/menu/vesamenu.cfg',
'menu label Wifislax64 Live')),
('salix-live', contains('boot/menus/mainmenu.cfg',
'MENU LABEL SALIX LIVE')),
('grml', contains('boot/isolinux/vesamenu.cfg',
'menu title Grml - Live Linux'))
]
for distro, predicate in test_vector:
predicates = [predicate] if callable(predicate) else predicate
if all(p() for p in predicates):
return distro
return None
if __name__ == '__main__':
iso_cfg_ext_dir = os.path.join(multibootusb_host_dir(), "iso_cfg_ext_dir")
iso_link = 'Downloads/clonezilla-live-2.4.2-32-amd64.iso'

@ -76,7 +76,7 @@ def install_distro():
config.status_text = "Copying ISO..."
iso.iso_extract_file(config.image_path, install_dir, "kernel")
copy_iso(config.image_path, install_dir)
elif config.distro == "salix-live":
elif config.distro in ["salix-live", 'wifislax']:
# iso.iso_extract_file(config.image_path, install_dir, "boot")
iso.iso_extract_file(config.image_path, install_dir,
['*syslinux', '*menus', '*vmlinuz', '*initrd*',

@ -149,6 +149,7 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0):
'centos-install' : CentosConfigTweaker,
'antix' : AntixConfigTweaker,
'salix-live' : SalixConfigTweaker,
'wifislax' : SalixConfigTweaker,
}
tweaker_class = tweaker_class_dict.get(distro)
@ -489,13 +490,7 @@ def update_mbusb_cfg_file(iso_link, usb_uuid, usb_mount, distro):
config_file.write("#start " + iso_basename(iso_link) + "\n")
config_file.write("LABEL " + iso_basename(iso_link) + "\n")
config_file.write("MENU LABEL " + iso_basename(iso_link) + "\n")
if distro == "salix-live":
if os.path.exists(os.path.join(config.usb_mount, 'multibootusb', iso_basename(iso_link), 'boot', 'grub2-linux.img')):
config_file.write(
"LINUX " + '/multibootusb/' + iso_basename(iso_link) + '/boot/grub2-linux.img' + "\n")
else:
config_file.write("BOOT " + '/multibootusb/' + iso_basename(iso_link) + '/' + isolinux_bin_dir(iso_link).replace("\\", "/") + '/' + distro + '.bs' + "\n")
elif distro == "pclinuxos":
if distro == "pclinuxos":
config_file.write("kernel " + '/multibootusb/' + iso_basename(iso_link) + '/isolinux/vmlinuz' + "\n")
config_file.write("append livecd=livecd root=/dev/rd/3 acpi=on vga=788 keyb=us vmalloc=256M nokmsboot "
"fromusb root=UUID=" + usb_uuid + " bootfromiso=/multibootusb/" +

Loading…
Cancel
Save