build: envkernel: cleanup behaviour (MR 2491)

recent changes to the kernels build infra in -next seem to have exposed
some issues with "pmbootstrap build --envkernel", specifically in the
case where the APKBUILD doesn't build out-of-tree.

We used to rely on the fact that the kernel output directory contains a
Makefile which points to the source directory, however this Makefile
now(?) contains an absolute path on the host, which won't match what's
in the chroot.

As a result, it's now necessary to build with the same output directory
as the APKBUILD.

We probably need some smarter code here... and/or more consistent
APKBUILDs.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-11-16 21:08:45 +01:00 committed by Oliver Smith
parent 60da40232d
commit 04635dcb3e
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -132,7 +132,7 @@ def run_abuild(
"""
chroot = Chroot.native()
build_path = Path("/home/pmos/build")
kbuild_out_source = "/mnt/linux/.output"
kbuild_out_source = f"/mnt/linux/{kbuild_out}"
# If the kernel was cross-compiled on the host rather than with the envkernel
# helper, we can still use the envkernel logic to package the artifacts for
@ -180,13 +180,7 @@ def run_abuild(
)
# Create symlink from abuild working directory to envkernel build directory
if kbuild_out != "":
if os.path.islink(chroot / "mnt/linux" / kbuild_out) and os.path.lexists(
chroot / "mnt/linux" / kbuild_out
):
pmb.chroot.root(["rm", Path("/mnt/linux", kbuild_out)])
pmb.chroot.root(["ln", "-s", "/mnt/linux", build_path / "src"])
pmb.chroot.root(["ln", "-s", kbuild_out_source, build_path / "src" / kbuild_out])
pmb.chroot.root(["ln", "-sf", "/mnt/linux", build_path / "src"])
cmd: list[PathString] = ["cp", apkbuild_path, chroot / build_path / "APKBUILD"]
pmb.helpers.run.root(cmd)