Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] build: fix umask test
@ 2016-05-31  7:46 Kurt Van Dijck
  2016-05-31  9:53 ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: Kurt Van Dijck @ 2016-05-31  7:46 UTC (permalink / raw)
  To: buildroot

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.

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 63502d0..846343d 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
1.8.5.rc3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v2] build: fix umask test
  2016-05-31  7:46 [Buildroot] [PATCH v2] build: fix umask test Kurt Van Dijck
@ 2016-05-31  9:53 ` Thomas Petazzoni
  2016-05-31  9:59   ` Kurt Van Dijck
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2016-05-31  9:53 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 31 May 2016 09:46:22 +0200, Kurt Van Dijck wrote:
> 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.
> 
> Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 63502d0..846343d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v2] build: fix umask test
  2016-05-31  9:53 ` Thomas Petazzoni
@ 2016-05-31  9:59   ` Kurt Van Dijck
  2016-05-31 10:24     ` Peter Korsgaard
  0 siblings, 1 reply; 6+ messages in thread
From: Kurt Van Dijck @ 2016-05-31  9:59 UTC (permalink / raw)
  To: buildroot

> > --- a/Makefile
> > +++ b/Makefile
> > @@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v2] build: fix umask test
  2016-05-31  9:59   ` Kurt Van Dijck
@ 2016-05-31 10:24     ` Peter Korsgaard
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2016-05-31 10:24 UTC (permalink / raw)
  To: buildroot

>>>>> "Kurt" == Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> writes:

 >> > --- a/Makefile
 >> > +++ b/Makefile
 >> > @@ -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.

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.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v2] build: fix umask test
@ 2016-06-19  4:12 Kurt Van Dijck
  2016-06-20 20:51 ` Peter Korsgaard
  0 siblings, 1 reply; 6+ messages in thread
From: Kurt Van Dijck @ 2016-06-19  4:12 UTC (permalink / raw)
  To: buildroot

Some shells' builtin umask does not print 2 leading 0's for the umask.
Switching to bash is done anyway.
This patch switches to bash before the umask test.

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
 Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 3f5c3d3..78b44c5 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,11 @@
 # You shouldn't need to mess with anything beyond this point...
 #--------------------------------------------------------------
 
+# we want bash as shell
+SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+	 else if [ -x /bin/bash ]; then echo /bin/bash; \
+	 else echo sh; fi; fi)
+
 # Trick for always running with a fixed umask
 UMASK = 0022
 ifneq ($(shell umask),$(UMASK))
@@ -227,11 +232,6 @@ else
   Q = @
 endif
 
-# we want bash as shell
-SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
-	 else if [ -x /bin/bash ]; then echo /bin/bash; \
-	 else echo sh; fi; fi)
-
 # kconfig uses CONFIG_SHELL
 CONFIG_SHELL := $(SHELL)
 
-- 
1.8.5.rc3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH v2] build: fix umask test
  2016-06-19  4:12 Kurt Van Dijck
@ 2016-06-20 20:51 ` Peter Korsgaard
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2016-06-20 20:51 UTC (permalink / raw)
  To: buildroot

>>>>> "Kurt" == Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> writes:

 > Some shells' builtin umask does not print 2 leading 0's for the umask.
 > Switching to bash is done anyway.
 > This patch switches to bash before the umask test.

 > Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>

Committed, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-20 20:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-31  7:46 [Buildroot] [PATCH v2] build: fix umask test Kurt Van Dijck
2016-05-31  9:53 ` Thomas Petazzoni
2016-05-31  9:59   ` Kurt Van Dijck
2016-05-31 10:24     ` Peter Korsgaard
  -- strict thread matches above, loose matches on Subject: below --
2016-06-19  4:12 Kurt Van Dijck
2016-06-20 20:51 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox