| # Update clones of the repositories we need in KAS_REPO_REF_DIR to speed up fetches |
| # Taken from Kas (Repo.__getattr__) to ensure the logic is right |
| from urllib.parse import urlparse |
| return ('{url.netloc}{url.path}' |
| "https://git.yoctoproject.org/git/poky", |
| "https://git.openembedded.org/meta-openembedded", |
| "https://git.yoctoproject.org/git/meta-virtualization", |
| "https://github.com/kraj/meta-clang", |
| if __name__ == "__main__": |
| if "KAS_REPO_REF_DIR" not in os.environ: |
| print("KAS_REPO_REF_DIR needs to be set") |
| base_repodir = pathlib.Path(os.environ["KAS_REPO_REF_DIR"]) |
| for repo in repositories: |
| repodir = base_repodir / repo_shortname(repo) |
| if "CI_CLEAN_REPOS" in os.environ: |
| print("Cleaning %s..." % repo) |
| shutil.rmtree(repodir, ignore_errors=True) |
| print("Updating %s..." % repo) |
| subprocess.run(["git", "-C", repodir, "-c", "gc.autoDetach=false", "fetch"], check=True) |
| print("Cloning %s..." % repo) |
| subprocess.run(["git", "clone", "--bare", repo, repodir], check=True) |