Add support for publishing the layer tarballs

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2018-02-05 17:40:49 +00:00
parent 38af6b0f6c
commit a71ea84970
3 changed files with 25 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#
# Called with $1 - The json file containing the repositories to use
# $2 - The shared directory where the repos are to be transferred
# $3 - Directory to publish artefacts to
#
import json
@ -14,12 +15,15 @@ import errno
import utils
if len(sys.argv) != 3:
print("Incorrect number of parameters, please call as %s <repo.json> <shared-sources-dir>" % sys.argv[0])
if len(sys.argv) != 4:
print("Incorrect number of parameters, please call as %s <repo.json> <shared-sources-dir> <publish-dir>" % sys.argv[0])
sys.exit(1)
repojson = sys.argv[1]
shared = sys.argv[2]
publish = None
if sys.argv[3] != "None":
publish = sys.argv[3]
ourconfig = utils.loadconfig(__file__)
@ -31,3 +35,5 @@ stashdir = ourconfig["REPO_STASH_DIR"]
for repo in sorted(repos.keys()):
utils.printheader("Intially fetching repo %s" % repo)
utils.fetchgitrepo(shared, repo, repos[repo], stashdir)
if publish:
utils.publishrepo(shared, repo, publish)

View File

@ -6,6 +6,7 @@
# $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
# $5 - Directory to publish artefacts to
#
import json
@ -18,14 +19,18 @@ import random
import utils
if len(sys.argv) != 5:
print("Incorrect number of parameters, please call as %s repo.json <shared-sources-dir> <autobuilder-workdir> <target>" % sys.argv[0])
if len(sys.argv) != 6:
print("Incorrect number of parameters, please call as %s repo.json <shared-sources-dir> <autobuilder-workdir> <target> <publish-dir>" % sys.argv[0])
sys.exit(1)
repojson = sys.argv[1]
shared = sys.argv[2]
targetdir = sys.argv[3]
target = sys.argv[4]
publish = None
if sys.argv[5] != "None":
publish = sys.argv[5]
scriptsdir = os.path.dirname(os.path.realpath(__file__))
ourconfig = utils.loadconfig(__file__)
@ -50,5 +55,7 @@ for repo in sorted(repos.keys()):
else:
utils.printheader("Fetching repo %s" % repo)
utils.fetchgitrepo(targetsubdir, repo, repos[repo], stashdir)
if publish:
utils.publishrepo(shared, repo, publish)
subprocess.check_call([scriptsdir + "/layer-config", targetdir, target])

View File

@ -126,6 +126,14 @@ def fetchgitrepo(clonedir, repo, params, stashdir):
subprocess.check_call(["git", "checkout", branch], cwd=sharedrepo)
subprocess.check_call(["git", "reset", revision, "--hard"], cwd=sharedrepo)
def publishrepo(clonedir, repo, publishdir):
sharedrepo = "%s/%s" % (clonedir, repo)
revision = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=sharedrepo)
archive_name = repo + "-" + revision + ".tar.bz2"
subprocess.check_call("git archive --format=tar HEAD --prefix=" + repo + "/ | bzip2 -c > " + archive_name, shell=True, cwd=sharedrepo)
subprocess.check_call("md5sum " + archive_name + " >> " + archive_name + ".md5sum", shell=True, cwd=sharedrepo)
mkdir(publishdir)
subprocess.check_call("rsync -av " + archive_name + "* " + publishdir, shell=True, cwd=sharedrepo)
def mkdir(path):
try: