From: Daan De Meyer Date: Fri, 28 Jul 2023 09:31:58 +0000 (+0200) Subject: apt: Make invoke_apt() and apt_cmd() slightly more generic X-Git-Tag: v15~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04961116bd2e377c2c61a2b322cec0fc78c8f980;p=thirdparty%2Fmkosi.git apt: Make invoke_apt() and apt_cmd() slightly more generic Let's allow passing in the apt command we want to execute. --- diff --git a/mkosi/distributions/debian.py b/mkosi/distributions/debian.py index 045c64423..09a0ccbe3 100644 --- a/mkosi/distributions/debian.py +++ b/mkosi/distributions/debian.py @@ -108,8 +108,8 @@ class DebianInstaller(DistributionInstaller): policyrcd.chmod(0o755) setup_apt(state, cls.repositories(state)) - invoke_apt(state, "update", apivfs=False) - invoke_apt(state, "install", packages, apivfs=apivfs) + invoke_apt(state, "apt-get", "update", apivfs=False) + invoke_apt(state, "apt-get", "install", packages, apivfs=apivfs) install_apt_sources(state, cls.repositories(state, local=False)) policyrcd.unlink() @@ -123,7 +123,7 @@ class DebianInstaller(DistributionInstaller): @classmethod def remove_packages(cls, state: MkosiState, packages: Sequence[str]) -> None: - invoke_apt(state, "purge", packages) + invoke_apt(state, "apt-get", "purge", packages) @staticmethod def architecture(arch: Architecture) -> str: diff --git a/mkosi/installer/apt.py b/mkosi/installer/apt.py index 4102d6876..d0d6444e6 100644 --- a/mkosi/installer/apt.py +++ b/mkosi/installer/apt.py @@ -53,7 +53,7 @@ def setup_apt(state: MkosiState, repos: Sequence[str]) -> None: f.write(f"{repo}\n") -def apt_cmd(state: MkosiState) -> list[str]: +def apt_cmd(state: MkosiState, command: str) -> list[str]: debarch = state.installer.architecture(state.config.architecture) trustedkeys = state.pkgmngr / "etc/apt/trusted.gpg" @@ -67,7 +67,7 @@ def apt_cmd(state: MkosiState) -> list[str]: "DEBIAN_FRONTEND=noninteractive", "DEBCONF_INTERACTIVE_SEEN=true", "INITRD=No", - "apt-get", + command, "-o", f"APT::Architecture={debarch}", "-o", f"APT::Architectures={debarch}", "-o", "APT::Immediate-Configure=off", @@ -97,10 +97,11 @@ def apt_cmd(state: MkosiState) -> list[str]: def invoke_apt( state: MkosiState, + command: str, operation: str, packages: Sequence[str] = (), apivfs: bool = True, ) -> None: - bwrap(apt_cmd(state) + [operation, *packages], + bwrap(apt_cmd(state, command) + [operation, *packages], apivfs=state.root if apivfs else None, env=state.config.environment)