]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
debian: move workspace package manager configuration into a tree
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>
Wed, 7 Jun 2023 09:15:23 +0000 (11:15 +0200)
committerJoerg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 8 Jun 2023 13:03:58 +0000 (15:03 +0200)
mkosi/distributions/debian.py

index 5ee962a26d31555e269a0aa098b3c2243aa3db93..e5e4ec5f2bb79770a82acf0f85fb0e6aa3d3ef2c 100644 (file)
@@ -159,11 +159,12 @@ class DebianInstaller(DistributionInstaller):
 
 
 def setup_apt(state: MkosiState, repos: Sequence[str]) -> None:
-    state.workspace.joinpath("apt").mkdir(exist_ok=True)
-    state.workspace.joinpath("apt/apt.conf.d").mkdir(exist_ok=True)
-    state.workspace.joinpath("apt/preferences.d").mkdir(exist_ok=True)
-    state.workspace.joinpath("apt/sources.list.d").mkdir(exist_ok=True)
-    state.workspace.joinpath("apt/log").mkdir(exist_ok=True)
+    state.pkgmngr.joinpath("etc/apt").mkdir(exist_ok=True, parents=True)
+    state.pkgmngr.joinpath("etc/apt/apt.conf.d").mkdir(exist_ok=True, parents=True)
+    state.pkgmngr.joinpath("etc/apt/preferences.d").mkdir(exist_ok=True, parents=True)
+    state.pkgmngr.joinpath("etc/apt/sources.list.d").mkdir(exist_ok=True, parents=True)
+    state.pkgmngr.joinpath("var/log/apt").mkdir(exist_ok=True, parents=True)
+    state.pkgmngr.joinpath("var/lib/apt").mkdir(exist_ok=True, parents=True)
 
     # TODO: Drop once apt 2.5.4 is widely available.
     state.root.joinpath("var").mkdir(mode=0o755, exist_ok=True)
@@ -171,7 +172,7 @@ def setup_apt(state: MkosiState, repos: Sequence[str]) -> None:
     state.root.joinpath("var/lib/dpkg").mkdir(mode=0o755, exist_ok=True)
     state.root.joinpath("var/lib/dpkg/status").touch()
 
-    config = state.workspace / "apt/apt.conf"
+    config = state.pkgmngr / "etc/apt/apt.conf"
     debarch = state.installer.architecture(state.config.architecture)
 
     config.write_text(
@@ -187,16 +188,16 @@ def setup_apt(state: MkosiState, repos: Sequence[str]) -> None:
             APT::Get::Allow-Remove-Essential "true";
             APT::Sandbox::User "root";
             Dir::Cache "{state.cache_dir}";
-            Dir::State "{state.workspace / "apt"}";
+            Dir::State "{state.pkgmngr / "var/lib/apt"}";
             Dir::State::status "{state.root / "var/lib/dpkg/status"}";
-            Dir::Etc "{state.workspace / "apt"}";
+            Dir::Etc "{state.pkgmngr / "etc/apt"}";
             Dir::Etc::trusted "/usr/share/keyrings/{state.config.release}-archive-keyring";
             Dir::Etc::trustedparts "/usr/share/keyrings";
-            Dir::Log "{state.workspace / "apt/log"}";
+            Dir::Log "{state.pkgmngr / "var/log/apt"}";
             Dir::Bin::dpkg "{shutil.which("dpkg")}";
             Debug::NoLocking "true";
             DPkg::Options:: "--root={state.root}";
-            DPkg::Options:: "--log={state.workspace / "apt/dpkg.log"}";
+            DPkg::Options:: "--log={state.pkgmngr / "var/log/apt/dpkg.log"}";
             DPkg::Options:: "--force-unsafe-io";
             DPkg::Options:: "--force-architecture";
             DPkg::Options:: "--force-depends";
@@ -207,7 +208,7 @@ def setup_apt(state: MkosiState, repos: Sequence[str]) -> None:
         )
     )
 
-    with state.workspace.joinpath("apt/sources.list").open("w") as f:
+    with state.workspace.joinpath("pkgmngr/etc/apt/sources.list").open("w") as f:
         for repo in repos:
             f.write(f"{repo}\n")
 
@@ -216,7 +217,7 @@ def setup_apt(state: MkosiState, repos: Sequence[str]) -> None:
             if not src.is_file():
                 continue
             if src.suffix in (".list", ".sources"):
-                shutil.copyfile(src, state.workspace.joinpath("apt/sources.list.d", src.name))
+                shutil.copyfile(src, state.workspace.joinpath("pkgmngr/etc/apt/sources.list.d", src.name))
 
 
 def invoke_apt(
@@ -226,7 +227,7 @@ def invoke_apt(
     apivfs: bool = True,
 ) -> CompletedProcess:
     env: dict[str, PathString] = dict(
-        APT_CONFIG=state.workspace / "apt/apt.conf",
+        APT_CONFIG=state.pkgmngr / "etc/apt/apt.conf",
         DEBIAN_FRONTEND="noninteractive",
         DEBCONF_INTERACTIVE_SEEN="true",
         KERNEL_INSTALL_BYPASS="1",
@@ -247,7 +248,7 @@ def install_apt_sources(state: MkosiState, repos: Sequence[str]) -> None:
                 f.write(f"{repo}\n")
 
     # Already contains a merged tree of repo_dirs after setup_apt
-    for src in state.workspace.joinpath("apt/sources.list.d").iterdir():
+    for src in state.workspace.joinpath("pkgmngr/etc/apt/sources.list.d").iterdir():
         dst = state.root.joinpath("etc/apt/sources.list.d", src.name)
         if dst.exists():
             continue