From: Daan De Meyer Date: Tue, 30 Jan 2024 20:18:46 +0000 (+0100) Subject: Write early apt config instead of /etc in package manager tree X-Git-Tag: v21~77^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8fd20eaa89208f991115dbf55b66b8ebd759f89;p=thirdparty%2Fmkosi.git Write early apt config instead of /etc in package manager tree This saves us from having to mount it separately as it will be mounted as part of mounting the package manager tree. --- diff --git a/mkosi/installer/__init__.py b/mkosi/installer/__init__.py index 4d64f4692..a19921c90 100644 --- a/mkosi/installer/__init__.py +++ b/mkosi/installer/__init__.py @@ -1,6 +1,5 @@ # SPDX-License-Identifier: LGPL-2.1+ -import os from pathlib import Path from mkosi.config import ConfigFeature @@ -66,7 +65,6 @@ def finalize_package_manager_mounts(context: Context) -> list[PathString]: mounts: list[PathString] = [ *(["--ro-bind", m, m] if (m := context.config.local_mirror) else []), - *(["--ro-bind", os.fspath(p), os.fspath(p)] if (p := context.workspace / "apt.conf").exists() else []), *finalize_crypto_mounts(tools=context.config.tools()), "--bind", context.packages, "/work/packages", ] diff --git a/mkosi/installer/apt.py b/mkosi/installer/apt.py index abf62b43c..c5005620e 100644 --- a/mkosi/installer/apt.py +++ b/mkosi/installer/apt.py @@ -46,11 +46,11 @@ def setup_apt(context: Context, repos: Iterable[AptRepository]) -> None: (context.cache_dir / "lib/apt").mkdir(exist_ok=True, parents=True) (context.cache_dir / "cache/apt").mkdir(exist_ok=True, parents=True) - # We have a special apt.conf outside of pkgmngr dir that only configures "Dir::Etc" that we pass to APT_CONFIG to - # tell apt it should read config files from /etc/apt in case this is overridden by distributions. This is required + # We have a special apt.conf outside of /etc/apt that only configures "Dir::Etc" that we pass to APT_CONFIG to tell + # apt it should read config files from /etc/apt in case this is overridden by distributions. This is required # because apt parses CLI configuration options after parsing its configuration files and as such we can't use CLI # options to tell apt where to look for configuration files. - config = context.workspace / "apt.conf" + config = context.pkgmngr / "etc/apt.conf" if not config.exists(): config.write_text( textwrap.dedent( @@ -72,7 +72,7 @@ def apt_cmd(context: Context, command: str) -> list[PathString]: cmdline: list[PathString] = [ "env", - f"APT_CONFIG={context.workspace / 'apt.conf'}", + "APT_CONFIG=/etc/apt.conf", "DEBIAN_FRONTEND=noninteractive", "DEBCONF_INTERACTIVE_SEEN=true", "INITRD=No",