mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
add size_extra_mb to profiles, use in cmd_image_build()
This commit is contained in:
parent
27aba2e21f
commit
5f6772eb39
2 changed files with 16 additions and 4 deletions
13
config.py
13
config.py
|
@ -21,6 +21,7 @@ PROFILE_DEFAULTS: Profile = {
|
|||
'hostname': 'kupfer',
|
||||
'username': 'kupfer',
|
||||
'password': None,
|
||||
'size_extra_mb': "0",
|
||||
}
|
||||
|
||||
PROFILE_EMPTY: Profile = {key: None for key in PROFILE_DEFAULTS.keys()}
|
||||
|
@ -105,7 +106,13 @@ def resolve_profile(
|
|||
if 'parent' in sparse and (parent_name := sparse['parent']):
|
||||
parent = resolve_profile(name=parent_name, sparse_profiles=sparse_profiles, resolved=resolved, _visited=_visited)[parent_name]
|
||||
full = parent | sparse
|
||||
|
||||
# add up size_extra_mb
|
||||
if 'size_extra_mb' in sparse:
|
||||
size = sparse['size_extra_mb']
|
||||
if isinstance(size, str) and size.startswith('+'):
|
||||
full['size_extra_mb'] = int(parent.get('size_extra_mb', 0)) + int(size.lstrip('+'))
|
||||
else:
|
||||
full['size_extra_mb'] = int(sparse['size_extra_mb'])
|
||||
# join our includes with parent's
|
||||
includes = set(parent.get('pkgs_include', []) + sparse.get('pkgs_include', []))
|
||||
if 'pkgs_exclude' in sparse:
|
||||
|
@ -126,6 +133,8 @@ def resolve_profile(
|
|||
if type(value) == list:
|
||||
full[key] = []
|
||||
|
||||
full['size_extra_mb'] = int(full['size_extra_mb'] or 0)
|
||||
|
||||
resolved[name] = full
|
||||
return resolved
|
||||
|
||||
|
@ -330,6 +339,8 @@ class ConfigStateHolder:
|
|||
if merge:
|
||||
new = deepcopy(self.file['profiles'][name])
|
||||
|
||||
logging.debug(f'new: {new}')
|
||||
logging.debug(f'profile: {profile}')
|
||||
new |= profile
|
||||
|
||||
if prune:
|
||||
|
|
7
image.py
7
image.py
|
@ -347,11 +347,12 @@ def cmd_build(profile_name: str = None, build_pkgs: bool = True, block_target: s
|
|||
enforce_wrap()
|
||||
profile = config.get_profile(profile_name)
|
||||
device, flavour = get_device_and_flavour(profile_name)
|
||||
size_extra_mb = profile["size_extra_mb"]
|
||||
|
||||
# TODO: PARSE DEVICE ARCH AND SECTOR SIZE
|
||||
arch = 'aarch64'
|
||||
sector_size = 4096
|
||||
rootfs_size_gb = FLAVOURS[flavour].get('size', 2)
|
||||
rootfs_size_mb = FLAVOURS[flavour].get('size', 2) * 1000
|
||||
|
||||
build_enable_qemu_binfmt(arch)
|
||||
|
||||
|
@ -371,7 +372,7 @@ def cmd_build(profile_name: str = None, build_pkgs: bool = True, block_target: s
|
|||
os.makedirs(os.path.dirname(image_path), exist_ok=True)
|
||||
|
||||
logging.info(f'Creating new file at {image_path}')
|
||||
create_img_file(image_path, f"{rootfs_size_gb}G")
|
||||
create_img_file(image_path, f"{rootfs_size_mb + size_extra_mb}M")
|
||||
|
||||
loop_device = losetup_rootfs_image(image_path, sector_size)
|
||||
|
||||
|
@ -387,7 +388,7 @@ def cmd_build(profile_name: str = None, build_pkgs: bool = True, block_target: s
|
|||
else:
|
||||
logging.info('Creating per-partition image files')
|
||||
boot_dev = create_img_file(get_image_path(device, flavour, 'boot'), IMG_FILE_BOOT_DEFAULT_SIZE)
|
||||
root_dev = create_img_file(get_image_path(device, flavour, 'root'), f'{rootfs_size_gb * 1000 - 200}M')
|
||||
root_dev = create_img_file(get_image_path(device, flavour, 'root'), f'{rootfs_size_mb + size_extra_mb - 200}M')
|
||||
|
||||
create_boot_fs(boot_dev, sector_size)
|
||||
create_root_fs(root_dev, sector_size)
|
||||
|
|
Loading…
Add table
Reference in a new issue