]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Write early apt config instead of /etc in package manager tree
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Jan 2024 20:18:46 +0000 (21:18 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 31 Jan 2024 13:24:43 +0000 (14:24 +0100)
This saves us from having to mount it separately as it will be mounted
as part of mounting the package manager tree.

mkosi/installer/__init__.py
mkosi/installer/apt.py

index 4d64f46929edfb5b91672ef9d08d1a12f9175380..a19921c9062179d4c34a49d3fbb0d014b58a66ab 100644 (file)
@@ -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",
     ]
index abf62b43c74e0b315e03340a78202c50deccd7ae..c5005620eb89e90bd0dab688191ef768cb7028f3 100644 (file)
@@ -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",