[oe] SRCPV migration

Richard Purdie rpurdie at rpsys.net
Tue Nov 17 10:01:02 UTC 2009


On Tue, 2009-11-17 at 09:55 +0100, Martin Jansa wrote: 
> OK better version
> 
> with this you can add
> 
> LOCALCOUNT_pn-bar ?= "4"
> to ie sane-srcrevs.inc
> 
> or
> 
> LOCALCOUNT ?= "4" to 
> recipes/foo/bar_git.bb
> 
> (btw seems like LOCALCOUNT_pn-bar has higher preferrence even if I use
> "LOCALCOUNT = 4" in recipe, why?)

As Phil mentioned, OVERRIDES

> And it will be ignored for all distros where BB_LOCALCOUNT_OVERRIDE is
> not set. 
> 
> With BB_LOCALCOUNT_OVERRIDE enabled, you can use LOCALCOUNT instead of
> PR bump if you just change SRCREV, for others will be LOCALCOUNT in
> SRCPV incremented by default.
> 
> If BB_GIT_CLONE_FOR_SRCREV is set than LOCALCOUNT is ALWAYS set to 
> "git list-rev | wc -l" which could be considered also as consistent PV
> scheme for multiple buildhosts.

Thats fine.

> BTW: SRCPV seems to be expanded in PV a bit sooner than SRCREV was,
> which with combination with BB_GIT_CLONE_FOR_SRCREV means that all git
> repositories are checked during recipe parsing (Klaus Kurzmann has a
> list of git repositories used in OE recipes which are not accessible)

SRCPV and SRCREV would expand at the same time. BB_GIT_CLONE_FOR_SRCREV
will hit the network a lot more though a I don't think it gets cached as
nicely as SRCREV/PV does.

diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index 8c0d7ea..3b527e2 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -448,6 +448,27 @@ class Fetch(object):
 
     srcrev_internal_helper = staticmethod(srcrev_internal_helper)
 
+    def localcount_internal_helper(ud, d):
+        """
+        Return:
+            a) a locked localcount if specified
+           b) None otherwise
+        """
+
+        localcount= None
+        if 'name' in ud.parm: 
+            pn = data.getVar("PN", d, 1)
+            localcount = data.getVar("LOCALCOUNT_pn-" + pn + "_" + ud.parm['name'], d, 1)

Just check getVar("LOCALCOUNT_" + ud.parm['name'], d, 1)

and require the user to set LOCALCOUNT_name_pn-foo = "bar".

+        if not localcount:
+            localcount = data.getVar("LOCALCOUNT", d, 1)
+        if localcount == "INVALID":
+            raise InvalidSRCREV("Please set LOCALCOUNT to a valid
value")

No point in checking for "INVALID", thats a special catch for the SRCREV
code you copied :)

+        if not localcount:
+            return None

You can just remove the above two lines.

+        return localcount
+
+    localcount_internal_helper =
staticmethod(localcount_internal_helper)
+
     def try_mirror(d, tarfn):
         """
         Try to use a mirrored version of the sources. We do this
@@ -550,15 +571,20 @@ class Fetch(object):
 
         latest_rev = self._build_revision(url, ud, d)
         last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev")
-        count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")
+        localcount = Fetch.localcount_internal_helper(ud, d)
+        if localcount is None:
+            count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")
+        else:
+            count = localcount

How about just doing:

uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False
count = None
if uselocalcount
         count = Fetch.localcount_internal_helper(ud, d)
if count is None:
         count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")


which combines you second patch too?

         if last_rev == latest_rev:
             return str(count + "+" + latest_rev)
 
-        if count is None:
-            count = "0"
-        else:
-            count = str(int(count) + 1)
+        if localcount is None:
+            if count is None:
+                count = "0"
+            else:
+                count = str(int(count) + 1)

There should be no need to do this?

Cheers,

Richard





More information about the Openembedded-devel mailing list