From 02f9da9a6450fa8aa42ad4b82b5467f8cd6e329c Mon Sep 17 00:00:00 2001
From: Caleb Connolly <caleb@postmarketos.org>
Date: Thu, 11 Jul 2024 00:52:22 +0200
Subject: [PATCH] build: init: simplify installing build deps (MR 2363)

No reason to handle abuild separately here.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
---
 pmb/build/init.py      | 9 ++++++---
 pmb/config/__init__.py | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/pmb/build/init.py b/pmb/build/init.py
index 649b88b5d..f7d77b190 100644
--- a/pmb/build/init.py
+++ b/pmb/build/init.py
@@ -15,16 +15,19 @@ from pmb.core import Chroot
 from pmb.core.context import get_context
 
 
-def init_abuild_minimal(chroot: Chroot = Chroot.native(), additional_pkgs: list[str] = []):
+def init_abuild_minimal(chroot: Chroot = Chroot.native(), build_pkgs: list[str] = []):
     """Initialize a minimal chroot with abuild where one can do 'abuild checksum'."""
     marker = chroot / "tmp/pmb_chroot_abuild_init_done"
     if os.path.exists(marker):
         return
 
+    if not build_pkgs:
+        build_pkgs = pmb.config.build_packages
+
     # pigz is multithreaded and makes compression must faster, we install it in the native
     # chroot and then symlink it into the buildroot so we aren't running it through QEMU.
     # pmb.chroot.apk.install(["pigz"], Chroot.native(), build=False)
-    pmb.chroot.apk.install(["abuild"] + additional_pkgs, chroot, build=False)
+    pmb.chroot.apk.install(build_pkgs, chroot, build=False)
 
     # Fix permissions
     pmb.chroot.root(["chown", "root:abuild", "/var/cache/distfiles"], chroot)
@@ -47,7 +50,7 @@ def init(chroot: Chroot = Chroot.native()) -> bool:
     # Initialize chroot, install packages
     pmb.chroot.init(Chroot.native())
     pmb.chroot.init(chroot)
-    init_abuild_minimal(chroot, additional_pkgs=pmb.config.build_packages)
+    init_abuild_minimal(chroot)
 
     # Generate package signing keys
     if not os.path.exists(get_context().config.work / "config_abuild/abuild.conf"):
diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py
index a22640c45..8c6fdd650 100644
--- a/pmb/config/__init__.py
+++ b/pmb/config/__init__.py
@@ -209,7 +209,7 @@ chroot_outdated = 3600 * 24 * 2
 
 # Packages that will be installed in a chroot before it builds packages
 # for the first time
-build_packages = ["abuild", "build-base", "ccache", "git"]
+build_packages = ["abuild", "apk-tools", "build-base", "ccache", "git"]
 
 #
 # PARSE
-- 
GitLab