Exemple #1
0
	def save(self):
		print "[MultiBootStartup] select new startup: ", self.list[self.selection]
		system("cp -f /boot/%s /boot/STARTUP"%self.list[self.selection])

		f = open('/boot/STARTUP', 'r')
		boot = f.readline()
		f.close()

		checkboot = True #check command line on/off
		writeoption = already = failboot = False
		bootline = boot.split("=",1)[1].split(" ",1)[0]
		if checkboot and (not bootline in Harddisk.getextdevices("ext4") or ('boxmode' in boot and len(boot) > 76) or ('boxmode' not in boot and len(boot) > 58)):
			failboot = True
		elif self.option_enabled:
			for x in self.optionsList:
				if (x[0] + "'" in boot or x[0] + " " in boot) and x[0] != self.optionsList[self.option][0]:
					boot = boot.replace(x[0],self.optionsList[self.option][0])
					writeoption = True
					break
				elif (x[0] + "'" in boot or x[0] + " " in boot) and x[0] == self.optionsList[self.option][0]:
					already = True
					break
			if not (writeoption or already):
				if "boxmode" in boot:
					failboot = checkboot
				elif self.option: #write boxmode=1 is not needed ???
					boot = boot.replace("rootwait", "rootwait hd51_4.%s" %(self.optionsList[self.option][0]))
					writeoption = True

		if self.enable_bootnamefile:
			originalname = 'STARTUP_%s' %boot[22:23]
			f = open('/boot/bootname', 'w')
			if failboot:
				f.write('STARTUP_1=STARTUP_1')
			else:
				f.write('%s=%s' %(originalname,self.list[self.selection]))
			f.close()

		if failboot:
			print "[MultiBootStartup] wrong bootsettings: " + boot
			sboot = "boot emmcflash0.kernel1 'root=/dev/mmcblk0p3 rw rootwait'"
			if '/dev/mmcblk0p3' in Harddisk.getextdevices("ext4"):
				f = open('/boot/STARTUP', 'w')
				f.write(sboot)
				f.close()
				txt = "Next boot will start from Image 1."
			else:
				txt = "Alternative Image 1 partition for repair not found.\nCaution, next boot is starts with your settings!\n"
			restartbox = self.session.openWithCallback(self.restartBOX,MessageBox,_("Wrong Bootsettings detected!\n\n%s\n%s\nDo you want to reboot now?") %(boot,txt), MessageBox.TYPE_YESNO)
			return
		elif writeoption:
			f = open('/boot/STARTUP', 'w')
			f.write(boot)
			f.close()
		restartbox = self.session.openWithCallback(self.restartBOX,MessageBox,_("Do you want to reboot now with selected image?"), MessageBox.TYPE_YESNO)
Exemple #2
0
 def list_files(self, PATH):
     files = []
     if SystemInfo["HaveMultiBoot"]:
         self.path = PATH
         for name in listdir(self.path):
             if path.isfile(path.join(self.path, name)):
                 try:
                     if self.MACHINEBUILD in ("hd51", "vs1500", "h7"):
                         cmdline = self.read_startup("/boot/" + name).split(
                             "=", 3)[3].split(" ", 1)[0]
                     elif self.MACHINEBUILD in ("8100s"):
                         cmdline = self.read_startup("/boot/" + name).split(
                             "=", 4)[4].split(" ", 1)[0]
                     else:
                         cmdline = self.read_startup("/boot/" + name).split(
                             "=", 1)[1].split(" ", 1)[0]
                     if cmdline in Harddisk.getextdevices("ext4"):
                         files.append(name)
                 except IndexError:
                     print '[ImageBackup] - IndexError in file: %s' % name
                     self.error_files += '/boot/' + name + ', '
         if getMachineBuild() not in ("gb7252", "cc1", "sf8008",
                                      "ustym4kpro"):
             files.append("Recovery")
     return files
Exemple #3
0
	def save(self):
		print "[MultiBootStartup] select new startup: ", self.list[self.selection]
		ret = system("cp -f '/boot/%s' /boot/STARTUP" %self.list[self.selection])
		if ret:
			self.session.open(MessageBox, _("File '/boot/%s' copy to '/boot/STARTUP' failed!") %self.list[self.selection], MessageBox.TYPE_ERROR)
			self.getCurrent()
			return

		writeoption = already = failboot = False
		newboot = boot = self.readlineFile('/boot/STARTUP')

		if self.checkBootEntry(boot):
			failboot = True
		elif self.option_enabled:
			for x in self.optionsList:
				if (x[0] + "'" in boot or x[0] + " " in boot) and x[0] != self.optionsList[self.option][0]:
					newboot = boot.replace(x[0],self.optionsList[self.option][0])
					writeoption = True
					break
				elif (x[0] + "'" in boot or x[0] + " " in boot) and x[0] == self.optionsList[self.option][0]:
					already = True
					break
			if not (writeoption or already):
				if "boxmode" in boot:
					failboot = True
				elif self.option:
					newboot = boot.replace("rootwait", "rootwait hd51_4.%s" %(self.optionsList[self.option][0]))
					writeoption = True

		if self.enable_bootnamefile:
			if failboot:
				self.writeFile('/boot/bootname', 'STARTUP_1=STARTUP_1')
			else:
				self.writeFile('/boot/bootname', '%s=%s' %('STARTUP_%s' %boot[22:23], self.list[self.selection]))

		message = _("Do you want to reboot now with selected image?")
		if failboot:
			print "[MultiBootStartup] wrong bootsettings: " + boot
			if '/dev/mmcblk0p3' in Harddisk.getextdevices("ext4"):
				if self.writeFile('/boot/STARTUP', "boot emmcflash0.kernel1 'root=/dev/mmcblk0p3 rw rootwait'"):
					txt = _("Next boot will start from Image 1.")
				else:
					txt =_("Can not repair file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
			else:
				txt = _("Alternative Image 1 partition for boot repair not found.") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
			message = _("Wrong Bootsettings detected!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
		elif writeoption:
			if not self.writeFile('/boot/STARTUP', newboot):
				txt = _("Can not write file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
				message = _("Write error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")

		#verify boot
		if failboot or writeoption:
			boot = self.readlineFile('/boot/STARTUP')
			if self.checkBootEntry(boot):
				txt = _("Error in file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
				message = _("Command line error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")

		self.session.openWithCallback(self.restartBOX,MessageBox, message, MessageBox.TYPE_YESNO)
Exemple #4
0
	def save(self):
		print "[MultiBootStartup] select new startup: ", self.list[self.selection]
		ret = system("cp -f '/boot/%s' /boot/STARTUP" %self.list[self.selection])
		if ret:
			self.session.open(MessageBox, _("File '/boot/%s' copy to '/boot/STARTUP' failed!") %self.list[self.selection], MessageBox.TYPE_ERROR)
			self.getCurrent()
			return

		writeoption = already = failboot = False
		newboot = boot = self.readlineFile('/boot/STARTUP')

		if self.checkBootEntry(boot):
			failboot = True
		elif self.option_enabled:
			for x in self.optionsList:
				if (x[0] + "'" in boot or x[0] + " " in boot) and x[0] != self.optionsList[self.option][0]:
					newboot = boot.replace(x[0],self.optionsList[self.option][0])
					writeoption = True
					break
				elif (x[0] + "'" in boot or x[0] + " " in boot) and x[0] == self.optionsList[self.option][0]:
					already = True
					break
			if not (writeoption or already):
				if "boxmode" in boot:
					failboot = True
				elif self.option:
					newboot = boot.replace("rootwait", "rootwait %s_4.%s" %(getMachineBuild(), self.optionsList[self.option][0]))
					writeoption = True

		if self.enable_bootnamefile:
			if failboot:
				self.writeFile('/boot/bootname', 'STARTUP_1=STARTUP_1')
			else:
				self.writeFile('/boot/bootname', '%s=%s' %('STARTUP_%s' %getMachineBuild() ,boot[22:23], self.list[self.selection]))

		message = _("Do you want to reboot now with selected image?")
		if failboot:
			print "[MultiBootStartup] wrong bootsettings: " + boot
			if '/dev/mmcblk0p3' in Harddisk.getextdevices("ext4"):
				if self.writeFile('/boot/STARTUP', "boot emmcflash0.kernel1 'root=/dev/mmcblk0p3 rw rootwait'"):
					txt = _("Next boot will start from Image 1.")
				else:
					txt =_("Can not repair file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
			else:
				txt = _("Alternative Image 1 partition for boot repair not found.") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
			message = _("Wrong Bootsettings detected!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
		elif writeoption:
			if not self.writeFile('/boot/STARTUP', newboot):
				txt = _("Can not write file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
				message = _("Write error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")

		#verify boot
		if failboot or writeoption:
			boot = self.readlineFile('/boot/STARTUP')
			if self.checkBootEntry(boot):
				txt = _("Error in file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
				message = _("Command line error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")

		self.session.openWithCallback(self.restartBOX,MessageBox, message, MessageBox.TYPE_YESNO)
Exemple #5
0
	def list_files(self, PATH):
		files = []
		self.path = PATH
		for name in listdir(self.path):
			if path.isfile(path.join(self.path, name)):
				cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
				if cmdline in Harddisk.getextdevices("ext4") and not name == "STARTUP":
					files.append(name)
		return files
	def list_files(self, PATH):
		files = []
		self.path = PATH
		for name in listdir(self.path):
			if path.isfile(path.join(self.path, name)):
				cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
				if cmdline in Harddisk.getextdevices("ext4") and not name == "STARTUP":
					files.append(name)
		return files
Exemple #7
0
    def list_files(self, PATH):
        files = []
        self.path = PATH
        for name in listdir(self.path):
            if path.isfile(path.join(self.path, name)):
                cmdline = self.read_startup('/boot/' + name).split('=', 1)[1].split(' ', 1)[0]
                if cmdline in Harddisk.getextdevices('ext4') and not name == 'cmdline.txt':
                    files.append(name)

        return files
	def list_files(self, PATH):
		files = []
		for name in listdir(PATH):
			if path.isfile(path.join(PATH, name)):
				try:
					cmdline = self.read_startup("/boot/" + name).split("=",3)[3].split(" ",1)[0]
				except IndexError:
					continue
				if cmdline in Harddisk.getextdevices("ext4") and not name == "STARTUP":
					files.append(name)
		return files
Exemple #9
0
	def list_files(self, PATH):
		files = []
		if SystemInfo["HaveMultiBoot"]:
			self.path = PATH
			for name in listdir(self.path):
				if path.isfile(path.join(self.path, name)):
					cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
					if cmdline in Harddisk.getextdevices("ext4"):
						files.append(name)
			files.append("Recovery")
		return files
Exemple #10
0
	def list_files(self, PATH):
		files = []
		for name in listdir(PATH):
			if path.isfile(path.join(PATH, name)):
				try:
					cmdline = self.read_startup("/boot/" + name).split("=",3)[3].split(" ",1)[0]
				except IndexError:
					continue
				if cmdline in Harddisk.getextdevices("ext4") and not name == "STARTUP":
					files.append(name)
		return files
Exemple #11
0
	def list_files(self, PATH):
		files = []
		if SystemInfo["HaveMultiBoot"]:
			self.path = PATH
			for name in listdir(self.path):
				if path.isfile(path.join(self.path, name)):
					cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
					if cmdline in Harddisk.getextdevices("ext4"):
						files.append(name)
			files.append("Recovery")
		return files
Exemple #12
0
	def list_files(self, PATH):
		files = []
		if SystemInfo["HaveMultiBoot"]:
			self.path = PATH
			for name in listdir(self.path):
				if path.isfile(path.join(self.path, name)):
					if self.MACHINEBUILD in ("hd51","vs1500","h7","ceryon7252"):
						cmdline = self.read_startup("/boot/" + name).split("=",3)[3].split(" ",1)[0]
					else:
						cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
					if cmdline in Harddisk.getextdevices("ext4"):
						files.append(name)
			if getMachineBuild() not in ("gb7252"):
				files.append("Recovery")
		return files
Exemple #13
0
    def list_files(self, PATH):
        files = []
        for name in listdir(PATH):
            if path.isfile(path.join(PATH, name)):
                try:
                    cmdline = self.read_startup('/boot/' + name).split(
                        '=', 3)[3].split(' ', 1)[0]
                except IndexError:
                    continue

                if cmdline in Harddisk.getextdevices(
                        'ext4') and not name == 'STARTUP':
                    files.append(name)

        return files
Exemple #14
0
	def list_files(self, PATH):
		files = []
		if SystemInfo["HaveMultiBoot"]:
			self.path = PATH
			for name in listdir(self.path):
				if path.isfile(path.join(self.path, name)):
					if self.MACHINEBUILD in ("hd51","vs1500","h7"):
						cmdline = self.read_startup("/boot/" + name).split("=",3)[3].split(" ",1)[0]
					elif self.MACHINEBUILD in ("8100s"):
						cmdline = self.read_startup("/boot/" + name).split("=",4)[4].split(" ",1)[0]
					else:
						cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
					if cmdline in Harddisk.getextdevices("ext4"):
						files.append(name)
			if getMachineBuild() not in ("gb7252"):
				files.append("Recovery")
		return files
Exemple #15
0
 def checkBootEntry(self, ENTRY):
     try:
         ret = False
         temp = ENTRY.split(' ')
         #read kernel, root as number and device name
         kernel = int(temp[1].split("emmcflash0.kernel")[1])
         root = int(temp[2].split("'root=/dev/mmcblk0p")[1])
         device = temp[2].split("=")[1]
         #read boxmode and new boxmode settings
         cmdx = 5
         cmd4 = "rootwait'"
         bootmode = '1'
         if 'boxmode' in ENTRY:
             cmdx = 6
             cmd4 = "rootwait"
             bootmode = temp[5].split(
                 "%s_4.boxmode=" % getMachineBuild())[1].replace("'", '')
         setmode = self.optionsList[self.option][0].split('=')[1]
         #verify entries
         if cmdx != len(temp) or 'boot' != temp[0] or 'rw' != temp[
                 3] or cmd4 != temp[
                     4] or kernel != root - kernel - 1 or "'" != ENTRY[-1:]:
             print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with not matching entries!"
             ret = True
         #verify length
         elif ('boxmode' not in ENTRY
               and len(ENTRY) > 58) or ('boxmode' in ENTRY
                                        and len(ENTRY) > 76):
             print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with line length!"
             ret = True
         #verify boxmode
         elif bootmode != setmode and not self.option_enabled:
             print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with unsupported boxmode!"
             ret = True
         #verify device
         elif not device in Harddisk.getextdevices("ext4"):
             print "[MultiBootStartup] Command line in '/boot/STARTUP' - boot device not exist!"
             ret = True
     except:
         print "[MultiBootStartup] Command line in '/boot/STARTUP' - unknown problem!"
         ret = True
     return ret
Exemple #16
0
	def checkBootEntry(self, ENTRY):
		try:
			ret = False
			temp = ENTRY.split(' ')
			#read kernel, root as number and device name
			kernel = int(temp[1].split("emmcflash0.kernel")[1])
			root = int(temp[4].split("root=/dev/mmcblk0p")[1])
			device = temp[4].split("=")[1]
			#read boxmode and new boxmode settings
			cmdx = 7
			cmd4 = "rootwait'"
			bootmode = '1'
			if 'boxmode' in ENTRY:
				cmdx = 8
				cmd4 = "rootwait"
				bootmode = temp[7].split("%s_4.boxmode=" %getMachineBuild())[1].replace("'",'')
			setmode = self.optionsList[self.option][0].split('=')[1]
			#verify entries
			if cmdx != len(temp) or 'boot' != temp[0] or 'rw' != temp[5] or cmd4 != temp[6] or kernel != root-kernel-1 or "'" != ENTRY[-1:]:
				print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with not matching entries!"
				ret = True
			#verify length
			elif ('boxmode' not in ENTRY and len(ENTRY) > 96) or ('boxmode' in ENTRY and len(ENTRY) > 115):
				print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with line length!"
				ret = True
			#verify boxmode
			elif bootmode != setmode and not self.option_enabled:
				print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with unsupported boxmode!"
				ret = True
			#verify device
			elif not device in Harddisk.getextdevices("ext4"):
				print "[MultiBootStartup] Command line in '/boot/STARTUP' - boot device not exist!"
				ret = True
		except:
			print "[MultiBootStartup] Command line in '/boot/STARTUP' - unknown problem!"
			ret = True
		return ret
Exemple #17
0
	def list_files(self, PATH):
		files = []
		if SystemInfo["HaveMultiBoot"]:
			self.path = PATH
			if SystemInfo["HasRootSubdir"]:
				for name in listdir(self.path):
					if path.isfile(path.join(self.path, name)):
						try:
							cmdline = self.find_rootfssubdir(name)
							if cmdline == None:
								continue
						except IndexError:
							continue
						cmdline_startup = self.find_rootfssubdir("STARTUP")
						if (cmdline != cmdline_startup) and (name != "STARTUP"):
							files.append(name)
				files.insert(0,"STARTUP")
			else:
				for name in listdir(self.path):
					if path.isfile(path.join(self.path, name)):
						try:
							if self.MACHINEBUILD in ("hd51","vs1500","h7"):
								cmdline = self.read_startup("/boot/" + name).split("=",3)[3].split(" ",1)[0]
							elif self.MACHINEBUILD in ("8100s"):
								cmdline = self.read_startup("/boot/" + name).split("=",4)[4].split(" ",1)[0]
							else:
								cmdline = self.read_startup("/boot/" + name).split("=",1)[1].split(" ",1)[0]
							if cmdline in Harddisk.getextdevices("ext4"):
								files.append(name)
						except IndexError:
							print '[ImageBackup] - IndexError in file: %s' %name
							self.error_files += '/boot/' + name + ', ' 
				if getMachineBuild() not in ("gb7252"):
					files.append("Recovery")
		else:
			files = "None"
		return files
Exemple #18
0
    def checkBootEntry(self, ENTRY):
        try:
            ret = False
            temp = ENTRY.split(' ')
            kernel = int(temp[1].split('emmcflash0.kernel')[1])
            root = int(temp[4].split('root=/dev/mmcblk0p')[1])
            device = temp[4].split('=')[1]
            cmdx = 7
            cmd4 = "rootwait'"
            bootmode = '1'
            if 'boxmode' in ENTRY:
                cmdx = 8
                cmd4 = 'rootwait'
                bootmode = temp[7].split(
                    '%s_4.boxmode=' % getMachineBuild())[1].replace("'", '')
            setmode = self.optionsList[self.option][0].split('=')[1]
            if cmdx != len(temp) or 'boot' != temp[0] or 'rw' != temp[
                    5] or cmd4 != temp[
                        6] or kernel != root - kernel - 1 or "'" != ENTRY[-1:]:
                print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with not matching entries!"
                ret = True
            elif 'boxmode' not in ENTRY and len(
                    ENTRY) > 96 or 'boxmode' in ENTRY and len(ENTRY) > 115:
                print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with line length!"
                ret = True
            elif bootmode != setmode and not self.option_enabled:
                print "[MultiBootStartup] Command line in '/boot/STARTUP' - problem with unsupported boxmode!"
                ret = True
            elif device not in Harddisk.getextdevices('ext4'):
                print "[MultiBootStartup] Command line in '/boot/STARTUP' - boot device not exist!"
                ret = True
        except:
            print "[MultiBootStartup] Command line in '/boot/STARTUP' - unknown problem!"
            ret = True

        return ret
Exemple #19
0
    def save(self):
        print "[MultiBootStartup] select new startup: ", self.list[
            self.selection]
        ret = system("cp -f '/boot/%s' /boot/STARTUP" %
                     self.list[self.selection])
        if ret:
            self.session.open(
                MessageBox,
                _("File '/boot/%s' not found - copy to /boot/STARTUP failed!")
                % self.list[self.selection], MessageBox.TYPE_ERROR)
            self.getCurrent()
            return

        newboot = boot = self.readlineFile('/boot/STARTUP')
        newmode = self.optionsList[self.option][0].split('=')[1]

        #check for wrong changes
        try:
            cmdfail = False
            bootcmd = boot.split("=", 1)[1].split(" ", 1)[0]
            bootmode = '1'
            temp = boot.split(' ')
            #read kernel and root
            kernel = int(temp[1].split("emmcflash0.kernel")[1])
            root = int(temp[2].split("'root=/dev/mmcblk0p")[1])
            #read boxmode
            cmd4 = "rootwait'"
            if 'boxmode' in boot:
                cmd4 = "rootwait"
                bootmode = temp[5].split("hd51_4.boxmode=")[1].replace("'", '')
            #verify settings
            if not ('boot' == temp[0] and 'rw' == temp[3] and cmd4 == temp[4]
                    and kernel == root - kernel - 1 and "'" == boot[-1:]
                    and bootcmd in Harddisk.getextdevices("ext4")):
                cmdfail = True
        except:
            cmdfail = True

        checkboot = True or cmdfail  #check command line on/off (forcing to True if fail in boot)
        writeoption = already = failboot = False

        if checkboot and (cmdfail or
                          (bootmode != newmode and not self.option_enabled) or
                          (len(boot.split('boxmode')) > 2) or
                          ('boxmode' in boot and len(boot) > 76) or
                          ('boxmode' not in boot and len(boot) > 58)):
            failboot = True
        elif self.option_enabled:
            for x in self.optionsList:
                if (x[0] + "'" in boot or x[0] + " "
                        in boot) and x[0] != self.optionsList[self.option][0]:
                    newboot = boot.replace(x[0],
                                           self.optionsList[self.option][0])
                    writeoption = True
                    break
                elif (x[0] + "'" in boot or x[0] + " "
                      in boot) and x[0] == self.optionsList[self.option][0]:
                    already = True
                    break
            if not (writeoption or already):
                if "boxmode" in boot:
                    failboot = checkboot
                elif self.option:
                    newboot = boot.replace(
                        "rootwait", "rootwait hd51_4.%s" %
                        (self.optionsList[self.option][0]))
                    writeoption = True

        if self.enable_bootnamefile:
            if failboot:
                self.writeFile('/boot/bootname', 'STARTUP_1=STARTUP_1')
            else:
                self.writeFile(
                    '/boot/bootname', '%s=%s' %
                    ('STARTUP_%s' % boot[22:23], self.list[self.selection]))

        message = _("Do you want to reboot now with selected image?")
        if failboot:
            print "[MultiBootStartup] wrong bootsettings: " + boot
            if '/dev/mmcblk0p3' in Harddisk.getextdevices("ext4"):
                if self.writeFile(
                        '/boot/STARTUP',
                        "boot emmcflash0.kernel1 'root=/dev/mmcblk0p3 rw rootwait'"
                ):
                    txt = _("Next boot will start from Image 1.")
                else:
                    txt = _("Can not repair file %s") % (
                        "'/boot/STARTUP'") + "\n" + _(
                            "Caution, next boot is starts with these settings!"
                        ) + "\n"
            else:
                txt = _(
                    "Alternative Image 1 partition for boot repair not found."
                ) + "\n" + _(
                    "Caution, next boot is starts with these settings!") + "\n"
            message = _("Wrong Bootsettings detected!") + "\n\n%s\n\n%s\n" % (
                boot, txt) + _("Do you want to reboot now?")
        elif writeoption:
            if not self.writeFile('/boot/STARTUP', newboot):
                txt = _("Can not write file %s") % (
                    "'/boot/STARTUP'") + "\n" + _(
                        "Caution, next boot is starts with these settings!"
                    ) + "\n"
                message = _("Write error!") + "\n\n%s\n\n%s\n" % (
                    boot, txt) + _("Do you want to reboot now?")
        self.session.openWithCallback(self.restartBOX, MessageBox, message,
                                      MessageBox.TYPE_YESNO)
Exemple #20
0
    def save(self):
        print '[MultiBootStartup] select new startup: ', self.list[
            self.selection]
        ret = system("cp -f '/boot/%s' /boot/STARTUP" %
                     self.list[self.selection])
        if ret:
            self.session.open(
                MessageBox,
                _("File '/boot/%s' copy to '/boot/STARTUP' failed!") %
                self.list[self.selection], MessageBox.TYPE_ERROR)
            self.getCurrent()
            return
        writeoption = already = failboot = False
        newboot = boot = self.readlineFile('/boot/STARTUP')
        if self.checkBootEntry(boot):
            failboot = True
        elif self.option_enabled:
            for x in self.optionsList:
                if (x[0] + "'" in boot or x[0] + ' '
                        in boot) and x[0] != self.optionsList[self.option][0]:
                    newboot = boot.replace(x[0],
                                           self.optionsList[self.option][0])
                    if self.optionsList[self.option][0] == 'boxmode=1':
                        newboot = newboot.replace('520M@248M', '440M@328M')
                        newboot = newboot.replace('200M@768M', '192M@768M')
                    elif self.optionsList[self.option][0] == 'boxmode=12':
                        newboot = newboot.replace('440M@328M', '520M@248M')
                        newboot = newboot.replace('192M@768M', '200M@768M')
                    writeoption = True
                    break
                elif (x[0] + "'" in boot or x[0] + ' '
                      in boot) and x[0] == self.optionsList[self.option][0]:
                    already = True
                    break

            if not (writeoption or already):
                if 'boxmode' in boot:
                    failboot = True
                elif self.option:
                    newboot = boot.replace(
                        'rootwait', 'rootwait %s_4.%s' %
                        (getMachineBuild(), self.optionsList[self.option][0]))
                    if self.optionsList[self.option][0] == 'boxmode=1':
                        newboot = newboot.replace('520M@248M', '440M@328M')
                        newboot = newboot.replace('200M@768M', '192M@768M')
                    elif self.optionsList[self.option][0] == 'boxmode=12':
                        newboot = newboot.replace('440M@328M', '520M@248M')
                        newboot = newboot.replace('192M@768M', '200M@768M')
                    writeoption = True
        if self.enable_bootnamefile:
            if failboot:
                self.writeFile('/boot/bootname', 'STARTUP_1=STARTUP_1')
            else:
                self.writeFile(
                    '/boot/bootname',
                    '%s=%s' % ('STARTUP_%s' % getMachineBuild(), boot[22:23],
                               self.list[self.selection]))
        message = _('Do you want to reboot now with selected image?')
        if failboot:
            print '[MultiBootStartup] wrong bootsettings: ' + boot
            if '/dev/mmcblk0p3' in Harddisk.getextdevices('ext4'):
                if self.writeFile(
                        '/boot/STARTUP',
                        "boot emmcflash0.kernel1 'brcm_cma=440M@328M brcm_cma=192M@768M root=/dev/mmcblk0p3 rw rootwait'"
                ):
                    txt = _('Next boot will start from Image 1.')
                else:
                    txt = _(
                        'Can not repair file %s'
                    ) % "'/boot/STARTUP'" + '\n' + _(
                        'Caution, next boot is starts with these settings!'
                    ) + '\n'
            else:
                txt = _(
                    'Alternative Image 1 partition for boot repair not found.'
                ) + '\n' + _(
                    'Caution, next boot is starts with these settings!') + '\n'
            message = _('Wrong Bootsettings detected!') + '\n\n%s\n\n%s\n' % (
                boot, txt) + _('Do you want to reboot now?')
        elif writeoption:
            if not self.writeFile('/boot/STARTUP', newboot):
                txt = _('Can not write file %s') % "'/boot/STARTUP'" + '\n' + _(
                    'Caution, next boot is starts with these settings!') + '\n'
                message = _('Write error!') + '\n\n%s\n\n%s\n' % (
                    boot, txt) + _('Do you want to reboot now?')
        if failboot or writeoption:
            boot = self.readlineFile('/boot/STARTUP')
            if self.checkBootEntry(boot):
                txt = _('Error in file %s') % "'/boot/STARTUP'" + '\n' + _(
                    'Caution, next boot is starts with these settings!') + '\n'
                message = _('Command line error!') + '\n\n%s\n\n%s\n' % (
                    boot, txt) + _('Do you want to reboot now?')
        self.session.openWithCallback(self.restartBOX, MessageBox, message,
                                      MessageBox.TYPE_YESNO)
Exemple #21
0
	def save(self):
		print "[MultiBootStartup] select new startup: ", self.list[self.selection]
		ret = system("cp -f '/boot/%s' /boot/STARTUP" %self.list[self.selection])
		if ret:
			self.session.open(MessageBox, _("File '/boot/%s' not found - copy to /boot/STARTUP failed!") %self.list[self.selection], MessageBox.TYPE_ERROR)
			self.getCurrent()
			return

		newboot = boot = self.readlineFile('/boot/STARTUP')
		newmode = self.optionsList[self.option][0].split('=')[1]

		#check for wrong changes
		try:
			cmdfail = False
			bootcmd = boot.split("=",1)[1].split(" ",1)[0]
			bootmode = '1'
			temp = boot.split(' ')
			#read kernel and root
			kernel = int(temp[1].split("emmcflash0.kernel")[1])
			root = int(temp[2].split("'root=/dev/mmcblk0p")[1])
			#read boxmode
			cmd4 = "rootwait'"
			if 'boxmode' in boot:
				cmd4 = "rootwait"
				bootmode = temp[5].split("hd51_4.boxmode=")[1].replace("'",'')
			#verify settings
			if not ('boot' == temp[0] and 'rw' == temp[3] and cmd4 == temp[4] and kernel == root-kernel-1 and "'" == boot[-1:] and bootcmd in Harddisk.getextdevices("ext4")):
				cmdfail = True
		except:
			cmdfail = True

		checkboot = True or cmdfail #check command line on/off (forcing to True if fail in boot)
		writeoption = already = failboot = False

		if checkboot and (cmdfail or (bootmode != newmode and not self.option_enabled) or (len(boot.split('boxmode')) > 2) or ('boxmode' in boot and len(boot) > 76) or ('boxmode' not in boot and len(boot) > 58)):
			failboot = True
		elif self.option_enabled:
			for x in self.optionsList:
				if (x[0] + "'" in boot or x[0] + " " in boot) and x[0] != self.optionsList[self.option][0]:
					newboot = boot.replace(x[0],self.optionsList[self.option][0])
					writeoption = True
					break
				elif (x[0] + "'" in boot or x[0] + " " in boot) and x[0] == self.optionsList[self.option][0]:
					already = True
					break
			if not (writeoption or already):
				if "boxmode" in boot:
					failboot = checkboot
				elif self.option:
					newboot = boot.replace("rootwait", "rootwait hd51_4.%s" %(self.optionsList[self.option][0]))
					writeoption = True

		if self.enable_bootnamefile:
			if failboot:
				self.writeFile('/boot/bootname', 'STARTUP_1=STARTUP_1')
			else:
				self.writeFile('/boot/bootname', '%s=%s' %('STARTUP_%s' %boot[22:23], self.list[self.selection]))

		message = _("Do you want to reboot now with selected image?")
		if failboot:
			print "[MultiBootStartup] wrong bootsettings: " + boot
			if '/dev/mmcblk0p3' in Harddisk.getextdevices("ext4"):
				if self.writeFile('/boot/STARTUP', "boot emmcflash0.kernel1 'root=/dev/mmcblk0p3 rw rootwait'"):
					txt = _("Next boot will start from Image 1.")
				else:
					txt =_("Can not repair file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
			else:
				txt = _("Alternative Image 1 partition for boot repair not found.") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
			message = _("Wrong Bootsettings detected!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
		elif writeoption:
			if not self.writeFile('/boot/STARTUP', newboot):
				txt = _("Can not write file %s") %("'/boot/STARTUP'") + "\n" + _("Caution, next boot is starts with these settings!") + "\n"
				message = _("Write error!") + "\n\n%s\n\n%s\n" %(boot, txt) + _("Do you want to reboot now?")
		self.session.openWithCallback(self.restartBOX,MessageBox, message, MessageBox.TYPE_YESNO)