pmb.build.init: refactor init marker related code

Put it in /tmp and touch it directly from python instead of running
pmb.chroot.root. This way it's slightly faster and doesn't require root
rights. Order the imports alphabetically while at it, and remove very
obvious comments.

Reviewed-by: Caleb Connolly <kc@postmarketos.org>
Tested-by: Caleb Connolly <kc@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230419192042.3951-2-ollieparanoid@postmarketos.org%3E
This commit is contained in:
Oliver Smith 2023-04-19 21:20:41 +02:00
parent a8695833d9
commit a8ab820015
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -1,8 +1,9 @@
# Copyright 2023 Oliver Smith # Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import os
import logging
import glob import glob
import logging
import os
import pathlib
import pmb.build import pmb.build
import pmb.config import pmb.config
@ -12,9 +13,8 @@ import pmb.helpers.run
def init(args, suffix="native"): def init(args, suffix="native"):
# Check if already initialized marker = f"{args.work}/chroot_{suffix}/tmp/pmb_chroot_build_init_done"
marker = "/var/local/pmbootstrap_chroot_build_init_done" if os.path.exists(marker):
if os.path.exists(args.work + "/chroot_" + suffix + marker):
return return
# Initialize chroot, install packages # Initialize chroot, install packages
@ -77,8 +77,7 @@ def init(args, suffix="native"):
"s/^ERROR_CLEANUP=.*/ERROR_CLEANUP=''/", "s/^ERROR_CLEANUP=.*/ERROR_CLEANUP=''/",
"/etc/abuild.conf"], suffix) "/etc/abuild.conf"], suffix)
# Mark the chroot as initialized pathlib.Path(marker).touch()
pmb.chroot.root(args, ["touch", marker], suffix)
def init_compiler(args, depends, cross, arch): def init_compiler(args, depends, cross, arch):