forked from mendersoftware/meta-mender-community
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kas: add caching for metadata layers from git
Changelog: Title Ticket: None Signed-off-by: TheYoctoJester <[email protected]> (cherry picked from commit 50ee529)
- Loading branch information
1 parent
fdea168
commit 5b394ac
Showing
2 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#! /usr/bin/env python3 | ||
|
||
# Update clones of the repositories we need in KAS_REPO_REF_DIR to speed up fetches | ||
|
||
import sys | ||
import os | ||
import shutil | ||
import subprocess | ||
import pathlib | ||
|
||
def repo_shortname(url): | ||
# Taken from Kas (Repo.__getattr__) to ensure the logic is right | ||
from urllib.parse import urlparse | ||
url = urlparse(url) | ||
return ('{url.netloc}{url.path}' | ||
.format(url=url) | ||
.replace('@', '.') | ||
.replace(':', '.') | ||
.replace('/', '.') | ||
.replace('*', '.')) | ||
|
||
repositories = ( | ||
"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", | ||
"https://github.com/mendersoftware/meta-mender", | ||
"https://github.com/agherzan/meta-raspberrypi", | ||
"https://github.com/OE4T/meta-tegra.git", | ||
"https://github.com/Freescale/meta-freescale", | ||
"https://github.com/Freescale/meta-freescale-distro", | ||
"https://github.com/Freescale/meta-freescale-3rdparty", | ||
"https://git.openembedded.org/openembedded-core", | ||
"https://git.openembedded.org/bitbake", | ||
"https://git.yoctoproject.org/git/meta-yocto", | ||
) | ||
|
||
if __name__ == "__main__": | ||
if "LAYERCACHE" not in os.environ: | ||
print("LAYERCACHE needs to be set") | ||
sys.exit(1) | ||
|
||
base_repodir = pathlib.Path(os.environ["LAYERCACHE"]) | ||
failed = False | ||
|
||
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) | ||
|
||
if repodir.exists(): | ||
try: | ||
print("Updating %s..." % repo) | ||
subprocess.run(["git", "-C", repodir, "-c", "gc.autoDetach=false", "fetch"], check=True) | ||
except subprocess.CalledProcessError as e: | ||
print(e) | ||
failed = True | ||
else: | ||
print("Cloning %s..." % repo) | ||
subprocess.run(["git", "clone", "--bare", repo, repodir], check=True) | ||
|
||
if failed: | ||
sys.exit(128) |