def create_metadata(repo, packages=None, comps=None): """ Generate YUM metadata for a repository. This method accepts a repository object and, based on its configuration, generates YUM metadata for it using the createrepo sister library. """ util.validate_repo(repo) conf = createrepo.MetaDataConfig() conf.directory = os.path.dirname(repo.pkgdir) conf.outputdir = os.path.dirname(repo.pkgdir) if packages: conf.pkglist = packages conf.quiet = True if comps: groupdir = tempfile.mkdtemp() conf.groupfile = os.path.join(groupdir, 'groups.xml') with open(conf.groupfile, 'w') as f: f.write(comps) generator = createrepo.SplitMetaDataGenerator(conf) generator.doPkgMetadata() generator.doRepoMetadata() generator.doFinalMove() if comps and os.path.exists(groupdir): shutil.rmtree(groupdir)
def set_path(repo, path): """ Set the local filesystem path to use for a repository object. """ util.validate_repo(repo) result = copy.copy(repo) # make a copy so the original is untouched # The following is wrapped in a try-except to suppress an anticipated # exception from YUM's yumRepo.py, line 530 and 557. try: result.pkgdir = path except yum.Errors.RepoError: pass return result