Skip to contentSkip to conversation

Makefile: add $BINARIES_DIR dependency to target-post-image target

PATCH New Brent Generous 2 participants 3 messages Jul 12, 2019 – Aug 5, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: add $BINARIES_DIR dependency to target-post-image target

Without this dependency, there is no guarantee that the $BINARIES_DIR has been created before this point. This can cause commands that intend to copy a file into $BINARIES_DIR to instead copy to a file named $BINARIES_DIR, causing later commands to create this directory to fail.

A comment above the target for $BINARIES_DIR mentions "do NOT list these as dependencies anywhere else". It wasn't clear from the git history why that should be the case. This seems like the correct way to handle the dependency on this directory.

---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
index c98a0ed87e..2ea7220484 100644
@@ -606,7 +606,6 @@ BR2_SDK_PREFIX ?= $(GNU_TARGET_NAME)_sdk-buildroot
 sdk: prepare-sdk $(BR2_TAR_HOST_DEPENDENCY)
 	@$(call MESSAGE,"Generating SDK tarball")
 	$(if $(BR2_SDK_PREFIX),,$(error BR2_SDK_PREFIX can not be empty))
-	$(Q)mkdir -p $(BINARIES_DIR)
 	$(TAR) czf "$(BINARIES_DIR)/$(BR2_SDK_PREFIX).tar.gz" \
 		--owner=0 --group=0 --numeric-owner \
 		--transform='s#^$(patsubst /%,%,$(HOST_DIR))#$(BR2_SDK_PREFIX)#' \
@@ -810,7 +809,7 @@ endif # merged /usr
 	touch $(TARGET_DIR)/usr
 
 .PHONY: target-post-image
-target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
+target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize | $(BINARIES_DIR)
 	@rm -f $(ROOTFS_COMMON_TAR)
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
 		$(call MESSAGE,"Executing post-image script $(s)"); \
Signature · 1 line
2.17.2
#1 lore raw

PATCH 1/1 Makefile: add $BINARIES_DIR dependency to target-post-image target

Brent, All,

Thanks for your contribution.

On 2019-07-12 16:10 +0000, Brent Generous spake thusly:

Quoted 9 lines

Without this dependency, there is no guarantee that the $BINARIES_DIR has been created before this point. This can cause commands that intend to copy a file into $BINARIES_DIR to instead copy to a file named $BINARIES_DIR, causing later commands to create this directory to fail.

A comment above the target for $BINARIES_DIR mentions "do NOT list these as dependencies anywhere else". It wasn't clear from the git history why that should be the case. This seems like the correct way to handle the dependency on this directory.

We've discussed this today during the developpers meeting, andwe concluded that the real solution would be to create the directory right before calling the post-image scripts. I've respun a v2:

    https://patchwork.ozlabs.org/patch/1141759/

Can you confirm this also fixes your issue?

Regards,
Yann E. MORIN.

Quoted 33 lines
---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
index c98a0ed87e..2ea7220484 100644
@@ -606,7 +606,6 @@ BR2_SDK_PREFIX ?= $(GNU_TARGET_NAME)_sdk-buildroot
 sdk: prepare-sdk $(BR2_TAR_HOST_DEPENDENCY)
 	@$(call MESSAGE,"Generating SDK tarball")
 	$(if $(BR2_SDK_PREFIX),,$(error BR2_SDK_PREFIX can not be empty))
-	$(Q)mkdir -p $(BINARIES_DIR)
 	$(TAR) czf "$(BINARIES_DIR)/$(BR2_SDK_PREFIX).tar.gz" \
 		--owner=0 --group=0 --numeric-owner \
 		--transform='s#^$(patsubst /%,%,$(HOST_DIR))#$(BR2_SDK_PREFIX)#' \
@@ -810,7 +809,7 @@ endif # merged /usr
 	touch $(TARGET_DIR)/usr
 
 .PHONY: target-post-image
-target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
+target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize | $(BINARIES_DIR)
 	@rm -f $(ROOTFS_COMMON_TAR)
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
 		$(call MESSAGE,"Executing post-image script $(s)"); \
Signature · 6 lines
2.17.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 Makefile: add $BINARIES_DIR dependency to target-post-image target

Hi Yann,

Quoted 21 lines · Yann E. MORIN

Brent, All,

Thanks for your contribution.

On 2019-07-12 16:10 +0000, Brent Generous spake thusly:

Quoted 1 line

Without this dependency, there is no guarantee that the

$BINARIES_DIR

Quoted 1 line

has been created before this point. This can cause commands that

intend

Quoted 2 lines

to copy a file into $BINARIES_DIR to instead copy to a file named $BINARIES_DIR, causing later commands to create this directory to

fail.

Quoted 2 lines

A comment above the target for $BINARIES_DIR mentions "do NOT list

these

Quoted 1 line

as dependencies anywhere else". It wasn't clear from the git

history why

Quoted 1 line

that should be the case. This seems like the correct way to handle

the

Quoted 1 line

dependency on this directory.

Quoted 8 lines

We've discussed this today during the developpers meeting, andwe concluded that the real solution would be to create the directory right
before calling the post-image scripts. I've respun a v2:

https://patchwork.ozlabs.org/patch/1141759/

Can you confirm this also fixes your issue?

This looks like a mix of two patches that do the same thing. The patch in d57e7307 that was applied to master however does fix my original issue.

I'm curious though -- d57e7307 does not have the order-only prerequisite, and instead uses mkdir -p in the recipe. Do you know why this is preferred over the order-only prerequisite?

Thanks,
Brent