def getpackages(self, **kwargs): """Valid parameters: :param local_info_repo: local rdoinfo repo to use instead of fetching the default one using distroinfo. :param tags: release tags to use (mitaka, newton, etc). """ local_info_repo = kwargs.get('local_info_repo') tags = kwargs.get('tags') info_files = self.config_options.info_files if not info_files: fail_req_config_missing('info_file') inforepo = None if local_info_repo: inforepo = info.DistroInfo( info_files=info_files, local_info=local_info_repo, cache_base_path=self.config_options.cache_dir) # NOTE(jpena): in general, info_files will only contain one file, # but it supports multiple... In that case, we will have a comma # separated list of URLs self.distroinfo_path = "%s/%s" % (local_info_repo.rstrip('/'), info_files[0]) for extra_file in info_files[1:]: self.distroinfo_path += ",%s/%s" % ( local_info_repo.rstrip('/')) elif self.config_options.rdoinfo_repo: inforepo = info.DistroInfo( info_files=info_files, remote_git_info=self.config_options.rdoinfo_repo, cache_base_path=self.config_options.cache_dir) rdoinfo_repo = self.config_options.rdoinfo_repo self.distroinfo_path = "%s/%s" % (rdoinfo_repo.rstrip('/'), info_files[0]) for extra_file in info_files[1:]: self.distroinfo_path += ",%s/%s" % (rdoinfo_repo.rstrip('/'), extra_file) else: fail_req_config_missing('repo') pkginfo = inforepo.get_info(apply_tag=tags) self.packages = pkginfo["packages"] if tags: # FIXME allow list of tags? self.packages = query.filter_pkgs(self.packages, {'tags': tags}) if self.config_options.downstream_tag: # filter out packages missing parameters with # downstream_tag downstream_tag = self.config_options.downstream_tag self.packages = query.filter_pkgs(self.packages, {'tags': downstream_tag}) return self.packages
def get_distro_info(distroinfo_repo): """Set up distro_info based on path""" info_file, info_repo, remote = parse_distro_info_path(distroinfo_repo) if remote: di = info.DistroInfo(info_file, remote_git_info=info_repo) else: di = info.DistroInfo(info_file, local_info=info_repo) return di.get_info()
def getpackages(self, **kwargs): """ Valid parameters: :param local_info_repo: local rdoinfo repo to use instead of fetching the default one using rdopkg. :param tags: OpenStack release tags to use (mitaka, newton, etc). """ local_info_repo = kwargs.get('local_info_repo') tags = kwargs.get('tags') inforepo = None info_files = self.config_options.rdoinfo_file if local_info_repo: inforepo = info.DistroInfo( info_files=self.config_options.rdoinfo_file, local_info=local_info_repo, cache_base_path=self.config_options.cache_dir) # NOTE(jpena): in general, info_files will only contain one file, # but it supports multiple... In that case, we will have a comma # separated list of URLs self.distroinfo_path = "%s/%s" % (local_info_repo.rstrip('/'), info_files[0]) for extra_file in info_files[1:]: self.distroinfo_path += ",%s/%s" % ( local_info_repo.rstrip('/')) elif self.config_options.rdoinfo_repo: inforepo = info.DistroInfo( info_files=self.config_options.rdoinfo_file, remote_git_info=self.config_options.rdoinfo_repo, cache_base_path=self.config_options.cache_dir) self.distroinfo_path = "%s/%s" % ( self.config_options.rdoinfo_repo.rstrip('/'), info_files[0]) for extra_file in info_files[1:]: self.distroinfo_path += ",%s/%s" % ( self.config_options.rdoinfo_repo.rstrip('/')) else: # distroinfo will fetch info files from the rdoinfo repo as needed # and store them under ~/.distroinfo/cache inforepo = info.DistroInfo( info_files=self.config_options.rdoinfo_file, remote_info=rdoinfo_repo, cache_base_path=self.config_options.cache_dir) self.distroinfo_path = "%s/%s" % (rdoinfo_repo.rstrip('/'), info_files[0]) for extra_file in info_files[1:]: self.distroinfo_path += ",%s/%s" % (rdoinfo_repo.rstrip('/')) pkginfo = inforepo.get_info(apply_tag=tags) self.packages = pkginfo["packages"] if tags: # FIXME allow list of tags? self.packages = query.filter_pkgs(self.packages, {'tags': tags}) return self.packages
def process_reviews(args): distroinfo = info.DistroInfo( info_files='rdo.yml', remote_info=rdoinfo_repo) inforepo = distroinfo.get_info() if args.number: after_fmt = None else: after = datetime.datetime.now() - datetime.timedelta(days=args.days) after_fmt = after.strftime('%Y-%m-%d') reviews = review_utils.get_osp_releases_reviews(args.release, after=after_fmt, number=args.number, status='merged') for review in reviews: rev_num = review['_number'] log_message('INFO', "Processing review %s" % rev_num, logfile) new_pkgs = new_pkgs_review(review, inforepo) for new_pkg in new_pkgs: if new_pkg['osp_release'] == args.release: process_package(new_pkg['name'], new_pkg['version'], new_pkg['osp_release'], args.dry_run, check_tarball=True, chglog_user=args.changelog_user, chglog_email=args.changelog_email, rdoinfo_tag=args.rdoinfo_tag)
def get_projects(info_files='rdo.yml', local_dir=local_info, tag=None, buildsys_tag=None): distroinfo = info.DistroInfo(info_files=info_files, local_info=local_dir) inforepo = distroinfo.get_info() all_packages = inforepo['packages'] # If tag and buildys_tag are not specified it returns # all packages if tag is None and buildsys_tag is None: return all_packages pkgs_tagged = [] # If tag is specified, it looks for packages with the specified # value in tags dict. if tag is not None: for package in all_packages: if tag in package['tags'].keys(): pkgs_tagged.append(package) # If buildsys_tag is specified, it looks for packages with the specified # value in buildsys-tags dict. if buildsys_tag is not None: for package in all_packages: if ('buildsys-tags' in package.keys() and buildsys_tag in package['buildsys-tags'].keys()): pkgs_tagged.append(package) return pkgs_tagged
def main(): args = parse_args() if args.number: after_fmt = None else: after = datetime.datetime.now() - datetime.timedelta(days=args.days) after_fmt = after.strftime('%Y-%m-%d') reviews = review_utils.get_osp_releases_reviews(args.release, after=after_fmt, number=args.number, status='merged') distroinfo = info.DistroInfo(info_files='rdo.yml', remote_info=rdoinfo_repo) inforepo = distroinfo.get_info() for review in reviews: submitted = format_time(review['submitted']) review_number = review['_number'] releases = releases_utils.get_new_releases_review(review) for release in releases: for repo in release['repos']: pkg = query.find_package(inforepo, repo, strict=True) if pkg: name = pkg['name'] else: name = repo print("%s %s %s %s" % (review_number, submitted, release['version'], name))
def parse_releases_info(rdoinfo_path, info_file='rdo.yml'): """Parse config release section """ data = dinfo.DistroInfo(info_files=info_file, local_info=rdoinfo_path).get_info() releases = data['releases'] releases_info = {} for release in releases: release_name = release['name'] info = release releases_info[release_name] = info return releases_info
def get_pin(package, release): distroinfo = info.DistroInfo(info_files='rdo.yml', local_info=local_info) inforepo = distroinfo.get_info() pkgs = [p for p in inforepo['packages'] if p['name'] == package] if not pkgs or len(pkgs) != 1: raise NotInRdoinfo("Package %s not found in rdoinfo" % package) pkg = pkgs[0] if release in pkg['tags'].keys(): pkg_rel_tag = pkg['tags'][release] if pkg_rel_tag and 'source-branch' in pkg_rel_tag.keys(): return pkg_rel_tag['source-branch'] else: return None else: raise NotInRdoinfoRelease("Package %s not found for release %s" % (package, release))
def parse_releases(rdoinfo_path, centos_release='7', info_file='rdo.yml'): """Parse config release section to extract buildsys-tags """ data = dinfo.DistroInfo(info_files=info_file, local_info=rdoinfo_path).get_info() releases = data['releases'] rel = {} dist_tag = "el{0}".format(centos_release) for release in releases: release_name = release['name'] filter_repos = [ dist for dist in release['repos'] if dist['name'] == dist_tag ] if filter_repos: tags = filter_repos[0]['buildsys-tags'] else: tags = release['repos'][0]['buildsys-tags'] rel[release_name] = tags return rel
def get_new_pinned_builds(location, release): new_pins = [] distroinfo = info.DistroInfo(info_files='rdo.yml', local_info=location) info2 = distroinfo.get_info() with helpers.cdir(location): with git.git_revision('HEAD~'): info1 = distroinfo.get_info() packages = query.tags_diff(info1, info2, tagsname='tags') for package in packages: name = package[0] tags = package[1] if release not in query.get_package(info1, name)['tags']: break pkg_tags = query.get_package(info2, name)['tags'][release] if release in tags and pkg_tags and 'source-branch' in pkg_tags.keys(): pinned_version = pkg_tags['source-branch'] new_pins.append({ 'name': name, 'release': release, 'version': pinned_version }) return new_pins
def update_uc(): args = parse_args() release_tag = args.tag rdoinfo_dir = args.location uc = load_uc(filter_all_minus_tripleo) uc_projects = list(uc.keys()) distroinfo = info.DistroInfo(info_files='rdo-full.yml', local_info=rdoinfo_dir) info_rdo = distroinfo.get_info() DEFAULT_RELEASES = info_rdo['package-default']['tags'] RELEASES_PUPPET = info_rdo['package-configs']['rpmfactory-puppet']['tags'] for pkg in info_rdo['packages']: project = pkg['project'] project_uc = UC_EXCEPTIONS.get(project, project) if project_uc in uc_projects: new_version = uc[project_uc] # "Setting %s to version %s" % (project, new_version) if 'tags' in pkg: tags = pkg['tags'] if 'under-review' in tags: print("Not updating %s, it is under review" % project) continue if 'version-locked' in tags: if tags['version-locked'] is None: print("Not updating %s, it is version-locked for all" " release tags" % project) continue else: if release_tag in tags['version-locked']: print("Not updating %s, it is version-locked for" " %s release tag" % (project, release_tag)) continue prev_version = tags.get(release_tag) if prev_version: prev_version = prev_version.get(SOURCE_BRANCH) else: if project.startswith('puppet'): tags = copy.copy(RELEASES_PUPPET) else: tags = copy.copy(DEFAULT_RELEASES) prev_version = None if 'tags' in pkg and release_tag not in pkg['tags']: print("Not updating %s, it is not included in release %s" % (project, release_tag)) continue tag_value = {SOURCE_BRANCH: new_version} if prev_version: if prev_version != new_version: print("%s updated from %s to %s" % (project, prev_version, new_version)) rdoinfo.update_tag('tags', project, release_tag, tag_value, local_dir=rdoinfo_dir) else: print("%s %s already up to date" % (project, new_version)) else: print("%s first time pin to %s" % (project, new_version)) rdoinfo.update_tag('tags', project, release_tag, tag_value, local_dir=rdoinfo_dir) uc_projects.remove(project_uc) else: # "%s not found in upper-constraints" % project pass