]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add dpkg and dpkg-query scripts
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 10 Jun 2024 12:37:12 +0000 (14:37 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 10 Jun 2024 13:06:52 +0000 (15:06 +0200)
mkosi/installer/apt.py
mkosi/resources/mkosi.md

index f782fa76dbad0123ef20c96716f7d8b6121006f8..fdf8a63d705aeb5d4b63fe7b35d01f2b109bec95 100644 (file)
@@ -48,6 +48,14 @@ class Apt(PackageManager):
     def cache_subdirs(cls, cache: Path) -> list[Path]:
         return [cache / "archives"]
 
+    @classmethod
+    def dpkg_cmd(cls, command: str) -> list[PathString]:
+        return [
+            command,
+            "--admindir=/buildroot/var/lib/dpkg",
+            "--root=/buildroot",
+        ]
+
     @classmethod
     def scripts(cls, context: Context) -> dict[str, list[PathString]]:
         return {
@@ -64,6 +72,12 @@ class Apt(PackageManager):
                     "apt-sortpkgs",
                 )
             },
+            **{
+                command: apivfs_cmd() + cls.dpkg_cmd(command) for command in(
+                    "dpkg",
+                    "dpkg-query",
+                )
+            },
             "mkosi-install"  : ["apt-get", "install"],
             "mkosi-upgrade"  : ["apt-get", "upgrade"],
             "mkosi-remove"   : ["apt-get", "purge"],
index 7a12aa544926cc5da754bcffec170ce7375e557a..19750585a0a266e69a6923da8f2659618b29c8d4 100644 (file)
@@ -2197,12 +2197,12 @@ available via `$PATH` to simplify common usecases.
   To execute the entire script inside the image, add a ".chroot" suffix
   to the name (`mkosi.build.chroot` instead of `mkosi.build`, etc.).
 
-* For all of the supported package managers except portage (`dnf`,
-  `rpm`, `apt`, `pacman`, `zypper`), scripts of the same name are put
-  into `$PATH` that make sure these commands operate on the image's root
-  directory with the configuration supplied by the user instead of on
-  the host system. This means that from a script, you can do e.g. `dnf
-  install vim` to install vim into the image.
+* For all of the supported package managers (`dnf`, `rpm`, `apt`, `dpkg`,
+  `pacman`, `zypper`), scripts of the same name are put into `$PATH`
+  that make sure these commands operate on the image's root directory
+  with the configuration supplied by the user instead of on the host
+  system. This means that from a script, you can do e.g.
+  `dnf install vim` to install vim into the image.
 
   Additionally, `mkosi-install`, `mkosi-reinstall`, `mkosi-upgrade` and
   `mkosi-remove` will invoke the corresponding operation of the package