Allow specify branch of mkimage-profiles git repo

This commit is contained in:
Mikhail Gordeev 2022-11-11 01:04:50 +03:00
parent d81e8c729a
commit 56c79cc1e1
2 changed files with 21 additions and 3 deletions

View File

@ -42,6 +42,10 @@ def parse_args():
'--patch-mp-prog',
help='program to change mkimage-profiles code',
)
parser.add_argument(
'--mkimage-profiles-branch',
help='force using mkimage-profiles from that branch',
)
parser.add_argument(
'--mkimage-profiles-git',
help='force using mkimage-profiles from that repository',
@ -112,7 +116,13 @@ def main():
if args.force_rebuild:
config_override['rebuild_after'] = {'days': 0}
for arg in ['key', 'remote', 'patch_mp_prog', 'mkimage_profiles_git']:
for arg in [
'key',
'remote',
'patch_mp_prog',
'mkimage_profiles_git',
'mkimage_profiles_branch',
]:
args_to_override(arg)
cb = cloud_build.CB(

View File

@ -63,7 +63,11 @@ class CB:
self.initialized = False
self._save_cwd = os.getcwd()
self.parse_config(config, config_override)
if config_override and 'mkimage_profiles_git' in config_override:
if config_override \
and (
'mkimage_profiles_branch' in config_override
or 'mkimage_profiles_git' in config_override
):
self.force_recreate_mp = True
else:
self.force_recreate_mp = False
@ -227,6 +231,7 @@ class CB:
self.mkimage_profiles_git = self.expand_path(
get_overrided('mkimage_profiles_git', '')
)
self.mkimage_profiles_branch = get_overrided('mkimage_profiles_branch')
self.log_level = getattr(logging, cfg.get('log_level', 'INFO').upper())
@ -427,7 +432,10 @@ Dir::Etc::preferencesparts "/var/empty";
self.call(['git', 'pull', '--ff-only'], fail_on_error=True)
else:
self.info('Downloading mkimage-profiles')
self.call(['git', 'clone', url, 'mkimage-profiles'])
git_clone = ['git', 'clone', url, 'mkimage-profiles']
if branch := self.mkimage_profiles_branch:
git_clone.extend(['--branch', branch])
self.call(git_clone)
# create file with proper brandings
with self.pushd('mkimage-profiles'):