Gentoo Archives: gentoo-dev

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Detecting Baselayout2/OpenRC from init.d scripts (summary of debate and plans from bug 270646)
Date: Sun, 07 Jun 2009 22:33:15
Message-Id: 20090607223308.GJ22927@orbis-terrarum.net
In Reply to: Re: [gentoo-dev] Detecting Baselayout2/OpenRC from init.d scripts (summary of debate and plans from bug 270646) by Josh Saddler
1 On Sun, Jun 07, 2009 at 01:45:15PM -0700, Josh Saddler wrote:
2 > Then, my fellow developers, ya'll need to tell us exactly what needs to
3 > change. That has not yet happened on the bugs, just a lot of offtopic
4 > discussion relevant to the package maintainers, but not to the GDP for
5 > documentation purposes. Just because there's lots of chatter on e.g.
6 > http://bugs.gentoo.org/show_bug.cgi?id=270646 doesn't mean that the GDP
7 > has any idea of how to proceed.
8 The final decision was pretty clear I thought, but I've written out the text of
9 what you need to add, so that you can add it ASAP to the documentation.
10
11 In handbook section "4.d. Writing Init Scripts", please add a link to the
12 OpenRC migration document. Alternatively, add everything below to the 4.d
13 block, and a link BACK from the OpenRC migration document to the portion of the
14 handbook.
15
16 The following goes into openrc-migration.xml:
17 Add a new toplevel L1 block, after the 'Finishing Up' L2 block:
18
19 =============
20
21 <h1>Converting init.d scripts</h1>
22 <note>
23 This section is intended primarily for developers, but is also relevant to
24 anybody with custom init.d scripts.
25 </note>
26 <h2>Detecting OpenRC</h2>
27 <p>
28 If your init.d script needs to detect being run under OpenRC specifically to
29 perform different actions, you are strongly encourage to use the following as
30 the means of detecting OpenRC:
31 </p>
32 <code description="OpenRC detection test, transitional">
33 [[ -f /lib/librc.so -o -f /etc/init.d/sysfs -o -f /libexec/rc/version ]]
34 </code>
35
36 <code description="Example usage">
37 depend() {
38 if [[ -f /lib/librc.so -o -f /etc/init.d/sysfs -o -f /libexec/rc/version ]]; then
39 need sysfs
40 fi
41 }
42 start() {
43 echo foobar >/sys/...
44 }
45 </code>
46
47 <p>
48 After $DATE [1], the official detection test will be:
49 </p>
50 <code description="OpenRC detection test, final">
51 [[ -f /libexec/rc/version ]]
52 </code>
53 <h2>Detecting the OpenRC version</h2>
54 <p>
55 If you need to know the exact version of OpenRC, you should RDEPEND on the
56 minimum version, and then read the file as follows:
57 </p>
58 <code description="OpenRC version query">
59 read version </libexec/rc/version
60 </code>
61
62 =============
63 I've just put $DATE in here since we don't know when yet.
64
65 --
66 Robin Hugh Johnson
67 Gentoo Linux Developer & Infra Guy
68 E-Mail : robbat2@g.o
69 GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85

Replies