def installImageTARBZ2(self, src_path, dst_path, kernel_dst_path, tmp_folder): 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 if BOX_NAME == "hd51" or BOX_NAME == "vs1500" or BOX_NAME == "e4hd": if OMB_GETMACHINEKERNELFILE == "kernel1.bin" and not os.path.exists( kernel_path): kernel_path = base_path + '/' + "kernel.bin" 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 else: self.showError(_("Error unpacking rootfs")) return False self.afterInstallImage(dst_path) return True
def __init__(self, session): self.session = session message = _("Where do you want to install openMultiboot?") disks_list = [] for p in harddiskmanager.getMountedPartitions(): if p and os.path.exists(p.mountpoint) and os.access( p.mountpoint, os.F_OK | os.R_OK ) and p.device and p.mountpoint != '/' and ( p.device[:2] == 'sd' or (p.device.startswith('mmcblk1p') and BOX_NAME not in ('xc7439', 'osmio4k', 'osmio4kplus', 'osmini4k')) or (p.device.startswith('mmcblk0p') and BOX_NAME not in ('sf8008', 'sf5008', 'sf8008m', 'et13000', 'et11000', 'et1x000', 'duo4k', 'duo4kse', 'uno4k', 'uno4kse', 'ultimo4k', 'solo4k', 'zero4k', 'hd51', 'hd52', 'dm820', 'dm7080', 'sf4008', 'dm900', 'dm920', 'gbquad4k', 'gbue4k', 'lunix3-4k', 'lunix-4k', 'vs1500', 'h7', '8100s', 'e4hd', 'gbmv200', 'multibox', 'multiboxse', 'h9se', 'h11', 'h9combo', 'h9combose', 'h9twin', 'h9twinse', 'h10', 'v8plus', 'hd60', 'hd61', 'hd66se', 'pulse4k', 'pulse4kmini', 'dual'))) and isMounted(p.mountpoint): disks_list.append((p.description + ' (%s)' % p.mountpoint, p)) 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 msgAddZipClosed(ret, curfile=None): if ret and curfile: try: found_dir = '' data_dir = OMB_MAIN_DIR + '/' + OMB_DATA_DIR if os.path.exists(data_dir): upload_dir = OMB_MAIN_DIR + '/' + OMB_UPLOAD_DIR if os.path.exists(upload_dir): found_dir = upload_dir else: for p in harddiskmanager.getMountedPartitions(): if p and os.access(p.mountpoint, os.F_OK | os.R_OK) and p.mountpoint != '/': data_dir = p.mountpoint + '/' + OMB_DATA_DIR if os.path.exists(data_dir) and isMounted( p.mountpoint): upload_dir = p.mountpoint + '/' + OMB_UPLOAD_DIR if os.path.exists(upload_dir): found_dir = upload_dir break if found_dir: ret = os.system("cp %s %s" % (curfile, found_dir)) if ret == 0: txt = _("zip archive was successfully added to '%s' OMB!" ) % (found_dir) else: txt = _("Error adding zip archive!") AddPopup(txt, type=MessageBox.TYPE_INFO, timeout=10, id="InfoAddZipArchive") except: pass
def checkStatusOMB(self): if self.checkflashImage(): if os.path.isfile('/sbin/open_multiboot'): if os.readlink("/sbin/init") == "/sbin/open_multiboot": return _('OMB enabled.') else: return _('OMB disabled.') else: return _('OMB disabled.') else: return _('OMB enabled.') return ''
def __init__(self, session, kernel_module, branding=False): self.session = session self.kernel_module = kernel_module if branding: self.timer = eTimer() self.timer.callback.append(self.warningMessage) self.timer.start(500, True) return message = _("You need the module ") + self.kernel_module + _( " to use openMultiboot\nDo you want install it?") self.session.openWithCallback(self.installCallback, MessageBox, message, MessageBox.TYPE_YESNO)
def KeyOk(self): if self.checktimer.isActive(): return if len(self.images_entries) > 1: self.select = self["list"].getIndex() name = self["list"].getCurrent() if name.startswith(_("(Folder")) or name.startswith(_("(Unpack")): return status = self.checkStatusOMB() self.session.openWithCallback( self.confirmNextbootCB, MessageBox, _('Set next boot to %s ?') % name + "\n" + status, MessageBox.TYPE_YESNO)
def keyRename(self): if self.checktimer.isActive(): return self.renameIndex = self["list"].getIndex() name = self["list"].getCurrent() if name.startswith(_("(Folder")) or name.startswith(_("(Unpack")): return 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 Plugins(**kwargs): return [ PluginDescriptor(name=_("OpenMultiboot"), description=_("Multi boot loader for enigma2 box"), icon='plugin.png', where=[ PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU ], fnc=OMBManager), PluginDescriptor(name=_("Open Multiboot"), where=PluginDescriptor.WHERE_FILESCAN, fnc=startFilescan) ]
def inputCallback(self, value): if value: file = self.data_dir + '/.timer' if int(value) < 5 or int(value) > 120: self.session.open(MessageBox, _('Incorrect time!'), MessageBox.TYPE_INFO) elif int(value) == 5: os.system('rm -rf ' + file) elif int(value) > 5: try: f = open(file, 'w') f.write(value) f.close() except: self.session.open(MessageBox, _('Error set new timeout!'), MessageBox.TYPE_INFO)
def alterInstallCallback(self, confirmed): if confirmed: os.system("chmod 755 %s" % loadScript) cmd = "%s %s" % (loadScript, BOX_NAME) text = _("Install") self.session.openWithCallback(self.afterLoadInstall, Console, text, [cmd])
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() if not self.session.nav.getRecordings() and self.checkStatusOMB( ) == _('OMB enabled.'): self.session.openWithCallback(self.confirmRebootCB, MessageBox, _('Do you want to reboot now ?'), MessageBox.TYPE_YESNO, default=False) else: self.refresh()
def changeTimeout(self, val): if val is not None and val >= 5: self.session.openWithCallback(self.inputCallback, InputBox, title=_("Set new timeout (sec)"), text=str(val), maxSize=False, type=Input.NUMBER)
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 -F /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, True)
def afterLoadNfidumpInstall(self): if not os.path.exists(OMB_NFIDUMP_BIN): self.error_message = _('Cannot install ') + self.kernel_module self.session.open(MessageBox, self.error_message, type=MessageBox.TYPE_ERROR) else: OMBManager(self.session)
def afterLoadInstall(self): if os.system('opkg list_installed | grep ' + self.kernel_module) != 0: self.error_message = _('Cannot install ') + self.kernel_module self.session.open(MessageBox, self.error_message, type=MessageBox.TYPE_ERROR) else: OMBManager(self.session)
def keyDelete(self): selected_image = self["list"].getCurrent() if not selected_image: return source_file = selected_image + '.zip' self.session.openWithCallback( self.deleteConfirm, MessageBox, _("Do you want to delete %s?") % source_file, MessageBox.TYPE_YESNO)
def installModule(self): self.timer.stop() self.error_message = '' if self.kernel_module == "nfidump": os.system("chmod 755 %s" % loadScript) cmd = 'opkg update && opkg install python-subprocess\n' cmd += "%s dmm_nfidump" % loadScript text = _("Install") self.session.openWithCallback(self.afterLoadNfidumpInstall, Console, text, [cmd]) return os.system('opkg update && opkg install python-subprocess') if os.system('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, True)
def keyInstall(self): text = _("Please select the necessary option...") menu = [(_("Standard install"), "standard"), (_("Use altenative folder"), "altenative")] def setAction(choice): if choice: if choice[1] == "standard": self.alt_install = False self.keyPostInstall() elif choice[1] == "altenative": self.alt_install = True self.keyPostInstall() dlg = self.session.openWithCallback(setAction, ChoiceBox, title=text, list=menu)
def __init__(self, session, mount_point): Screen.__init__(self, session) self.setTitle(_('openMultiboot Manager') + ": %s" % mount_point) 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.name = '' self["key_ok"] = Button('') self["nextboot"] = Button('') 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["config_actions"] = ActionMap( [ "OkCancelActions", "ColorActions", "EPGSelectActions", "MenuActions" ], { "cancel": self.keyCancel, "red": self.keyRename, "yellow": self.keyDelete, "green": self.keyInstall, "blue": self.keyExtra, "menu": self.keyExtra, "info": self.keyAbout, "ok": self.KeyOk }) self.setrcType() self.checktimer = eTimer() self.checktimer.callback.append(self.getMultiboot) if self.checkflashImage(): self.checktimer.start(2000, True)
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 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(500)
def formatDevice(self, confirmed): if confirmed: self.messagebox = self.session.open( MessageBox, _('Please wait while format is in progress.'), type=MessageBox.TYPE_INFO, enable_input=False) self.timer = eTimer() self.timer.callback.append(self.doFormatDevice) self.timer.start(100, True)
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 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 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 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 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 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 keyDelete(self): if self.checktimer.isActive(): return 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)