Creating a clean root filesystem (with overlay) without rebuilding all the packages
Every time you invoke "make", the root filesystem image is completely re-created from the contents of output/target/, the post-build scripts are executed and the rootfs overlays are copied.
So if you make a change to a rootfs overlay, a change to a post-build script, or you add/remove stuff from output/target/, simply running "make" is sufficient.
However, if your aim is to remove output/target/ completely with the hope that it will reinstall all packages, then indeed this doesn't work, and we have good reasons for not supporting this, because there are many situations where this can give an incorrect result.
Can Buildroot build the root filesystem without building the Linux kernel?
Well, just disable BR2_LINUX_KERNEL
and Buildroot will no longer build the kernel.
How to clean only target in buildroot
Buildroot tracks build progress with .stamp_xxx in each package build dir.
target install is actually the last stage for each package. So removing the .stamp_target_installed file from each package build dir would cause it to reinstall to target
In the latest buildroot, you can simply do the following:
rm -rf output/target
find output/ -name ".stamp_target_installed" -delete
rm -f output/build/host-gcc-final-*/.stamp_host_installed
In some older buildroot, there are a few other files in output that tracks the creation of the target dir with the skeleton. Citing the mailing list message, we could summarize following:
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".
boot.scr rebuild in buildroot
If you dirclean host-uboot-tools it will rebuild your script. The reason is that mkimage (which generates the script) is called in the HOST_UBOOT_TOOLS_INSTALL_CMDS function in the uboot-tools.mk file.
As your personal script is in your external buildroot directory and you will probably want to iterate writing and testing it quickly you will want to make it every time. There is a way to do this each time you run make. No cleaning of anything is required. The post image script is the key.
For example, create your post-image.sh script and specify it in your defconfig file.
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/RK3308/post-image.sh"
In that post-iamge.sh script, run the command to generate your boot script, here is an example :
# Generate the uboot script
$ubootName/tools/mkimage -C none -A arm -T script -d $BR2_EXTERNAL_RK3308_PATH/board/RK3308/boot.cmd $BINARIES_DIR/boot.scr
Each time you run make, the boot.scr will be regenerated.
If you want to see all of this in context, here is an external buildroot repo for the rk3308 chipset.
This is the post-image.sh file.
This is the definition of that file in the defonconfig file.
Patching a file in resulting rootfs
First of all take a look at BR2_EXTERNAL mechanism. This way you can manage your project/configurations/package independent from Buildroot tree.
Then look at "Root filesystem overlays (BR2_ROOTFS_OVERLAY)" and "Post-build scripts (BR2_ROOTFS_POST_BUILD_SCRIPT)" in Customizing the generated target filesystem section. They describe both ways, i.e supply your custom file via fs-overlay or run a post-build script and alter the file within this script.
Related Topics
How Does Copy_From_User from the Linux Kernel Work Internally
Find Out If File Has Been Modified Within the Last 2 Minutes
How to Toggle Cr/Lf in Gnu Screen
Bash: Delete Based on File Date Stamp
What Is the Use of File Descriptor 255 in Bash Process
PDF Lib Install Fail on Linux Server. Using Pecl Install PDFlib
Advice Regarding Installing Arm Toolchain on Ubuntu Vm (64Bit)
Create .So Files on Linux Without Using Pic (Position Independent Code) (X86 32Bit)
How to Add Chromedriver to Path in Linux
Add Blank Line After Every Result in Grep
Cuda Performance Penalty When Running in Windows
Docker Copy with File Globbing
How to Replace to Apostrophe ' Inside a File Using Sed