如何清理buildroot中的唯一目标

How to clean only target in buildroot

我弄乱了目标 fs 中的一些文件。所以我想重新组装它。但不是全部重建。

make clean 只是擦除所有输出,+ 构建目录。 应该使用什么命令通过 output/build/ 结构递归地仅删除目标目录和所有相关的 .stamp_some_step 文件,迫使 buildroot 根据当前配置重新组装文件系统,而不是一次又一次地重建所有库和二进制文件?

Buildroot 有特殊的 make 目标来清除特定包的构建目录,但这不会触及任何已安装的文件。引用 user manual:

When a package is removed from the configuration, Buildroot does not do anything special. It does not remove the files installed by this package from the target root filesystem or from the toolchain sysroot. A full rebuild is needed to get rid of this package. However, generally you don’t necessarily need this package to be removed right now: you can wait for the next lunch break to restart the build from scratch.

也就是说,您可以通过 运行ning make <PKG-NAME>-dirclean 删除特定包的构建文件。例如,如果我想删除 i2c-tools 的构建文件,我会 运行 make i2c-tools-dirclean<PKG-NAME>-dirclean 目标只是在 output/build/<PKG-NAME> 目录中 运行s 一个 rm -rf。这不会从 output/target/ 中删除已安装的文件。如果你想在没有完全重建的情况下从你的 rootfs 中删除文件,那很好 - 你可以进入 output/target/, rm 你不再需要的文件,然后 运行 make 重新生成您的最终图像。确保您的 Buildroot 配置也未设置为重建和安装您要删除的包。

Buildroot 在每个包构建目录中使用 .stamp_xxx 跟踪构建进度。 target install 实际上是每个包的最后阶段。因此,从每个包构建目录中删除 .stamp_target_installed 文件会导致它重新安装到目标

在最新的 buildroot 中,您可以简单地执行以下操作:

rm -rf output/target
find output/ -name ".stamp_target_installed" -delete
rm -f output/build/host-gcc-final-*/.stamp_host_installed

在一些较旧的 buildroot 中,输出中还有一些其他文件跟踪目标目录与骨架的创建。引用 mailing list message,我们可以总结如下:

Does a "rm -rf output/target && make" work?

As Thomas said, it does not work. But, some unofficial hacks exist:

  • remove build/.root will force to reinstall skeleton
  • remove build/*/.stamp_target_installed force reinstall each target package
  • depending of you toolchain, you can reinstall libc and co by removing:
  • stamps/ext-toolchain-installed (external)
  • stamps/ct-ng-toolchain-installed (ctng)
  • target/lib/libc.so.0 (buildroot)

And then simply do make again.

Remind, there are ton of reasons these tips could do wrong things. The only current official way to rebuild target is "make clean".