rpm_patcher.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:combirepo 作者: Samsung 项目源码 文件源码
def __use_cached_root_or_prepare(self):
        """
        Tries to find cached root and uses it in case it exists and prepares
        it otherwise.
        """
        image_info = "{0}".format((self.names, self.repositories,
                                   self.architecture,
                                   os.path.basename(self.kickstart_file_path)))
        cached_images_info_paths = files.find_fast(
            patching_cache_path, ".*preliminary_image.info.txt")
        matching_images_path = None
        for info_path in cached_images_info_paths:
            cached_images_path = info_path.replace(".info.txt", "")
            if not os.path.isdir(cached_images_path):
                logging.error("Directory {0} not "
                              "found!".format(cached_images_path))
                continue
            lines = []
            with open(info_path, "r") as info_file:
                for line in info_file:
                    lines.append(line)
            if lines[0] == image_info:
                matching_images_path = cached_images_path
                break
        if matching_images_path is not None:
            self.patching_root = matching_images_path
            logging.info("Found already prepared patching root: "
                         "{0}".format(matching_images_path))
        else:
            self.__prepare()
            cached_chroot_path = os.path.join(
                patching_cache_path, os.path.basename(
                    self.patching_root) + "preliminary_image")
            hidden_subprocess.call(
                "Saving chroot to cache",
                ["cp", "-a", self.patching_root, cached_chroot_path])
            info_path = cached_chroot_path + ".info.txt"
            with open(info_path, "wb") as info_file:
                info_file.write(image_info)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号