Skip to contentSkip to conversation

build: fix umask test

PATCH Superseded Kurt Van Dijck 3 participants 4 messages May 31, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 build: fix umask test

Some shells' builtin umask does not print 2 leading 0's for the umask. Not doing so would break the comparison.
zsh does not parse 022 as octal, so it is easier to compare the umask as ascii string.
This patch fixes the umask comparison across different shells.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 63502d0..846343d 100644
@@ -26,7 +26,7 @@
 
 # Trick for always running with a fixed umask
 UMASK = 0022
-ifneq ($(shell umask),$(UMASK))
+ifneq (00$(shell umask | sed -e "s/^0*//g"),$(UMASK))
 .PHONY: _all $(MAKECMDGOALS)
 
 $(MAKECMDGOALS): _all
Signature · 1 line
1.8.5.rc3
#1 lore raw

PATCH v2 1/1 build: fix umask test

Hello,

Quoted 16 lines · Kurt Van Dijck

Some shells' builtin umask does not print 2 leading 0's for the umask. Not doing so would break the comparison.
zsh does not parse 022 as octal, so it is easier to compare the umask as ascii string.
This patch fixes the umask comparison across different shells.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 63502d0..846343d 100644

Makefile line 29

Quoted 5 lines
Makefile +1 -1
@@ -26,7 +26,7 @@
 
 # Trick for always running with a fixed umask
 UMASK = 0022
-ifneq ($(shell umask),$(UMASK))
+ifneq (00$(shell umask | sed -e "s/^0*//g"),$(UMASK))

Doesn't this makes the assumption that "umask" will always return a value that starts with two zeros ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v2 1/1 build: fix umask test

Quoted 11 lines

Makefile line 29

Quoted 8 lines
Makefile +1 -1
@@ -26,7 +26,7 @@
 
 # Trick for always running with a fixed umask
 UMASK = 0022
-ifneq ($(shell umask),$(UMASK))
+ifneq (00$(shell umask | sed -e "s/^0*//g"),$(UMASK))

Doesn't this makes the assumption that "umask" will always return a value that starts with two zeros ?

No.
the "umask | sed -e ..." strips leading 0's, when present. "00$(...)" glues 00 in front of the stripped umask, so it is compatible again.

Kind regards,
Kurt

#3 lore raw

PATCH v2 1/1 build: fix umask test

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

"Kurt" == Kurt Van Dijck <[email protected]> writes:

Makefile +0 -0
@@ -26,7 +26,7 @@
 
Quoted 7 lines

Makefile line 29

Quoted 4 lines
Makefile +1 -1
 # Trick for always running with a fixed umask
 UMASK = 0022
-ifneq ($(shell umask),$(UMASK))
+ifneq (00$(shell umask | sed -e "s/^0*//g"),$(UMASK))

Doesn't this makes the assumption that "umask" will always return a value that starts with two zeros ?

Quoted 4 lines

No.
the "umask | sed -e ..." strips leading 0's, when present. "00$(...)" glues 00 in front of the stripped umask, so it is compatible again.

True. I still think moving the SHELL= line to the very top of the file is a safer/cleaner approach, so the same shell is used everywhere in Buildroot.

Signature · 1 line
Bye, Peter Korsgaard