* [yocto-autobuilder-helper][PATCH] prepare-shared-repos: Allow to tag poky git
@ 2024-11-15 14:02 mathieu.dubois-briand
2024-11-15 14:21 ` [yocto-patches] " Quentin Schulz
0 siblings, 1 reply; 3+ messages in thread
From: mathieu.dubois-briand @ 2024-11-15 14:02 UTC (permalink / raw)
To: yocto-patches; +Cc: Mathieu Dubois-Briand
From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
scripts/prepare-shared-repos | 6 ++++++
scripts/utils.py | 10 ++++++++++
2 files changed, 16 insertions(+)
diff --git a/scripts/prepare-shared-repos b/scripts/prepare-shared-repos
index 1b756520b701..3d10af4e6d63 100755
--- a/scripts/prepare-shared-repos
+++ b/scripts/prepare-shared-repos
@@ -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)
diff --git a/scripts/utils.py b/scripts/utils.py
index 8e6463d8c62c..122a56d3c3e4 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -280,6 +280,16 @@ 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", "remote", "add", "tag", tagremote], cwd=sharedrepo)
+ subprocess.check_call(["git", "push", "tag", tagname], cwd=sharedrepo)
+ subprocess.check_call(["git", "remote", "rm", "tag"], 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()
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [yocto-patches] [yocto-autobuilder-helper][PATCH] prepare-shared-repos: Allow to tag poky git
2024-11-15 14:02 [yocto-autobuilder-helper][PATCH] prepare-shared-repos: Allow to tag poky git mathieu.dubois-briand
@ 2024-11-15 14:21 ` Quentin Schulz
2024-11-15 14:27 ` Mathieu Dubois-Briand
0 siblings, 1 reply; 3+ messages in thread
From: Quentin Schulz @ 2024-11-15 14:21 UTC (permalink / raw)
To: yocto-patches; +Cc: Mathieu Dubois-Briand
Hi Mathieu,
On 11/15/24 3:02 PM, Mathieu Dubois-Briand via lists.yoctoproject.org wrote:
> From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
>
> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> ---
> scripts/prepare-shared-repos | 6 ++++++
> scripts/utils.py | 10 ++++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/scripts/prepare-shared-repos b/scripts/prepare-shared-repos
> index 1b756520b701..3d10af4e6d63 100755
> --- a/scripts/prepare-shared-repos
> +++ b/scripts/prepare-shared-repos
> @@ -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)
> diff --git a/scripts/utils.py b/scripts/utils.py
> index 8e6463d8c62c..122a56d3c3e4 100644
> --- a/scripts/utils.py
> +++ b/scripts/utils.py
> @@ -280,6 +280,16 @@ 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", "remote", "add", "tag", tagremote], cwd=sharedrepo)
> + subprocess.check_call(["git", "push", "tag", tagname], cwd=sharedrepo)
> + subprocess.check_call(["git", "remote", "rm", "tag"], cwd=sharedrepo)
> +
Apparently git-push supports pushing without a remote, c.f. the manpage:
git push [--all | --branches | --mirror | --tags]
[--follow-tags] [--atomic] [-n | --dry-run]
[--receive-pack=<git-receive-pack>]
[--repo=<repository>] [-f | --force] [-d | --delete]
[--prune] [-q | --quiet] [-v | --verbose]
[-u | --set-upstream] [-o <string> |
--push-option=<string>]
[--[no-]signed|--signed=(true|false|if-asked)]
[--force-with-lease[=<refname>[:<expect>]]
[--force-if-includes]]
[--no-verify] [<repository> [<refspec>...]]
[...]
<repository>
The "remote" repository that is the destination of a push
operation. This parameter can be either a URL (see the section GIT URLS
below) or the name of a remote (see the section REMOTES below).
This would avoid leftovers from stopped/interrupted/broken runs to mess
with the git remote addition which could fail if the remote already exists.
Either don't use an explicit local remote, or remove it beforehand.
Except that removing a non-existing remote will fail check_call, so you
probably want to simply run the command and ignore the return code.
Cheers,
Quentin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [yocto-patches] [yocto-autobuilder-helper][PATCH] prepare-shared-repos: Allow to tag poky git
2024-11-15 14:21 ` [yocto-patches] " Quentin Schulz
@ 2024-11-15 14:27 ` Mathieu Dubois-Briand
0 siblings, 0 replies; 3+ messages in thread
From: Mathieu Dubois-Briand @ 2024-11-15 14:27 UTC (permalink / raw)
To: Quentin Schulz; +Cc: yocto-patches
On Fri, Nov 15, 2024 at 03:21:15PM +0100, Quentin Schulz wrote:
> Hi Mathieu,
>
> Apparently git-push supports pushing without a remote, c.f. the manpage:
>
> git push [--all | --branches | --mirror | --tags] [--follow-tags]
> [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
> [--repo=<repository>] [-f | --force] [-d | --delete]
> [--prune] [-q | --quiet] [-v | --verbose]
> [-u | --set-upstream] [-o <string> |
> --push-option=<string>]
> [--[no-]signed|--signed=(true|false|if-asked)]
> [--force-with-lease[=<refname>[:<expect>]]
> [--force-if-includes]]
> [--no-verify] [<repository> [<refspec>...]]
>
> [...]
>
> <repository>
> The "remote" repository that is the destination of a push
> operation. This parameter can be either a URL (see the section GIT URLS
> below) or the name of a remote (see the section REMOTES below).
Oh, that's nice! I was definitely not aware of this possibility. I will
send a new version.
>
> This would avoid leftovers from stopped/interrupted/broken runs to mess with
> the git remote addition which could fail if the remote already exists.
>
Um right, I did not think about builds potentially interrupted in the
mean time, thanks.
> Either don't use an explicit local remote, or remove it beforehand. Except
> that removing a non-existing remote will fail check_call, so you probably
> want to simply run the command and ignore the return code.
>
> Cheers,
> Quentin
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-15 14:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 14:02 [yocto-autobuilder-helper][PATCH] prepare-shared-repos: Allow to tag poky git mathieu.dubois-briand
2024-11-15 14:21 ` [yocto-patches] " Quentin Schulz
2024-11-15 14:27 ` Mathieu Dubois-Briand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.