]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Switch to reprepro for generating local apt repositories
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 14 Apr 2024 20:27:13 +0000 (22:27 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 15 Apr 2024 06:05:03 +0000 (08:05 +0200)
We don't install dpkg-dev in tools trees anymore to avoid pulling
in perl, which means we don't have access to dpkg-scanpackages in
tools trees anymore.

Instead of adding back dpkg-dev, let's instead switch to reprepro
for generating our local apt repository. It's written in C, packaged
everywhere and has hardly any dependencies.

mkosi/installer/apt.py
mkosi/resources/mkosi-tools/mkosi.conf.d/10-arch.conf
mkosi/resources/mkosi-tools/mkosi.conf.d/10-debian-ubuntu.conf
mkosi/resources/mkosi-tools/mkosi.conf.d/10-fedora/mkosi.conf
mkosi/resources/mkosi-tools/mkosi.conf.d/10-opensuse.conf

index bbea6351553509897cc3b95d4b911c89b96d42a4..1391a8bfc38d4216fbfb784d081d9bfe4b5bed34 100644 (file)
@@ -215,16 +215,29 @@ class Apt(PackageManager):
 
     @classmethod
     def createrepo(cls, context: Context) -> None:
-        with (context.packages / "Packages").open("wb") as f:
-            run(
-                ["dpkg-scanpackages", "."],
-                stdout=f,
-                sandbox=context.sandbox(
-                    mounts=[Mount(context.packages, context.packages, ro=True)],
-                    options=["--chdir", context.packages],
-                ),
+        if not (conf := context.packages / "conf/distributions").exists():
+            conf.parent.mkdir(exist_ok=True)
+            conf.write_text(
+                textwrap.dedent(
+                    f"""\
+                    Origin: mkosi
+                    Label: mkosi
+                    Architectures: {context.config.distribution.architecture(context.config.architecture)}
+                    Codename: mkosi
+                    Components: main
+                    Description: mkosi local repository
+                    """
+                )
             )
 
+        run(
+            ["reprepro", "includedeb", "mkosi"] + [d.name for d in context.packages.glob("*.deb")],
+            sandbox=context.sandbox(
+                mounts=[Mount(context.packages, context.packages)],
+                options=["--chdir", context.packages],
+            ),
+        )
+
         (context.pkgmngr / "etc/apt/sources.list.d").mkdir(parents=True, exist_ok=True)
         (context.pkgmngr / "etc/apt/sources.list.d/mkosi-local.sources").write_text(
             textwrap.dedent(
@@ -232,7 +245,8 @@ class Apt(PackageManager):
                 Enabled: yes
                 Types: deb
                 URIs: file:///work/packages
-                Suites: ./
+                Suites: mkosi
+                Components: main
                 Trusted: yes
                 """
             )
index 29310457af132f3b8bd22c00b798e64838666d85..67c67ac83853969ce3225c1f6eda8b7f7c71efa4 100644 (file)
@@ -23,6 +23,7 @@ Packages=
         pesign
         python-cryptography
         qemu-base
+        reprepro
         sbsigntools
         shadow
         squashfs-tools
index 79d5c3ba400c224662fe11a93a8dcbe930963df9..0ca27c2093feb4017dd55d086834e5b18047a21d 100644 (file)
@@ -30,6 +30,7 @@ Packages=
         python3-cryptography
         python3-pefile
         qemu-system
+        reprepro
         sbsigntool
         squashfs-tools
         swtpm-tools
index a9097722a977a11df69e7a7702503077d64bde66..fa2b1165ecf4cf5923f9594808f65839e9e254b0 100644 (file)
@@ -14,5 +14,6 @@ Packages=
         qemu-system-aarch64-core
         qemu-system-ppc-core
         qemu-system-s390x-core
+        reprepro
         systemd-ukify
         zypper
index a7a911bac959f2e6dba0a227823b61a3c92c94b8..ba28f448d721a1e1532b5dcc76f77078af55674b 100644 (file)
@@ -22,6 +22,7 @@ Packages=
         policycoreutils
         python3-pefile
         qemu-headless
+        reprepro
         sbsigntools
         shadow
         squashfs