Allow patching mkimage-profiles

This commit is contained in:
Mikhail Gordeev 2022-05-30 17:15:03 +03:00
parent 217e0b240a
commit e8130b4a17
4 changed files with 22 additions and 1 deletions

View File

@ -38,6 +38,10 @@ def parse_args():
'--key', '--key',
help='gpg key to sign', help='gpg key to sign',
) )
parser.add_argument(
'--patch-mp-prog',
help='program to change mkimage-profiles code',
)
parser.add_argument( parser.add_argument(
'--remote', '--remote',
help='remote to sync images', help='remote to sync images',
@ -104,7 +108,7 @@ def main():
if args.force_rebuild: if args.force_rebuild:
config_override['rebuild_after'] = {'days': 0} config_override['rebuild_after'] = {'days': 0}
for arg in ['key', 'remote']: for arg in ['key', 'remote', 'patch_mp_prog']:
args_to_override(arg) args_to_override(arg)
cb = cloud_build.CB( cb = cloud_build.CB(

View File

@ -216,6 +216,9 @@ class CB:
msg = f'Could not read config file `{e.filename}`: {e.strerror}' msg = f'Could not read config file `{e.filename}`: {e.strerror}'
raise Error(msg) raise Error(msg)
def get_overrided(key):
return cfg.get(key, override.get(key))
def lazy_get_raises(key): def lazy_get_raises(key):
if key in override: if key in override:
return override[key] return override[key]
@ -233,6 +236,12 @@ class CB:
self._image_repo = cfg.get('image_repo') self._image_repo = cfg.get('image_repo')
self.patch_mp_prog = get_overrided('patch_mp_prog')
if (patch_mp_prog := self.patch_mp_prog) is not None:
self.patch_mp_prog = self.expand_path(
Path(patch_mp_prog)
).absolute().as_posix()
self.try_build_all = cfg.get('try_build_all', False) self.try_build_all = cfg.get('try_build_all', False)
self.no_delete = cfg.get('no_delete', True) self.no_delete = cfg.get('no_delete', True)
@ -394,6 +403,10 @@ Dir::Etc::preferencesparts "/var/empty";
def escape_branch(self, branch: str) -> str: def escape_branch(self, branch: str) -> str:
return re.sub(r'\.', '_', branch) return re.sub(r'\.', '_', branch)
def patch_mp(self):
if (patch_mp_prog := self.patch_mp_prog) is not None:
self.call([patch_mp_prog])
def ensure_mkimage_profiles(self) -> None: def ensure_mkimage_profiles(self) -> None:
"""Checks that mkimage-profiles exists or clones it""" """Checks that mkimage-profiles exists or clones it"""
@ -418,6 +431,7 @@ Dir::Etc::preferencesparts "/var/empty";
# create file with proper brandings # create file with proper brandings
with self.pushd('mkimage-profiles'): with self.pushd('mkimage-profiles'):
self.patch_mp()
with open(f'conf.d/{PROG}.mk', 'w') as f: with open(f'conf.d/{PROG}.mk', 'w') as f:
for image in self.images: for image in self.images:
target = self.target_by_image(image) target = self.target_by_image(image)

View File

@ -184,6 +184,7 @@ class Call():
'make': make, 'make': make,
'gpg2': gpg, 'gpg2': gpg,
'rsync': rsync, 'rsync': rsync,
'/bin/true': SUBPROCESS_CALL,
DEFAULT: error_call, DEFAULT: error_call,
} }

View File

@ -5,6 +5,8 @@ log_level: debug
external_files: /tmp/cloud-build/external_files external_files: /tmp/cloud-build/external_files
patch_mp_prog: /bin/true
bad_arches: bad_arches:
- armh - armh