summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/setup.py
diff options
context:
space:
mode:
authorAlexander Kanavin <alex@linutronix.de>2025-09-29 14:56:15 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-05 23:47:05 +0100
commit29841a05bedcbc6be4de0873a694eaadf95bd03c (patch)
treeae05fdffbd223492e8fb0b2da289c0d599b9b7cc /bitbake/lib/bb/tests/setup.py
parent01b884c8fbc24e8901cb6149bdbfd94ce9f4a4b5 (diff)
downloadpoky-29841a05bedcbc6be4de0873a694eaadf95bd03c.tar.gz
bitbake: bitbake-setup: add support for specifying branches in repo checkouts
Previously bitbake-setup was checking out 'detached commits' using fetcher's nobranch feature, as that is the only option when only a revision is in the config. Branches are optional, but beneficial, as - checkout directory will be on a branch, making it easier for users to understand where they are if they need to make changes (also bitbake will print branch information instead of saying 'HEAD:sha'). - supply chain security! Enforcing a branch means any specified revision has to be on it, and no one can sneak in (accidentally or deliberately!) some dangling commit, or something from their private branch in the same repo. (Bitbake rev: 14dd5f53913419a6c26c0b809a592bd19ae8495a) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/setup.py')
-rw-r--r--bitbake/lib/bb/tests/setup.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/bitbake/lib/bb/tests/setup.py b/bitbake/lib/bb/tests/setup.py
index fb2c15f545..329a0c5259 100644
--- a/bitbake/lib/bb/tests/setup.py
+++ b/bitbake/lib/bb/tests/setup.py
@@ -87,7 +87,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
87 bbsetup = os.path.abspath(os.path.dirname(__file__) + "/../../../bin/bitbake-setup") 87 bbsetup = os.path.abspath(os.path.dirname(__file__) + "/../../../bin/bitbake-setup")
88 return bb.process.run("{} --global-settings {} {}".format(bbsetup, os.path.join(self.tempdir, 'global-config'), cmd)) 88 return bb.process.run("{} --global-settings {} {}".format(bbsetup, os.path.join(self.tempdir, 'global-config'), cmd))
89 89
90 def add_json_config_to_registry(self, name, rev): 90 def add_json_config_to_registry(self, name, rev, branch):
91 config = """ 91 config = """
92{ 92{
93 "sources": { 93 "sources": {
@@ -98,6 +98,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
98 "uri": "file://%s" 98 "uri": "file://%s"
99 } 99 }
100 }, 100 },
101 "branch": "%s",
101 "rev": "%s" 102 "rev": "%s"
102 }, 103 },
103 "path": "test-repo" 104 "path": "test-repo"
@@ -134,7 +135,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
134 }, 135 },
135 "version": "1.0" 136 "version": "1.0"
136} 137}
137""" % (self.testrepopath, rev) 138""" % (self.testrepopath, branch, rev)
138 os.makedirs(os.path.join(self.registrypath, os.path.dirname(name)), exist_ok=True) 139 os.makedirs(os.path.join(self.registrypath, os.path.dirname(name)), exist_ok=True)
139 with open(os.path.join(self.registrypath, name), 'w') as f: 140 with open(os.path.join(self.registrypath, name), 'w') as f:
140 f.write(config) 141 f.write(config)
@@ -208,12 +209,12 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
208 self.assertNotIn("test-config-1", out[0]) 209 self.assertNotIn("test-config-1", out[0])
209 self.assertNotIn("test-config-2", out[0]) 210 self.assertNotIn("test-config-2", out[0])
210 211
211 json_1 = self.add_json_config_to_registry('test-config-1.conf.json', 'master') 212 json_1 = self.add_json_config_to_registry('test-config-1.conf.json', 'master', 'master')
212 out = self.runbbsetup("list") 213 out = self.runbbsetup("list")
213 self.assertIn("test-config-1", out[0]) 214 self.assertIn("test-config-1", out[0])
214 self.assertNotIn("test-config-2", out[0]) 215 self.assertNotIn("test-config-2", out[0])
215 216
216 json_2 = self.add_json_config_to_registry('config-2/test-config-2.conf.json', 'master') 217 json_2 = self.add_json_config_to_registry('config-2/test-config-2.conf.json', 'master', 'master')
217 out = self.runbbsetup("list --write-json={}".format(os.path.join(self.tempdir, "test-configs.json"))) 218 out = self.runbbsetup("list --write-json={}".format(os.path.join(self.tempdir, "test-configs.json")))
218 self.assertIn("test-config-1", out[0]) 219 self.assertIn("test-config-1", out[0])
219 self.assertIn("test-config-2", out[0]) 220 self.assertIn("test-config-2", out[0])
@@ -270,7 +271,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
270 branch = "another-branch" 271 branch = "another-branch"
271 self.git('checkout -b {}'.format(branch), cwd=self.testrepopath) 272 self.git('checkout -b {}'.format(branch), cwd=self.testrepopath)
272 self.add_file_to_testrepo('test-file', test_file_content) 273 self.add_file_to_testrepo('test-file', test_file_content)
273 json_1 = self.add_json_config_to_registry('test-config-1.conf.json', branch) 274 json_1 = self.add_json_config_to_registry('test-config-1.conf.json', branch, branch)
274 for c in ('gadget','gizmo','gadget-notemplate','gizmo-notemplate'): 275 for c in ('gadget','gizmo','gadget-notemplate','gizmo-notemplate'):
275 buildpath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c)) 276 buildpath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c))
276 os.environ['BBPATH'] = os.path.join(buildpath, 'build') 277 os.environ['BBPATH'] = os.path.join(buildpath, 'build')