Bug 15576 - Cannot skip post-image script with `make prepare-sdk`
Summary: Cannot skip post-image script with `make prepare-sdk`
Status: RESOLVED MOVED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2023.02.1
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-20 17:09 UTC by mscdex
Modified: 2024-06-15 15:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mscdex 2023-05-20 17:09:54 UTC
Generally in my post-image scripts I perform some intensive tasks that are strictly for the benefit of the preparation and creation of disk images or ISOs. However, if all I want to do is to prepare an SDK, I don't need to do any of these tasks because the SDK should just be building the toolchain, host packages, and (in my case) generating the environment-setup script.

It would be very useful to have an official/built-in way to bypass the post-image script (and possibly the other scripts) when doing `make prepare-sdk` (either implicitly or explicitly).
Comment 1 mscdex 2023-05-21 00:22:51 UTC
My current workaround involves a special environment variable that allows my scripts to bail out early. However, that unfortunately doesn't do anything for when buildroot creates a (compressed) rootfs, which takes substantially longer than my post-* scripts.

If there is some way to prevent buildroot from unnecessarily creating the rootfs when preparing the SDK, I'd be set...
Comment 2 Yann E. MORIN 2023-05-21 14:13:08 UTC
mscdex, All,

Thanks for the report.

> It would be very useful to have an official/built-in way to bypass the
> post-image script

That's indeed pretty surprising. Could you please try this patch (not sure
if bugzilla keeps or removes TABs, so adapt if need be):

diff --git a/Makefile b/Makefile
index 3d0783242f..05b422d8d2 100644
--- a/Makefile
+++ b/Makefile
@@ -592,7 +592,7 @@ prepare: $(BUILD_DIR)/buildroot-config/auto.conf
 world: target-post-image
 
 .PHONY: prepare-sdk
-prepare-sdk: world
+prepare-sdk: target-finalize staging-finalize host-finalize
 	@$(call MESSAGE,"Rendering the SDK relocatable")
 	PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath host
 	PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath staging


> (and possibly the other scripts) when doing `make prepare-sdk` (either
> implicitly or explicitly).

Post-fakeroot scripts are only caled when building an image, so the above patch
should also cover that case.

As for the post-build scripts, they are supposed to actually fixup the build,
and they may have to explixitly tweak host/ and staging/ for the purpose of
doing small last-minute cleanups and tweaks of various sorts, some which may
be needed to get a working SDK (I know of such a case). So I'm afraid that
is not going to be possible to cover both cases.

In such a case, I'd suggest that what you are doing, setting an environment
variable when you build the SDK and/or doing the full build, and checking that
variable in your post-build scripts, is the correct thing to do. I would
however argue that what your post-build scripts should not modify target/,
staging/, and/or host/ in a way that is incomaptible with assembling an SDK.

Regards,
Yann E. MORIN.
Comment 3 mscdex 2023-05-22 18:24:03 UTC
Yann,

Your suggested patch seems to do the trick. The post-image script is skipped and more importantly the generating and compressing of the rootfs is skipped!
Comment 4 Yann E. MORIN 2023-05-24 20:11:11 UTC
mscdex, All,

> Your suggested patch seems to do the trick.

But in fact, it is not correct, because such an SDK would be missing the
host tools needed to build the actual images.

Indeed, those host tools are only built as dependencies of the image
targets; so, if the image targets are not built, those tools will not
be either.

Now, one may argue that it would be perfectly valid that the SDK does
not contain host tools to build images, but others may argue otherwise.
And I tend to place myself in the second category.

So, I withdraw this patch of mine. We'll need a better solution...

Regards,
Yann E. MORIN.
Comment 5 Yann E. MORIN 2024-06-15 15:08:32 UTC
Thank you for your report.

The issue tracker for the Buildroot project has been moved to
the Gitlab.com issue tracker:
    https://gitlab.com/buildroot.org/buildroot/-/issues

We are taking this opportunity to close old issues in this old
tracker. If you believe your issue is still relevant, please
open one in the new issue tracker.

Thank you!