]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
apt: Remove mounts argument from invoke()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 Aug 2024 06:17:51 +0000 (08:17 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 Aug 2024 06:55:12 +0000 (08:55 +0200)
mkosi/distributions/debian.py
mkosi/installer/apt.py

index 25eb9240a35c1ce3288fed17b4ec219fba81a844..a2a3ddb2e19a652ac4fdb11d35bdcd3df1eed3a4 100644 (file)
@@ -136,21 +136,21 @@ class Installer(DistributionInstaller):
         # By configuring Debug::pkgDpkgPm=1, apt-get install will not actually execute any dpkg commands, so
         # all it does is download the essential debs and tell us their full in the apt cache without actually
         # installing them.
-        with tempfile.NamedTemporaryFile(mode="r") as f:
-            Apt.invoke(
-                context,
-                "install",
-                [
-                    "-oDebug::pkgDPkgPm=1",
-                    f"-oDPkg::Pre-Install-Pkgs::=cat >{f.name}",
-                    "?essential",
-                    "?exact-name(usr-is-merged)",
-                    "base-files",
-                ],
-                mounts=[Mount(f.name, f.name)],
-            )
+        Apt.invoke(
+            context,
+            "install",
+            [
+                "-oDebug::pkgDPkgPm=1",
+                # context.pkgmngr is always mounted writable to /etc so let's use that as a channel to get the list of
+                # essential packages out of the sandbox.
+                "-oDPkg::Pre-Install-Pkgs::=cat >/etc/apt/essential",
+                "?essential",
+                "?exact-name(usr-is-merged)",
+                "base-files",
+            ],
+        )
 
-            essential = f.read().strip().splitlines()
+        essential = (context.pkgmngr / "etc/apt/essential").read_text().strip().splitlines()
 
         # Now, extract the debs to the chroot by first extracting the sources tar file out of the deb and
         # then extracting the tar file into the chroot.
index 59effcb327b2adc8c4c617c5b92ed50407ea0bc3..7bfdae7fc8ac6d6277c1f0dde4b51a8ec59c4128 100644 (file)
@@ -208,7 +208,6 @@ class Apt(PackageManager):
         arguments: Sequence[str] = (),
         *,
         apivfs: bool = False,
-        mounts: Sequence[Mount] = (),
         stdout: _FILE = None,
     ) -> CompletedProcess:
         return run(
@@ -218,7 +217,7 @@ class Apt(PackageManager):
                     binary="apt-get",
                     network=True,
                     vartmp=True,
-                    mounts=[Mount(context.root, "/buildroot"), *cls.mounts(context), *mounts],
+                    mounts=[Mount(context.root, "/buildroot"), *cls.mounts(context)],
                     extra=apivfs_cmd() if apivfs else []
                 )
             ),