Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:ukbeast89:branches:X11:XOrg
amdvlk
update-version.py
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File update-version.py of Package amdvlk
#!/usr/bin/env python import os import re import git import argparse from git import Repo, Git from bs4 import BeautifulSoup amdvlk_url = 'https://github.com/GPUOpen-Drivers/AMDVLK.git' def clone_repo(git_url, repo_dir): try: repo = Repo(repo_dir) origin = repo.remotes.origin origin.fetch() except (git.exc.GitCommandError, git.exc.NoSuchPathError, git.exc.InvalidGitRepositoryError): print(f"cloning {git_url}...") repo = Repo.clone_from(git_url, repo_dir) return repo def read_repo_xml(repo_xml_path): with open(repo_xml_path, 'r') as f: data = f.read() bsdata = BeautifulSoup(data, 'xml') projects = bsdata.find_all('project') version = {} for p in projects: name = p.get('name') revision = p.get('revision') version[name] = revision return version def update_obs_xml(obs_xml_path, new_rev): urls = [] vers = {} url_re = "GPUOpen-Drivers\/(.*)<\/param>" rev_re = 'name="revision">(.*)<\/param>' result_data = [] with open(obs_xml_path, 'r') as f: data = f.read().splitlines() for line in data: url_line = re.search(url_re, line) rev_line = re.search(rev_re, line) new_line = line if url_line: pj = url_line.groups()[0] urls.append(pj) elif rev_line: revision = rev_line.groups()[0] vers[urls[-1]] = revision new_line = line.replace(revision, new_rev[urls[-1]]) result_data.append(new_line) with open(obs_xml_path, 'w') as f: f.write("\n".join(result_data)) def update_spec_file(spec_file, tag): def replace_version(match_obj): if match_obj: return match_obj.group(1) + str(tag)[2:] # get the old tag with open(spec_file, "r") as sf: sf_lines = sf.read().splitlines() new_sf = [] for ind, s in enumerate(sf_lines): new_sf.append(re.sub(r'(Version:\s+).*', replace_version, s)) with open(spec_file, "w") as sf: sf.writelines(s + "\n" for s in new_sf) if __name__ == "__main__": parser = argparse.ArgumentParser(description='Scripts that updates amdvlk version.') parser.add_argument('--obs-dir', required=True, help='Location of the obs amdvlk repo') parser.add_argument('--repo-dir', required=True, help='Location to clone the Git amdvlk repo') args = parser.parse_args() repo_dir = args.repo_dir repo = clone_repo(amdvlk_url, repo_dir) tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime) latest_tag = tags[-1] print(f"checking out amdvlk latest tag: {latest_tag} ...") repo.git.checkout(latest_tag) repo_xml = os.path.join(args.repo_dir, "default.xml") print(f"reading from file: {repo_xml} ...") versions = read_repo_xml(repo_xml) versions['AMDVLK'] = latest_tag.path obs_service_xml = os.path.join(args.obs_dir, "_service") print(f"writing to file: {obs_service_xml} ...") update_obs_xml(obs_service_xml, versions) spec_file = os.path.join(args.obs_dir, "amdvlk.spec") print(f"updating the spec file: {spec_file}") update_spec_file(spec_file, latest_tag)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor