From: Mario Domenech Goulart <mario@ossystems.com.br>
To: openembedded-devel@lists.openembedded.org
Cc: Otavio Salvador <otavio@ossystems.com.br>
Subject: Re: [RFH] Support for automatic package versining using git describe
Date: Wed, 04 Mar 2009 15:34:57 -0300 [thread overview]
Message-ID: <87eixc40oz.fsf@ucpel.tche.br> (raw)
In-Reply-To: <87iqmp5f58.fsf@neumann.lab.ossystems.com.br> (Otavio Salvador's message of "Fri, 13 Feb 2009 00:32:21 -0200")
[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]
Hi
On Fri, 13 Feb 2009 00:32:21 -0200 Otavio Salvador <otavio@ossystems.com.br> wrote:
> One of nice features we've been using is the git-describe to get
> versions based on tags; many projects are using it to name the
> development releases and it does give a better view of how diverged it
> from last released version.
>
> So we're looking for a way to use it to generate the PV based on
> that. The current git fetcher already has the required support to get
> tags, so we can use it as SRCREV, but not yet to use git-describe.
Attached is an attempt to implement this idea. One could use
bb.fetch.describe_revision for, say, AUTOPV generation, like
bb.fetch.get_srcrev is used for AUTOREV.
Example (from bitbake.conf):
AUTOREV = "${@bb.fetch.get_srcrev(d)}"
AUTOPV = "${@bb.fetch.describe_revision(d)}"
It would be nice if somebody could review the attached patch, since I
don't know much about bitbake internals.
P.S.: sorry if this message is messing up threading in your email client.
I'm replying to a fake original message, since I don't have the original
one.
Best wishes.
Mario
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: describe-revision.diff --]
[-- Type: text/x-diff, Size: 4817 bytes --]
Index: lib/bb/fetch/__init__.py
===================================================================
--- lib/bb/fetch/__init__.py (revision 1152)
+++ lib/bb/fetch/__init__.py (working copy)
@@ -196,6 +196,20 @@
srcrev_internal_call = False
+def get_scms(d, urldata, rev_support_only = True):
+ scms = []
+ for u in urldata:
+ ud = urldata[u]
+ if rev_support_only or ud.method.suppports_srcrev():
+ if not ud.setup:
+ ud.setup_localpath(d)
+ scms.append(u)
+
+ if len(scms) == 0:
+ bb.msg.error(bb.msg.domain.Fetcher, "SRCREV was used yet no valid SCM was found in SRC_URI")
+
+ return scms
+
def get_srcrev(d):
"""
Return the version string for the current package
@@ -217,21 +231,9 @@
if bb.fetch.srcrev_internal_call:
return "SRCREVINACTION"
- scms = []
-
- # Only call setup_localpath on URIs which suppports_srcrev()
urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False)
- for u in urldata:
- ud = urldata[u]
- if ud.method.suppports_srcrev():
- if not ud.setup:
- ud.setup_localpath(d)
- scms.append(u)
+ scms = get_scms(d, urldata)
- if len(scms) == 0:
- bb.msg.error(bb.msg.domain.Fetcher, "SRCREV was used yet no valid SCM was found in SRC_URI")
- raise ParameterError
-
bb.data.setVar('__BB_DONT_CACHE','1', d)
if len(scms) == 1:
@@ -253,6 +255,21 @@
return format
+def describe_revision(d):
+ urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False)
+ bb.data.setVar('__BB_DONT_CACHE','1', d)
+ scms = get_scms(d, urldata)
+ scm = ''
+ if len(scms) == 1:
+ scm = scms[0]
+ else:
+ bb.msg.error(bb.msg.domain.Fetcher, "describe_revision does not support multiple SCMs.")
+
+ try:
+ return urldata[scm].method.describe_revision(scm, urldata[scm], d)
+ except NoMethodError:
+ return "NO_REV_DESCR"
+
def localpath(url, d, cache = True):
"""
Called from the parser with cache=False since the cache isn't ready
Index: lib/bb/fetch/git.py
===================================================================
--- lib/bb/fetch/git.py (revision 1152)
+++ lib/bb/fetch/git.py (working copy)
@@ -42,11 +42,12 @@
ud.proto = ud.parm['protocol']
ud.branch = ud.parm.get("branch", "master")
+ ud.tag = None
tag = Fetch.srcrev_internal_helper(ud, d)
if tag is True:
ud.tag = self.latest_revision(url, ud, d)
- elif tag:
+ elif tag and tag != "1":
ud.tag = tag
if not ud.tag or ud.tag == "master":
@@ -141,6 +142,16 @@
def _want_sortable_revision(self, url, ud, d):
return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False
+ def _chrepo(self, repodir, ud, d):
+ # Check if we have the rev already
+ if not os.path.exists(repodir):
+ print "no repo"
+ self.go(None, ud, d)
+
+ os.chdir(repodir)
+ if not self._contains_ref(ud.tag, d):
+ self.go(None, ud, d)
+
def _sortable_revision(self, url, ud, d):
"""
This is only called when _want_sortable_revision called true
@@ -162,15 +173,8 @@
cwd = os.getcwd()
- # Check if we have the rev already
- if not os.path.exists(repodir):
- print "no repo"
- self.go(None, ud, d)
+ self._chrepo(repodir, ud, d)
- os.chdir(repodir)
- if not self._contains_ref(ud.tag, d):
- self.go(None, ud, d)
-
output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True)
os.chdir(cwd)
@@ -179,3 +183,27 @@
return sortable_revision
+ def describe_revision(self, url, ud, d):
+ """
+ Return the output of 'git describe' or 'NO_REV_DESCR' in
+ case no tag is found.
+ """
+ gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
+ repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
+
+ # Runtime warning on wrongly configured sources
+ if ud.tag == "1":
+ bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url)
+ return "0+1"
+
+ cwd = os.getcwd()
+
+ self._chrepo(repodir, ud, d)
+
+ rev_descr = ''
+ try:
+ rev_descr = runfetchcmd("git describe 2>/dev/null", d, quiet=True).strip()
+ except FetchError:
+ rev_descr = "NO_REV_DESCR"
+ os.chdir(cwd)
+ return rev_descr
next parent reply other threads:[~2009-03-05 12:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87iqmp5f58.fsf@neumann.lab.ossystems.com.br>
2009-03-04 18:34 ` Mario Domenech Goulart [this message]
2009-03-05 13:43 ` [RFH] Support for automatic package versining using git describe Otavio Salvador
2009-03-05 21:31 ` Mario Domenech Goulart
2009-03-05 21:37 ` Koen Kooi
2009-03-06 0:50 ` Mike (mwester)
2009-02-13 2:32 Otavio Salvador
2009-02-13 8:59 ` Koen Kooi
2009-02-13 10:46 ` Otavio Salvador
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eixc40oz.fsf@ucpel.tche.br \
--to=mario@ossystems.com.br \
--cc=openembedded-devel@lists.openembedded.org \
--cc=otavio@ossystems.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox