diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2014-09-03 15:09:06 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-09-03 11:09:05 +0100 |
commit | 198ed4b5bb11ea045b69523abb9244bd8d5df465 (patch) | |
tree | 69d48df7ded351577435cb44c4a92d03bd2e3da9 /meta | |
parent | c39e2632ff65d505215fdb9b91058cd80ae3e49c (diff) | |
download | poky-198ed4b5bb11ea045b69523abb9244bd8d5df465.tar.gz |
systemd: add support for executing scripts under /etc/rcS.d
This patch adds support for systemd to execute scripts under /etc/rcS.d.
To be compitable, all services translated from /etc/rcS.d/ scripts would
run before services translated from /etc/rcN.d scripts.
[YOCTO #5159]
(From OE-Core rev: 90bb8e8f9bc2454590d230b209fc749ea7270b9e)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch | 138 | ||||
-rw-r--r-- | meta/recipes-core/systemd/systemd_216.bb | 1 |
2 files changed, 139 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch b/meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch new file mode 100644 index 0000000000..9aa07c1b10 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch | |||
@@ -0,0 +1,138 @@ | |||
1 | Upstream-Status: Inappropriate [OE specific] | ||
2 | |||
3 | Subject: add support for executing scripts under /etc/rcS.d/ | ||
4 | |||
5 | To be compatible, all services translated from scripts under /etc/rcS.d would | ||
6 | run before services translated from scripts under /etc/rcN.d. | ||
7 | |||
8 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
9 | --- | ||
10 | src/sysv-generator/sysv-generator.c | 50 ++++++++++++++++++++++++++++--------- | ||
11 | 1 file changed, 38 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c | ||
14 | index 9a869ba..10c55c0 100644 | ||
15 | --- a/src/sysv-generator/sysv-generator.c | ||
16 | +++ b/src/sysv-generator/sysv-generator.c | ||
17 | @@ -43,7 +43,8 @@ | ||
18 | |||
19 | typedef enum RunlevelType { | ||
20 | RUNLEVEL_UP, | ||
21 | - RUNLEVEL_DOWN | ||
22 | + RUNLEVEL_DOWN, | ||
23 | + RUNLEVEL_SYSINIT | ||
24 | } RunlevelType; | ||
25 | |||
26 | static const struct { | ||
27 | @@ -58,6 +59,9 @@ static const struct { | ||
28 | { "rc4.d", SPECIAL_RUNLEVEL4_TARGET, RUNLEVEL_UP }, | ||
29 | { "rc5.d", SPECIAL_RUNLEVEL5_TARGET, RUNLEVEL_UP }, | ||
30 | |||
31 | + /* Debian style rcS.d, also adopted by OE */ | ||
32 | + { "rcS.d", SPECIAL_SYSINIT_TARGET, RUNLEVEL_SYSINIT}, | ||
33 | + | ||
34 | /* Standard SysV runlevels for shutdown */ | ||
35 | { "rc0.d", SPECIAL_POWEROFF_TARGET, RUNLEVEL_DOWN }, | ||
36 | { "rc6.d", SPECIAL_REBOOT_TARGET, RUNLEVEL_DOWN } | ||
37 | @@ -66,7 +70,7 @@ static const struct { | ||
38 | directories in this order, and we want to make sure that | ||
39 | sysv_start_priority is known when we first load the | ||
40 | unit. And that value we only know from S links. Hence | ||
41 | - UP must be read before DOWN */ | ||
42 | + UP/SYSINIT must be read before DOWN */ | ||
43 | }; | ||
44 | |||
45 | typedef struct SysvStub { | ||
46 | @@ -82,6 +86,8 @@ typedef struct SysvStub { | ||
47 | char **conflicts; | ||
48 | bool has_lsb; | ||
49 | bool reload; | ||
50 | + bool default_dependencies; | ||
51 | + bool from_rcsd; | ||
52 | } SysvStub; | ||
53 | |||
54 | const char *arg_dest = "/tmp"; | ||
55 | @@ -156,6 +162,9 @@ static int generate_unit_file(SysvStub *s) { | ||
56 | "Description=%s\n", | ||
57 | s->path, s->description); | ||
58 | |||
59 | + if (!s->default_dependencies) | ||
60 | + fprintf(f, "DefaultDependencies=no\n"); | ||
61 | + | ||
62 | if (!isempty(before)) | ||
63 | fprintf(f, "Before=%s\n", before); | ||
64 | if (!isempty(after)) | ||
65 | @@ -661,18 +670,30 @@ static int fix_order(SysvStub *s, Hashmap *all_services) { | ||
66 | if (s->has_lsb && other->has_lsb) | ||
67 | continue; | ||
68 | |||
69 | - if (other->sysv_start_priority < s->sysv_start_priority) { | ||
70 | - r = strv_extend(&s->after, other->name); | ||
71 | + /* All scripts under /etc/rcS.d should execute before scripts under | ||
72 | + * /etc/rcN.d */ | ||
73 | + if (!other->from_rcsd && s->from_rcsd) { | ||
74 | + r = strv_extend(&s->before, other->name); | ||
75 | if (r < 0) | ||
76 | return log_oom(); | ||
77 | - } | ||
78 | - else if (other->sysv_start_priority > s->sysv_start_priority) { | ||
79 | - r = strv_extend(&s->before, other->name); | ||
80 | + } else if (other->from_rcsd && !s->from_rcsd) { | ||
81 | + r = strv_extend(&s->after, other->name); | ||
82 | if (r < 0) | ||
83 | return log_oom(); | ||
84 | - } | ||
85 | - else | ||
86 | - continue; | ||
87 | + } else { | ||
88 | + if (other->sysv_start_priority < s->sysv_start_priority) { | ||
89 | + r = strv_extend(&s->after, other->name); | ||
90 | + if (r < 0) | ||
91 | + return log_oom(); | ||
92 | + } | ||
93 | + else if (other->sysv_start_priority > s->sysv_start_priority) { | ||
94 | + r = strv_extend(&s->before, other->name); | ||
95 | + if (r < 0) | ||
96 | + return log_oom(); | ||
97 | + } | ||
98 | + else | ||
99 | + continue; | ||
100 | + } | ||
101 | |||
102 | /* FIXME: Maybe we should compare the name here lexicographically? */ | ||
103 | } | ||
104 | @@ -725,6 +746,8 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) { | ||
105 | return log_oom(); | ||
106 | |||
107 | service->sysv_start_priority = -1; | ||
108 | + service->default_dependencies = true; | ||
109 | + service->from_rcsd = false; | ||
110 | service->name = name; | ||
111 | service->path = fpath; | ||
112 | |||
113 | @@ -810,9 +833,11 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) { | ||
114 | |||
115 | if (de->d_name[0] == 'S') { | ||
116 | |||
117 | - if (rcnd_table[i].type == RUNLEVEL_UP) { | ||
118 | + if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) { | ||
119 | service->sysv_start_priority = | ||
120 | MAX(a*10 + b, service->sysv_start_priority); | ||
121 | + service->default_dependencies = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?false:true; | ||
122 | + service->from_rcsd = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?true:false; | ||
123 | } | ||
124 | |||
125 | r = set_ensure_allocated(&runlevel_services[i], | ||
126 | @@ -825,7 +850,8 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) { | ||
127 | goto finish; | ||
128 | |||
129 | } else if (de->d_name[0] == 'K' && | ||
130 | - (rcnd_table[i].type == RUNLEVEL_DOWN)) { | ||
131 | + (rcnd_table[i].type == RUNLEVEL_DOWN || | ||
132 | + rcnd_table[i].type == RUNLEVEL_SYSINIT)) { | ||
133 | |||
134 | r = set_ensure_allocated(&shutdown_services, | ||
135 | trivial_hash_func, trivial_compare_func); | ||
136 | -- | ||
137 | 1.9.1 | ||
138 | |||
diff --git a/meta/recipes-core/systemd/systemd_216.bb b/meta/recipes-core/systemd/systemd_216.bb index 5f7deafec4..929b8aef25 100644 --- a/meta/recipes-core/systemd/systemd_216.bb +++ b/meta/recipes-core/systemd/systemd_216.bb | |||
@@ -30,6 +30,7 @@ SRC_URI = "git://anongit.freedesktop.org/systemd/systemd;branch=master;protocol= | |||
30 | file://optional_secure_getenv.patch \ | 30 | file://optional_secure_getenv.patch \ |
31 | file://uclibc-sysinfo_h.patch \ | 31 | file://uclibc-sysinfo_h.patch \ |
32 | file://uclibc-get-physmem.patch \ | 32 | file://uclibc-get-physmem.patch \ |
33 | file://0001-add-support-for-executing-scripts-under-etc-rcS.d.patch \ | ||
33 | file://0001-missing.h-add-fake-__NR_memfd_create-for-MIPS.patch \ | 34 | file://0001-missing.h-add-fake-__NR_memfd_create-for-MIPS.patch \ |
34 | file://touchscreen.rules \ | 35 | file://touchscreen.rules \ |
35 | file://00-create-volatile.conf \ | 36 | file://00-create-volatile.conf \ |