From c6bcb0dacf8664f56bca873ec6f7a6c06335974c Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 19 Apr 2023 21:20:42 +0200 Subject: [PATCH] Speed up 'pmbootstrap checksum' Don't install gcc, ccache, git when the user only wants to update the checksums of a package. Reviewed-by: Caleb Connolly Tested-by: Caleb Connolly Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230419192042.3951-3-ollieparanoid@postmarketos.org%3E --- pmb/build/__init__.py | 2 +- pmb/build/checksum.py | 4 ++-- pmb/build/init.py | 31 +++++++++++++++++++++++-------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/pmb/build/__init__.py b/pmb/build/__init__.py index 4d84175b..fb764e52 100644 --- a/pmb/build/__init__.py +++ b/pmb/build/__init__.py @@ -1,6 +1,6 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -from pmb.build.init import init, init_compiler +from pmb.build.init import init, init_abuild_minimal, init_compiler from pmb.build.envkernel import package_kernel from pmb.build.kconfig import menuconfig from pmb.build.newapkbuild import newapkbuild diff --git a/pmb/build/checksum.py b/pmb/build/checksum.py index e10fefc3..921ed676 100644 --- a/pmb/build/checksum.py +++ b/pmb/build/checksum.py @@ -10,7 +10,7 @@ import pmb.helpers.pmaports def update(args, pkgname): """ Fetch all sources and update the checksums in the APKBUILD. """ - pmb.build.init(args) + pmb.build.init_abuild_minimal(args) pmb.build.copy_to_buildpath(args, pkgname) logging.info("(native) generate checksums for " + pkgname) pmb.chroot.user(args, ["abuild", "checksum"], @@ -24,7 +24,7 @@ def update(args, pkgname): def verify(args, pkgname): """ Fetch all sources and verify their checksums. """ - pmb.build.init(args) + pmb.build.init_abuild_minimal(args) pmb.build.copy_to_buildpath(args, pkgname) logging.info("(native) verify checksums for " + pkgname) diff --git a/pmb/build/init.py b/pmb/build/init.py index bab64695..3847e7b7 100644 --- a/pmb/build/init.py +++ b/pmb/build/init.py @@ -12,14 +12,14 @@ import pmb.chroot.apk import pmb.helpers.run -def init(args, suffix="native"): - marker = f"{args.work}/chroot_{suffix}/tmp/pmb_chroot_build_init_done" +def init_abuild_minimal(args, suffix="native"): + """ Initialize a minimal chroot with abuild where one can do + 'abuild checksum'. """ + marker = f"{args.work}/chroot_{suffix}/tmp/pmb_chroot_abuild_init_done" if os.path.exists(marker): return - # Initialize chroot, install packages - pmb.chroot.apk.install(args, pmb.config.build_packages, suffix, - build=False) + pmb.chroot.apk.install(args, ["abuild"], suffix, build=False) # Fix permissions pmb.chroot.root(args, ["chown", "root:abuild", @@ -27,6 +27,24 @@ def init(args, suffix="native"): pmb.chroot.root(args, ["chmod", "g+w", "/var/cache/distfiles"], suffix) + # Add user to group abuild + pmb.chroot.root(args, ["adduser", "pmos", "abuild"], suffix) + + pathlib.Path(marker).touch() + + +def init(args, suffix="native"): + """ Initialize a chroot for building packages with abuild. """ + marker = f"{args.work}/chroot_{suffix}/tmp/pmb_chroot_build_init_done" + if os.path.exists(marker): + return + + init_abuild_minimal(args, suffix) + + # Initialize chroot, install packages + pmb.chroot.apk.install(args, pmb.config.build_packages, suffix, + build=False) + # Generate package signing keys chroot = args.work + "/chroot_" + suffix if not os.path.exists(args.work + "/config_abuild/abuild.conf"): @@ -63,9 +81,6 @@ def init(args, suffix="native"): "/usr/local/bin/gzip"], suffix) pmb.chroot.root(args, ["chmod", "+x", "/usr/local/bin/gzip"], suffix) - # Add user to group abuild - pmb.chroot.root(args, ["adduser", "pmos", "abuild"], suffix) - # abuild.conf: Don't clean the build folder after building, so we can # inspect it afterwards for debugging pmb.chroot.root(args, ["sed", "-i", "-e", "s/^CLEANUP=.*/CLEANUP=''/",