mirror of
git://git.yoctoproject.org/yocto-autobuilder-helper.git
synced 2025-07-19 20:59:02 +02:00
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:
parent
6bf85dbbdc
commit
7f70683c57
|
@ -26,20 +26,7 @@ ourconfig = utils.loadconfig(__file__)
|
||||||
with open(repojson) as f:
|
with open(repojson) as f:
|
||||||
repos = json.load(f)
|
repos = json.load(f)
|
||||||
|
|
||||||
stash = ourconfig["REPO_STASH_DIR"]
|
stashdir = ourconfig["REPO_STASH_DIR"]
|
||||||
|
|
||||||
for repo in sorted(repos.keys()):
|
for repo in sorted(repos.keys()):
|
||||||
sharedrepo = "%s/%s" % (shared, repo)
|
utils.fetchgitrepo(shared, repo, repos[repo], stashdir)
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
# Called with $1 - The json file containing the repositories to use
|
# 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')
|
# $2 - The shared directory where the repos are to be transferred from (can be 'None')
|
||||||
# $3 - The autobuilder working directory
|
# $3 - The autobuilder working directory
|
||||||
|
# $4 - The target to filter the repos to
|
||||||
#
|
#
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -28,8 +29,9 @@ ourconfig = utils.loadconfig(__file__)
|
||||||
with open(repojson) as f:
|
with open(repojson) as f:
|
||||||
repos = json.load(f)
|
repos = json.load(f)
|
||||||
|
|
||||||
if shared:
|
# FIXME: Need to filter repo list to the list of repos we need from ourconfig
|
||||||
"cp shared targetdir"
|
for repo in sorted(repos.keys()):
|
||||||
else:
|
if shared:
|
||||||
"prepare-shared-repos repojson targetdir"
|
subprocess.check_call(["rsync", "-a", "%s/%s" % (shared, repo), "%s/%s" % (targetdir, repo)])
|
||||||
|
else:
|
||||||
|
utils.fetchgitrepo(targetdir, repo, repos[repo], stashdir)
|
||||||
|
|
|
@ -85,6 +85,22 @@ def loadconfig(f):
|
||||||
def runcmd(cmd):
|
def runcmd(cmd):
|
||||||
return subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
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):
|
def printheader(msg):
|
||||||
print("")
|
print("")
|
||||||
print("====================================================================================================")
|
print("====================================================================================================")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user