Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: move not copy files to BIN_DIR #10655

Closed
wants to merge 1 commit into from
Closed

Conversation

aparcar
Copy link
Member

@aparcar aparcar commented Sep 9, 2022

Building images usally stores them in KDIR_TMP and then copies them over to BIN_DIR. This is fine as rebuilding of images overwrites existing images. When using the EXTRA_IMAGE_NAME variable frequently this fills up the ImageBuilder KDIR_TMP folder since every built image is stored forever.

This commit moves every image instead of copying it. I couldn't find any reason which this shouldn't be done. While at it rename FILE_DIR to BIN_DIR to lower the entropy inside the codebase.

Below an example how sysupgrade.openwrt.org filled up after the release of 22.03.0 where every created image contains a hash of the package selction in the filename:

 aparcar@asu-01:~/asu/worker1/cache/22.03.0$ du -d 1 -h
 400M    ./kirkwood
 260M    ./gemini
 2.0G    ./ipq806x
 1.7G    ./ipq40xx
 8.1G    ./ramips
 4.0K    ./octeon
 495M    ./sunxi
 728M    ./lantiq
 1.8G    ./rockchip
 3.7G    ./mediatek
 4.0K    ./realtek
 5.4G    ./mvebu
 8.9G    ./ath79
 3.0G    ./bcm47xx
 14G     ./bcm27xx
 11G     ./x86
 4.0K    ./bcm63xx
 312M    ./mpc85xx
 600M    ./apm821xx
 5.4G    ./bcm53xx
 66G     .

Signed-off-by: Paul Spooren mail@aparcar.org

Building images usally stores them in KDIR_TMP and then copies them over
to BIN_DIR. This is fine as rebuilding of images overwrites existing
images. When using the EXTRA_IMAGE_NAME variable frequently this fills
up the ImageBuilder KDIR_TMP folder since every built image is stored
forever.

This commit moves every image instead of copying it. I couldn't find any
reason which this shouldn't be done. While at it rename FILE_DIR to
BIN_DIR to lower the entropy inside the codebase.

Below an example how sysupgrade.openwrt.org filled up after the release
of 22.03.0 where every created image contains a hash of the package
selction in the filename:

     aparcar@asu-01:~/asu/worker1/cache/22.03.0$ du -d 1 -h
     400M    ./kirkwood
     260M    ./gemini
     2.0G    ./ipq806x
     1.7G    ./ipq40xx
     8.1G    ./ramips
     4.0K    ./octeon
     495M    ./sunxi
     728M    ./lantiq
     1.8G    ./rockchip
     3.7G    ./mediatek
     4.0K    ./realtek
     5.4G    ./mvebu
     8.9G    ./ath79
     3.0G    ./bcm47xx
     14G     ./bcm27xx
     11G     ./x86
     4.0K    ./bcm63xx
     312M    ./mpc85xx
     600M    ./apm821xx
     5.4G    ./bcm53xx
     66G     .

Signed-off-by: Paul Spooren <mail@aparcar.org>
@aparcar aparcar marked this pull request as ready for review September 9, 2022 19:39
@aparcar
Copy link
Member Author

aparcar commented Sep 9, 2022

@ynezz please have a look, you implemented the artifacts stuff a long time ago.

@aparcar
Copy link
Member Author

aparcar commented Sep 9, 2022

@nbd168 also you please, this is old old Makefile stuff

@aparcar
Copy link
Member Author

aparcar commented Sep 9, 2022

Okay this is certainly WIP since it breaks when building multiple profiles at once. It would be a fix for the issue described but not for regular setups.

@aparcar aparcar marked this pull request as draft September 9, 2022 23:00
@@ -474,7 +474,7 @@ define Device/Build/initramfs
$(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare
$(1)-images: $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE))
$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE)
cp $$^ $$@
mv $$^ $$@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the ImageBuilder doesn't itself create initramfs images, doesn't that then mean that the image file placed there by the buildroot will be moved away on the first build and unavailable for future builds for the same profile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test if this issue actually happens? Looking at Imagebuilder archives I don't see the KDIR_TMP folder being shipped and everything that's moved comes. from KDIR_TMP.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this and it works just fine.

@aparcar
Copy link
Member Author

aparcar commented Sep 10, 2022

An alternative implementation is below where a cleanup step is performed after each image create:

#10664

@aparcar
Copy link
Member Author

aparcar commented Sep 10, 2022

Cleaning KDIR_TMP is the easier approach as it touches less things. Closing this

@aparcar aparcar closed this Sep 10, 2022
@mans0n mans0n added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/scripts/tools pull request/issues for build, scripts and tools related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants