Skip to contentSkip to conversation

bitbake: fetch2: Add sanity check for SHA validity of tag and adjust SHA define order

PATCH In review Zhenhua Luo 3 participants 13 messages Dec 24, 2013 – Jan 20, 2014

lore
Share & tools
lore
#0 lore raw

cover bitbake: fetch2: Add sanity check for SHA validity of tag and adjust SHA define order

* Add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in tag.

* To allign with above change, the priority of revision needs to be adjusted as following, otherwise SHA defined by SRCREV will be overriden by rev/tag defined by SRC_URI.
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

Zhenhua Luo (2):
bitbake: fetch2/git: Add sanity check for SHA validity of tag
bitbake: fetch2: adjust the priority of revision definition

 lib/bb/fetch2/__init__.py | 19 ++++++++++---------
 lib/bb/fetch2/git.py      | 29 +++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 1/2 bitbake: fetch2/git: Add sanity check for SHA validity of tag

The change add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in tag.

---
 lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
lib/bb/fetch2/git.py +27 -2
index bd107db..1c2d5d3 100644
@@ -116,6 +116,15 @@ class Git(FetchMethod):
             ud.branches[name] = branch
             ud.unresolvedrev[name] = branch
 
+        tags = ud.parm.get("tag", "").split(',')
+        if len(tags) != len(ud.names):
+            raise bb.fetch2.ParameterError("The number of name and tag parameters is not balanced", ud.url)
+        ud.tags = {}
+        for name in ud.names:
+            tag = tags[ud.names.index(name)]
+            ud.tags[name] = tag
+            ud.unresolvedrev[name] = tag
+
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
         ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0") or ud.rebaseable
@@ -218,7 +227,10 @@ class Git(FetchMethod):
         os.chdir(ud.clonedir)
         for name in ud.names:
             if not self._contains_ref(ud, d, name):
-                raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
+                if ud.tags[name]: 
+                    raise bb.fetch2.FetchError("Unable to find revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))
+                else:
+                    raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
 
     def build_mirror_data(self, ud, d):
         # Generate a mirror tarball if needed
@@ -288,6 +300,18 @@ class Git(FetchMethod):
         return True
 
     def _contains_ref(self, ud, d, name):
+        if len(ud.tags[name]) != 0:
+            cmd =  "%s tag --contains %s --list %s 2> /dev/null | wc -l" % (
+                ud.basecmd, ud.revisions[name], ud.tags[name])
+            try:
+                output = runfetchcmd(cmd, d, quiet=True)
+            except bb.fetch2.FetchError:
+                return False
+            if len(output.split()) > 1:
+                raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
+            else:
+                return output.split()[0] != "0"
+
         cmd =  "%s branch --contains %s --list %s 2> /dev/null | wc -l" % (
             ud.basecmd, ud.revisions[name], ud.branches[name])
         try:
@@ -296,7 +320,8 @@ class Git(FetchMethod):
             return False
         if len(output.split()) > 1:
             raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
-        return output.split()[0] != "0"
+        else:
+            return output.split()[0] != "0"
 
     def _revision_key(self, ud, d, name):
         """
Signature · 1 line
1.8.4.2
#2 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 3 lines · Zhenhua Luo

The change add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in tag.

I've tested this patch with corner case reported in:
http://lists.openembedded.org/pipermail/openembedded-core/2013-December/087486.html

and now I can "fix" yajl recipe fetch just by adding "tag=1.0.12" into the SRC_URI.

But it's still a bit confusing for SRCREVs which are accessible from some tag, but aren't corresponding to that tag directly, people will assume that tag=foo in SRC_URI is really what will be used, but instead some older SRCREV can be used.

Maybe we need 3rd option to prevent default "master" branch and handle SRCREVs not included in any branch and not matching any tag differently?

Then we can add sanity check that when tag= and SRCREV are both used than SRCREV should point to SHA-1 of annotated tag or dereferrenced tag.

Quoted 74 lines
---
 lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
lib/bb/fetch2/git.py +27 -2
index bd107db..1c2d5d3 100644
@@ -116,6 +116,15 @@ class Git(FetchMethod):
             ud.branches[name] = branch
             ud.unresolvedrev[name] = branch
 
+        tags = ud.parm.get("tag", "").split(',')
+        if len(tags) != len(ud.names):
+            raise bb.fetch2.ParameterError("The number of name and tag parameters is not balanced", ud.url)
+        ud.tags = {}
+        for name in ud.names:
+            tag = tags[ud.names.index(name)]
+            ud.tags[name] = tag
+            ud.unresolvedrev[name] = tag
+
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
         ud.write_tarballs = ((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0") or ud.rebaseable
@@ -218,7 +227,10 @@ class Git(FetchMethod):
         os.chdir(ud.clonedir)
         for name in ud.names:
             if not self._contains_ref(ud, d, name):
-                raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
+                if ud.tags[name]: 
+                    raise bb.fetch2.FetchError("Unable to find revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))
+                else:
+                    raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
 
     def build_mirror_data(self, ud, d):
         # Generate a mirror tarball if needed
@@ -288,6 +300,18 @@ class Git(FetchMethod):
         return True
 
     def _contains_ref(self, ud, d, name):
+        if len(ud.tags[name]) != 0:
+            cmd =  "%s tag --contains %s --list %s 2> /dev/null | wc -l" % (
+                ud.basecmd, ud.revisions[name], ud.tags[name])
+            try:
+                output = runfetchcmd(cmd, d, quiet=True)
+            except bb.fetch2.FetchError:
+                return False
+            if len(output.split()) > 1:
+                raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
+            else:
+                return output.split()[0] != "0"
+
         cmd =  "%s branch --contains %s --list %s 2> /dev/null | wc -l" % (
             ud.basecmd, ud.revisions[name], ud.branches[name])
         try:
@@ -296,7 +320,8 @@ class Git(FetchMethod):
             return False
         if len(output.split()) > 1:
             raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
-        return output.split()[0] != "0"
+        else:
+            return output.split()[0] != "0"
 
     def _revision_key(self, ud, d, name):
         """
Signature · 7 lines
1.8.4.2


_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#3 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 17 lines

-----Original Message-----
From: [email protected] [mailto:bitbake-devel- [email protected]] On Behalf Of Martin Jansa
Sent: Friday, January 03, 2014 9:44 PM

Quoted 3 lines · Zhenhua Luo

The change add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in tag.

I've tested this patch with corner case reported in:
http://lists.openembedded.org/pipermail/openembedded-core/2013-
December/087486.html

and now I can "fix" yajl recipe fetch just by adding "tag=1.0.12" into the SRC_URI.

Quoted 7 lines

But it's still a bit confusing for SRCREVs which are accessible from some tag, but aren't corresponding to that tag directly, people will assume that tag=foo in SRC_URI is really what will be used, but instead some older SRCREV can be used.

Maybe we need 3rd option to prevent default "master" branch and handle SRCREVs not included in any branch and not matching any tag differently?

[Luo Zhenhua-B19537] Do you mean adding a new option to skip the validity check of SHA?

Quoted 2 lines

Then we can add sanity check that when tag= and SRCREV are both used than SRCREV should point to SHA-1 of annotated tag or dereferrenced tag.

[Luo Zhenhua-B19537] I submitted another patch to adjust the revision definition priority(http://patches.openembedded.org/patch/63703/).
SHA define priority sequence.
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

When tag is defined in SRC_URI, there are three SHA definition scenarios:
* SRCREV is set to SHA corresponding to the tag, commit corresponding to the tag will be used
* SRCREV is set to an older SHA in the tag, the older commit in the tag will be used
* SRCREV is not set, commit corresponding to the tag will be used.
Does above implementation make sense? Or any other better method?

Best Regards,

Zhenhua

Quoted 89 lines
Quoted 10 lines
---
 lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
lib/bb/fetch2/git.py index renamed from lib/bb/fetch2/git.py +0 -0

bd107db..1c2d5d3 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 121

Quoted 6 lines
lib/bb/fetch2/git.py +3 -0
@@ -116,6 +116,15 @@ class Git(FetchMethod):
             ud.branches[name] = branch
             ud.unresolvedrev[name] = branch
 
+        tags = ud.parm.get("tag", "").split(',')
+        if len(tags) != len(ud.names):
+            raise bb.fetch2.ParameterError("The number of name and tag

parameters is not balanced", ud.url)

Quoted 10 lines
lib/bb/fetch2/git.py +6 -0
+        ud.tags = {}
+        for name in ud.names:
+            tag = tags[ud.names.index(name)]
+            ud.tags[name] = tag
+            ud.unresolvedrev[name] = tag
+
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
         ud.write_tarballs =

((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0")

or ud.rebaseable @@ -218,7 +227,10 @@ class Git(FetchMethod):

Quoted 4 lines

os.chdir(ud.clonedir)
for name in ud.names:
if not self._contains_ref(ud, d, name):
- raise bb.fetch2.FetchError("Unable to find revision %s

in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))

lib/bb/fetch2/git.py

Quoted 2 lines
lib/bb/fetch2/git.py +2 -0
+                if ud.tags[name]:
+                    raise bb.fetch2.FetchError("Unable to find

revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))

lib/bb/fetch2/git.py

Quoted 13 lines
lib/bb/fetch2/git.py +4 -0
+                else:
+                    raise bb.fetch2.FetchError("Unable to find
+ revision %s in branch %s even from upstream" % (ud.revisions[name],
+ ud.branches[name]))
 
     def build_mirror_data(self, ud, d):
         # Generate a mirror tarball if needed @@ -288,6 +300,18 @@

class Git(FetchMethod):
return True

def _contains_ref(self, ud, d, name):

lib/bb/fetch2/git.py +2 -0
+        if len(ud.tags[name]) != 0:
+            cmd =  "%s tag --contains %s --list %s 2> /dev/null | wc -

l" % (

lib/bb/fetch2/git.py class Git(FetchMethod):

Quoted 7 lines
lib/bb/fetch2/git.py +7 -0
+                ud.basecmd, ud.revisions[name], ud.tags[name])
+            try:
+                output = runfetchcmd(cmd, d, quiet=True)
+            except bb.fetch2.FetchError:
+                return False
+            if len(output.split()) > 1:
+                raise bb.fetch2.FetchError("The command '%s' gave

output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

lib/bb/fetch2/git.py class Git(FetchMethod):

Quoted 4 lines
lib/bb/fetch2/git.py +3 -0
+            else:
+                return output.split()[0] != "0"
+
         cmd =  "%s branch --contains %s --list %s 2> /dev/null | wc -

l" % (

lib/bb/fetch2/git.py class Git(FetchMethod): · line 322

Quoted 6 lines

ud.basecmd, ud.revisions[name], ud.branches[name])
try:

lib/bb/fetch2/git.py +0 -0
@@ -296,7 +320,8 @@ class Git(FetchMethod):
             return False
         if len(output.split()) > 1:
             raise bb.fetch2.FetchError("The command '%s' gave output

with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

Quoted 10 lines
lib/bb/fetch2/git.py +2 -2
-        return output.split()[0] != "0"
+        else:
+            return output.split()[0] != "0"
 
     def _revision_key(self, ud, d, name):
         """
--

1.8.4.2

Quoted 4 lines

_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel

--
Martin 'JaMa' Jansa jabber: [email protected]

#4 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 17 lines · On Mon, Jan 06, 2014 at 04:25:00AM +0000, [email protected] wrote:
Quoted 17 lines

-----Original Message-----
From: [email protected] [mailto:bitbake-devel- [email protected]] On Behalf Of Martin Jansa
Sent: Friday, January 03, 2014 9:44 PM

Quoted 3 lines · Zhenhua Luo

The change add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in tag.

I've tested this patch with corner case reported in:
http://lists.openembedded.org/pipermail/openembedded-core/2013-
December/087486.html

and now I can "fix" yajl recipe fetch just by adding "tag=1.0.12" into the SRC_URI.

Quoted 8 lines
Quoted 7 lines

But it's still a bit confusing for SRCREVs which are accessible from some tag, but aren't corresponding to that tag directly, people will assume that tag=foo in SRC_URI is really what will be used, but instead some older SRCREV can be used.

Maybe we need 3rd option to prevent default "master" branch and handle SRCREVs not included in any branch and not matching any tag differently?

[Luo Zhenhua-B19537] Do you mean adding a new option to skip the validity check of SHA?

Yes, I was thinking about something like nobranch parameter which will explicitly say that selected SRCREV is known to be not included in any branch or any tag.

In most cases it shouldn't be needed but still such corner cases exist (e.g. rebased repos).

Quoted 11 lines
Quoted 2 lines

Then we can add sanity check that when tag= and SRCREV are both used than SRCREV should point to SHA-1 of annotated tag or dereferrenced tag.

[Luo Zhenhua-B19537] I submitted another patch to adjust the revision definition priority(http://patches.openembedded.org/patch/63703/).
SHA define priority sequence.
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

When tag is defined in SRC_URI, there are three SHA definition scenarios:
* SRCREV is set to SHA corresponding to the tag, commit corresponding to the tag will be used

This is OK, but you cannot check that it really corresponds and show warning if not, because it could be now allowed variant with older SHA as bellow.

Quoted 1 line

* SRCREV is set to an older SHA in the tag, the older commit in the tag will be used

This one is IMHO a bit confusing, because people can notice SRC_URI=.*;tag=foo

and then they don't notice SRCREV in the recipe (or don't expect it to be older commit in foo tag) and they just assume that tag=foo means the tip of the tag will be used in build.

In most cases such commit is also included in some branch and using just SRC_URI=.*;branch=foo + SRCREV would be less confusing.

So I would show warning in this case.

In very few exceptions (if any) where you really want SRCREV not included in any branch and included in some tag, but not corresponding to that tag you would use
SRC_URI=.*;nobranch + SRCREV

Quoted 2 lines

* SRCREV is not set, commit corresponding to the tag will be used. Does above implementation make sense? Or any other better method?

We're doing something similar
https://github.com/openwebos/meta-webos/blob/master/classes/webos_enhanced_submissions.bbclass
with the advantage that we can say that all our components which inherit this class have to use annotated tags (with lightweight tags you can use SRCREV corresponding with tag which exists only in remote repository, but isn't in your downloads/premirror version, even when the SRCREV exists already - annotated tag has always new SRCREV so fetcher will always update the repo and we don't need to use git ls-remote to verify that SRCREV is matching the tag.

Quoted 89 lines
Quoted 89 lines
Quoted 10 lines
---
 lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
lib/bb/fetch2/git.py index renamed from lib/bb/fetch2/git.py +0 -0

bd107db..1c2d5d3 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 121

Quoted 6 lines
lib/bb/fetch2/git.py +3 -0
@@ -116,6 +116,15 @@ class Git(FetchMethod):
             ud.branches[name] = branch
             ud.unresolvedrev[name] = branch
 
+        tags = ud.parm.get("tag", "").split(',')
+        if len(tags) != len(ud.names):
+            raise bb.fetch2.ParameterError("The number of name and tag

parameters is not balanced", ud.url)

Quoted 10 lines
lib/bb/fetch2/git.py +6 -0
+        ud.tags = {}
+        for name in ud.names:
+            tag = tags[ud.names.index(name)]
+            ud.tags[name] = tag
+            ud.unresolvedrev[name] = tag
+
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
         ud.write_tarballs =

((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0")

or ud.rebaseable @@ -218,7 +227,10 @@ class Git(FetchMethod):

Quoted 4 lines

os.chdir(ud.clonedir)
for name in ud.names:
if not self._contains_ref(ud, d, name):
- raise bb.fetch2.FetchError("Unable to find revision %s

in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))

lib/bb/fetch2/git.py

Quoted 2 lines
lib/bb/fetch2/git.py +2 -0
+                if ud.tags[name]:
+                    raise bb.fetch2.FetchError("Unable to find

revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))

lib/bb/fetch2/git.py

Quoted 13 lines
lib/bb/fetch2/git.py +4 -0
+                else:
+                    raise bb.fetch2.FetchError("Unable to find
+ revision %s in branch %s even from upstream" % (ud.revisions[name],
+ ud.branches[name]))
 
     def build_mirror_data(self, ud, d):
         # Generate a mirror tarball if needed @@ -288,6 +300,18 @@

class Git(FetchMethod):
return True

def _contains_ref(self, ud, d, name):

lib/bb/fetch2/git.py +2 -0
+        if len(ud.tags[name]) != 0:
+            cmd =  "%s tag --contains %s --list %s 2> /dev/null | wc -

l" % (

lib/bb/fetch2/git.py class Git(FetchMethod):

Quoted 7 lines
lib/bb/fetch2/git.py +7 -0
+                ud.basecmd, ud.revisions[name], ud.tags[name])
+            try:
+                output = runfetchcmd(cmd, d, quiet=True)
+            except bb.fetch2.FetchError:
+                return False
+            if len(output.split()) > 1:
+                raise bb.fetch2.FetchError("The command '%s' gave

output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

lib/bb/fetch2/git.py class Git(FetchMethod):

Quoted 4 lines
lib/bb/fetch2/git.py +3 -0
+            else:
+                return output.split()[0] != "0"
+
         cmd =  "%s branch --contains %s --list %s 2> /dev/null | wc -

l" % (

lib/bb/fetch2/git.py class Git(FetchMethod): · line 322

Quoted 6 lines

ud.basecmd, ud.revisions[name], ud.branches[name])
try:

lib/bb/fetch2/git.py +0 -0
@@ -296,7 +320,8 @@ class Git(FetchMethod):
             return False
         if len(output.split()) > 1:
             raise bb.fetch2.FetchError("The command '%s' gave output

with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

Quoted 10 lines
lib/bb/fetch2/git.py +2 -2
-        return output.split()[0] != "0"
+        else:
+            return output.split()[0] != "0"
 
     def _revision_key(self, ud, d, name):
         """
--

1.8.4.2

Quoted 4 lines

_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel

--
Martin 'JaMa' Jansa jabber: [email protected]

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#5 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

It is a simple way to add "nobranch" option to skip the SHA validity check. I have posted a patch, please review.

http://patches.openembedded.org/patch/64197/

Best Regards,

Zhenhua

Quoted 201 lines

-----Original Message-----
From: Martin Jansa [mailto:[email protected]]
Sent: Monday, January 06, 2014 5:13 PM
To: Luo Zhenhua-B19537
Cc: Guo Chunrong-B40290; [email protected]; Yu Zongchun-B40527; Schmitt Richard-B43082; Liu Ting-B28495
Subject: Re: [bitbake-devel] [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 10 lines · On Mon, Jan 06, 2014 at 04:25:00AM +0000, [email protected] wrote:
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:bitbake-devel- [email protected]] On Behalf Of Martin Jansa
Sent: Friday, January 03, 2014 9:44 PM

Quoted 3 lines · Zhenhua Luo

The change add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in

tag.

Quoted 8 lines
Quoted 8 lines

I've tested this patch with corner case reported in:
http://lists.openembedded.org/pipermail/openembedded-core/2013-
December/087486.html

and now I can "fix" yajl recipe fetch just by adding "tag=1.0.12" into the SRC_URI.

Quoted 7 lines
Quoted 7 lines

But it's still a bit confusing for SRCREVs which are accessible from some tag, but aren't corresponding to that tag directly, people will assume that tag=foo in SRC_URI is really what will be used, but instead some older SRCREV can be used.

Maybe we need 3rd option to prevent default "master" branch and handle SRCREVs not included in any branch and not matching any tag

differently?

Quoted 1 line

[Luo Zhenhua-B19537] Do you mean adding a new option to skip the

validity check of SHA?

Yes, I was thinking about something like nobranch parameter which will explicitly say that selected SRCREV is known to be not included in any branch or any tag.

In most cases it shouldn't be needed but still such corner cases exist (e.g. rebased repos).

Quoted 2 lines
Quoted 2 lines

Then we can add sanity check that when tag= and SRCREV are both used than SRCREV should point to SHA-1 of annotated tag or dereferrenced

tag.

Quoted 1 line

[Luo Zhenhua-B19537] I submitted another patch to adjust the revision

definition priority(http://patches.openembedded.org/patch/63703/).

Quoted 7 lines

SHA define priority sequence.
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

When tag is defined in SRC_URI, there are three SHA definition

scenarios:

Quoted 1 line

* SRCREV is set to SHA corresponding to the tag, commit

corresponding

Quoted 1 line

to the tag will be used

This is OK, but you cannot check that it really corresponds and show warning if not, because it could be now allowed variant with older SHA as bellow.

Quoted 2 lines

* SRCREV is set to an older SHA in the tag, the older commit in the
tag will be used

This one is IMHO a bit confusing, because people can notice SRC_URI=.*;tag=foo

and then they don't notice SRCREV in the recipe (or don't expect it to be older commit in foo tag) and they just assume that tag=foo means the tip of the tag will be used in build.

In most cases such commit is also included in some branch and using just SRC_URI=.*;branch=foo + SRCREV would be less confusing.

So I would show warning in this case.

In very few exceptions (if any) where you really want SRCREV not included in any branch and included in some tag, but not corresponding to that tag you would use SRC_URI=.*;nobranch + SRCREV

Quoted 2 lines

* SRCREV is not set, commit corresponding to the tag will be used. Does above implementation make sense? Or any other better method?

We're doing something similar
https://github.com/openwebos/meta-
webos/blob/master/classes/webos_enhanced_submissions.bbclass with the advantage that we can say that all our components which inherit this class have to use annotated tags (with lightweight tags you can use SRCREV corresponding with tag which exists only in remote repository, but isn't in your downloads/premirror version, even when the SRCREV exists already - annotated tag has always new SRCREV so fetcher will always update the repo and we don't need to use git ls-remote to verify that SRCREV is matching the tag.

Quoted 26 lines
Quoted 26 lines
Quoted 10 lines
---
 lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
lib/bb/fetch2/git.py index renamed from lib/bb/fetch2/git.py +0 -0

bd107db..1c2d5d3 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 122

Quoted 7 lines
lib/bb/fetch2/git.py +4 -0
@@ -116,6 +116,15 @@ class Git(FetchMethod):
             ud.branches[name] = branch
             ud.unresolvedrev[name] = branch
 
+        tags = ud.parm.get("tag", "").split(',')
+        if len(tags) != len(ud.names):
+            raise bb.fetch2.ParameterError("The number of name
+ and tag

parameters is not balanced", ud.url)

Quoted 8 lines
lib/bb/fetch2/git.py +6 -0
+        ud.tags = {}
+        for name in ud.names:
+            tag = tags[ud.names.index(name)]
+            ud.tags[name] = tag
+            ud.unresolvedrev[name] = tag
+
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

ud.write_tarballs =
((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0")

or ud.rebaseable @@ -218,7 +227,10 @@ class Git(FetchMethod):

Quoted 4 lines

os.chdir(ud.clonedir)
for name in ud.names:
if not self._contains_ref(ud, d, name):
- raise bb.fetch2.FetchError("Unable to find

revision %s

Quoted 55 lines
Quoted 55 lines

in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))

lib/bb/fetch2/git.py

Quoted 2 lines
lib/bb/fetch2/git.py +2 -0
+                if ud.tags[name]:
+                    raise bb.fetch2.FetchError("Unable to find

revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))

Quoted 12 lines
lib/bb/fetch2/git.py +5 -0
+                else:
+                    raise bb.fetch2.FetchError("Unable to find
+ revision %s in branch %s even from upstream" %
+ (ud.revisions[name],
+ ud.branches[name]))
 
     def build_mirror_data(self, ud, d):
         # Generate a mirror tarball if needed @@ -288,6 +300,18

@@ class Git(FetchMethod):
return True

def _contains_ref(self, ud, d, name):

lib/bb/fetch2/git.py

Quoted 3 lines
lib/bb/fetch2/git.py +3 -0
+        if len(ud.tags[name]) != 0:
+            cmd =  "%s tag --contains %s --list %s 2> /dev/null |
+ wc -

l" % (

lib/bb/fetch2/git.py class Git(FetchMethod):

Quoted 7 lines
lib/bb/fetch2/git.py +7 -0
+                ud.basecmd, ud.revisions[name], ud.tags[name])
+            try:
+                output = runfetchcmd(cmd, d, quiet=True)
+            except bb.fetch2.FetchError:
+                return False
+            if len(output.split()) > 1:
+                raise bb.fetch2.FetchError("The command '%s' gave

output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

Quoted 5 lines
lib/bb/fetch2/git.py +3 -0
+            else:
+                return output.split()[0] != "0"
+
         cmd =  "%s branch --contains %s --list %s 2> /dev/null |

wc -

l" % (

Quoted 7 lines

ud.basecmd, ud.revisions[name], ud.branches[name])
try:

lib/bb/fetch2/git.py +0 -0
@@ -296,7 +320,8 @@ class Git(FetchMethod):
             return False
         if len(output.split()) > 1:
             raise bb.fetch2.FetchError("The command '%s' gave

output

with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

Quoted 10 lines
lib/bb/fetch2/git.py +2 -2
-        return output.split()[0] != "0"
+        else:
+            return output.split()[0] != "0"
 
     def _revision_key(self, ud, d, name):
         """
--

1.8.4.2

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel

--
Martin 'JaMa' Jansa jabber: [email protected]

--
Martin 'JaMa' Jansa jabber: [email protected]

#6 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 3 lines · On Tue, Jan 07, 2014 at 03:29:22AM +0000, [email protected] wrote:

It is a simple way to add "nobranch" option to skip the SHA validity check. I have posted a patch, please review.

http://patches.openembedded.org/patch/64197/

The v2 looks good and it's already merged :).

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines

Then we can add sanity check that when tag= and SRCREV are both used than SRCREV should point to SHA-1 of annotated tag or dereferrenced

tag.

Quoted 1 line

[Luo Zhenhua-B19537] I submitted another patch to adjust the revision

definition priority(http://patches.openembedded.org/patch/63703/).

Quoted 7 lines

SHA define priority sequence.
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

When tag is defined in SRC_URI, there are three SHA definition

Quoted 8 lines
Quoted 8 lines

scenarios:

Quoted 1 line

* SRCREV is set to SHA corresponding to the tag, commit

corresponding

Quoted 1 line

to the tag will be used

This is OK, but you cannot check that it really corresponds and show warning if not, because it could be now allowed variant with older SHA as bellow.

Be aware that for this to work correctly you need to run "git fetch --tags" or equivalent, because with lightweight tags you can have repo like this:

SHA-1
A123 <- tag-1.0
B123
C123 <- master HEAD

You're building C123 or tag-1.0 when C123 revision already exists, so fetcher creates clone including all 3 SHA-1s, it creates tarball with checkout and puts it on PREMIRROR.

Someone in upstream adds tag-1.1 pointing to B123

SHA-1

A123  <- tag-1.0
B123  <- tag-1.1
C123  <- master HEAD

Someone changes recipe to use:
SRCREV = "B123"
SRC_URI = "git://foo;tag=tag-1.1"

Current fetcher starts by checking if "B123" SHA-1 exists in checkout in downloads directory (or even downloaded from PREMIRROR) and it returns yes, so it doesn't try to update it, but then if you try to check that B123 corresponds with "tag-1.1" it fails, because tag-1.1 doesn't exist yet in current checkout/premirror.

With annotated tags it's not problem because every new tag has new SHA-1, so fetcher always updates the checkout first when checking for new tag.

Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

* SRCREV is set to an older SHA in the tag, the older commit in the
tag will be used

This one is IMHO a bit confusing, because people can notice SRC_URI=.*;tag=foo

and then they don't notice SRCREV in the recipe (or don't expect it to be older commit in foo tag) and they just assume that tag=foo means the tip of the tag will be used in build.

Quoted 8 lines
Quoted 8 lines

In most cases such commit is also included in some branch and using just SRC_URI=.*;branch=foo + SRCREV would be less confusing.

So I would show warning in this case.

In very few exceptions (if any) where you really want SRCREV not included in any branch and included in some tag, but not corresponding to that tag you would use SRC_URI=.*;nobranch + SRCREV

I think that with nobranch patch now merged we should show warning when this case happens, people shouldn't use tag parameter when they don't want exactly that tag.

Quoted 114 lines
Quoted 114 lines
Quoted 2 lines

* SRCREV is not set, commit corresponding to the tag will be used. Does above implementation make sense? Or any other better method?

We're doing something similar
https://github.com/openwebos/meta-
webos/blob/master/classes/webos_enhanced_submissions.bbclass with the advantage that we can say that all our components which inherit this class have to use annotated tags (with lightweight tags you can use SRCREV corresponding with tag which exists only in remote repository, but isn't in your downloads/premirror version, even when the SRCREV exists already - annotated tag has always new SRCREV so fetcher will always update the repo and we don't need to use git ls-remote to verify that SRCREV is matching the tag.

Quoted 26 lines
Quoted 26 lines
Quoted 10 lines
---
 lib/bb/fetch2/git.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
lib/bb/fetch2/git.py index renamed from lib/bb/fetch2/git.py +0 -0

bd107db..1c2d5d3 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 122

Quoted 7 lines
lib/bb/fetch2/git.py +4 -0
@@ -116,6 +116,15 @@ class Git(FetchMethod):
             ud.branches[name] = branch
             ud.unresolvedrev[name] = branch
 
+        tags = ud.parm.get("tag", "").split(',')
+        if len(tags) != len(ud.names):
+            raise bb.fetch2.ParameterError("The number of name
+ and tag

parameters is not balanced", ud.url)

Quoted 8 lines
lib/bb/fetch2/git.py +6 -0
+        ud.tags = {}
+        for name in ud.names:
+            tag = tags[ud.names.index(name)]
+            ud.tags[name] = tag
+            ud.unresolvedrev[name] = tag
+
         ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
 
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

ud.write_tarballs =
((data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) or "0") != "0")

or ud.rebaseable @@ -218,7 +227,10 @@ class Git(FetchMethod):

Quoted 4 lines

os.chdir(ud.clonedir)
for name in ud.names:
if not self._contains_ref(ud, d, name):
- raise bb.fetch2.FetchError("Unable to find

revision %s

Quoted 55 lines
Quoted 55 lines

in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))

lib/bb/fetch2/git.py

Quoted 2 lines
lib/bb/fetch2/git.py +2 -0
+                if ud.tags[name]:
+                    raise bb.fetch2.FetchError("Unable to find

revision %s in tag %s even from upstream" % (ud.revisions[name], ud.tags[name]))

Quoted 12 lines
lib/bb/fetch2/git.py +5 -0
+                else:
+                    raise bb.fetch2.FetchError("Unable to find
+ revision %s in branch %s even from upstream" %
+ (ud.revisions[name],
+ ud.branches[name]))
 
     def build_mirror_data(self, ud, d):
         # Generate a mirror tarball if needed @@ -288,6 +300,18

@@ class Git(FetchMethod):
return True

def _contains_ref(self, ud, d, name):

lib/bb/fetch2/git.py

Quoted 3 lines
lib/bb/fetch2/git.py +3 -0
+        if len(ud.tags[name]) != 0:
+            cmd =  "%s tag --contains %s --list %s 2> /dev/null |
+ wc -

l" % (

lib/bb/fetch2/git.py class Git(FetchMethod):

Quoted 7 lines
lib/bb/fetch2/git.py +7 -0
+                ud.basecmd, ud.revisions[name], ud.tags[name])
+            try:
+                output = runfetchcmd(cmd, d, quiet=True)
+            except bb.fetch2.FetchError:
+                return False
+            if len(output.split()) > 1:
+                raise bb.fetch2.FetchError("The command '%s' gave

output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

Quoted 5 lines
lib/bb/fetch2/git.py +3 -0
+            else:
+                return output.split()[0] != "0"
+
         cmd =  "%s branch --contains %s --list %s 2> /dev/null |

wc -

l" % (

Quoted 7 lines

ud.basecmd, ud.revisions[name], ud.branches[name])
try:

lib/bb/fetch2/git.py +0 -0
@@ -296,7 +320,8 @@ class Git(FetchMethod):
             return False
         if len(output.split()) > 1:
             raise bb.fetch2.FetchError("The command '%s' gave

output

with more then 1 line unexpectedly, output: '%s'" % (cmd, output))

Quoted 10 lines
lib/bb/fetch2/git.py +2 -2
-        return output.split()[0] != "0"
+        else:
+            return output.split()[0] != "0"
 
     def _revision_key(self, ud, d, name):
         """
--

1.8.4.2

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel

--
Martin 'JaMa' Jansa jabber: [email protected]

--
Martin 'JaMa' Jansa jabber: [email protected]

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#7 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 47 lines

-----Original Message-----
From: Martin Jansa [mailto:[email protected]]
Sent: Tuesday, January 07, 2014 10:47 PM

Quoted 1 line · On Tue, Jan 07, 2014 at 03:29:22AM +0000, [email protected] wrote:

It is a simple way to add "nobranch" option to skip the SHA validity

check. I have posted a patch, please review.

Quoted 2 lines

http://patches.openembedded.org/patch/64197/

The v2 looks good and it's already merged :).

Quoted 1 line
Quoted 1 line
Quoted 1 line

When tag is defined in SRC_URI, there are three SHA

definition

Quoted 8 lines
Quoted 8 lines

scenarios:

Quoted 1 line

* SRCREV is set to SHA corresponding to the tag, commit

corresponding

Quoted 1 line

to the tag will be used

This is OK, but you cannot check that it really corresponds and show warning if not, because it could be now allowed variant with older SHA as bellow.

Be aware that for this to work correctly you need to run "git fetch -- tags" or equivalent, because with lightweight tags you can have repo like this:

SHA-1
A123 <- tag-1.0
B123
C123 <- master HEAD

You're building C123 or tag-1.0 when C123 revision already exists, so fetcher creates clone including all 3 SHA-1s, it creates tarball with checkout and puts it on PREMIRROR.

Someone in upstream adds tag-1.1 pointing to B123

SHA-1

A123  <- tag-1.0
B123  <- tag-1.1
C123  <- master HEAD

Someone changes recipe to use:
SRCREV = "B123"
SRC_URI = "git://foo;tag=tag-1.1"

Quoted 8 lines

Current fetcher starts by checking if "B123" SHA-1 exists in checkout in downloads directory (or even downloaded from PREMIRROR) and it returns yes, so it doesn't try to update it, but then if you try to check that B123 corresponds with "tag-1.1" it fails, because tag-1.1 doesn't exist yet in current checkout/premirror.

With annotated tags it's not problem because every new tag has new SHA-1, so fetcher always updates the checkout first when checking for new tag.

[Luo Zhenhua-B19537] Thanks for the explanation.

Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

* SRCREV is set to an older SHA in the tag, the older commit

in

Quoted 14 lines
Quoted 14 lines
Quoted 1 line

the tag will be used

This one is IMHO a bit confusing, because people can notice SRC_URI=.*;tag=foo

and then they don't notice SRCREV in the recipe (or don't expect it to be older commit in foo tag) and they just assume that tag=foo means the tip of the tag will be used in build.

In most cases such commit is also included in some branch and using just SRC_URI=.*;branch=foo + SRCREV would be less confusing.

So I would show warning in this case.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

In very few exceptions (if any) where you really want SRCREV not included in any branch and included in some tag, but not corresponding to that tag you would use SRC_URI=.*;nobranch + SRCREV

I think that with nobranch patch now merged we should show warning when this case happens, people shouldn't use tag parameter when they don't want exactly that tag.

[Luo Zhenhua-B19537] You point is to show warning when SRCREV and tag are set, meanwhile SRCREV is not corresponding to the tag, right?

Best Regards,

Zhenhua

#8 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 73 lines · On Wed, Jan 08, 2014 at 10:21:53AM +0000, [email protected] wrote:
Quoted 47 lines

-----Original Message-----
From: Martin Jansa [mailto:[email protected]]
Sent: Tuesday, January 07, 2014 10:47 PM

Quoted 1 line · On Tue, Jan 07, 2014 at 03:29:22AM +0000, [email protected] wrote:

It is a simple way to add "nobranch" option to skip the SHA validity

check. I have posted a patch, please review.

Quoted 2 lines

http://patches.openembedded.org/patch/64197/

The v2 looks good and it's already merged :).

Quoted 1 line
Quoted 1 line
Quoted 1 line

When tag is defined in SRC_URI, there are three SHA

definition

Quoted 8 lines
Quoted 8 lines

scenarios:

Quoted 1 line

* SRCREV is set to SHA corresponding to the tag, commit

corresponding

Quoted 1 line

to the tag will be used

This is OK, but you cannot check that it really corresponds and show warning if not, because it could be now allowed variant with older SHA as bellow.

Be aware that for this to work correctly you need to run "git fetch -- tags" or equivalent, because with lightweight tags you can have repo like this:

SHA-1
A123 <- tag-1.0
B123
C123 <- master HEAD

You're building C123 or tag-1.0 when C123 revision already exists, so fetcher creates clone including all 3 SHA-1s, it creates tarball with checkout and puts it on PREMIRROR.

Someone in upstream adds tag-1.1 pointing to B123

SHA-1

A123  <- tag-1.0
B123  <- tag-1.1
C123  <- master HEAD

Someone changes recipe to use:
SRCREV = "B123"
SRC_URI = "git://foo;tag=tag-1.1"

Quoted 8 lines

Current fetcher starts by checking if "B123" SHA-1 exists in checkout in downloads directory (or even downloaded from PREMIRROR) and it returns yes, so it doesn't try to update it, but then if you try to check that B123 corresponds with "tag-1.1" it fails, because tag-1.1 doesn't exist yet in current checkout/premirror.

With annotated tags it's not problem because every new tag has new SHA-1, so fetcher always updates the checkout first when checking for new tag.

[Luo Zhenhua-B19537] Thanks for the explanation.

Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

* SRCREV is set to an older SHA in the tag, the older commit

in

Quoted 14 lines
Quoted 14 lines
Quoted 1 line

the tag will be used

This one is IMHO a bit confusing, because people can notice SRC_URI=.*;tag=foo

and then they don't notice SRCREV in the recipe (or don't expect it to be older commit in foo tag) and they just assume that tag=foo means the tip of the tag will be used in build.

In most cases such commit is also included in some branch and using just SRC_URI=.*;branch=foo + SRCREV would be less confusing.

So I would show warning in this case.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

In very few exceptions (if any) where you really want SRCREV not included in any branch and included in some tag, but not corresponding to that tag you would use SRC_URI=.*;nobranch + SRCREV

I think that with nobranch patch now merged we should show warning when this case happens, people shouldn't use tag parameter when they don't want exactly that tag.

[Luo Zhenhua-B19537] You point is to show warning when SRCREV and tag are set, meanwhile SRCREV is not corresponding to the tag, right?

Yes

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#9 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 3 lines · Martin Jansa
Quoted 1 line

[Luo Zhenhua-B19537] You point is to show warning when SRCREV and tag are set, meanwhile SRCREV is not corresponding to the tag, right?

Yes

We have several different issues around and the moment and I'm worried some cases are going to get lost. We really need a list of them along with the planed fix. As I see it we have:

a) conflicting SRCREV and tag/rev url parameters

Plan: bb.error on this case asking the user to say what they want

b) dereferencing of tags when checking existance of commits

Plan: Add ^{} to ls-remote command to allow dereferencing

c) tags may get resolved to incorrect tags in sub directories

Plan: Need to anchor tag/branch search expression

What else are we missing?

Ideally we could do with examples of these in the fetcher test code too...

Cheers,

Richard

#10 lore raw

Re: [PATCH 1/2] bitbake: fetch2/git: Add sanity check for SHA validity of tag

Quoted 19 lines · Richard Purdie
Quoted 3 lines · Martin Jansa
Quoted 1 line

[Luo Zhenhua-B19537] You point is to show warning when SRCREV and tag are set, meanwhile SRCREV is not corresponding to the tag, right?

Yes

We have several different issues around and the moment and I'm worried some cases are going to get lost. We really need a list of them along with the planed fix. As I see it we have:

a) conflicting SRCREV and tag/rev url parameters

Plan: bb.error on this case asking the user to say what they want

b) dereferencing of tags when checking existance of commits

Plan: Add ^{} to ls-remote command to allow dereferencing

c) tags may get resolved to incorrect tags in sub directories

Quoted 8 lines

Plan: Need to anchor tag/branch search expression

What else are we missing?

Ideally we could do with examples of these in the fetcher test code too...

FWIW I have fixed the above issues with the patchset that I've sent out (and is in master-next). Are there any remaining issues?

Cheers,

Richard

#11 lore raw

PATCH 2/2 bitbake: fetch2: adjust the priority of revision definition

In reply to Zhenhua Luo

The sanity check for commit validity has been added for branch, to support the commit included in tag rather than branch, the commit validity check should be supported for tag as well.

To allign with above change, the priority of revision needs to be adjusted as following, otherwise SHA defined by SRCREV will be overriden by rev/tag defined by SRC_URI.

New SHA check order:
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

---
 lib/bb/fetch2/__init__.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
lib/bb/fetch2/__init__.py +10 -9
index 8fdf59c..4c5c2e8 100644
@@ -862,17 +862,12 @@ def try_mirrors(d, origud, mirrors, check = False):
 def srcrev_internal_helper(ud, d, name):
     """
     Return:
-        a) a source revision if specified
-        b) latest revision if SRCREV="AUTOINC"
-        c) None if not specified
+        a) a source revision if SHA is specified by SRCREV
+        b) a source revision if revision is specified in SRC_URI
+        c) latest revision if SRCREV="AUTOINC"
+        d) None if not specified
     """
 
-    if 'rev' in ud.parm:
-        return ud.parm['rev']
-
-    if 'tag' in ud.parm:
-        return ud.parm['tag']
-
     rev = None
     pn = d.getVar("PN", True)
     if name != '':
@@ -883,6 +878,12 @@ def srcrev_internal_helper(ud, d, name):
         rev = d.getVar("SRCREV_pn-%s" % pn, True)
     if not rev:
         rev = d.getVar("SRCREV", True)
+    if not rev:
+        if 'rev' in ud.parm:
+            return ud.parm['rev']
+    if not rev:
+        if 'tag' in ud.parm:
+            return ud.parm['tag']
     if rev == "INVALID":
         var = "SRCREV_pn-%s" % pn
         if name != '':
Signature · 1 line
1.8.4.2
#12 lore raw
In reply to Zhenhua Luo

Any comment on the patch to support SHA validate of tag?

Best Regards,

Zhenhua

Quoted 32 lines

-----Original Message-----
From: Zhenhua Luo [mailto:[email protected]]
Sent: Tuesday, December 24, 2013 4:07 PM
To: [email protected]
Cc: Liu Ting-B28495; Yu Zongchun-B40527; Guo Chunrong-B40290; Luo Zhenhua-B19537
Subject: [PATCH 0/2] bitbake: fetch2: Add sanity check for SHA validity of tag and adjust SHA define order

* Add the sanity check for SHA valididy when tag is defined in SRC_URI, the check is useful for rebased git tree in which the referred commit is not valid in branch and is saved in tag.

* To allign with above change, the priority of revision needs to be adjusted as following, otherwise SHA defined by SRCREV will be overriden by rev/tag defined by SRC_URI.
a) a source revision if SHA is specified by SRCREV
b) a source revision if revision is specified in SRC_URI
c) latest revision if SRCREV="AUTOINC"
d) None if not specified

Zhenhua Luo (2):
bitbake: fetch2/git: Add sanity check for SHA validity of tag
bitbake: fetch2: adjust the priority of revision definition

 lib/bb/fetch2/__init__.py | 19 ++++++++++---------
 lib/bb/fetch2/git.py      | 29 +++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 11 deletions(-)

--
1.8.4.2