Пример #1
0
    def start(self):
        if utils.is_running():
            raise script_exceptions.AlreadyRunning

        utils.set_running()
        log.log("Starting GUI")
        log.log("Arch set to {}".format(config.arch))

        self.background = addon.get_bool_setting('background')
        self.verify_files = addon.get_bool_setting('verify_files')

        funcs.create_directory(libreelec.UPDATE_DIR)

        utils.check_update_files(builds.get_build_from_notify_file(),
                                 force_dialog=True)

        self.installed_build = self.get_installed_build()

        self.select_build()

        utils.remove_update_files()

        self.check_archive()

        self.maybe_download()

        self.maybe_verify()

        rpi.maybe_disable_overclock()

        utils.maybe_schedule_extlinux_update()

        utils.maybe_run_backup()

        self.confirm()
Пример #2
0
 def maybe_extract(self):
     if self.verify_files:
         tf = tarfile.open(self.selected_build.tar_name, 'r')
         utils.log("Starting extraction from tar file " + self.selected_build.tar_name)
         
         # Create the .update directory if necessary.
         if not os.path.exists(constants.UPDATE_DIR):
             utils.log("Creating {} directory".format(constants.UPDATE_DIR))
             os.mkdir(constants.UPDATE_DIR)
         
         # Extract the update files from the tar file to the .update directory.
         tar_members = (m for m in tf.getmembers()
                        if os.path.basename(m.name) in constants.UPDATE_FILES)
         for member in tar_members:
             ti = tf.extractfile(member)
             outfile = os.path.join(constants.UPDATE_DIR, os.path.basename(member.name))
             try:
                 with progress.FileProgress("Extracting", ti, outfile, ti.size,
                                            self.background) as extractor:
                     extractor.start()
                 utils.log("Extracted " + outfile)
             except script_exceptions.Canceled:
                 utils.remove_update_files()
                 sys.exit(0)
             except script_exceptions.WriteError as e:
                 utils.write_error(outfile, str(e))
                 sys.exit(1)
 
         tf.close()
     else:
         # Just move the tar file to the update directory.
         os.rename(self.selected_build.tar_name,
                   os.path.join(constants.UPDATE_DIR, self.selected_build.tar_name))
Пример #3
0
 def maybe_verify(self):
     if self.verify_files:
         # Verify the md5 sums.
         os.chdir(constants.UPDATE_DIR)
         for f in constants.UPDATE_IMAGES:
             md5sum = open(f + '.md5').read().split()[0]
             utils.log("{}.md5 file = {}".format(f, md5sum))
     
             if not self.md5sum_verified(md5sum, f):
                 utils.log("{} md5 mismatch!".format(f))
                 xbmcgui.Dialog().ok("{} md5 mismatch".format(f),
                                     "The {} image from".format(f),
                                     self.selected_build.filename,
                                     "is corrupt. The update files will be removed.")
                 utils.remove_update_files()
                 sys.exit(1)
             else:
                 utils.log("{} md5 is correct".format(f))
Пример #4
0
    def maybe_verify(self):
        if not self.verify_files:
            return

        log.log("Verifying update file")
        with closing(tarfile.open(self.update_tar_path, 'r')) as tf:
            tar_names = tf.getnames()

            for update_image in libreelec.UPDATE_IMAGES:
                path_in_tar = next(
                    name for name in tar_names
                    if name.endswith(os.path.join('target', update_image)))
                ti = tf.extractfile(path_in_tar)
                temp_image_path = os.path.join(TEMP_PATH, update_image)
                try:
                    with progress.FileProgress(L10n(32018), ti,
                                               temp_image_path, ti.size,
                                               self.background) as extractor:
                        extractor.start()
                    log.log("Extracted " + temp_image_path)
                except script_exceptions.Canceled:
                    return
                except script_exceptions.WriteError as e:
                    utils.write_error(temp_image_path, str(e))
                    return

                md5sum = tf.extractfile(path_in_tar + '.md5').read().split()[0]
                log.log("{}.md5 file = {}".format(update_image, md5sum))

                if not progress.md5sum_verified(md5sum, temp_image_path,
                                                self.background):
                    log.log("{} md5 mismatch!".format(update_image))
                    utils.ok(
                        L10n(32019).format(update_image),
                        self.selected_build.filename,
                        L10n(32020).format(update_image), L10n(32021))
                    utils.remove_update_files()
                    return
                else:
                    log.log("{} md5 is correct".format(update_image))

                funcs.remove_file(temp_image_path)
Пример #5
0
    def start(self):
        if utils.is_running():
            raise script_exceptions.AlreadyRunning

        utils.set_running()
        log.log("Starting")

        builds.arch = utils.get_arch()
        log.log("Set arch to {}".format(builds.arch))

        if addon.get_bool_setting('set_timeout'):
            builds.timeout = float(addon.get_setting('timeout'))

        self.background = addon.get_bool_setting('background')
        self.verify_files = addon.get_bool_setting('verify_files')
        
        funcs.create_directory(openelec.UPDATE_DIR)

        utils.check_update_files(builds.get_build_from_notify_file(),
                                 force_dialog=True)

        self.installed_build = self.get_installed_build()

        self.select_build()

        utils.remove_update_files()

        self.check_archive()

        self.maybe_download()

        self.maybe_verify()

        rpi.maybe_disable_overclock()

        utils.maybe_schedule_extlinux_update()

        utils.maybe_run_backup()

        self.confirm()
Пример #6
0
    def maybe_verify(self):
        if not self.verify_files:
            return

        log.log("Verifying update file")
        with closing(tarfile.open(self.update_tar_path, 'r')) as tf:
            tar_names = tf.getnames()

            for update_image in openelec.UPDATE_IMAGES:
                path_in_tar = next(name for name in tar_names
                                   if name.endswith(os.path.join('target', update_image)))
                ti = tf.extractfile(path_in_tar)
                temp_image_path = os.path.join(TEMP_PATH, update_image)
                try:
                    with progress.FileProgress(L10n(32018), ti, temp_image_path, ti.size,
                                               self.background) as extractor:
                        extractor.start()
                    log.log("Extracted " + temp_image_path)
                except script_exceptions.Canceled:
                    return
                except script_exceptions.WriteError as e:
                    utils.write_error(temp_image_path, str(e))
                    return

                md5sum = tf.extractfile(path_in_tar + '.md5').read().split()[0]
                log.log("{}.md5 file = {}".format(update_image, md5sum))
        
                if not progress.md5sum_verified(md5sum, temp_image_path,
                                                self.background):
                    log.log("{} md5 mismatch!".format(update_image))
                    utils.ok(L10n(32019).format(update_image),
                             self.selected_build.filename,
                             L10n(32020).format(update_image), L10n(32021))
                    utils.remove_update_files()
                    return
                else:
                    log.log("{} md5 is correct".format(update_image))

                funcs.remove_file(temp_image_path)