diff mbox

[v4,1/9] Makefile: don't depend on the umask

Message ID 1416586748-12936-2-git-send-email-guido@vanguardiasur.com.ar
State Accepted
Headers show

Commit Message

Guido Martínez Nov. 21, 2014, 4:19 p.m. UTC
Some packages and BR itself create files and directories on the target
with cp/mkdir/etc which depend on the umask at the time of building.

To fix this, use a trick inside the Makefile which wraps all rules when
the umask is not 0022. This sets the umask at the top level, and then
the building process continues as usual.

Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>
---
 Makefile | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Arnout Vandecappelle July 13, 2015, 9:35 a.m. UTC | #1
On 11/21/14 17:19, Guido Martínez wrote:
> Some packages and BR itself create files and directories on the target
> with cp/mkdir/etc which depend on the umask at the time of building.
> 
> To fix this, use a trick inside the Makefile which wraps all rules when
> the umask is not 0022. This sets the umask at the top level, and then
> the building process continues as usual.
> 
> Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>

Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tested-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

 Without this patch, building with umask 077 yields the following in rootfs.tar:

-rw------- 0/0             122 2015-07-13 11:28 ./etc/os-release

After the patch, we get:

-rw-r--r-- 0/0             122 2015-07-13 11:31 ./etc/os-release

 Also verified that it has virtually no impact on the time of 'make -qp'.

 Regards,
 Arnout

> ---
>  Makefile | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 3d8283b..eeb1412 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -24,6 +24,19 @@
>  # You shouldn't need to mess with anything beyond this point...
>  #--------------------------------------------------------------
>  
> +# Trick for always running with a fixed umask
> +UMASK=0022
> +ifneq ($(shell umask),$(UMASK))
> +.PHONY: all $(MAKECMDGOALS)
> +
> +all:
> +	@umask $(UMASK) && $(MAKE)
> +
> +$(MAKECMDGOALS):
> +	@umask $(UMASK) && $(MAKE) $@
> +
> +else # umask
> +
>  # This is our default rule, so must come first
>  all:
>  
> @@ -932,3 +945,5 @@ include docs/manual/manual.mk
>  -include $(BR2_EXTERNAL)/docs/*/*.mk
>  
>  .PHONY: $(noconfig_targets)
> +
> +endif #umask
>
Thomas Petazzoni July 13, 2015, 10:59 a.m. UTC | #2
Dear Guido Martínez,

On Fri, 21 Nov 2014 13:19:00 -0300, Guido Martínez wrote:
> Some packages and BR itself create files and directories on the target
> with cp/mkdir/etc which depend on the umask at the time of building.
> 
> To fix this, use a trick inside the Makefile which wraps all rules when
> the umask is not 0022. This sets the umask at the top level, and then
> the building process continues as usual.
> 
> Signed-off-by: Guido Martínez <guido@vanguardiasur.com.ar>
> ---
>  Makefile | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

Applied with some additional changes:

    [Thomas: add --no-print-directory, as suggested by Arnout.]

Thanks!

Thomas
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 3d8283b..eeb1412 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,19 @@ 
 # You shouldn't need to mess with anything beyond this point...
 #--------------------------------------------------------------
 
+# Trick for always running with a fixed umask
+UMASK=0022
+ifneq ($(shell umask),$(UMASK))
+.PHONY: all $(MAKECMDGOALS)
+
+all:
+	@umask $(UMASK) && $(MAKE)
+
+$(MAKECMDGOALS):
+	@umask $(UMASK) && $(MAKE) $@
+
+else # umask
+
 # This is our default rule, so must come first
 all:
 
@@ -932,3 +945,5 @@  include docs/manual/manual.mk
 -include $(BR2_EXTERNAL)/docs/*/*.mk
 
 .PHONY: $(noconfig_targets)
+
+endif #umask