debbuilder: Support layer-specific repo in sbuild

In [1], a mechanism was proposed to create layer-specific aptly binary
repositories in addition to the existing `deb-local-binary`, to better
separate the binary dependencies of each layer.

For this new mechanism to work, new repositories must be dynamically
taken into account by `sbuild`, by adding a new `--extra-repository`
argument referring to the layer of the package being built, which is
precisely what this change does.

[1] https://review.opendev.org/c/starlingx/root/+/893095

Test Plan:
PASS - Build packages of different layers successfully

Story: 2010797
Task: 48698

Change-Id: Ib09ddf042584bc418c6a07773e920901961938ee
Signed-off-by: Luan Nunes Utimura <LuanNunes.Utimura@windriver.com>
This commit is contained in:
Luan Nunes Utimura 2023-08-29 14:57:31 -03:00
parent 2ba0342194
commit 25c1d0807b
1 changed files with 13 additions and 4 deletions

View File

@ -442,7 +442,7 @@ class Debbuilder:
response['msg'] = 'All idle chroots are refreshed'
return response
def assemble_extra_repo(self, snapshot_idx):
def assemble_extra_repo(self, snapshot_idx, repo=""):
repomgr_url = None
if not os.path.exists(STX_LOCALRC):
self.logger.warning('stx-localrc does not exist')
@ -459,17 +459,21 @@ class Debbuilder:
break
if repomgr_url:
repomgr_url = ' '.join(['deb [trusted=yes]', repomgr_url + REPO_BUILD + '-' + snapshot_idx, self.attrs['dist'], 'main'])
if repo:
repomgr_url = f"deb [trusted=yes] {repomgr_url}{repo} {self.attrs['dist']} main"
else:
repomgr_url = ' '.join(['deb [trusted=yes]', repomgr_url + REPO_BUILD + '-' + snapshot_idx, self.attrs['dist'], 'main'])
self.logger.warning("The extra repository URL is %s", repomgr_url)
return repomgr_url
def add_task(self, request_form):
response = check_request(request_form,
['user', 'project', 'type', 'dsc', 'snapshot_idx'])
['user', 'project', 'type', 'dsc', 'snapshot_idx', 'layer'])
if response:
return response
user = request_form['user']
snapshot_index = request_form['snapshot_idx']
layer = request_form['layer']
chroot = '-'.join([self.attrs['dist'], self.attrs['arch'], user])
if not self.has_chroot(chroot):
@ -506,7 +510,12 @@ class Debbuilder:
repo_url = self.assemble_extra_repo(snapshot_index)
extra_repo = '--extra-repository=\'%s\'' % (repo_url)
bcommand = ' '.join([bcommand, jobs, '-c', chroot, extra_repo,
layer_url = self.assemble_extra_repo(
snapshot_index, repo=f"deb-local-binary-{layer}"
)
layer_repo = '--extra-repository=\'%s\'' % (layer_url)
bcommand = ' '.join([bcommand, jobs, '-c', chroot, layer_repo, extra_repo,
'--build-dir', dsc_build_dir, dsc])
self.logger.debug("Build command: %s" % (bcommand))
self.attrs['state'] = 'works'