summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch138
1 files changed, 138 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 @@
1Upstream-Status: Inappropriate [OE specific]
2
3Subject: add support for executing scripts under /etc/rcS.d/
4
5To be compatible, all services translated from scripts under /etc/rcS.d would
6run before services translated from scripts under /etc/rcN.d.
7
8Signed-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
13diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
14index 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--
1371.9.1
138