prepare-shared-repos/shared-repo-unpack: Allow future option to filter repos and implement more functionality

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2018-01-22 16:12:34 +00:00
parent 6bf85dbbdc
commit 7f70683c57
3 changed files with 25 additions and 20 deletions

View File

@ -26,20 +26,7 @@ ourconfig = utils.loadconfig(__file__)
with open(repojson) as f:
repos = json.load(f)
stash = ourconfig["REPO_STASH_DIR"]
stashdir = ourconfig["REPO_STASH_DIR"]
for repo in sorted(repos.keys()):
sharedrepo = "%s/%s" % (shared, repo)
branch = repos[repo][1]
revision = repos[repo][2]
if os.path.exists(stash + "/" + repo):
subprocess.check_call(["git", "clone", "file://%s/%s" % (stash, repo), "%s/%s" % (shared, repo)])
subprocess.check_call(["git", "remote", "rm", "origin"], cwd=sharedrepo)
subprocess.check_call(["git", "remote", "add", "origin", repos[repo][0]], cwd=sharedrepo)
subprocess.check_call(["git", "fetch", "origin", "-t"], cwd=sharedrepo)
else:
subprocess.check_call(["git", "clone", repos[repo][0], sharedrepo])
subprocess.check_call(["git", "checkout", branch], cwd=sharedrepo)
subprocess.check_call(["git", "reset", revision, "--hard"], cwd=sharedrepo)
utils.fetchgitrepo(shared, repo, repos[repo], stashdir)

View File

@ -5,6 +5,7 @@
# Called with $1 - The json file containing the repositories to use
# $2 - The shared directory where the repos are to be transferred from (can be 'None')
# $3 - The autobuilder working directory
# $4 - The target to filter the repos to
#
import json
@ -28,8 +29,9 @@ ourconfig = utils.loadconfig(__file__)
with open(repojson) as f:
repos = json.load(f)
# FIXME: Need to filter repo list to the list of repos we need from ourconfig
for repo in sorted(repos.keys()):
if shared:
"cp shared targetdir"
subprocess.check_call(["rsync", "-a", "%s/%s" % (shared, repo), "%s/%s" % (targetdir, repo)])
else:
"prepare-shared-repos repojson targetdir"
utils.fetchgitrepo(targetdir, repo, repos[repo], stashdir)

View File

@ -85,6 +85,22 @@ def loadconfig(f):
def runcmd(cmd):
return subprocess.check_output(cmd, stderr=subprocess.STDOUT)
def fetchgitrepo(clonedir, repo, params, stashdir):
sharedrepo = "%s/%s" % (clonedir, repo)
branch = params["branch"]
revision = params["revision"]
if os.path.exists(stash + "/" + repo):
subprocess.check_call(["git", "clone", "file://%s/%s" % (stashdir, repo), "%s/%s" % (clonedir, repo)])
subprocess.check_call(["git", "remote", "rm", "origin"], cwd=sharedrepo)
subprocess.check_call(["git", "remote", "add", "origin", params["url"]], cwd=sharedrepo)
subprocess.check_call(["git", "fetch", "origin", "-t"], cwd=sharedrepo)
else:
subprocess.check_call(["git", "clone", params["url"], sharedrepo])
subprocess.check_call(["git", "checkout", branch], cwd=sharedrepo)
subprocess.check_call(["git", "reset", revision, "--hard"], cwd=sharedrepo)
def printheader(msg):
print("")
print("====================================================================================================")