Пример #1
0
    def flashimage(self):
        self["header"].setText(_("Flashing Image"))
        self["summary_header"].setText(self["header"].getText())

        def findimagefiles(path):
            for path, subdirs, files in os.walk(path):
                if not subdirs and files:
                    return checkimagefiles(files) and path

        imagefiles = findimagefiles(self.unzippedimage)
        if imagefiles:
            self.ROOTFSSUBDIR = "none"
            bootSlots = MultiBoot.getBootSlots()
            if bootSlots:
                self.MTDKERNEL = bootSlots[self.multibootslot]["kernel"].split(
                    '/')[2]
                if bootSlots[self.multibootslot].get("ubi"):
                    self.MTDROOTFS = bootSlots[self.multibootslot]["device"]
                else:
                    self.MTDROOTFS = bootSlots[
                        self.multibootslot]["device"].split('/')[2]
                if MultiBoot.hasRootSubdir():
                    self.ROOTFSSUBDIR = bootSlots[
                        self.multibootslot]["rootsubdir"]
            else:
                self.MTDKERNEL = getMachineMtdKernel()
                self.MTDROOTFS = getMachineMtdRoot()
            if getMachineBuild(
            ) in ("dm820",
                  "dm7080"):  # temp solution ofgwrite autodetection not ready
                CMD = "/usr/bin/ofgwrite -rmmcblk0p1 '%s'" % imagefiles
            elif self.MTDKERNEL == self.MTDROOTFS:  # receiver with kernel and rootfs on one partition
                CMD = "/usr/bin/ofgwrite -r '%s'" % imagefiles
            else:
                CMD = "/usr/bin/ofgwrite -r -k '%s'" % imagefiles  #normal non multiboot receiver
            if MultiBoot.canMultiBoot():
                if (self.ROOTFSSUBDIR
                    ) is None:  # receiver with SD card multiboot
                    CMD = "/usr/bin/ofgwrite -r%s -k%s -m0 '%s'" % (
                        self.MTDROOTFS, self.MTDKERNEL, imagefiles)
                else:
                    CMD = "/usr/bin/ofgwrite -r -k -m%s '%s'" % (
                        self.multibootslot, imagefiles)
            self.containerofgwrite = Console()
            self.containerofgwrite.ePopen(CMD, self.FlashimageDone)
            fbClass.getInstance().lock()
        else:
            self.session.openWithCallback(
                self.abort,
                MessageBox,
                _("Image to install is invalid\n%s") % self.imagename,
                type=MessageBox.TYPE_ERROR,
                simple=True)
Пример #2
0
    def flashImage(self):
        def findImageFiles(path):
            for path, subDirs, files in walk(path):
                if not subDirs and files:
                    return checkImageFiles(files) and path

        self["header"].setText(_("Flashing Image"))
        self["summary_header"].setText(self["header"].getText())
        imageFiles = findImageFiles(self.unzippedImage)
        if imageFiles:
            rootSubDir = "none"
            bootSlots = MultiBoot.getBootSlots()
            if bootSlots:
                mtdKernel = bootSlots[self.slotCode]["kernel"].split(sep)[2]
                mtdRootFS = bootSlots[self.slotCode]["device"] if bootSlots[
                    self.slotCode].get("ubi") else bootSlots[
                        self.slotCode]["device"].split(sep)[2]
                if MultiBoot.hasRootSubdir():
                    rootSubDir = bootSlots[self.slotCode]["rootsubdir"]
            else:
                mtdKernel = BoxInfo.getItem("mtdkernel")
                mtdRootFS = BoxInfo.getItem("mtdrootfs")
            if MultiBoot.canMultiBoot(
            ):  # Receiver with SD card MultiBoot if (rootSubDir) is None.
                cmdArgs = ["-r%s" % mtdRootFS,
                           "-k%s" %
                           mtdKernel, "-m0"] if (rootSubDir) is None else [
                               "-r", "-k", "-m%s" % self.slotCode
                           ]
            elif BoxInfo.getItem("model") in (
                    "dm820", "dm7080"
            ):  # Temp solution ofgwrite auto detection not ready.
                cmdArgs = ["-rmmcblk0p1"]
            elif mtdKernel == mtdRootFS:  # Receiver with kernel and rootfs on one partition.
                cmdArgs = ["-r"]
            else:  # Normal non MultiBoot receiver.
                cmdArgs = ["-r", "-k"]
            self.containerOFGWrite = Console()
            self.containerOFGWrite.ePopen([OFGWRITE, OFGWRITE] + cmdArgs +
                                          ['%s' % imageFiles],
                                          callback=self.flashImageDone)
            fbClass.getInstance().lock()
        else:
            self.session.openWithCallback(
                self.keyCancel,
                MessageBox,
                _("Error: Image '%s' to install is invalid!") % self.imageName,
                type=MessageBox.TYPE_ERROR,
                windowTitle=self.getTitle())