def __init__(self, session, mount_point): Screen.__init__(self, session) self.setTitle(_('openMultiboot Manager')) self.session = session self.mount_point = mount_point self.data_dir = mount_point + '/' + OMB_DATA_DIR self.upload_dir = mount_point + '/' + OMB_UPLOAD_DIR self.select = None self["label1"] = Label(_("Current Running Image:")) self["label2"] = Label("") self.populateImagesList() self["list"] = List(self.images_list) self["list"].onSelectionChanged.append(self.onSelectionChanged) self["background"] = Pixmap() self["key_red"] = Button(_('Rename')) self["key_yellow"] = Button() self["key_blue"] = Button(_('Menu')) if BRANDING: self["key_green"] = Button(_('Install')) else: self["key_green"] = Button('') self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "MenuActions"], { "cancel": self.close, "red": self.keyRename, "yellow": self.keyDelete, "green": self.keyInstall, "blue": self.showMen, "ok": self.KeyOk, "menu": self.showMen, })
def __init__(self, session, mount_point): Screen.__init__(self, session) self.setTitle(_('openMultiboot Manager')) self.session = session self.mount_point = mount_point self.data_dir = mount_point + '/' + OMB_DATA_DIR self.upload_dir = mount_point + '/' + OMB_UPLOAD_DIR self.populateImagesList() self["list"] = List(self.images_list) self["list"].onSelectionChanged.append(self.onSelectionChanged) self["background"] = Pixmap() self["key_red"] = Button(_('Rename')) self["key_yellow"] = Button() self["key_blue"] = Button(_('About')) if BRANDING: self["key_green"] = Button(_('Install')) else: self["key_green"] = Button('') self["config_actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "cancel": self.close, "red": self.keyRename, "yellow": self.keyDelete, "green": self.keyInstall, "blue": self.keyAbout })
def __init__(self, session, kernel_module): self.session = session self.kernel_module = kernel_module message = _("You need the module ") + self.kernel_module + _(" to use openMultiboot\nDo you want install it?") disks_list = [] for partition in harddiskmanager.getMountedPartitions(): if partition.mountpoint != '/': disks_list.append((partition.description, partition.mountpoint)) self.session.openWithCallback(self.installCallback, MessageBox, message, MessageBox.TYPE_YESNO)
def installPrepare(self): self.timer.stop() selected_image = self.selected_image selected_image_identifier = self.guessIdentifierName(selected_image) source_file = self.mount_point + '/' + OMB_UPLOAD_DIR + '/' + selected_image + '.zip' target_folder = self.mount_point + '/' + OMB_DATA_DIR + '/' + selected_image_identifier kernel_target_folder = self.mount_point + '/' + OMB_DATA_DIR + '/.kernels' kernel_target_file = kernel_target_folder + '/' + selected_image_identifier + '.bin' if not os.path.exists(kernel_target_folder): try: os.makedirs(kernel_target_folder) except OSError as exception: self.showError(_("Cannot create kernel folder %s") % kernel_target_folder) return if os.path.exists(target_folder): self.showError(_("The folder %s already exist") % target_folder) return try: os.makedirs(target_folder) except OSError as exception: self.showError(_("Cannot create folder %s") % target_folder) return tmp_folder = self.mount_point + '/' + OMB_TMP_DIR if os.path.exists(tmp_folder): os.system(OMB_RM_BIN + ' -rf ' + tmp_folder) try: os.makedirs(tmp_folder) os.makedirs(tmp_folder + '/ubi') os.makedirs(tmp_folder + '/jffs2') except OSError as exception: self.showError(_("Cannot create folder %s") % tmp_folder) return if os.system(OMB_UNZIP_BIN + ' ' + source_file + ' -d ' + tmp_folder) != 0: self.showError(_("Cannot deflate image")) return if self.installImage(tmp_folder, target_folder, kernel_target_file, tmp_folder): os.system(OMB_RM_BIN + ' -f ' + source_file) self.messagebox.close() self.close() os.system(OMB_RM_BIN + ' -rf ' + tmp_folder)
def __init__(self, session, mount_point, upload_list): Screen.__init__(self, session) self.setTitle(_('openMultiboot Install')) self.session = session self.mount_point = mount_point self['info'] = Label(_("Choose the image to install")) self["list"] = List(upload_list) self["actions"] = ActionMap(["SetupActions"], { "cancel": self.keyCancel, "ok": self.keyInstall })
def doFormatDevice(self): self.timer.stop() self.error_message = '' if os.system('umount /dev/' + self.response.device) != 0: self.error_message = _('Cannot umount the device') else: if os.system('/sbin/mkfs.ext4 /dev/' + self.response.device) != 0: self.error_message = _('Cannot format the device') else: if os.system('mount /dev/' + self.response.device + ' ' + self.response.mountpoint) != 0: self.error_message = _('Cannot remount the device') self.messagebox.close() self.timer = eTimer() self.timer.callback.append(self.afterFormat) self.timer.start(100)
def installImageTARBZ2(self, src_path, dst_path, kernel_dst_path, tmp_folder): base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE if os.system(OMB_TAR_BIN + ' jxf %s -C %s' % (rootfs_path,dst_path)) != 0: self.showError(_("Error unpacking rootfs")) return False if os.path.exists(dst_path + '/usr/bin/enigma2'): if os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) return False self.dirtyHack(dst_path) return True
def keyRename(self): self.renameIndex = self["list"].getIndex() name = self["list"].getCurrent() if self["list"].getIndex() == 0: if name.endswith('(Flash)'): name = name[:-8] self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=_("Please enter new name:"), text=name)
def installImage(self, src_path, dst_path, kernel_dst_path, tmp_folder): if OMB_GETIMAGEFILESYSTEM == "ubi": return self.installImageUBI(src_path, dst_path, kernel_dst_path, tmp_folder) elif OMB_GETIMAGEFILESYSTEM == "jffs2": return self.installImageJFFS2(src_path, dst_path, kernel_dst_path, tmp_folder) else: self.showError(_("Your STB doesn\'t seem supported")) return False
def __init__(self, session): self.session = session message = _("Where do you want to install openMultiboot?") disks_list = [] for partition in harddiskmanager.getMountedPartitions(): if partition and partition.mountpoint and partition.device and partition.mountpoint != '/' and partition.device[:2] == 'sd': disks_list.append((partition.description, partition)) if len(disks_list) > 0: disks_list.append((_("Cancel"), None)) self.session.openWithCallback(self.initCallback, MessageBox, message, list=disks_list) else: self.session.open( MessageBox, _("No suitable devices found"), type = MessageBox.TYPE_ERROR )
def keyDelete(self): if len(self.images_entries) == 0: return index = self["list"].getIndex() if index >= 0 and index < len(self.images_entries): self.entry_to_delete = self.images_entries[index] if self.canDeleteEntry(self.entry_to_delete): self.session.openWithCallback(self.deleteConfirm, MessageBox, _("Do you want to delete %s?") % self.entry_to_delete['label'], MessageBox.TYPE_YESNO)
def __init__(self, session, mount_point, upload_list): Screen.__init__(self, session) self.setTitle(_('openMultiboot Install')) self.session = session self.mount_point = mount_point self.esize = "128KiB" self.vid_offset = "2048" self.nandsim_parm = "first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15" self['info'] = Label(_("Choose the image to install")) self["list"] = List(upload_list) self["actions"] = ActionMap(["SetupActions"], { "cancel": self.keyCancel, "ok": self.keyInstall })
def Plugins(**kwargs): return [ PluginDescriptor( name="OpenMultiboot", description=_("OpenMultiboot Manager"), icon="plugin.png", where=[PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU], fnc=OMBManager, ) ]
def confirmNextbootCB(self, ret): if ret: image = self.images_entries[self.select]['identifier'] print "[OMB] set nextboot to %s" % image file_entry = self.data_dir + '/.nextboot' f = open(file_entry, 'w') f.write(image) f.close() self.session.openWithCallback(self.confirmRebootCB, MessageBox,_('Do you want to reboot now ?'), MessageBox.TYPE_YESNO)
def installModule(self): self.timer.stop() self.error_message = '' if os.system('opkg update && opkg install ' + self.kernel_module) != 0: self.error_message = _('Cannot install ' + self.kernel_module) self.messagebox.close() self.timer = eTimer() self.timer.callback.append(self.afterInstall) self.timer.start(100)
def onSelectionChanged(self): if len(self.images_entries) == 0: return index = self["list"].getIndex() if index >= 0 and index < len(self.images_entries): entry = self.images_entries[index] if self.canDeleteEntry(entry): self["key_yellow"].setText(_('Delete')) else: self["key_yellow"].setText('')
def installImageTARBZ2(self, src_path, dst_path, kernel_dst_path, tmp_folder): base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE if os.system(OMB_TAR_BIN + ' jxf %s -C %s' % (rootfs_path, dst_path)) != 0: self.showError(_("Error unpacking rootfs")) return False if os.path.exists(dst_path + '/usr/bin/enigma2'): if os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) return False self.dirtyHack(dst_path) return True
def __init__(self, session, mount_point, upload_list): Screen.__init__(self, session) self.setTitle(_('openMultiboot Install')) self.session = session self.mount_point = mount_point self.esize = "128KiB" self.vid_offset = "2048" # yuju off # self.nandsim_parm = "first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15" self['info'] = Label(_("Choose the image to install")) self["list"] = List(upload_list) self["actions"] = ActionMap(["SetupActions"], { "cancel": self.keyCancel, "ok": self.keyInstall })
def __init__(self, session): self.session = session message = _("Where do you want to install openMultiboot?") disks_list = [] for partition in harddiskmanager.getMountedPartitions(): if partition and partition.mountpoint and partition.device and partition.mountpoint != '/' and partition.device[: 2] == 'sd': disks_list.append((partition.description, partition)) if len(disks_list) > 0: disks_list.append((_("Cancel"), None)) self.session.openWithCallback(self.initCallback, MessageBox, message, list=disks_list) else: self.session.open(MessageBox, _("No suitable devices found"), type=MessageBox.TYPE_ERROR)
def deleteAnswer(self, answer): if answer: os.system('rm -rf ' + self.data_dir) self.waitmessagebox = self.session.open( MessageBox, _('Please wait 40 seconds, while delete is in progress.'), MessageBox.TYPE_INFO, enable_input=False) self.waittimer = eTimer() self.waittimer.callback.append(self.deleteFolder) self.waittimer.start(40000, True)
def keyInstall(self): self.selected_image = self["list"].getCurrent() if not self.selected_image: return self.messagebox = self.session.open(MessageBox, _('Please wait while installation is in progress.\nThis operation may take a while.'), MessageBox.TYPE_INFO, enable_input = False) self.timer = eTimer() self.timer.callback.append(self.installPrepare) self.timer.start(100) self.error_timer = eTimer() self.error_timer.callback.append(self.showErrorCallback)
def Plugins(**kwargs): return [ PluginDescriptor(name="OpenMultiboot", description=_("OpenMultiboot Manager"), icon='plugin.png', where=[ PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU ], fnc=OMBManager) ]
def installCallback(self, confirmed): if confirmed: if self.kernel_module != "nfidump": self.messagebox = self.session.open( MessageBox, _('Please wait while installation is in progress.'), MessageBox.TYPE_INFO, enable_input=False) self.timer = eTimer() self.timer.callback.append(self.installModule) self.timer.start(100, True)
def __init__(self, session): Screen.__init__(self, session) self.setTitle(_('openMultiboot About')) about = "openMultiboot Manager " + OMB_MANAGER_VERION + "\n" about += "(c) 2014 Impex-Sat Gmbh & Co.KG\n\n" about += "Written by Sandro Cavazzoni <*****@*****.**>" self['about'] = Label(about) self["actions"] = ActionMap(["SetupActions"], {"cancel": self.keyCancel})
def keyDelete(self): if len(self.images_entries) == 0: return index = self["list"].getIndex() if index >= 0 and index < len(self.images_entries): self.entry_to_delete = self.images_entries[index] if self.canDeleteEntry(self.entry_to_delete): self.session.openWithCallback( self.deleteConfirm, MessageBox, _("Do you want to delete %s?") % self.entry_to_delete['label'], MessageBox.TYPE_YESNO)
def confirmNextbootCB(self, ret): if ret: image = self.images_entries[self.select]['identifier'] print "[OMB] set nextboot to %s" % image file_entry = self.data_dir + '/.nextboot' f = open(file_entry, 'w') f.write(image) f.close() self.session.openWithCallback(self.confirmRebootCB, MessageBox, _('Do you want to reboot now ?'), MessageBox.TYPE_YESNO)
def filescanOpen(list, session, **kwargs): try: file = list[0].path if file: session.openWithCallback( boundFunction(msgAddZipClosed, curfile=file), MoveToupload, file) else: session.open(MessageBox, _("Read error current dir, sorry."), MessageBox.TYPE_ERROR) except: pass
def afterInstall(self): self.timer.stop() if len(self.error_message) > 0: if self.kernel_module == 'kernel-module-nandsim' and nandsim_alrenative_module and BOX_NAME: for name in nandsim_alrenative_module: if BOX_NAME == name: message = _("You want to install an alternative kernel-module-nandsim?\nLinux version may be different from the module!") self.session.openWithCallback(self.alterInstallCallback, MessageBox, message, MessageBox.TYPE_YESNO) return self.session.open(MessageBox, self.error_message, type = MessageBox.TYPE_ERROR) else: OMBManager(self.session)
def __init__(self, session, data_dir): Screen.__init__(self, session) self.data_dir = data_dir self.list = [] ConfigListScreen.__init__(self, self.list) self["key_red"] = Label(_("Save")) self["actions"] = ActionMap(["WizardActions", "ColorActions"], { "red": self.saveConf, "back": self.close }) self.bootmenu_enabled = NoSave(ConfigYesNo(default=True)) if os.path.isfile(self.data_dir + '/.bootmenu.lock'): self.bootmenu_enabled.value = False self.list.append( getConfigListEntry(_("Enable Boot Menu"), self.bootmenu_enabled)) self["config"].list = self.list self["config"].l.setList(self.list)
def deleteConfirm(self, confirmed): if confirmed: selected_image = self["list"].getCurrent() if not selected_image: return source_file = self.mount_point + '/' + OMB_UPLOAD_DIR + '/' + selected_image + '.zip' ret = os.system(OMB_RM_BIN + ' -rf ' + source_file) if ret == 0: self.close() else: self.session.open(MessageBox, _("Error removing zip archive!"), type=MessageBox.TYPE_ERROR)
def __init__(self, session, mount_point, upload_list): Screen.__init__(self, session) self.setTitle(_('openMultiboot Install')) self.session = session self.mount_point = mount_point self.alt_install = False self.esize = "128KiB" self.vid_offset = "2048" self.nandsim_parm = "first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15" self['info'] = Label(_("Choose the image to install")) self["list"] = List(upload_list) self["key_red"] = Button(_('Exit')) self["key_yellow"] = Button(_('Delete')) self["key_green"] = Button(_('Install')) self["actions"] = ActionMap( ["SetupActions", "ColorActions"], { "cancel": self.keyCancel, "red": self.keyCancel, "yellow": self.keyDelete, "green": self.keyInstall, "ok": self.keyInstall })
def installImageJFFS2(self, src_path, dst_path, kernel_dst_path, tmp_folder): rc = True mtdfile = "/dev/mtdblock0" for i in range(0, 20): mtdfile = "/dev/mtdblock%d" % i if not os.path.exists(mtdfile): break base_path = src_path + '/' + ( self.alt_install and config.plugins.omb.alternative_image_folder.value or OMB_GETIMAGEFOLDER) rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE jffs2_path = src_path + '/jffs2' if os.path.exists(OMB_UNJFFS2_BIN): if os.system("%s %s %s" % (OMB_UNJFFS2_BIN, rootfs_path, jffs2_path)) != 0: self.showError(_("Error unpacking rootfs")) rc = False if os.path.exists(jffs2_path + '/usr/bin/enigma2'): if os.system(OMB_CP_BIN + ' -rp ' + jffs2_path + '/* ' + dst_path) != 0: self.showError(_("Error copying unpacked rootfs")) rc = False if os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) rc = False else: os.system(OMB_MODPROBE_BIN + ' loop') os.system(OMB_MODPROBE_BIN + ' mtdblock') os.system(OMB_MODPROBE_BIN + ' block2mtd') os.system(OMB_MKNOD_BIN + ' ' + mtdfile + ' b 31 0') os.system(OMB_LOSETUP_BIN + ' /dev/loop0 ' + rootfs_path) os.system( OMB_ECHO_BIN + ' "/dev/loop0,%s" > /sys/module/block2mtd/parameters/block2mtd' % self.esize) os.system(OMB_MOUNT_BIN + ' -t jffs2 ' + mtdfile + ' ' + jffs2_path) if os.path.exists(jffs2_path + '/usr/bin/enigma2'): if os.system(OMB_CP_BIN + ' -rp ' + jffs2_path + '/* ' + dst_path) != 0: self.showError(_("Error copying unpacked rootfs")) rc = False if os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) rc = False else: self.showError(_("Generic error in unpaack process")) rc = False os.system(OMB_UMOUNT_BIN + ' ' + jffs2_path) os.system(OMB_RMMOD_BIN + ' block2mtd') os.system(OMB_RMMOD_BIN + ' mtdblock') os.system(OMB_RMMOD_BIN + ' loop') self.afterInstallImage(dst_path) return rc
def __init__(self, session, data_dir): Screen.__init__(self, session) self.data_dir = data_dir self.list = [] ConfigListScreen.__init__(self, self.list) self["key_red"] = Label(_("Save")) self["actions"] = ActionMap(["WizardActions", "ColorActions"], { "red": self.saveConf, "back": self.close }) self.bootmenu_enabled = NoSave(ConfigYesNo(default=True)) if os.path.isfile(self.data_dir + '/.bootmenu.lock'): self.bootmenu_enabled.value = False self.list.append(getConfigListEntry(_("Enable Boot Menu"), self.bootmenu_enabled)) self["config"].list = self.list self["config"].l.setList(self.list)
def initCallback(self, response): if response: fs_type = self.getFSType(response.device) if fs_type not in ['ext3', 'ext4']: self.response = response self.session.openWithCallback( self.formatDevice, MessageBox, _("Filesystem not supported\nDo you want format your drive?" ), type=MessageBox.TYPE_YESNO) else: self.createDir(response)
def initCallback(self, response): if response: fs_type = self.getFSType(response.device) if fs_type not in ['ext3', 'ext4']: self.response = response self.session.openWithCallback( self.formatDevice, MessageBox, _("Filesystem not supported\nDo you want format your drive?"), type = MessageBox.TYPE_YESNO ) else: self.createDir(response)
def installImage(self, src_path, dst_path, kernel_dst_path, tmp_folder): if "ubi" in OMB_GETIMAGEFILESYSTEM: return self.installImageUBI(src_path, dst_path, kernel_dst_path, tmp_folder) elif "jffs2" in OMB_GETIMAGEFILESYSTEM: return self.installImageJFFS2(src_path, dst_path, kernel_dst_path, tmp_folder) elif "tar.bz2" in OMB_GETIMAGEFILESYSTEM: return self.installImageTARBZ2(src_path, dst_path, kernel_dst_path, tmp_folder) else: self.showError(_("Your STB doesn\'t seem supported")) return False
def installImageUBI(self, src_path, dst_path, kernel_dst_path, tmp_folder): for i in range(0, 20): mtdfile = "/dev/mtd" + str(i) if os.path.exists(mtdfile) is False: break mtd = str(i) base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE ubi_path = src_path + '/ubi' # This is idea from EGAMI Team to handle universal UBIFS unpacking - used only for INI-HDp model if OMB_GETMACHINEBUILD in ('inihdp'): if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/ubi_reader/ubi_extract_files.py"): ubifile = "/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/ubi_reader/ubi_extract_files.py" else: ubifile = "/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/ubi_reader/ubi_extract_files.pyo" cmd= "chmod 755 " + ubifile rc = os.system(cmd) cmd = "python " + ubifile + " " + rootfs_path + " -o " + ubi_path rc = os.system(cmd) os.system(OMB_CP_BIN + ' -rp ' + ubi_path + '/rootfs/* ' + dst_path) rc = os.system(cmd) cmd = ('chmod -R +x ' + dst_path) rc = os.system(cmd) cmd = 'rm -rf ' + ubi_path rc = os.system(cmd) os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) return True virtual_mtd = tmp_folder + '/virtual_mtd' os.system(OMB_MODPROBE_BIN + ' nandsim cache_file=' + virtual_mtd + ' ' + self.nandsim_parm) if not os.path.exists('/dev/mtd' + mtd): os.system('rmmod nandsim') self.showError(_("Cannot create virtual MTD device")) return False os.system(OMB_DD_BIN + ' if=' + rootfs_path + ' of=/dev/mtdblock' + mtd + ' bs=2048') os.system(OMB_UBIATTACH_BIN + ' /dev/ubi_ctrl -m ' + mtd + ' -O ' + self.vid_offset) os.system(OMB_MOUNT_BIN + ' -t ubifs ubi1_0 ' + ubi_path) if os.path.exists(ubi_path + '/usr/bin/enigma2'): os.system(OMB_CP_BIN + ' -rp ' + ubi_path + '/* ' + dst_path) os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) os.system(OMB_UMOUNT_BIN + ' ' + ubi_path) os.system(OMB_UBIDETACH_BIN + ' -m ' + mtd) os.system(OMB_RMMOD_BIN + ' nandsim') return True
def installPrepare(self): self.timer.stop() selected_image = self.selected_image selected_image_identifier = self.guessIdentifierName(selected_image) source_file = self.mount_point + '/' + OMB_UPLOAD_DIR + '/' + selected_image + '.zip' target_folder = self.mount_point + '/' + OMB_DATA_DIR + '/' + selected_image_identifier kernel_target_folder = self.mount_point + '/' + OMB_DATA_DIR + '/.kernels' kernel_target_file = kernel_target_folder + '/' + selected_image_identifier + '.bin' if not os.path.exists(kernel_target_folder): try: os.makedirs(kernel_target_folder) except OSError as exception: self.showError( _("Cannot create kernel folder %s") % kernel_target_folder) return if os.path.exists(target_folder): self.showError(_("The folder %s already exist") % target_folder) return try: os.makedirs(target_folder) except OSError as exception: self.showError(_("Cannot create folder %s") % target_folder) return tmp_folder = self.mount_point + '/' + OMB_TMP_DIR if os.path.exists(tmp_folder): os.system(OMB_RM_BIN + ' -rf ' + tmp_folder) try: os.makedirs(tmp_folder) os.makedirs(tmp_folder + '/ubi') os.makedirs(tmp_folder + '/jffs2') except OSError as exception: self.showError(_("Cannot create folder %s") % tmp_folder) return if os.system(OMB_UNZIP_BIN + ' ' + source_file + ' -d ' + tmp_folder) != 0: self.showError(_("Cannot deflate image")) return nfifile = glob.glob('%s/*.nfi' % tmp_folder) if nfifile: if not self.extractImageNFI(nfifile[0], tmp_folder): self.showError(_("Cannot extract nfi image")) return if self.installImage(tmp_folder, target_folder, kernel_target_file, tmp_folder): os.system(OMB_RM_BIN + ' -f ' + source_file) self.messagebox.close() self.close() os.system(OMB_RM_BIN + ' -rf ' + tmp_folder)
def __init__(self, session, kernel_module): self.session = session self.kernel_module = kernel_module message = _("You need the module " + self.kernel_module + " to use openMultiboot\nDo you want install it?") disks_list = [] for partition in harddiskmanager.getMountedPartitions(): if partition.mountpoint != '/': disks_list.append( (partition.description, partition.mountpoint)) self.session.openWithCallback(self.installCallback, MessageBox, message, MessageBox.TYPE_YESNO)
def __init__(self, session): Screen.__init__(self, session) self.setTitle(_('openMultiboot About')) about = "openMultiboot Manager " + OMB_MANAGER_VERION + "\n" about += "(c) 2014 Impex-Sat Gmbh & Co.KG\n\n" about += "Written by Sandro Cavazzoni <*****@*****.**>" self['about'] = Label(about) self["actions"] = ActionMap(["SetupActions"], { "cancel": self.keyCancel })
def createDir(self, partition): data_dir = partition.mountpoint + '/' + OMB_DATA_DIR upload_dir = partition.mountpoint + '/' + OMB_UPLOAD_DIR try: os.makedirs(data_dir) os.makedirs(upload_dir) except OSError as exception: self.session.open( MessageBox, _("Cannot create data folder"), type = MessageBox.TYPE_ERROR ) return self.session.open(OMBManagerList, partition.mountpoint)
def __init__(self, session, mount_point): Screen.__init__(self, session) self.setTitle(_('openMultiboot Manager')) self.session = session mount_point = mount_point.rstrip("/") self.mount_point = mount_point self.data_dir = mount_point + '/' + OMB_DATA_DIR self.upload_dir = mount_point + '/' + OMB_UPLOAD_DIR self.select = None self["label1"] = Label(_("Current Running Image:")) self["label2"] = Label("") self.populateImagesList() self["list"] = List(self.images_list) self["list"].onSelectionChanged.append(self.onSelectionChanged) self["background"] = Pixmap() self["key_red"] = Button(_('Rename')) self["key_yellow"] = Button() self["key_blue"] = Button(_('Menu')) if BRANDING: self["key_green"] = Button(_('Install')) else: self["key_green"] = Button('') self["actions"] = ActionMap( ["OkCancelActions", "ColorActions", "MenuActions"], { "cancel": self.close, "red": self.keyRename, "yellow": self.keyDelete, "green": self.keyInstall, "blue": self.showMen, "ok": self.KeyOk, "menu": self.showMen, })
def __init__(self, session): Screen.__init__(self, session) self.setTitle(_('openMultiboot About')) about = "openMultiboot Manager " + OMB_MANAGER_VERION + "\n" about += BOX_NAME + "\n" about += "(c) 2014 Impex-Sat Gmbh & Co.KG\n\n" about += "Written by Sandro Cavazzoni <*****@*****.**>" about += "\n" about += "Modded by Meo" about += "\n" about += "\nPatch for openPli Dimitrij <*****@*****.**>" self['about'] = Label(about) self["actions"] = ActionMap(["SetupActions"], {"cancel": self.keyCancel})
def startFilescan(**kwargs): from Components.Scanner import Scanner, ScanPath if not os.path.exists( '/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/.autoscan' ): return [] return \ Scanner(mimetypes=["application/zip"], paths_to_scan = [ ScanPath(path = "", with_subdirs = False), ], name = "Open Multiboot", description = _("Add zip archive with image in 'open-multiboot-upload'"), openfnc = filescanOpen, )
def createDir(self, partition): data_dir = partition.mountpoint + '/' + OMB_DATA_DIR upload_dir = partition.mountpoint + '/' + OMB_UPLOAD_DIR try: if not os.path.exists(data_dir): os.makedirs(data_dir) if not os.path.exists(upload_dir): os.makedirs(upload_dir) except OSError as exception: self.session.open(MessageBox, _("Cannot create data folder"), type = MessageBox.TYPE_ERROR) return # if os.path.isfile('/sbin/open_multiboot'): # os.system("ln -sfn /sbin/open_multiboot /sbin/init") self.session.open(OMBManagerList, partition.mountpoint)
def installImageJFFS2(self, src_path, dst_path, kernel_dst_path, tmp_folder): rc = True mtdfile = "/dev/mtdblock0" for i in range(0, 20): mtdfile = "/dev/mtdblock%d" % i if not os.path.exists(mtdfile): break base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE jffs2_path = src_path + '/jffs2' if os.path.exists('/usr/bin/unjffs2'): if os.system("unjffs2 %s %s" % (rootfs_path, jffs2_path)) != 0: self.showError(_("Error unpacking rootfs")) rc = False if os.path.exists(jffs2_path + '/usr/bin/enigma2'): if os.system('cp -rp ' + jffs2_path + '/* ' + dst_path) != 0: self.showError(_("Error copying unpacked rootfs")) rc = False if os.system('cp ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) rc = False else: Console().ePopen("modprobe loop") Console().ePopen("modprobe mtdblock") Console().ePopen("modprobe block2mtd") Console().ePopen("mknod %s b 31 0" % mtdfile) Console().ePopen("losetup /dev/loop0 %s" % rootfs_path) Console().ePopen( 'echo "/dev/loop0,%s" > /sys/module/block2mtd/parameters/block2mtd' % self.esize) Console().ePopen("mount -t jffs2 %s %s" % (mtdfile, jffs2_path)) if os.path.exists(jffs2_path + '/usr/bin/enigma2'): if os.system('cp -rp ' + jffs2_path + '/* ' + dst_path) != 0: self.showError(_("Error copying unpacked rootfs")) rc = False if os.system('cp ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) rc = False else: self.showError(_("Generic error in unpack process")) rc = False Console().ePopen("umount %s" % jffs2_path) Console().ePopen("rmmod block2mtd") Console().ePopen("rmmod mtdblock") Console().ePopen("rmmod loop") return rc
def keyInstall(self): upload_list = [] if os.path.exists(self.upload_dir): for file_entry in os.listdir(self.upload_dir): if file_entry[0] == '.' or file_entry == 'flash.zip': continue if len(file_entry) > 4 and file_entry[-4:] == '.zip': upload_list.append(file_entry[:-4]) if len(upload_list) > 0: self.session.openWithCallback(self.refresh, OMBManagerInstall, self.mount_point, upload_list) else: self.session.open( MessageBox, _("Please upload an image inside %s") % self.upload_dir, type=MessageBox.TYPE_ERROR )
def installImageJFFS2(self, src_path, dst_path, kernel_dst_path, tmp_folder): rc = True mtdfile = "/dev/mtdblock0" for i in range(0, 20): mtdfile = "/dev/mtdblock%d" % i if not os.path.exists(mtdfile): break base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE jffs2_path = src_path + '/jffs2' if os.path.exists(OMB_UNJFFS2_BIN): if os.system("%s %s %s" % (OMB_UNJFFS2_BIN, rootfs_path, jffs2_path)) != 0: self.showError(_("Error unpacking rootfs")) rc = False if os.path.exists(jffs2_path + '/usr/bin/enigma2'): if os.system(OMB_CP_BIN + ' -rp ' + jffs2_path + '/* ' + dst_path) != 0: self.showError(_("Error copying unpacked rootfs")) rc = False if os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) rc = False else: os.system(OMB_MODPROBE_BIN + ' loop') os.system(OMB_MODPROBE_BIN + ' mtdblock') os.system(OMB_MODPROBE_BIN + ' block2mtd') os.system(OMB_MKNOD_BIN + ' ' + mtdfile + ' b 31 0') os.system(OMB_LOSETUP_BIN + ' /dev/loop0 ' + rootfs_path) os.system(OMB_ECHO_BIN + ' "/dev/loop0,%s" > /sys/module/block2mtd/parameters/block2mtd' % self.esize) os.system(OMB_MOUNT_BIN + ' -t jffs2 ' + mtdfile + ' ' + jffs2_path) if os.path.exists(jffs2_path + '/usr/bin/enigma2'): if os.system(OMB_CP_BIN + ' -rp ' + jffs2_path + '/* ' + dst_path) != 0: self.showError(_("Error copying unpacked rootfs")) rc = False if os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) != 0: self.showError(_("Error copying kernel")) rc = False else: self.showError(_("Generic error in unpack process")) rc = False os.system(OMB_UMOUNT_BIN + ' ' + jffs2_path) os.system(OMB_RMMOD_BIN + ' block2mtd') os.system(OMB_RMMOD_BIN + ' mtdblock') os.system(OMB_RMMOD_BIN + ' loop') return rc
def createDir(self, partition): data_dir = partition.mountpoint + '/' + OMB_DATA_DIR upload_dir = partition.mountpoint + '/' + OMB_UPLOAD_DIR try: os.makedirs(data_dir) os.makedirs(upload_dir) except OSError as exception: self.session.open( MessageBox, _("Cannot create data folder"), type = MessageBox.TYPE_ERROR ) return # by Meo. We are installing in flash. We can link init to open_multiboot # so we can disable it in open multiboot postinst. # In this way we will be sure to have not open_multiboot init in mb installed images. if os.path.isfile('/sbin/open_multiboot'): os.system("ln -sfn /sbin/open_multiboot /sbin/init") self.session.open(OMBManagerList, partition.mountpoint)
def keyInstall(self): if not BRANDING: return upload_list = [] if os.path.exists(self.upload_dir): for file_entry in os.listdir(self.upload_dir): if file_entry[0] == '.' or file_entry == 'flash.zip': continue if len(file_entry) > 4 and file_entry[-4:] == '.zip': upload_list.append(file_entry[:-4]) if len(upload_list) > 0: self.session.openWithCallback(self.refresh, OMBManagerInstall, self.mount_point, upload_list) else: self.session.open( MessageBox, _("Please upload an image inside %s") % self.upload_dir, type = MessageBox.TYPE_ERROR )
def createDir(self, partition): data_dir = partition.mountpoint + '/' + OMB_DATA_DIR upload_dir = partition.mountpoint + '/' + OMB_UPLOAD_DIR try: os.makedirs(data_dir) os.makedirs(upload_dir) except OSError as exception: self.session.open(MessageBox, _("Cannot create data folder"), type=MessageBox.TYPE_ERROR) return # by Meo. We are installing in flash. We can link init to open_multiboot # so we can disable it in open multiboot postinst. # In this way we will be sure to have not open_multiboot init in mb installed images. if os.path.isfile('/sbin/open_multiboot'): os.system("ln -sfn /sbin/open_multiboot /sbin/init") self.session.open(OMBManagerList, partition.mountpoint)
def keyInstall(self): if self.checktimer.isActive(): return if not BRANDING: return if not self.checkflashImage(): return upload_list = [] if os.path.exists(self.upload_dir): for file_entry in os.listdir(self.upload_dir): if file_entry[0] == '.' or file_entry == 'flash.zip': continue if len(file_entry) > 4 and file_entry[-4:] == '.zip': upload_list.append(file_entry[:-4]) if len(upload_list) > 0: self.session.openWithCallback(self.afterInstall, OMBManagerInstall, self.mount_point, upload_list) else: self.session.open(MessageBox, _("Please upload an image inside %s") % self.upload_dir, type=MessageBox.TYPE_ERROR)
def installImageUBI(self, src_path, dst_path, kernel_dst_path, tmp_folder): for i in range(0, 20): mtdfile = "/dev/mtd" + str(i) if os.path.exists(mtdfile) is False: break mtd = str(i) #if OMB_GETBOXTYPE in ('whatever'): # self.showError(_("Your STB doesn\'t seem supported")) # return False base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE ubi_path = src_path + '/ubi' virtual_mtd = tmp_folder + '/virtual_mtd' os.system(OMB_MODPROBE_BIN + ' nandsim cache_file=' + virtual_mtd + ' first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15') if not os.path.exists('/dev/mtd' + mtd): os.system('rmmod nandsim') self.showError(_("Cannot create virtual MTD device")) return False os.system(OMB_DD_BIN + ' if=' + rootfs_path + ' of=/dev/mtdblock' + mtd + ' bs=2048') os.system(OMB_UBIATTACH_BIN + ' /dev/ubi_ctrl -m ' + mtd + ' -O 2048') os.system(OMB_MOUNT_BIN + ' -t ubifs ubi1_0 ' + ubi_path) if os.path.exists(ubi_path + '/usr/bin/enigma2'): os.system(OMB_CP_BIN + ' -rp ' + ubi_path + '/* ' + dst_path) os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) os.system(OMB_UMOUNT_BIN + ' ' + ubi_path) os.system(OMB_UBIDETACH_BIN + ' -m ' + mtd) os.system(OMB_RMMOD_BIN + ' nandsim') return True
def deleteConfirm(self, confirmed): if confirmed and len(self.entry_to_delete['path']) > 1: self.messagebox = self.session.open(MessageBox,_('Please wait while delete is in progress.'), MessageBox.TYPE_INFO, enable_input = False) self.timer = eTimer() self.timer.callback.append(self.deleteImage) self.timer.start(100)
def formatDevice(self, confirmed): if confirmed: self.messagebox = self.session.open(MessageBox, _('Please wait while format is in progress.'), MessageBox.TYPE_INFO, enable_input = False) self.timer = eTimer() self.timer.callback.append(self.doFormatDevice) self.timer.start(100)
def installCallback(self, confirmed): if confirmed: self.messagebox = self.session.open(MessageBox,_('Please wait while installation is in progress.'), MessageBox.TYPE_INFO, enable_input = False) self.timer = eTimer() self.timer.callback.append(self.installModule) self.timer.start(100)
def installImageUBI(self, src_path, dst_path, kernel_dst_path, tmp_folder): for i in range(0, 20): mtdfile = "/dev/mtd" + str(i) if os.path.exists(mtdfile) is False: break mtd = str(i) base_path = src_path + '/' + OMB_GETIMAGEFOLDER rootfs_path = base_path + '/' + OMB_GETMACHINEROOTFILE kernel_path = base_path + '/' + OMB_GETMACHINEKERNELFILE ubi_path = src_path + '/ubi' # This is idea from EGAMI Team to handle universal UBIFS unpacking - used only for INI-HDp model if OMB_GETMACHINEBUILD in ('inihdp'): if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/ubi_reader/ubi_extract_files.py"): ubifile = "/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/ubi_reader/ubi_extract_files.py" else: ubifile = "/usr/lib/enigma2/python/Plugins/Extensions/OpenMultiboot/ubi_reader/ubi_extract_files.pyo" cmd= "chmod 755 " + ubifile rc = os.system(cmd) cmd = "python " + ubifile + " " + rootfs_path + " -o " + ubi_path rc = os.system(cmd) os.system(OMB_CP_BIN + ' -rp ' + ubi_path + '/rootfs/* ' + dst_path) rc = os.system(cmd) cmd = ('chmod -R +x ' + dst_path) rc = os.system(cmd) cmd = 'rm -rf ' + ubi_path rc = os.system(cmd) os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) return True virtual_mtd = tmp_folder + '/virtual_mtd' os.system(OMB_MODPROBE_BIN + ' nandsim cache_file=' + virtual_mtd + ' ' + self.nandsim_parm) if not os.path.exists('/dev/mtd' + mtd): os.system('rmmod nandsim') self.showError(_("Cannot create virtual MTD device")) return False if OMB_GETBRANDOEM in ('xcore'): os.system(OMB_DD_BIN + ' if=' + rootfs_path + ' of=/dev/mtd' + mtd + ' bs=2048') else: os.system(OMB_DD_BIN + ' if=' + rootfs_path + ' of=/dev/mtdblock' + mtd + ' bs=2048') os.system(OMB_UBIATTACH_BIN + ' /dev/ubi_ctrl -m ' + mtd + ' -O ' + self.vid_offset) os.system(OMB_MOUNT_BIN + ' -t ubifs ubi1_0 ' + ubi_path) if os.path.exists(ubi_path + '/usr/bin/enigma2'): os.system(OMB_CP_BIN + ' -rp ' + ubi_path + '/* ' + dst_path) os.system(OMB_CP_BIN + ' ' + kernel_path + ' ' + kernel_dst_path) os.system(OMB_UMOUNT_BIN + ' ' + ubi_path) os.system(OMB_UBIDETACH_BIN + ' -m ' + mtd) os.system(OMB_RMMOD_BIN + ' nandsim') # WARNING: dirty hack by Meo # # In a perfect world all the images are perfect and do their work. # But this is not a perfect world and we have to help OMB to # prevent funny cases for non standard images. # My apologies to Sandro for this bad code. if not os.path.exists('/usr/lib/python2.7/boxbranding.so'): os.system("ln -s /usr/lib/enigma2/python/boxbranding.so /usr/lib/python2.7/boxbranding.so") if os.path.exists(dst_path + '/usr/lib/python2.7/boxbranding.py'): os.system("cp /usr/lib/enigma2/python/boxbranding.so " + dst_path + "/usr/lib/python2.7/boxbranding.so") os.system("rm -f " + dst_path + '/usr/lib/python2.7/boxbranding.py') if not os.path.exists(dst_path + "/usr/lib/python2.7/subprocess.pyo"): os.system("cp /usr/lib/python2.7/subprocess.pyo " + dst_path + "/usr/lib/python2.7/subprocess.pyo") # openmultiboot installed in the multiboot image. where the init will go ? if os.path.exists(dst_path + '/sbin/open_multiboot'): os.system("rm -f " + dst_path + '/sbin/open_multiboot') os.system("rm -f " + dst_path + '/sbin/open-multiboot-branding-helper.py') # We can't create the init symlink because it will be overwrited by openmultiboot os.system('ln -sfn /sbin/init.sysvinit ' + dst_path + '/sbin/open_multiboot') # our friends Pli if dst_path.find('OpenPLi') != -1: import fileinput for line in fileinput.input(dst_path + '/etc/init.d/volatile-media.sh', inplace=True): if 'mount -t tmpfs -o size=64k tmpfs /media' in line: print "mountpoint -q \"/media\" || mount -t tmpfs -o size=64k tmpfs /media" else: print line.rstrip() # end dirty ! return True