Skip to content

Commit 2c411d5

Browse files
committed
[multiboot] small fix for chkroot UBIMB
1 parent 936ecde commit 2c411d5

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

lib/python/Components/SystemInfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def getWakeOnLANType(fileName):
377377
BoxInfo.setItem("HasKexecMultiboot", fileHas("/proc/cmdline", "kexec=1"))
378378
BoxInfo.setItem("cankexec", BoxInfo.getItem("kexecmb") and fileExists("/usr/bin/kernel_auto.bin") and fileExists("/usr/bin/STARTUP.cpio.gz") and not BoxInfo.getItem("HasKexecMultiboot"))
379379
BoxInfo.setItem("HasChkrootMultiboot", MultiBoot.isFat32("/dev/block/by-name/others") or fileExists("/dev/block/by-name/startup"))
380-
BoxInfo.setItem("canchkroot", fileExists("/dev/block/by-name/others") and not BoxInfo.getItem("HasChkrootMultiboot") and not fileExists("/etc/.disableChkroot"))
380+
BoxInfo.setItem("canchkroot", (BoxInfo.getItem("hasUBIMB") or fileExists("/dev/block/by-name/others")) and not BoxInfo.getItem("HasChkrootMultiboot") and not fileExists("/etc/.disableChkroot"))
381381
BoxInfo.setItem("CanNotDoSimultaneousTranscodeAndPIP", MODEL in ("vusolo4k", "gbquad4k", "gbquad4kpro", "gbue4k"))
382382
BoxInfo.setItem("canRecovery", MODEL in ("hd51", "vs1500", "h7", "h17", "8100s") and ("disk.img", "mmcblk0p1") or MODEL in ("xc7439", "osmio4k", "osmio4kplus", "osmini4k") and ("emmc.img", "mmcblk1p1") or MODEL in ("gbmv200", "sf8008", "sf8008m", "sx988", "ip8", "ustym4kpro", "ustym4kottpremium", "ustym4ks2ottx", "beyonwizv2", "viper4k", "og2ott4k", "og2s4k", "sx88v2", "sx888") and ("usb_update.bin", "none"))
383383
BoxInfo.setItem("CanUse3DModeChoices", fileExists("/proc/stb/fb/3dmode_choices") and True or False)

lib/python/Screens/Information.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,20 @@ def formatNumber(number):
859859
info.append(formatLine("P1", _("Total flash"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
860860
info.append(formatLine("P1", _("Used flash"), f"{scaleNumber(diskUsed)} ({scaleNumber(diskUsed, 'Iec')})"))
861861
info.append(formatLine("P1", _("Free flash"), f"{scaleNumber(diskFree)} ({scaleNumber(diskFree, 'Iec')})"))
862+
try:
863+
with open("/proc/mtd") as mtd:
864+
for line in mtd:
865+
if '"kernel' in line:
866+
parts = line.split()
867+
name = parts[3].strip('"')
868+
size = int(parts[1], 16)
869+
if name == "kernel":
870+
label = _("Kernel partition")
871+
else:
872+
label = _("Kernel%s partition") % name.replace("kernel", "")
873+
info.append(formatLine("P1", label, "%s (%s)" % (scaleNumber(size), scaleNumber(size, "Iec"))))
874+
except:
875+
pass
862876
info.append("")
863877
info.append(formatLine("S", _("RAM (Details)")))
864878
if self.extraSpacing:

lib/python/Screens/MultiBootManager.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, session, *args):
9191
"blue": (self.restoreImage, _("Restore the highlighted slot"))
9292
}, prio=0, description=_("MultiBoot Manager Actions"))
9393
self["restoreActions"].setEnabled(False)
94-
if BoxInfo.getItem("HasKexecMultiboot") or BoxInfo.getItem("HasGPT") or BoxInfo.getItem("hasUBIMB"):
94+
if BoxInfo.getItem("HasKexecMultiboot") or BoxInfo.getItem("HasGPT"):
9595
self["moreSlotActions"] = HelpableActionMap(self, ["ColorActions"], {
9696
"blue": (self.moreSlots, _("Add more slots"))
9797
}, prio=0, description=_("MultiBoot Manager Actions"))
@@ -168,8 +168,6 @@ def deleteImageCallback(self, result):
168168
def moreSlots(self):
169169
if BoxInfo.getItem("HasGPT"):
170170
self.session.open(GPTSlotManager)
171-
elif BoxInfo.getItem("hasUBIMB"):
172-
self.session.open(UBISlotManager)
173171
else:
174172
self.session.open(KexecSlotManager)
175173

@@ -239,7 +237,7 @@ def selectionChanged(self):
239237
self["restartActions"].setEnabled(True)
240238
self["deleteActions"].setEnabled(True)
241239
self["restoreActions"].setEnabled(False)
242-
if (BoxInfo.getItem("HasKexecMultiboot") and slotCode == "R") or BoxInfo.getItem("HasGPT") or BoxInfo.getItem("hasUBIMB"):
240+
if (BoxInfo.getItem("HasKexecMultiboot") and slotCode == "R") or BoxInfo.getItem("HasGPT"):
243241
self["restoreActions"].setEnabled(False)
244242
self["moreSlotActions"].setEnabled(True)
245243
self["key_blue"].setText(_("Add more slots"))
@@ -713,17 +711,23 @@ def __init__(self, session, *args):
713711
self["key_red"] = StaticText()
714712
self["key_green"] = StaticText()
715713
self["description"] = Label()
714+
greenAction = (self.rootInit, _("Start the Chkroot initialization"))
715+
if BoxInfo.getItem("hasUBIMB"):
716+
greenAction = (self.UBIMBInit, _("Start the Chkroot initialization"))
716717
self["actions"] = HelpableActionMap(self, ["OkCancelActions", "ColorActions"], {
717718
"ok": (self.close, _("Close the Chkroot MultiBoot Manager")),
718719
"cancel": (self.close, _("Close the Chkroot MultiBoot Manager")),
719720
"red": (self.disableChkroot, _("Disable the MultiBoot option")),
720-
"green": (self.rootInit, _("Start the Chkroot initialization"))
721+
"green": greenAction
721722
}, prio=-1, description=_("Chkroot Manager Actions"))
722723
self["key_red"].setText(_("Disable Chkroot"))
723724
self["key_green"].setText(_("Initialize"))
724725
self.descriptionSuffix = _("The %s %s will reboot within 1 seconds.") % getBoxDisplayName()
725726
self["description"].setText("%s\n\n%s" % (_("Press GREEN to enable MultiBoot!"), self.descriptionSuffix))
726727

728+
def UBIMBInit(self):
729+
self.session.open(UBISlotManager)
730+
727731
def rootInit(self):
728732
def rootInitCallback(*args, **kwargs):
729733
self.session.open(TryQuitMainloop, QUIT_REBOOT)
@@ -866,15 +870,15 @@ def createSlots(self):
866870
def formatDeviceCallback(self):
867871
def closeStartUpCallback(answer):
868872
if answer:
869-
self.close()
873+
self.session.open(TryQuitMainloop, QUIT_REBOOT)
870874
MOUNTPOINT = "/tmp/boot"
871875
mtdRootFs = BoxInfo.getItem("mtdrootfs")
872876
mtdKernel = BoxInfo.getItem("mtdkernel")
873877
device = self.UBISlotManagerDevice
874878
uuidRootFS = fileReadLine(f"/dev/uuid/{device}2", default=None, source=MODULE_NAME)
875879
diskSize = self.partitionSizeGB(f"/dev/{device}")
876880

877-
startupContent = f"kernel=/dev/{mtdKernel} root=/dev/{mtdRootFs} flash=1 rootfstype=ubifs\n"
881+
startupContent = f"kernel=/dev/{mtdKernel} ubi.mtd=rootfs root=ubi0:rootfs flash=1 rootfstype=ubifs\n"
878882
with open(f"{MOUNTPOINT}/STARTUP", "w") as fd:
879883
fd.write(startupContent)
880884
with open(f"{MOUNTPOINT}/STARTUP_FLASH", "w") as fd:
@@ -913,7 +917,9 @@ def deviceSelectionCallback(self, selection):
913917
def partitionSizeGB(self, dev):
914918
try:
915919
base = dev.replace("/dev/", "")
916-
path = f"/sys/class/block/{base}/size"
920+
pathClass = f"/sys/class/block/{base}/size"
921+
pathBlock = f"/sys/block/{base}/size"
922+
path = pathClass if exists(pathClass) else pathBlock
917923
with open(path) as fd:
918924
blocks = int(fd.read().strip())
919925
return (blocks * 512) // (1024 * 1024 * 1024)

0 commit comments

Comments
 (0)