prepare-shared-repos: Allow to tag poky git

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mathieu Dubois-Briand 2024-11-18 11:13:53 +01:00 committed by Richard Purdie
parent 440a0b2d8f
commit 78806a4f4c
2 changed files with 14 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import tempfile
import utils
poky_tag_remote = "git@push.yoctoproject.org:poky-ci-archive"
parser = utils.ArgParser(description='Iterates over a set of repositories in a json file and sets up a shared directory containing them.')
@ -26,6 +27,9 @@ parser.add_argument('sharedsrcdir',
parser.add_argument('-p', '--publish-dir',
action='store',
help="Where to publish artefacts to (optional)")
parser.add_argument('-t', '--tag',
action='store',
help="Git tag to create (optional)")
args = parser.parse_args()
@ -49,6 +53,8 @@ with tempfile.TemporaryDirectory(prefix="shared-repo-temp-", dir="/home/pokybuil
utils.fetchgitrepo(tempdir, repo, repos[repo], stashdir, depth=1)
if args.publish_dir:
utils.publishrepo(tempdir, repo, args.publish_dir)
if repo == "poky" and args.tag:
utils.taggitrepo(tempdir, repo, repos[repo], poky_tag_remote, args.tag)
utils.printheader("Creating shared src tarball")
subprocess.check_call("tar -I zstd -cf " + args.sharedsrcdir.rstrip("/") + ".tar.zst ./*", shell=True, cwd=tempdir)

View File

@ -280,6 +280,14 @@ def fetchgitrepo(clonedir, repo, params, stashdir, depth=None):
subprocess.check_call(["git", "reset", "origin/" + branch, "--hard"], cwd=sharedrepo)
subprocess.check_call(["git", "reset", revision, "--hard"], cwd=sharedrepo)
def taggitrepo(clonedir, repo, params, tagremote, tagname):
sharedrepo = "%s/%s" % (clonedir, repo)
revision = params["revision"]
print("Creating tag...")
subprocess.check_call(["git", "tag", tagname, revision], cwd=sharedrepo)
print("Pushing tag...")
subprocess.check_call(["git", "push", tagremote, tagname], cwd=sharedrepo)
def publishrepo(clonedir, repo, publishdir):
sharedrepo = "%s/%s" % (clonedir, repo)
revision = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=sharedrepo).decode('utf-8').strip()