Openembedded Devel Discussions
 help / color / mirror / Atom feed
From: Mario Domenech Goulart <mario@ossystems.com.br>
To: Otavio Salvador <otavio@ossystems.com.br>
Cc: openembedded-devel@lists.openembedded.org
Subject: Re: [RFH] Support for automatic package versining using git describe
Date: Thu, 05 Mar 2009 18:31:05 -0300	[thread overview]
Message-ID: <87sklr3bdy.fsf@ossystems.com.br> (raw)
In-Reply-To: <87skls2ihj.fsf@neumann.lab.ossystems.com.br> (Otavio Salvador's message of "Thu, 05 Mar 2009 10:43:04 -0300")

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

On Thu, 05 Mar 2009 10:43:04 -0300 Otavio Salvador <otavio@ossystems.com.br> wrote:

> Mario Domenech Goulart <mario@ossystems.com.br> writes:
>
>> 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":
>
> [...]
>
> Please drop this hook since it is our internal workaround for the lack
> of the AUTOREV in our recipes.

Sure.  Attached is the new patch.

Best wishes.
Mario


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: describe-revision2.diff --]
[-- Type: text/x-diff, Size: 4384 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,25 @@
 
     return format
 
+def describe_revision(d):
+    """ 
+    Return the output of 'git describe' or 'NO_REV_DESCR' in case no
+    tag is found.
+    """
+    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)
@@ -141,6 +141,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 +172,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 +182,23 @@
         return sortable_revision
         
 
+    def describe_revision(self, url, ud, d):
+        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

  reply	other threads:[~2009-03-05 21:35 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 ` [RFH] Support for automatic package versining using git describe Mario Domenech Goulart
2009-03-05 13:43   ` Otavio Salvador
2009-03-05 21:31     ` Mario Domenech Goulart [this message]
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=87sklr3bdy.fsf@ossystems.com.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