Skip to content

Commit

Permalink
Activate Multiboot for gbtrio4k
Browse files Browse the repository at this point in the history
Add FlashOnline and ImageBackup for gbtrio4k
  • Loading branch information
teamblue-e2 committed Mar 10, 2020
1 parent beeb290 commit 39a1ac1
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 62 deletions.
4 changes: 2 additions & 2 deletions lib/python/Components/SystemInfo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enigma import eDVBResourceManager, Misc_Options, eDVBCIInterfaces
from Tools.Directories import fileExists, fileCheck, pathExists, fileHas, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN
from Tools.HardwareInfo import HardwareInfo
from boxbranding import getBoxType, getMachineBuild, getBrandOEM
from boxbranding import getBoxType, getMachineBuild, getBrandOEM, getMachineMtdRoot

SystemInfo = {}

Expand Down Expand Up @@ -129,5 +129,5 @@ def getHasTuners():
SystemInfo["HasSDswap"] = getMachineBuild() in ("h9", "i55plus") and pathExists("/dev/mmcblk0p1")
SystemInfo["CanProc"] = SystemInfo["HasMMC"] and getBrandOEM() != "vuplus"
SystemInfo["canRecovery"] = getMachineBuild() in ('gbmv200',) and ('usb_update.bin','none')
SystemInfo["FlashOnlineBackup"] = getMachineBuild() not in ('gbmv200', )
SystemInfo["FlashOnlineBackup"] = getMachineBuild() not in ('dummy')
SystemInfo["LnbPowerAlwaysOn"] = getBoxType() in ('vusolo4k', 'vuduo4k', 'vuultimo4k')
101 changes: 77 additions & 24 deletions lib/python/Plugins/SystemPlugins/SoftwareManager/Flash_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
import os
import shutil
import math
from boxbranding import getBoxType, getMachineBrand, getMachineName, getMachineRootFile, getMachineKernelFile
from boxbranding import getBoxType, getImageDistro, getMachineBrand, getImageVersion, getMachineBuild, getMachineName, getMachineRootFile, getMachineKernelFile, getMachineMtdKernel, getMachineMtdRoot
distro = getImageDistro()
ImageVersion = getImageVersion()
ROOTFSBIN = getMachineRootFile()
KERNELBIN = getMachineKernelFile()
MTDKERNEL = getMachineMtdKernel()
MTDROOTFS = getMachineMtdRoot()

#############################################################################################################
# Create a List of imagetypes
Expand All @@ -37,8 +43,6 @@
flashPath = '/media/hdd/images/flash'
flashTmp = '/media/hdd/images/tmp'
ofgwritePath = '/usr/bin/ofgwrite'
ROOTFSBIN = getMachineRootFile()
KERNELBIN = getMachineKernelFile()
#############################################################################################################

def Freespace(dev):
Expand Down Expand Up @@ -66,9 +70,14 @@ def __init__(self, session):
Screen.__init__(self, session)
self.session = session
self.selection = 0
self.devrootfs = "/dev/mmcblk0p4"
if getMachineBuild() in ("gb7252"):
self.devrootfs = "/dev/mmcblk0p4"
else:
self.devrootfs = "/dev/mmcblk1p3"
self.multi = 1
self.list = self.list_files("/boot")
self.MTDKERNEL = getMachineMtdKernel()
self.MTDROOTFS = getMachineMtdRoot()

Screen.setTitle(self, _("Flash On the Fly"))
if SystemInfo["canMultiBoot"]:
Expand Down Expand Up @@ -127,13 +136,13 @@ def quit(self):

def blue(self):
if self.check_hdd():
self.session.open(doFlashImage, online = False, list=self.list[self.selection], multi=self.multi, devrootfs=self.devrootfs)
self.session.open(doFlashImage, online = False, list=self.list[self.selection], multi=self.multi, devrootfs=self.devrootfs, mtdkernel=self.MTDKERNEL, mtdrootfs=self.MTDROOTFS)
else:
self.close()

def green(self):
if self.check_hdd():
self.session.open(doFlashImage, online = True, list=self.list[self.selection], multi=self.multi, devrootfs=self.devrootfs)
self.session.open(doFlashImage, online = True, list=self.list[self.selection], multi=self.multi, devrootfs=self.devrootfs, mtdkernel=self.MTDKERNEL, mtdrootfs=self.MTDROOTFS)
else:
self.close()

Expand All @@ -147,30 +156,65 @@ def yellow(self):
self.multi = self.multi[-1:]
print "[Flash Online] MULTI:",self.multi
cmdline = self.read_startup("/boot/" + self.list[self.selection]).split("=",3)[3].split(" ",1)[0]
self.devrootfs = cmdline
self.devrootfs = self.find_rootfs_dev(self.list[self.selection])
print "[Flash Online] MULTI rootfs ", self.devrootfs

self.read_current_multiboot()

def read_current_multiboot(self):
if getMachineBuild() in ("gbmv200"):
if self.list[self.selection] == "Recovery":
cmdline = self.read_startup("/boot/STARTUP").split("=",1)[1].split(" ",1)[0]
else:
cmdline = self.read_startup("/boot/" + self.list[self.selection]).split("=",1)[1].split(" ",1)[0]
else:
if self.list[self.selection] == "Recovery":
cmdline = self.read_startup("/boot/cmdline.txt").split("=",1)[1].split(" ",1)[0]
else:
cmdline = self.read_startup("/boot/" + self.list[self.selection]).split("=",1)[1].split(" ",1)[0]
cmdline = cmdline.lstrip("/dev/")
self.MTDROOTFS = cmdline
self.MTDKERNEL = cmdline[:-1] + str(int(cmdline[-1:]) -1)
print "[Flash Online] kernel device: ",self.MTDKERNEL
print "[Flash Online] rootfsdevice: ",self.MTDROOTFS

def read_startup(self, FILE):
file = FILE
with open(file, 'r') as myfile:
data=myfile.read().replace('\n', '')
myfile.close()
return data

def find_rootfs_dev(self, file):
startup_content = self.read_startup("/boot/" + file)
return startup_content[startup_content.find("root=")+5:].split()[0]

def list_files(self, PATH):
files = []
if SystemInfo["canMultiBoot"]:
path = PATH
for name in os.listdir(path):
if name != 'bootname' and os.path.isfile(os.path.join(path, name)):
try:
cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
except IndexError:
continue
cmdline_startup = self.read_startup("/boot/STARTUP").split("=",1)[1].split(" ",1)[0]
if (cmdline != cmdline_startup) and (name != "STARTUP"):
files.append(name)
files.insert(0,"STARTUP")
if getMachineBuild() in ("gbmv200"):
for name in os.listdir(path):
if name != 'bootname' and os.path.isfile(os.path.join(path, name)):
try:
cmdline = self.find_rootfs_dev(name)
except IndexError:
continue
cmdline_startup = self.find_rootfs_dev("STARTUP")
if (cmdline != cmdline_startup) and (name != "STARTUP"):
files.append(name)
files.insert(0,"STARTUP")
else:
for name in os.listdir(path):
if name != 'bootname' and os.path.isfile(os.path.join(path, name)):
try:
cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
except IndexError:
continue
cmdline_startup = self.read_startup("/boot/cmdline.txt").split("=",1)[1].split(" ",1)[0]
if (cmdline != cmdline_startup) and (name != "cmdline.txt"):
files.append(name)
files.insert(0,"cmdline.txt")
else:
files = "None"

Expand All @@ -189,8 +233,8 @@ class doFlashImage(Screen):
<widget name="key_blue" position="420,460" zPosition="2" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
<widget name="imageList" position="10,10" zPosition="1" size="680,450" font="Regular;20" scrollbarMode="showOnDemand" transparent="1" />
</screen>"""
def __init__(self, session, online, list=None, multi=None, devrootfs=None ):

def __init__(self, session, online, list=None, multi=None, devrootfs=None, mtdkernel=None, mtdrootfs=None ):
Screen.__init__(self, session)
self.session = session

Expand All @@ -207,6 +251,8 @@ def __init__(self, session, online, list=None, multi=None, devrootfs=None ):
self.List = list
self.multi=multi
self.devrootfs=devrootfs
self.MTDKERNEL = mtdkernel
self.MTDROOTFS = mtdrootfs
self.imagePath = imagePath
self.feedurl = images[self.imagesCounter][1]
self["imageList"] = MenuList(self.imagelist)
Expand Down Expand Up @@ -317,7 +363,12 @@ def Start_Flashing(self):
if self.simulate:
text += _("Simulate (no write)")
if SystemInfo["canMultiBoot"]:
cmdlist.append("%s -n -r -k -m%s %s > /dev/null 2>&1" % (ofgwritePath, self.multi, flashTmp))
if getMachineBuild() in ("gbmv200"):
cmdlist.append("%s -r%s -k%s %s > /dev/null 2>&1" % (ofgwritePath, self.MTDROOTFS, self.MTDKERNEL, flashTmp))
else:
cmdlist.append("%s -n -r -k -m%s %s > /dev/null 2>&1" % (ofgwritePath, self.multi, flashTmp))
elif getMachineBuild() in ("gbmv200"):
cmdlist.append("%s -n -r%s -k%s %s > /dev/null 2>&1" % (ofgwritePath, MTDROOTFS, MTDKERNEL, flashTmp))
else:
cmdlist.append("%s -n -r -k %s > /dev/null 2>&1" % (ofgwritePath, flashTmp))
self.close()
Expand All @@ -329,10 +380,12 @@ def Start_Flashing(self):
if SystemInfo["canMultiBoot"]:
if not self.List == "STARTUP":
os.system('mkfs.ext4 -F ' + self.devrootfs)
cmdlist.append("%s -r -k -m%s %s > /dev/null 2>&1" % (ofgwritePath, self.multi, flashTmp))
if not self.List == "STARTUP":
cmdlist.append("umount -fl /oldroot_bind > /dev/null 2>&1")
cmdlist.append("umount -fl /newroot > /dev/null 2>&1")
if getMachineBuild() in ("gbmv200"):
cmdlist.append("%s -r%s -k%s %s > /dev/null 2>&1" % (ofgwritePath, self.MTDROOTFS, self.MTDKERNEL, flashTmp))
else:
cmdlist.append("%s -r -k -m%s %s > /dev/null 2>&1" % (ofgwritePath, self.multi, flashTmp))
elif getMachineBuild() in ("gbmv200"):
cmdlist.append("%s -r%s -k%s %s > /dev/null 2>&1" % (ofgwritePath, MTDROOTFS, MTDKERNEL, flashTmp))
else:
cmdlist.append("%s -r -k %s > /dev/null 2>&1" % (ofgwritePath, flashTmp))
message = "echo -e '\n"
Expand Down

0 comments on commit 39a1ac1

Please sign in to comment.