def zip_all_libs_to_cache(self):
     os.system('rm -rf ' + self.cache_libs_path + '/*')
     FileUtils.create_dir(self.cache_libs_path)
     for dir in FileUtils.listdir_nohidden(self.generated_path):
         ZipUtils.zip_dir(self.generated_path + '/' + dir,
                          self.cache_libs_path + '/' + dir + '.zip')
     FileUtils.copy_file_or_dir(self.prebuild_path + self.manifest_file,
                                self.cache_path)
Exemplo n.º 2
0
 def unzip_cache(self):
     logger.info(f'Unzip cache, from {self.cache_libs_path} to {self.generated_path}')
     with step('unzip_prebuild_libs'):
         FileUtils.remove_dir(self.prebuild_path)
         FileUtils.create_dir(self.generated_path)
         FileUtils.copy_file_or_dir(os.path.join(self.cache_path, self.manifest_file), self.prebuild_path)
         # Unzip libs to pod-binary folder
         for zip_path in glob.iglob(os.path.join(self.cache_libs_path, '*.zip')):
             ZipUtils.unzip(zip_path, self.generated_path)
 def unzip_cache(self):
     with step('unzip_prebuild_libs'):
         FileUtils.remove_dir(self.prebuild_path)
         FileUtils.create_dir(self.generated_path)
         FileUtils.copy_file_or_dir(self.cache_path + self.manifest_file,
                                    self.prebuild_path)
         # Unzip libs to pod-binary folder
         for zipPath in glob.iglob(self.cache_libs_path + '/*.zip'):
             ZipUtils.unzip(zipPath, self.generated_path)
    def prebuild_if_needed(self, push=True):
        self.fetch_and_apply_cache()
        subprocess.run(['bundle', 'exec', 'pod', 'install'], check=True)
        # Sync with cache directory

        if not os.path.isfile(self.delta_path):
            logger.info('No change in prebuilt frameworks')
            return
        try:
            with open(self.delta_path) as f:
                FileUtils.create_dir(self.cache_path)
                data = f.read()
                data = re.sub('"', '', data)
                updatedMatches = re.findall(r'Updated: \[(.*)\]', data)
                if updatedMatches:
                    updated = updatedMatches[0].strip()
                    logger.info("Updated frameworks: {}".format(updated))
                    if len(updated):
                        libs = updated.split(',')
                        for lib in libs:
                            libName = lib.strip()
                            self.clean_cache(libName)
                            self.zip_to_cache(libName)

                deletedMatches = re.findall(r'Deleted: \[(.*)\]', data)
                if deletedMatches:
                    deleted = deletedMatches[0].strip()
                    logger.info('Deleted frameworks: {}'.format(deleted))
                    if len(deleted):
                        libs = deleted.split(',')
                        for lib in libs:
                            self.clean_cache(lib.strip())
                # Copy manifest file
                FileUtils.copy_file_or_dir(
                    self.prebuild_path + self.manifest_file, self.cache_path)
                if push:
                    self.push_all_to_git(self.cache_path)
        except Exception as e:
            raise e