* [Buildroot] [PATCH] build: fix umask test
@ 2016-05-30 7:06 Kurt Van Dijck
2016-05-30 7:55 ` Peter Korsgaard
0 siblings, 1 reply; 12+ messages in thread
From: Kurt Van Dijck @ 2016-05-30 7:06 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.
This patch makes sure that the umask has (at least) 4 digits.
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..9a36769 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@
# Trick for always running with a fixed umask
UMASK = 0022
-ifneq ($(shell umask),$(UMASK))
+ifneq ($(shell printf "%04o\n" `umask`),$(UMASK))
.PHONY: _all $(MAKECMDGOALS)
$(MAKECMDGOALS): _all
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 7:06 [Buildroot] [PATCH] build: fix umask test Kurt Van Dijck
@ 2016-05-30 7:55 ` Peter Korsgaard
2016-05-30 8:05 ` Peter Korsgaard
0 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2016-05-30 7:55 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.
> Not doing so would break the comparison.
> This patch makes sure that the umask has (at least) 4 digits.
> 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..9a36769 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -26,7 +26,7 @@
> # Trick for always running with a fixed umask
> UMASK = 0022
> -ifneq ($(shell umask),$(UMASK))
> +ifneq ($(shell printf "%04o\n" `umask`),$(UMASK))
Thanks, but with at least zsh this doesn't work:
zsh --version
zsh 5.0.7 (x86_64-pc-linux-gnu)
umask
022
printf "%04o\n" $(umask)
0026
It seems like the printf arguments are always handled as decimal.
It does work on bash though:
bash --version
GNU bash, version 4.3.33(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
umask
0022
printf "%04o\n" $(umask)
0022
It seems we need to use the base#number syntax, E.G. 8#`umask` to get
zsh to interprete it as octal, but bash doesn't seem to like it :/
But the real question is why this happens in the first place? We do set
SHELL=bash, so all of this should be running under bash where it works.
What shell are you using and how is your setup?
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 7:55 ` Peter Korsgaard
@ 2016-05-30 8:05 ` Peter Korsgaard
2016-05-30 9:17 ` Thomas Petazzoni
0 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2016-05-30 8:05 UTC (permalink / raw)
To: buildroot
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
Hi,
> It seems we need to use the base#number syntax, E.G. 8#`umask` to get
> zsh to interprete it as octal, but bash doesn't seem to like it :/
> But the real question is why this happens in the first place? We do set
> SHELL=bash, so all of this should be running under bash where it works.
Sorry, I misremembered. This logic is above the line where we assign
bash to SHELL, so it runs with /bin/sh as shell. On my system, this is
dash and it behaves like bash in this regard. What shell do you use?
In any case, I think the proper fix is to simply move the SHELL= line
above here to ensure we get consistent results.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 8:05 ` Peter Korsgaard
@ 2016-05-30 9:17 ` Thomas Petazzoni
2016-05-30 9:53 ` Kurt Van Dijck
2016-05-30 9:56 ` Peter Korsgaard
0 siblings, 2 replies; 12+ messages in thread
From: Thomas Petazzoni @ 2016-05-30 9:17 UTC (permalink / raw)
To: buildroot
Hello,
On Mon, 30 May 2016 10:05:58 +0200, Peter Korsgaard wrote:
> Sorry, I misremembered. This logic is above the line where we assign
> bash to SHELL, so it runs with /bin/sh as shell. On my system, this is
> dash and it behaves like bash in this regard. What shell do you use?
From the Kurt's previous e-mails, I believe he is using mksh as his
shell.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 9:17 ` Thomas Petazzoni
@ 2016-05-30 9:53 ` Kurt Van Dijck
2016-05-30 9:59 ` Peter Korsgaard
2016-05-30 9:56 ` Peter Korsgaard
1 sibling, 1 reply; 12+ messages in thread
From: Kurt Van Dijck @ 2016-05-30 9:53 UTC (permalink / raw)
To: buildroot
> Hello,
>
> On Mon, 30 May 2016 10:05:58 +0200, Peter Korsgaard wrote:
>
> > Sorry, I misremembered. This logic is above the line where we assign
> > bash to SHELL, so it runs with /bin/sh as shell. On my system, this is
> > dash and it behaves like bash in this regard. What shell do you use?
>
> From the Kurt's previous e-mails, I believe he is using mksh as his
> shell.
indeed, mksh it is.
I understand the zsh problem, on the other hand,
any number prefixed with a 0 is octal, isn't it?
Anyway, I'll re-think the patch too...
Kurt
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 9:17 ` Thomas Petazzoni
2016-05-30 9:53 ` Kurt Van Dijck
@ 2016-05-30 9:56 ` Peter Korsgaard
1 sibling, 0 replies; 12+ messages in thread
From: Peter Korsgaard @ 2016-05-30 9:56 UTC (permalink / raw)
To: buildroot
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:
> Hello,
> On Mon, 30 May 2016 10:05:58 +0200, Peter Korsgaard wrote:
>> Sorry, I misremembered. This logic is above the line where we assign
>> bash to SHELL, so it runs with /bin/sh as shell. On my system, this is
>> dash and it behaves like bash in this regard. What shell do you use?
> From the Kurt's previous e-mails, I believe he is using mksh as his
> shell.
Yes, I noticed as well. I should stop reading my mails in reverse order
;)
--
Venlig hilsen,
Peter Korsgaard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 9:53 ` Kurt Van Dijck
@ 2016-05-30 9:59 ` Peter Korsgaard
2016-05-30 21:09 ` Kurt Van Dijck
0 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2016-05-30 9:59 UTC (permalink / raw)
To: buildroot
>>>>> "Kurt" == Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> writes:
Hi,
> I understand the zsh problem, on the other hand,
> any number prefixed with a 0 is octal, isn't it?
Apparently not to zsh. I haven't found any official notice about it, but
googling around shows this (old!) patch:
http://www.zsh.org/mla/workers/1995/msg00518.html
> Anyway, I'll re-think the patch too...
Just moving up the SHELL= line above this check should be enough.
--
Venlig hilsen,
Peter Korsgaard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 9:59 ` Peter Korsgaard
@ 2016-05-30 21:09 ` Kurt Van Dijck
2016-05-30 21:31 ` Arnout Vandecappelle
0 siblings, 1 reply; 12+ messages in thread
From: Kurt Van Dijck @ 2016-05-30 21:09 UTC (permalink / raw)
To: buildroot
>
> Hi,
>
> > I understand the zsh problem, on the other hand,
> > any number prefixed with a 0 is octal, isn't it?
>
> Apparently not to zsh. I haven't found any official notice about it, but
> googling around shows this (old!) patch:
>
> http://www.zsh.org/mla/workers/1995/msg00518.html
>
> > Anyway, I'll re-think the patch too...
>
> Just moving up the SHELL= line above this check should be enough.
I see, but how would that help when bash is not on the system?
Is bash a prerequisite?
I was thinking on using /bin/printf to avoid using the shell builtin.
Kurt
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 21:09 ` Kurt Van Dijck
@ 2016-05-30 21:31 ` Arnout Vandecappelle
2016-05-31 7:43 ` Kurt Van Dijck
0 siblings, 1 reply; 12+ messages in thread
From: Arnout Vandecappelle @ 2016-05-30 21:31 UTC (permalink / raw)
To: buildroot
On 05/30/16 23:09, Kurt Van Dijck wrote:
>>
>> Hi,
>>
>> > I understand the zsh problem, on the other hand,
>> > any number prefixed with a 0 is octal, isn't it?
>>
>> Apparently not to zsh. I haven't found any official notice about it, but
>> googling around shows this (old!) patch:
>>
>> http://www.zsh.org/mla/workers/1995/msg00518.html
>>
>> > Anyway, I'll re-think the patch too...
>>
>> Just moving up the SHELL= line above this check should be enough.
>
> I see, but how would that help when bash is not on the system?
> Is bash a prerequisite?
Yes, bash is a prerequisite. Some of our own scripts are bash scripts.
Moreover, quite a few packages just assume that the shell is bash. Requiring
bash and setting is as SHELL is the simplest way to handle that.
>
> I was thinking on using /bin/printf to avoid using the shell builtin.
I don't have /bin/printf, only /usr/bin/printf...
Regards,
Arnout
>
> Kurt
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-30 21:31 ` Arnout Vandecappelle
@ 2016-05-31 7:43 ` Kurt Van Dijck
2016-05-31 7:48 ` Peter Korsgaard
0 siblings, 1 reply; 12+ messages in thread
From: Kurt Van Dijck @ 2016-05-31 7:43 UTC (permalink / raw)
To: buildroot
> >
> > I see, but how would that help when bash is not on the system?
> > Is bash a prerequisite?
>
> Yes, bash is a prerequisite. Some of our own scripts are bash scripts.
> Moreover, quite a few packages just assume that the shell is bash. Requiring
> bash and setting is as SHELL is the simplest way to handle that.
The Makefile only recommends /bin/bash, it falls back to 'sh' when bash
is not present.
>
> >
> > I was thinking on using /bin/printf to avoid using the shell builtin.
>
> I don't have /bin/printf, only /usr/bin/printf...
Thanks for mentioning, I'll address the problem without printf.
Kurt
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-31 7:43 ` Kurt Van Dijck
@ 2016-05-31 7:48 ` Peter Korsgaard
2016-05-31 9:35 ` Kurt Van Dijck
0 siblings, 1 reply; 12+ messages in thread
From: Peter Korsgaard @ 2016-05-31 7:48 UTC (permalink / raw)
To: buildroot
>>>>> "Kurt" == Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> writes:
>> >
>> > I see, but how would that help when bash is not on the system?
>> > Is bash a prerequisite?
>>
>> Yes, bash is a prerequisite. Some of our own scripts are bash scripts.
>> Moreover, quite a few packages just assume that the shell is bash. Requiring
>> bash and setting is as SHELL is the simplest way to handle that.
> The Makefile only recommends /bin/bash, it falls back to 'sh' when bash
> is not present.
Yes, but support/dependencies/dependencies.sh checks for bash and bails
out if not available.
--
Venlig hilsen,
Peter Korsgaard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Buildroot] [PATCH] build: fix umask test
2016-05-31 7:48 ` Peter Korsgaard
@ 2016-05-31 9:35 ` Kurt Van Dijck
0 siblings, 0 replies; 12+ messages in thread
From: Kurt Van Dijck @ 2016-05-31 9:35 UTC (permalink / raw)
To: buildroot
> >>>>> "Kurt" == Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> writes:
>
> >> >
> >> > I see, but how would that help when bash is not on the system?
> >> > Is bash a prerequisite?
> >>
> >> Yes, bash is a prerequisite. Some of our own scripts are bash scripts.
> >> Moreover, quite a few packages just assume that the shell is bash. Requiring
> >> bash and setting is as SHELL is the simplest way to handle that.
>
> > The Makefile only recommends /bin/bash, it falls back to 'sh' when bash
> > is not present.
>
> Yes, but support/dependencies/dependencies.sh checks for bash and bails
> out if not available.
I wasn't aware of this :-)
I already sent out a v2 of the patch which makes it shell-independant.
Kurt
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-05-31 9:35 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30 7:06 [Buildroot] [PATCH] build: fix umask test Kurt Van Dijck
2016-05-30 7:55 ` Peter Korsgaard
2016-05-30 8:05 ` Peter Korsgaard
2016-05-30 9:17 ` Thomas Petazzoni
2016-05-30 9:53 ` Kurt Van Dijck
2016-05-30 9:59 ` Peter Korsgaard
2016-05-30 21:09 ` Kurt Van Dijck
2016-05-30 21:31 ` Arnout Vandecappelle
2016-05-31 7:43 ` Kurt Van Dijck
2016-05-31 7:48 ` Peter Korsgaard
2016-05-31 9:35 ` Kurt Van Dijck
2016-05-30 9:56 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox