From 3c91abd175e396571e85eb12aa1debf220e8a160 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 19 Sep 2022 05:40:17 +0200 Subject: [PATCH] image.py: use new constants.POST_CMDS for post-cmd instead of per-flavour cmd --- constants.py | 3 +++ image.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/constants.py b/constants.py index e44fd48..a2531a5 100644 --- a/constants.py +++ b/constants.py @@ -66,6 +66,9 @@ FLAVOURS: dict[str, Flavour] = { } } +POST_CMDS = ['kupfer-config apply'] + + REPOSITORIES = [ 'boot', 'cross', diff --git a/image.py b/image.py index 1e4afe1..2bfb6cf 100644 --- a/image.py +++ b/image.py @@ -10,7 +10,7 @@ from subprocess import CompletedProcess from typing import Union from chroot.device import DeviceChroot, get_device_chroot -from constants import Arch, BASE_PACKAGES, FLAVOURS +from constants import Arch, BASE_PACKAGES, FLAVOURS, POST_CMDS from config import config, Profile from distro.distro import get_base_distro, get_kupfer_https from exec.cmd import run_root_cmd, generate_cmd_su @@ -306,7 +306,6 @@ def install_rootfs( profile: Profile, ): user = profile['username'] or 'kupfer' - post_cmds = FLAVOURS[flavour.name].get('post_cmds', []) chroot = get_device_chroot(device=get_device_name(device), flavour=flavour.name, arch=arch, packages=packages, use_local_repos=use_local_repos) mount_chroot(rootfs_device, bootfs_device, chroot) @@ -329,12 +328,13 @@ def install_rootfs( extra_repos=get_kupfer_https(arch).repos, in_chroot=True, ), - 'etc/hostname': profile['hostname'], + 'etc/hostname': profile['hostname'] or 'kupfer', } for target, content in files.items(): root_write_file(os.path.join(chroot.path, target.lstrip('/')), content) - if post_cmds: - result = chroot.run_cmd(' && '.join(post_cmds)) + if POST_CMDS: + logging.info("Running post-install CMDs") + result = chroot.run_cmd(' && '.join(POST_CMDS)) assert isinstance(result, subprocess.CompletedProcess) if result.returncode != 0: raise Exception('Error running post_cmds')