Skip to contentSkip to conversation

recipetool: create: keep tag= in SRC_URI

PATCH New Babanpreet Singh 1 participant 2 messages Nov 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 recipetool: create: keep tag= in SRC_URI

The fetcher now checks that tag= resolves to SRCREV, so stop dropping the tag from the SRC_URI of the recipe.

[YOCTO #15816]

---
 meta/lib/oeqa/selftest/cases/recipetool.py | 7 ++++++-
 scripts/lib/recipetool/create.py           | 2 --
 2 files changed, 6 insertions(+), 3 deletions(-)
meta/lib/oeqa/selftest/cases/recipetool.py +6 -1
index 54b7cb3a65..c278abdab2 100644
@@ -776,7 +776,7 @@ class RecipetoolCreateTests(RecipetoolBase):
         inherits = ['setuptools3']
         self._test_recipe_contents(recipefile, checkvars, inherits)
 
-    def _test_recipetool_create_git(self, srcuri, branch=None):
+    def _test_recipetool_create_git(self, srcuri, branch=None, extravars=None):
         # Basic test to check http git URL mangling works
         temprecipe = os.path.join(self.tempdir, 'recipe')
         os.makedirs(temprecipe)
@@ -792,6 +792,7 @@ class RecipetoolCreateTests(RecipetoolBase):
                 checkvars['SRC_URI'] = 'git%s;protocol=%s' % (srcuri[len(scheme):], scheme)
         if ';branch=' not in srcuri:
             checkvars['SRC_URI'] += ';branch=' + (branch or 'master')
+        checkvars.update(extravars or {})
         self._test_recipe_contents(recipefile, checkvars, [])
 
     def test_recipetool_create_git_http(self):
@@ -806,6 +807,10 @@ class RecipetoolCreateTests(RecipetoolBase):
     def test_recipetool_create_git_srcbranch(self):
         self._test_recipetool_create_git('git://git.yoctoproject.org/matchbox-keyboard;protocol=https', 'matchbox-keyboard-0-1')
 
+    def test_recipetool_create_git_srcuri_branch_tag(self):
+        self._test_recipetool_create_git('git://git.yoctoproject.org/matchbox-keyboard;branch=matchbox-keyboard-0-1;protocol=https;tag=0.1.1',
+                                         extravars={'SRCREV': '630d89068dc0a1e9199306d405cb32f892dfa4d3'})
+
     def _go_urifiy(self, url, version, modulepath = None, pathmajor = None, subdir = None):
         modulepath = ",path='%s'" % modulepath if len(modulepath) else ''
         pathmajor = ",pathmajor='%s'" % pathmajor if len(pathmajor) else ''
scripts/lib/recipetool/create.py +0 -2
index e0da96dea0..662e7a6232 100644
@@ -600,8 +600,6 @@ def create_recipe(args):
                 logger.error(str(err))
                 logger.error("Possibly wrong tag name is provided")
                 sys.exit(1)
-            # Drop tag from srcuri as it will have conflicts with SRCREV during recipe parse.
-            del params['tag']
         srcuri = bb.fetch.encodeurl((scheme, network, path, user, passwd, params))
 
         if os.path.exists(os.path.join(srctree, '.gitmodules')) and srcuri.startswith('git://'):
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 recipetool: create: fix git URLs that only specify a tag

A git URL with tag= and no branch= fails with:

Unable to resolve '' in upstream git repository

AUTOREV has no branch to follow now that bitbake no longer defaults to master. Fetch the tag itself, which also lets the branch be found from it.

AI-Generated: Uses Claude (claude-fable-5-2)

---

Notes:
Tested with oe-selftest -r recipetool.RecipetoolCreateTests. Not tried on wrynose, which has the same code.

 meta/lib/oeqa/selftest/cases/recipetool.py | 7 +++++++
 scripts/lib/recipetool/create.py           | 4 ++++
 2 files changed, 11 insertions(+)
meta/lib/oeqa/selftest/cases/recipetool.py +7 -0
index c278abdab2..804efcc755 100644
@@ -811,6 +811,13 @@ class RecipetoolCreateTests(RecipetoolBase):
         self._test_recipetool_create_git('git://git.yoctoproject.org/matchbox-keyboard;branch=matchbox-keyboard-0-1;protocol=https;tag=0.1.1',
                                          extravars={'SRCREV': '630d89068dc0a1e9199306d405cb32f892dfa4d3'})
 
+    def test_recipetool_create_git_srcuri_tag(self):
+        # The 0.1.1 tag is only on the matchbox-keyboard-0-1 branch
+        srcuri = 'git://git.yoctoproject.org/matchbox-keyboard;protocol=https;tag=0.1.1'
+        self._test_recipetool_create_git(srcuri,
+                                         extravars={'SRC_URI': srcuri + ';branch=matchbox-keyboard-0-1',
+                                                    'SRCREV': '630d89068dc0a1e9199306d405cb32f892dfa4d3'})
+
     def _go_urifiy(self, url, version, modulepath = None, pathmajor = None, subdir = None):
         modulepath = ",path='%s'" % modulepath if len(modulepath) else ''
         pathmajor = ",pathmajor='%s'" % pathmajor if len(pathmajor) else ''
scripts/lib/recipetool/create.py +4 -0
index 662e7a6232..0e73f462d3 100644
@@ -520,6 +520,10 @@ def create_recipe(args):
             storeTagName = params['tag']
             params['nobranch'] = '1'
             del params['tag']
+            if srcrev == '${AUTOREV}':
+                # Nothing for ${AUTOREV} to resolve without a branch, so
+                # fetch the tag itself
+                srcrev = storeTagName
         # Assume 'master' branch if not set
         if scheme in ['git', 'gitsm'] and 'branch' not in params and 'nobranch' not in params:
             params['branch'] = 'master'
Signature · 1 line
2.43.0