Gentoo Archives: gentoo-embedded

From: Natanael Copa <natanael.copa@×××××.com>
To: gentoo-embedded@l.g.o
Cc: Roy Marples <uberlord@g.o>
Subject: Re: [gentoo-embedded] init.d scripts and bash
Date: Fri, 09 Mar 2007 10:07:52
Message-Id: 1173434811.5390.13.camel@localhost
In Reply to: Re: [gentoo-embedded] init.d scripts and bash by Ned Ludd
1 On Fri, 2007-03-09 at 01:08 -0800, Ned Ludd wrote:
2 > On Fri, 2007-03-09 at 07:39 +0000, Roy Marples wrote:
3 > > On Thu, 08 Mar 2007 16:00:50 -0800
4 > > Ned Ludd <solar@g.o> wrote:
5 > >
6 > > > On Thu, 2007-03-08 at 17:00 +0100, Natanael Copa wrote:
7 > > > > Hi,
8 > > > >
9 > > > > Are there anybody more than me that use the gentoo init.d scripts
10 > > > > without using bash?
11 > > > >
12 > > > > Most init.d scripts runs just fine with a small runscript wrapper.
13 > > > > A few needs patching to work, typically replacing:
14 > > > >
15 > > > > [[ expr || expr ]]
16 > > > >
17 > > > > with:
18 > > > >
19 > > > > [[ expr ]] || [[ expr ]]
20 > >
21 > > Well, not many shells support that either.
22 > > [ expr -o expr ]
23 > > or
24 > > [ expr ] || [ expr]
25 > > should work across the board.
26 > >
27 > > > > But sometimes arrays and such are used (very often its easy to work
28 > > > > around)
29 > >
30 > > Yes it's easy to work around.
31 > > Infact we had a discussion about this on -dev and posted the below
32 > > function
33 > >
34 > > _get_array() {
35 > > if [ -n "${BASH}" ] ; then
36 > > case "$(declare -p "$1" 2>/dev/null)" in
37 > > "declare -a "*)
38 > > echo "set -- \"\${$1[@]}\""
39 > > return
40 > > ;;
41 > > esac
42 > > fi
43 > >
44 > > echo "eval set -- \"\$$1\""
45 > > }
46 > >
47 > > eval "$(_get_array "config_${IFVAR}")"
48 > > for cmd in "$@" ; do
49 > > ...
50 > > done
51 > >
52 > > Which means we can support bash arrays AND a non bash array
53 > > config_eth0=( "one" "t w o" "three" )
54 > > and
55 > > config_eth0="'one' 't w o' 'three'"
56 > >
57 > > > >
58 > > > > Are there any hope for setting a gentoo policy that says bash
59 > > > > specific things should be avoided if possible in init.d scripts?
60 > >
61 > > There's no such policy. Our policy has always been init scripts should
62 > > be parseable by a shell. The shell in question has always been bash
63 > > because
64 > > 1) baselayout-1 requires it
65 > > 2) bash forces itself to be /bin/sh anyway
66 > >
67 > > The lastest bash in the tree no longer enforces it's /bin/sh - instead
68 > > it only creates the link if it does not exist, allowing any shell to be
69 > > used. Yay!
70 >
71 >
72 > Sweet ass sweet...
73 >
74 > I'm sure it will take time to get 99% of the misc remaining bash init
75 > scripts converted over as we find them. If we mostly target server stuff
76 > for now we will be fine..
77 >
78 > > > That is a goal with baselayout-2. I'd be interested if we started a
79 > > > tracker bug for such things. I think policy might be a bit far
80 > > > reaching at this point. But it's for sure a worthwhile goal.
81 > >
82 > > baselayout-2 is pure C (except for the init scripts themselves) and is
83 > > nearing the final stage of development before it enters the tree. It
84 > > currently works with any shell in portage except for zsh and ksh. It
85 > > can work with bb provided that some things are disabled.
86
87 Sweeeet!!!!
88
89 How can I getting envolved in the baselayout-2 development?
90
91 > Gimme bugs.. I need #'s if I'm going to work toward solving them.
92
93 I have a bunch of of them and patches too. I will start reporting them.
94
95 > I'd rather not disable vs update bb to conform with what you need.
96 > Removing our s-s-d for us is very undesirable as long as we have an
97 > alternative to the current bloated s-s-d. So please give us bugs
98 > to work towards solving etc..
99
100 I'm not sure I understood. Bugs where use of s-s-d dont work with
101 busybox s-s-d? They are few. I patched busybox s-s-d to support --chuid
102 user:group and the problems I had went away.
103
104 I think there is still need to fix the verbosity of busybox s-s-d. I
105 will look at it some day.
106
107 > I think Natanael might also become one of your best testers and bug
108 > reporters. He has been very helpful in the past and I'm sure he will
109 > continue to be in the future.
110
111 Looks like I will :-) My alpinelinux project (distro based on gentoo) is
112 going pretty well.
113
114 > > I'm making it a policy that all init scripts on my local machines have
115 > > already been changed. Naughty me. I've filed bugs for a few other
116 > > scripts too.
117 >
118 > Natanael please search bugzilla for scripts you have noticed in which
119 > Roy has not already filed bugs. If no bug exists please file one
120 > (patches attached if you can)
121
122 I have a bunch of patches. Will do!
123
124 > > So for a desktop it should work off the bat. Not sure if
125 > > I'll put baselayout-2 on my server right now as it's headless and it's a
126 > > PITA to get a head to it.
127 > >
128 > > Once baselayout-2 hits portage then we can have a tracker bug.
129 > >
130 > > Thanks
131 > >
132 > > Roy
133 > >
134 > --
135 > Ned Ludd <solar@g.o>
136 > Gentoo Linux
137 >
138
139 --
140 gentoo-embedded@g.o mailing list