public inbox for gentoo-embedded@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-embedded] init.d scripts and bash
@ 2007-03-08 16:00 Natanael Copa
  2007-03-09  0:00 ` Ned Ludd
  0 siblings, 1 reply; 7+ messages in thread
From: Natanael Copa @ 2007-03-08 16:00 UTC (permalink / raw
  To: gentoo-embedded

Hi,

Are there anybody more than me that use the gentoo init.d scripts
without using bash?

Most init.d scripts runs just fine with a small runscript wrapper. A few
needs patching to work, typically replacing:

  [[ expr || expr ]]

with:

  [[ expr ]] || [[ expr ]]

But sometimes arrays and such are used (very often its easy to work
around)

Are there any hope for setting a gentoo policy that says bash specific
things should be avoided if possible in init.d scripts?

Natanael Copa

-- 
gentoo-embedded@gentoo.org mailing list



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

* Re: [gentoo-embedded] init.d scripts and bash
  2007-03-08 16:00 [gentoo-embedded] init.d scripts and bash Natanael Copa
@ 2007-03-09  0:00 ` Ned Ludd
       [not found]   ` <20070309073937.154cff79@uberpc.marples.name>
  0 siblings, 1 reply; 7+ messages in thread
From: Ned Ludd @ 2007-03-09  0:00 UTC (permalink / raw
  To: gentoo-embedded; +Cc: Roy Marples

On Thu, 2007-03-08 at 17:00 +0100, Natanael Copa wrote:
> Hi,
> 
> Are there anybody more than me that use the gentoo init.d scripts
> without using bash?
> 
> Most init.d scripts runs just fine with a small runscript wrapper. A few
> needs patching to work, typically replacing:
> 
>   [[ expr || expr ]]
> 
> with:
> 
>   [[ expr ]] || [[ expr ]]
> 
> But sometimes arrays and such are used (very often its easy to work
> around)
> 
> Are there any hope for setting a gentoo policy that says bash specific
> things should be avoided if possible in init.d scripts?

That is a goal with baselayout-2. I'd be interested if we started a
tracker bug for such things. I think policy might be a bit far 
reaching at this point. But it's for sure a worthwhile goal.

-- 
Ned Ludd <solar@gentoo.org>
Gentoo Linux

-- 
gentoo-embedded@gentoo.org mailing list



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

* Re: [gentoo-embedded] init.d scripts and bash
       [not found]   ` <20070309073937.154cff79@uberpc.marples.name>
@ 2007-03-09  9:08     ` Ned Ludd
  2007-03-09 10:06       ` Natanael Copa
  2007-03-09 11:51       ` Natanael Copa
  0 siblings, 2 replies; 7+ messages in thread
From: Ned Ludd @ 2007-03-09  9:08 UTC (permalink / raw
  To: Roy Marples; +Cc: gentoo-embedded

On Fri, 2007-03-09 at 07:39 +0000, Roy Marples wrote:
> On Thu, 08 Mar 2007 16:00:50 -0800
> Ned Ludd <solar@gentoo.org> wrote:
> 
> > On Thu, 2007-03-08 at 17:00 +0100, Natanael Copa wrote:
> > > Hi,
> > > 
> > > Are there anybody more than me that use the gentoo init.d scripts
> > > without using bash?
> > > 
> > > Most init.d scripts runs just fine with a small runscript wrapper.
> > > A few needs patching to work, typically replacing:
> > > 
> > >   [[ expr || expr ]]
> > > 
> > > with:
> > > 
> > >   [[ expr ]] || [[ expr ]]
> 
> Well, not many shells support that either.
> [ expr -o expr ]
> or
> [ expr ] || [ expr]
> should work across the board.
> 
> > > But sometimes arrays and such are used (very often its easy to work
> > > around)
> 
> Yes it's easy to work around.
> Infact we had a discussion about this on -dev and posted the below
> function
> 
> _get_array() {
>     if [ -n "${BASH}" ] ; then
>         case "$(declare -p "$1" 2>/dev/null)" in
>             "declare -a "*)
>                 echo "set -- \"\${$1[@]}\""
>                 return
>                 ;; 
>         esac
>     fi
> 
>     echo "eval set -- \"\$$1\""
> }
> 
> eval "$(_get_array "config_${IFVAR}")"
> for cmd in "$@" ; do
>  ...
> done
> 
> Which means we can support bash arrays AND a non bash array
> config_eth0=( "one" "t w o" "three" )
> and
> config_eth0="'one' 't w o' 'three'"
> 
> > > 
> > > Are there any hope for setting a gentoo policy that says bash
> > > specific things should be avoided if possible in init.d scripts?
> 
> There's no such policy. Our policy has always been init scripts should
> be parseable by a shell. The shell in question has always been bash
> because
> 1) baselayout-1 requires it
> 2) bash forces itself to be /bin/sh anyway
> 
> The lastest bash in the tree no longer enforces it's /bin/sh - instead
> it only creates the link if it does not exist, allowing any shell to be
> used. Yay!


Sweet ass sweet...

I'm sure it will take time to get 99% of the misc remaining bash init
scripts converted over as we find them. If we mostly target server stuff
for now we will be fine..

> > That is a goal with baselayout-2. I'd be interested if we started a
> > tracker bug for such things. I think policy might be a bit far 
> > reaching at this point. But it's for sure a worthwhile goal.
>  
> baselayout-2 is pure C (except for the init scripts themselves) and is
> nearing the final stage of development before it enters the tree. It
> currently works with any shell in portage except for zsh and ksh. It
> can work with bb provided that some things are disabled.

Gimme bugs.. I need #'s if I'm going to work toward solving them.
I'd rather not disable vs update bb to conform with what you need.
Removing our s-s-d for us is very undesirable as long as we have an
alternative to the current bloated s-s-d. So please give us bugs 
to work towards solving etc..

I think Natanael might also become one of your best testers and bug
reporters. He has been very helpful in the past and I'm sure he will
continue to be in the future.



> 
> I'm making it a policy that all init scripts on my local machines have
> already been changed. Naughty me. I've filed bugs for a few other
> scripts too. 

Natanael please search bugzilla for scripts you have noticed in which
Roy has not already filed bugs. If no bug exists please file one
(patches attached if you can)


> So for a desktop it should work off the bat. Not sure if
> I'll put baselayout-2 on my server right now as it's headless and it's a
> PITA to get a head to it.
> 
> Once baselayout-2 hits portage then we can have a tracker bug.
> 
> Thanks
> 
> Roy
> 
-- 
Ned Ludd <solar@gentoo.org>
Gentoo Linux

-- 
gentoo-embedded@gentoo.org mailing list



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

* Re: [gentoo-embedded] init.d scripts and bash
  2007-03-09  9:08     ` Ned Ludd
@ 2007-03-09 10:06       ` Natanael Copa
  2007-03-09 11:51       ` Natanael Copa
  1 sibling, 0 replies; 7+ messages in thread
From: Natanael Copa @ 2007-03-09 10:06 UTC (permalink / raw
  To: gentoo-embedded; +Cc: Roy Marples

On Fri, 2007-03-09 at 01:08 -0800, Ned Ludd wrote:
> On Fri, 2007-03-09 at 07:39 +0000, Roy Marples wrote:
> > On Thu, 08 Mar 2007 16:00:50 -0800
> > Ned Ludd <solar@gentoo.org> wrote:
> > 
> > > On Thu, 2007-03-08 at 17:00 +0100, Natanael Copa wrote:
> > > > Hi,
> > > > 
> > > > Are there anybody more than me that use the gentoo init.d scripts
> > > > without using bash?
> > > > 
> > > > Most init.d scripts runs just fine with a small runscript wrapper.
> > > > A few needs patching to work, typically replacing:
> > > > 
> > > >   [[ expr || expr ]]
> > > > 
> > > > with:
> > > > 
> > > >   [[ expr ]] || [[ expr ]]
> > 
> > Well, not many shells support that either.
> > [ expr -o expr ]
> > or
> > [ expr ] || [ expr]
> > should work across the board.
> > 
> > > > But sometimes arrays and such are used (very often its easy to work
> > > > around)
> > 
> > Yes it's easy to work around.
> > Infact we had a discussion about this on -dev and posted the below
> > function
> > 
> > _get_array() {
> >     if [ -n "${BASH}" ] ; then
> >         case "$(declare -p "$1" 2>/dev/null)" in
> >             "declare -a "*)
> >                 echo "set -- \"\${$1[@]}\""
> >                 return
> >                 ;; 
> >         esac
> >     fi
> > 
> >     echo "eval set -- \"\$$1\""
> > }
> > 
> > eval "$(_get_array "config_${IFVAR}")"
> > for cmd in "$@" ; do
> >  ...
> > done
> > 
> > Which means we can support bash arrays AND a non bash array
> > config_eth0=( "one" "t w o" "three" )
> > and
> > config_eth0="'one' 't w o' 'three'"
> > 
> > > > 
> > > > Are there any hope for setting a gentoo policy that says bash
> > > > specific things should be avoided if possible in init.d scripts?
> > 
> > There's no such policy. Our policy has always been init scripts should
> > be parseable by a shell. The shell in question has always been bash
> > because
> > 1) baselayout-1 requires it
> > 2) bash forces itself to be /bin/sh anyway
> > 
> > The lastest bash in the tree no longer enforces it's /bin/sh - instead
> > it only creates the link if it does not exist, allowing any shell to be
> > used. Yay!
> 
> 
> Sweet ass sweet...
> 
> I'm sure it will take time to get 99% of the misc remaining bash init
> scripts converted over as we find them. If we mostly target server stuff
> for now we will be fine..
> 
> > > That is a goal with baselayout-2. I'd be interested if we started a
> > > tracker bug for such things. I think policy might be a bit far 
> > > reaching at this point. But it's for sure a worthwhile goal.
> >  
> > baselayout-2 is pure C (except for the init scripts themselves) and is
> > nearing the final stage of development before it enters the tree. It
> > currently works with any shell in portage except for zsh and ksh. It
> > can work with bb provided that some things are disabled.

Sweeeet!!!!

How can I getting envolved in the baselayout-2 development?

> Gimme bugs.. I need #'s if I'm going to work toward solving them.

I have a bunch of of them and patches too. I will start reporting them.

> I'd rather not disable vs update bb to conform with what you need.
> Removing our s-s-d for us is very undesirable as long as we have an
> alternative to the current bloated s-s-d. So please give us bugs 
> to work towards solving etc..

I'm not sure I understood. Bugs where use of s-s-d dont work with
busybox s-s-d? They are few. I patched busybox s-s-d to support --chuid
user:group and the problems I had went away.

I think there is still need to fix the verbosity of busybox s-s-d. I
will look at it some day.

> I think Natanael might also become one of your best testers and bug
> reporters. He has been very helpful in the past and I'm sure he will
> continue to be in the future.

Looks like I will :-) My alpinelinux project (distro based on gentoo) is
going pretty well.

> > I'm making it a policy that all init scripts on my local machines have
> > already been changed. Naughty me. I've filed bugs for a few other
> > scripts too. 
> 
> Natanael please search bugzilla for scripts you have noticed in which
> Roy has not already filed bugs. If no bug exists please file one
> (patches attached if you can)

I have a bunch of patches. Will do!

> > So for a desktop it should work off the bat. Not sure if
> > I'll put baselayout-2 on my server right now as it's headless and it's a
> > PITA to get a head to it.
> > 
> > Once baselayout-2 hits portage then we can have a tracker bug.
> > 
> > Thanks
> > 
> > Roy
> > 
> -- 
> Ned Ludd <solar@gentoo.org>
> Gentoo Linux
> 

-- 
gentoo-embedded@gentoo.org mailing list



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

* Re: [gentoo-embedded] init.d scripts and bash
  2007-03-09  9:08     ` Ned Ludd
  2007-03-09 10:06       ` Natanael Copa
@ 2007-03-09 11:51       ` Natanael Copa
       [not found]         ` <20070309115825.52cd9d73@uberlaptop>
  1 sibling, 1 reply; 7+ messages in thread
From: Natanael Copa @ 2007-03-09 11:51 UTC (permalink / raw
  To: gentoo-embedded; +Cc: Roy Marples

On Fri, 2007-03-09 at 01:08 -0800, Ned Ludd wrote:
> On Fri, 2007-03-09 at 07:39 +0000, Roy Marples wrote:

> > baselayout-2 is pure C (except for the init scripts themselves) and is
> > nearing the final stage of development before it enters the tree. It
> > currently works with any shell in portage except for zsh and ksh. It
> > can work with bb provided that some things are disabled.
> 
> Gimme bugs.. I need #'s if I'm going to work toward solving them.

https://bugs.gentoo.org/show_bug.cgi?id=170080
https://bugs.gentoo.org/show_bug.cgi?id=170081
https://bugs.gentoo.org/show_bug.cgi?id=170084
https://bugs.gentoo.org/show_bug.cgi?id=170085
https://bugs.gentoo.org/show_bug.cgi?id=170087
https://bugs.gentoo.org/show_bug.cgi?id=170091
https://bugs.gentoo.org/show_bug.cgi?id=170092
https://bugs.gentoo.org/show_bug.cgi?id=170093

I have some other patches that fixes modprobe issues with openswan and
similar. I don't know if is should post those also.


Thanks!

-- 
gentoo-embedded@gentoo.org mailing list



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

* Re: [gentoo-embedded] init.d scripts and bash
       [not found]         ` <20070309115825.52cd9d73@uberlaptop>
@ 2007-03-09 12:58           ` Natanael Copa
       [not found]             ` <20070309142717.6373940c@uberlaptop.development.ltl>
  0 siblings, 1 reply; 7+ messages in thread
From: Natanael Copa @ 2007-03-09 12:58 UTC (permalink / raw
  To: Roy Marples; +Cc: gentoo-embedded

On Fri, 2007-03-09 at 11:58 +0000, Roy Marples wrote:
> On Fri, 09 Mar 2007 12:51:22 +0100
> Natanael Copa <natanael.copa@gmail.com> wrote:
> 
> > On Fri, 2007-03-09 at 01:08 -0800, Ned Ludd wrote:
> > > On Fri, 2007-03-09 at 07:39 +0000, Roy Marples wrote:
> > 
> > > > baselayout-2 is pure C (except for the init scripts themselves)
> > > > and is nearing the final stage of development before it enters
> > > > the tree. It currently works with any shell in portage except for
> > > > zsh and ksh. It can work with bb provided that some things are
> > > > disabled.
> > > 
> > > Gimme bugs.. I need #'s if I'm going to work toward solving them.
> > 
> > https://bugs.gentoo.org/show_bug.cgi?id=170080
> > https://bugs.gentoo.org/show_bug.cgi?id=170081
> > https://bugs.gentoo.org/show_bug.cgi?id=170084
> > https://bugs.gentoo.org/show_bug.cgi?id=170085
> > https://bugs.gentoo.org/show_bug.cgi?id=170087
> > https://bugs.gentoo.org/show_bug.cgi?id=170091
> > https://bugs.gentoo.org/show_bug.cgi?id=170092
> > https://bugs.gentoo.org/show_bug.cgi?id=170093
> > 
> > I have some other patches that fixes modprobe issues with openswan and
> > similar. I don't know if is should post those also.
> 
> Could you redo your patches to stop using [[ .. ]] and just [ .. ] so
> they work on dash, ash and FreeBSD sh.

oh... Then the amount of needed patches increase dramatically. [[ works
fine in busybox.

# grep '\[\[' /etc/init.d/* | wc -l
535

I just dumped the patches I already have. It will require too much time
to rework them right now but I will do it little by little.

It would be easier for me if you just post a comment in bugzilla for
those who has [[. Then I can fix them one by one.

> Thanks
> 
> Roy

btw... I'm very curious of this baselayout-2. where can I download the
sources?

I have my own baselayout and was almost starting with a rewrite in C.
http://dev.alpinelinux.org/alpine/alpine-baselayout/

Natanael Copa

-- 
gentoo-embedded@gentoo.org mailing list



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

* Re: [gentoo-embedded] init.d scripts and bash
       [not found]             ` <20070309142717.6373940c@uberlaptop.development.ltl>
@ 2007-03-09 15:12               ` Natanael Copa
  0 siblings, 0 replies; 7+ messages in thread
From: Natanael Copa @ 2007-03-09 15:12 UTC (permalink / raw
  To: Roy Marples; +Cc: gentoo-embedded

On Fri, 2007-03-09 at 14:27 +0000, Roy Marples wrote:
> On Fri, 09 Mar 2007 13:58:35 +0100
> Natanael Copa <natanael.copa@gmail.com> wrote:
> > > Could you redo your patches to stop using [[ .. ]] and just [ .. ]
> > > so they work on dash, ash and FreeBSD sh.
> > 
> > oh... Then the amount of needed patches increase dramatically.
> > [[ works fine in busybox.
> 
> No it doesn't
> 
> [[ ${foo} == *foo* && ${blahblah} != 2 ]]
> 
> fails

I noticed that when i did a second review for [[ ]] and have already
uploaded a fix.

#170080, #170081 and #170084 should be ok by now. Will continue when I
get a chance.



-- 
gentoo-embedded@gentoo.org mailing list



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

end of thread, other threads:[~2007-03-09 15:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-08 16:00 [gentoo-embedded] init.d scripts and bash Natanael Copa
2007-03-09  0:00 ` Ned Ludd
     [not found]   ` <20070309073937.154cff79@uberpc.marples.name>
2007-03-09  9:08     ` Ned Ludd
2007-03-09 10:06       ` Natanael Copa
2007-03-09 11:51       ` Natanael Copa
     [not found]         ` <20070309115825.52cd9d73@uberlaptop>
2007-03-09 12:58           ` Natanael Copa
     [not found]             ` <20070309142717.6373940c@uberlaptop.development.ltl>
2007-03-09 15:12               ` Natanael Copa

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