All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Qi <Qi.Chen@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH 09/26] systemd: add support for executing scripts under /etc/rcS.d
Date: Tue, 2 Sep 2014 18:53:55 +0800	[thread overview]
Message-ID: <09976ba7b8afef4bca4ac35d9a66f08bfa98a047.1409655125.git.Qi.Chen@windriver.com> (raw)
In-Reply-To: <cover.1409655125.git.Qi.Chen@windriver.com>

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]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 ...ort-for-executing-scripts-under-etc-rcS.d.patch | 138 +++++++++++++++++++++
 meta/recipes-core/systemd/systemd_216.bb           |   1 +
 2 files changed, 139 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch

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 0000000..9aa07c1
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-add-support-for-executing-scripts-under-etc-rcS.d.patch
@@ -0,0 +1,138 @@
+Upstream-Status: Inappropriate [OE specific]
+
+Subject: add support for executing scripts under /etc/rcS.d/
+
+To be compatible, all services translated from scripts under /etc/rcS.d would
+run before services translated from scripts under /etc/rcN.d.
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/sysv-generator/sysv-generator.c | 50 ++++++++++++++++++++++++++++---------
+ 1 file changed, 38 insertions(+), 12 deletions(-)
+
+diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
+index 9a869ba..10c55c0 100644
+--- a/src/sysv-generator/sysv-generator.c
++++ b/src/sysv-generator/sysv-generator.c
+@@ -43,7 +43,8 @@
+ 
+ typedef enum RunlevelType {
+         RUNLEVEL_UP,
+-        RUNLEVEL_DOWN
++        RUNLEVEL_DOWN,
++        RUNLEVEL_SYSINIT
+ } RunlevelType;
+ 
+ static const struct {
+@@ -58,6 +59,9 @@ static const struct {
+         { "rc4.d",  SPECIAL_RUNLEVEL4_TARGET, RUNLEVEL_UP },
+         { "rc5.d",  SPECIAL_RUNLEVEL5_TARGET, RUNLEVEL_UP },
+ 
++        /* Debian style rcS.d, also adopted by OE */
++        { "rcS.d",  SPECIAL_SYSINIT_TARGET,   RUNLEVEL_SYSINIT},
++
+         /* Standard SysV runlevels for shutdown */
+         { "rc0.d",  SPECIAL_POWEROFF_TARGET,  RUNLEVEL_DOWN },
+         { "rc6.d",  SPECIAL_REBOOT_TARGET,    RUNLEVEL_DOWN }
+@@ -66,7 +70,7 @@ static const struct {
+            directories in this order, and we want to make sure that
+            sysv_start_priority is known when we first load the
+            unit. And that value we only know from S links. Hence
+-           UP must be read before DOWN */
++           UP/SYSINIT must be read before DOWN */
+ };
+ 
+ typedef struct SysvStub {
+@@ -82,6 +86,8 @@ typedef struct SysvStub {
+         char **conflicts;
+         bool has_lsb;
+         bool reload;
++        bool default_dependencies;
++        bool from_rcsd;
+ } SysvStub;
+ 
+ const char *arg_dest = "/tmp";
+@@ -156,6 +162,9 @@ static int generate_unit_file(SysvStub *s) {
+                 "Description=%s\n",
+                 s->path, s->description);
+ 
++        if (!s->default_dependencies)
++                fprintf(f, "DefaultDependencies=no\n");
++
+         if (!isempty(before))
+                 fprintf(f, "Before=%s\n", before);
+         if (!isempty(after))
+@@ -661,18 +670,30 @@ static int fix_order(SysvStub *s, Hashmap *all_services) {
+                 if (s->has_lsb && other->has_lsb)
+                         continue;
+ 
+-                if (other->sysv_start_priority < s->sysv_start_priority) {
+-                        r = strv_extend(&s->after, other->name);
++                /* All scripts under /etc/rcS.d should execute before scripts under
++                 * /etc/rcN.d */
++                if (!other->from_rcsd && s->from_rcsd) {
++                        r = strv_extend(&s->before, other->name);
+                         if (r < 0)
+                                 return log_oom();
+-                }
+-                else if (other->sysv_start_priority > s->sysv_start_priority) {
+-                        r = strv_extend(&s->before, other->name);
++                } else if (other->from_rcsd && !s->from_rcsd) {
++                        r = strv_extend(&s->after, other->name);
+                         if (r < 0)
+                                 return log_oom();
+-                }
+-                else
+-                        continue;
++                } else {
++                        if (other->sysv_start_priority < s->sysv_start_priority) {
++                                r = strv_extend(&s->after, other->name);
++                                if (r < 0)
++                                        return log_oom();
++                        }
++                        else if (other->sysv_start_priority > s->sysv_start_priority) {
++                                r = strv_extend(&s->before, other->name);
++                                if (r < 0)
++                                        return log_oom();
++                        }
++                        else
++                                continue;
++                 }
+ 
+                 /* FIXME: Maybe we should compare the name here lexicographically? */
+         }
+@@ -725,6 +746,8 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
+                                 return log_oom();
+ 
+                         service->sysv_start_priority = -1;
++                        service->default_dependencies = true;
++                        service->from_rcsd = false;
+                         service->name = name;
+                         service->path = fpath;
+ 
+@@ -810,9 +833,11 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
+ 
+                                 if (de->d_name[0] == 'S')  {
+ 
+-                                        if (rcnd_table[i].type == RUNLEVEL_UP) {
++                                        if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) {
+                                                 service->sysv_start_priority =
+                                                         MAX(a*10 + b, service->sysv_start_priority);
++                                                service->default_dependencies = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?false:true;
++                                                service->from_rcsd = (rcnd_table[i].type == RUNLEVEL_SYSINIT)?true:false;
+                                         }
+ 
+                                         r = set_ensure_allocated(&runlevel_services[i],
+@@ -825,7 +850,8 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
+                                                 goto finish;
+ 
+                                 } else if (de->d_name[0] == 'K' &&
+-                                           (rcnd_table[i].type == RUNLEVEL_DOWN)) {
++                                           (rcnd_table[i].type == RUNLEVEL_DOWN ||
++                                            rcnd_table[i].type == RUNLEVEL_SYSINIT)) {
+ 
+                                         r = set_ensure_allocated(&shutdown_services,
+                                                                  trivial_hash_func, trivial_compare_func);
+-- 
+1.9.1
+
diff --git a/meta/recipes-core/systemd/systemd_216.bb b/meta/recipes-core/systemd/systemd_216.bb
index 8fc79e4..776006f 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=
            file://optional_secure_getenv.patch \
            file://uclibc-sysinfo_h.patch \
            file://uclibc-get-physmem.patch \
+           file://0001-add-support-for-executing-scripts-under-etc-rcS.d.patch \
            file://0001-missing.h-add-fake-__NR_memfd_create-for-MIPS.patch \
            file://touchscreen.rules \
            file://00-create-volatile.conf \
-- 
1.9.1



  parent reply	other threads:[~2014-09-02 10:54 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02 10:53 [PATCH 00/26] systemd upgrade to 216 and other misc fixes Chen Qi
2014-09-02 10:53 ` [PATCH 01/26] systemd: upgrade to 216 Chen Qi
2014-09-04 19:30   ` Peter A. Bigot
2014-09-04 19:37     ` Burton, Ross
2014-09-05 10:21     ` Enrico Scholz
2014-09-08 17:02       ` Burton, Ross
2014-09-02 10:53 ` [PATCH 02/26] systemd: add PACKAGECONFIG for curl Chen Qi
2014-09-02 14:59   ` Burton, Ross
2014-09-03  2:38     ` ChenQi
2014-09-02 10:53 ` [PATCH 03/26] systemd: make runlevel work in non-runlevel targets Chen Qi
2014-09-02 10:53 ` [PATCH 04/26] update-rc.d: fix logic in populate_packages_updatercd Chen Qi
2014-09-02 10:53 ` [PATCH 05/26] alsa-state: fix pkg_postinst and set INHIBIT_UPDATERCD_BBCLASS Chen Qi
2014-09-02 10:53 ` [PATCH 06/26] keymaps: fix for systemd Chen Qi
2014-09-02 10:53 ` [PATCH 07/26] systemd: add kbd-keymaps to RRECOMMENDS of systemd-vconsole-setup Chen Qi
2014-09-02 10:53 ` [PATCH 08/26] v86d: set INHIBIT_UPDATERCD_BBCLASS if 'sysvinit' not in DISTRO_FEATURES Chen Qi
2014-09-02 10:53 ` Chen Qi [this message]
2014-09-02 15:00   ` [PATCH 09/26] systemd: add support for executing scripts under /etc/rcS.d Burton, Ross
2014-09-03  2:38     ` ChenQi
2014-09-02 10:53 ` [PATCH 10/26] dhcp: add dhcpd.service Chen Qi
2014-09-02 15:03   ` Burton, Ross
2014-09-03  2:39     ` ChenQi
2014-09-02 10:53 ` [PATCH 11/26] dhcp: add dhcrelay.service Chen Qi
2014-09-02 10:53 ` [PATCH 12/26] acpid: upgrade to 2.0.22 and add systemd support Chen Qi
2014-09-02 15:24   ` Burton, Ross
2014-09-03  2:39     ` ChenQi
2014-09-02 10:53 ` [PATCH 13/26] cups: make cups daemon start correctly Chen Qi
2014-09-02 15:36   ` Burton, Ross
2014-09-03  2:41     ` ChenQi
2014-09-02 10:54 ` [PATCH 14/26] cups: add systemd support Chen Qi
2014-09-02 15:38   ` Burton, Ross
2014-09-03  3:01     ` ChenQi
2014-09-02 10:54 ` [PATCH 15/26] rpcbind: avoid entering failed status after stopping daemon Chen Qi
2014-09-02 10:54 ` [PATCH 16/26] at: remove dependency on initscripts Chen Qi
2014-09-02 10:54 ` [PATCH 17/26] at: inherit update-rc.d to handle sysv init script Chen Qi
2014-09-02 10:54 ` [PATCH 18/26] keymaps: remove dependency on initscripts Chen Qi
2014-09-02 10:54 ` [PATCH 19/26] packagegroup-core-boot: conditionally rdepend on VIRTUAL-RUNTIME_initscripts Chen Qi
2014-09-02 10:54 ` [PATCH 20/26] initscripts: mask several init scripts Chen Qi
2014-09-02 10:54 ` [PATCH 21/26] keymaps: mask keymap when necessary Chen Qi
2014-09-02 10:54 ` [PATCH 22/26] v86d: mask fbsetup " Chen Qi
2014-09-02 10:54 ` [PATCH 23/26] psplash: mask psplash in case of systemd Chen Qi
2014-09-02 10:54 ` [PATCH 24/26] modutils-initscripts: mask modutils " Chen Qi
2014-09-02 10:54 ` [PATCH 25/26] run-postinsts.service: remove redundant line Chen Qi
2014-09-02 17:17   ` Burton, Ross
2014-09-03  2:50     ` ChenQi
2014-09-02 10:54 ` [PATCH 26/26] systemd: enable forwarding messages to syslog daemon Chen Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09976ba7b8afef4bca4ac35d9a66f08bfa98a047.1409655125.git.Qi.Chen@windriver.com \
    --to=qi.chen@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.