* [PATCH] buildhistory.bbclass: add cloning
@ 2021-02-14 15:53 akuster
2021-02-14 17:12 ` [OE-core] " Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: akuster @ 2021-02-14 15:53 UTC (permalink / raw)
To: openembedded-core
Provide a method to clone and push to a git repo
Provide a method to pre-populate buildhistory
Maybe remove the need for external scripts to do the same
Three new variables:
BUILDHISTORY_CLONE - Enable the cloning function
BUILDHISTORY_BRANCH - branch used for checkout and pushing
BUILDHISTORY_REPO_URI - git repo uri
example:
BUILDHISTORY_CLONE = "1"
BUILDHISTORY_BRANCH="${DISTRO}/gatesgarth/${MACHINE}"
BUILDHISTORY_REPO_URI = "git@gitlab.com:akuster/oe-buildhistory"
BUILDHISTORY_PUSH_REPO = "origin ${BUILDHISTORY_BRANCH}"
Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
meta/classes/buildhistory.bbclass | 59 +++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 117a44eaf38..8ed420174e9 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -44,6 +44,15 @@ BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
BUILDHISTORY_PUSH_REPO ?= ""
BUILDHISTORY_TAG ?= "build"
+# Branch for checkout
+BUILDHISTORY_BRANCH ?= ""
+
+# git uri to clone and push too
+BUILDHISTORY_REPO_URI ?= ""
+
+# Clone previous buildhistory from repo
+BUILDHISTORY_CLONE ?= ""
+
SSTATEPOSTINSTFUNCS_append = " buildhistory_emit_pkghistory"
# We want to avoid influencing the signatures of sstate tasks - first the function itself:
sstate_install[vardepsexclude] += "buildhistory_emit_pkghistory"
@@ -858,6 +867,51 @@ END
fi) || true
}
+python buildhistory_clone() {
+ import subprocess
+
+ histdir = d.getVar('BUILDHISTORY_DIR')
+ repo_uri = d.getVar("BUILDHISTORY_REPO_URI")
+ bh_branch = d.getVar("BUILDHISTORY_BRANCH")
+
+ if not repo_uri:
+ bb.note("BUILDHISTORY_REPO_URI not set")
+ return
+
+ if not bh_branch:
+ bb.note("BUILDHISTORY_BRANCH not set")
+ return
+
+ if not os.path.isdir(histdir):
+ cmd = ['git', 'clone', repo_uri, histdir]
+ ret = subprocess.call(cmd)
+ if ret != 0:
+ bb.error('Failed to clond %s!' % repo_uri)
+
+ cmd = ['git', '-C', histdir, 'checkout','-b', bh_branch]
+ ret = subprocess.call(cmd)
+ if ret != 0:
+ bb.error('Failed to checkout branch %s!' % bh_branch)
+
+ if not os.path.isdir(histdir):
+ rerturn
+
+ if os.path.isdir(os.path.join(histdir, '.git')):
+ cmd =['git', '-C', histdir, 'config', '--get', 'remote.origin.url']
+ hasurl = subprocess.call(cmd, shell=True)
+ if hasurl:
+ cmd = ['git', '-C', histdir, 'remote', 'add', '-f', '-t', bh_branch, '-m', bh_branch, 'origin', repo_uri]
+ subprocess.call(cmd)
+
+ cmd = ['git', '-C', histdir, 'checkout', bh_branch]
+ ret = subprocess.call(cmd)
+ if ret != 0:
+ bb.error('Failed to checkout branch %s' % bh_branch)
+
+ cmd = ['git', '-C', histdir, 'branch', '--set-upstream-to=origin/%s' % bh_branch]
+ subprocess.call(cmd)
+}
+
python buildhistory_eventhandler() {
if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip():
reset = e.data.getVar("BUILDHISTORY_RESET")
@@ -874,6 +928,11 @@ python buildhistory_eventhandler() {
for entry in entries:
os.rename(os.path.join(rootdir, entry),
os.path.join(olddir, entry))
+
+ if e.data.getVar("BUILDHISTORY_CLONE") == "1":
+ localdata = bb.data.createCopy(e.data)
+ bb.build.exec_func("buildhistory_clone", d)
+
elif isinstance(e, bb.event.BuildCompleted):
if reset:
import shutil
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [OE-core] [PATCH] buildhistory.bbclass: add cloning
2021-02-14 15:53 [PATCH] buildhistory.bbclass: add cloning akuster
@ 2021-02-14 17:12 ` Richard Purdie
2021-02-14 17:59 ` akuster
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2021-02-14 17:12 UTC (permalink / raw)
To: akuster, openembedded-core
On Sun, 2021-02-14 at 15:53 +0000, akuster wrote:
> Provide a method to clone and push to a git repo
> Provide a method to pre-populate buildhistory
> Maybe remove the need for external scripts to do the same
>
> Three new variables:
> BUILDHISTORY_CLONE - Enable the cloning function
> BUILDHISTORY_BRANCH - branch used for checkout and pushing
> BUILDHISTORY_REPO_URI - git repo uri
>
> example:
> BUILDHISTORY_CLONE = "1"
> BUILDHISTORY_BRANCH="${DISTRO}/gatesgarth/${MACHINE}"
> BUILDHISTORY_REPO_URI = "git@gitlab.com:akuster/oe-buildhistory"
> BUILDHISTORY_PUSH_REPO = "origin ${BUILDHISTORY_BRANCH}"
>
> Signed-off-by: Armin Kuster <akuster808@gmail.com>
> ---
> meta/classes/buildhistory.bbclass | 59 +++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
Whether or not this is a good idea I'm not sure but I don't like the
variable names. How about configuring as:
BUILDHISTORY_CLONE = "git@gitlab.com:akuster/oe-buildhistory"
BUILDHISTORY_CLONE_BRANCH="${DISTRO}/gatesgarth/${MACHINE}"
BUILDHISTORY_PUSH_REPO = "origin ${BUILDHISTORY_BRANCH}"
?
You're unlikely to not set a repo uri if you set clone...
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [OE-core] [PATCH] buildhistory.bbclass: add cloning
2021-02-14 17:12 ` [OE-core] " Richard Purdie
@ 2021-02-14 17:59 ` akuster
0 siblings, 0 replies; 3+ messages in thread
From: akuster @ 2021-02-14 17:59 UTC (permalink / raw)
To: Richard Purdie, openembedded-core
On 2/14/21 9:12 AM, Richard Purdie wrote:
> On Sun, 2021-02-14 at 15:53 +0000, akuster wrote:
>> Provide a method to clone and push to a git repo
>> Provide a method to pre-populate buildhistory
>> Maybe remove the need for external scripts to do the same
>>
>> Three new variables:
>> BUILDHISTORY_CLONE - Enable the cloning function
>> BUILDHISTORY_BRANCH - branch used for checkout and pushing
>> BUILDHISTORY_REPO_URI - git repo uri
>>
>> example:
>> BUILDHISTORY_CLONE = "1"
>> BUILDHISTORY_BRANCH="${DISTRO}/gatesgarth/${MACHINE}"
>> BUILDHISTORY_REPO_URI = "git@gitlab.com:akuster/oe-buildhistory"
>> BUILDHISTORY_PUSH_REPO = "origin ${BUILDHISTORY_BRANCH}"
>>
>> Signed-off-by: Armin Kuster <akuster808@gmail.com>
>> ---
>> meta/classes/buildhistory.bbclass | 59 +++++++++++++++++++++++++++++++
>> 1 file changed, 59 insertions(+)
> Whether or not this is a good idea I'm not sure
Not sure either but I did notice the AB does handle this separately and
so did the OE world build Martin setup so why not create a framework
that folks can opt-in if they want to.
> but I don't like the
> variable names. How about configuring as:
>
> BUILDHISTORY_CLONE = "git@gitlab.com:akuster/oe-buildhistory"
> BUILDHISTORY_CLONE_BRANCH="${DISTRO}/gatesgarth/${MACHINE}"
> BUILDHISTORY_PUSH_REPO = "origin ${BUILDHISTORY_BRANCH}"
works for me. I am not married to the names.
> ?
>
> You're unlikely to not set a repo uri if you set clone...
Right.
thanks for the input.
-armin
>
> Cheers,
>
> Richard
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-14 17:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-14 15:53 [PATCH] buildhistory.bbclass: add cloning akuster
2021-02-14 17:12 ` [OE-core] " Richard Purdie
2021-02-14 17:59 ` akuster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox