summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
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-14 11:24:57 +0100
commit1a55c45617c9464c2808b8c8329add3711d4bf72 (patch)
tree11a725fda4d20551ad6a529e88e502057ab44941 /bitbake/bin
parentdd358f75f4b99f5ed18d9349713970c7d1a9646f (diff)
downloadpoky-1a55c45617c9464c2808b8c8329add3711d4bf72.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: 45ed9b9faebdaa8cb7cc8dd2a6d51ec8eea06e73) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-setup12
1 files changed, 10 insertions, 2 deletions
diff --git a/bitbake/bin/bitbake-setup b/bitbake/bin/bitbake-setup
index ce5cd5e65f..8ceacada9a 100755
--- a/bitbake/bin/bitbake-setup
+++ b/bitbake/bin/bitbake-setup
@@ -86,13 +86,17 @@ def checkout_layers(layers, layerdir, d):
86 86
87 r_remote = r_data['git-remote'] 87 r_remote = r_data['git-remote']
88 rev = r_remote['rev'] 88 rev = r_remote['rev']
89 branch = r_remote.get('branch', None)
89 remotes = r_remote['remotes'] 90 remotes = r_remote['remotes']
90 91
91 for remote in remotes: 92 for remote in remotes:
92 type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"]) 93 type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"])
93 fetchuri = bb.fetch.encodeurl(('git',host,path,user,pswd,params)) 94 fetchuri = bb.fetch.encodeurl(('git',host,path,user,pswd,params))
94 print(" {}".format(r_name)) 95 print(" {}".format(r_name))
95 fetcher = bb.fetch.Fetch(["{};protocol={};rev={};nobranch=1;destsuffix={}".format(fetchuri,type,rev,repodir)], d) 96 if branch:
97 fetcher = bb.fetch.Fetch(["{};protocol={};rev={};branch={};destsuffix={}".format(fetchuri,type,rev,branch,repodir)], d)
98 else:
99 fetcher = bb.fetch.Fetch(["{};protocol={};rev={};nobranch=1;destsuffix={}".format(fetchuri,type,rev,repodir)], d)
96 do_fetch(fetcher, layerdir) 100 do_fetch(fetcher, layerdir)
97 101
98 if os.path.exists(os.path.join(layerdir, repodir, 'scripts/oe-setup-build')): 102 if os.path.exists(os.path.join(layerdir, repodir, 'scripts/oe-setup-build')):
@@ -444,12 +448,16 @@ def are_layers_changed(layers, layerdir, d):
444 448
445 r_remote = r_data['git-remote'] 449 r_remote = r_data['git-remote']
446 rev = r_remote['rev'] 450 rev = r_remote['rev']
451 branch = r_remote.get('branch', None)
447 remotes = r_remote['remotes'] 452 remotes = r_remote['remotes']
448 453
449 for remote in remotes: 454 for remote in remotes:
450 type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"]) 455 type,host,path,user,pswd,params = bb.fetch.decodeurl(remotes[remote]["uri"])
451 fetchuri = bb.fetch.encodeurl(('git',host,path,user,pswd,params)) 456 fetchuri = bb.fetch.encodeurl(('git',host,path,user,pswd,params))
452 fetcher = bb.fetch.FetchData("{};protocol={};rev={};nobranch=1;destsuffix={}".format(fetchuri,type,rev,repodir), d) 457 if branch:
458 fetcher = bb.fetch.FetchData("{};protocol={};rev={};branch={};destsuffix={}".format(fetchuri,type,rev,branch,repodir), d)
459 else:
460 fetcher = bb.fetch.FetchData("{};protocol={};rev={};nobranch=1;destsuffix={}".format(fetchuri,type,rev,repodir), d)
453 upstream_revision = fetcher.method.latest_revision(fetcher, d, 'default') 461 upstream_revision = fetcher.method.latest_revision(fetcher, d, 'default')
454 rev_parse_result = bb.process.run('git -C {} rev-parse HEAD'.format(os.path.join(layerdir, repodir))) 462 rev_parse_result = bb.process.run('git -C {} rev-parse HEAD'.format(os.path.join(layerdir, repodir)))
455 local_revision = rev_parse_result[0].strip() 463 local_revision = rev_parse_result[0].strip()