From: Frederic Crozat Date: Fri, 12 Apr 2013 16:56:26 +0200 Subject: Revert "service: drop support for SysV scripts for the early boot" This reverts commit 3cdebc217c42c8529086f2965319b6a48eaaeabe. [Implementation note: currently, the unit is generated, but not activated even if symlinks exist in boot.d. Hmmm... -jengelh@inai.de] --- src/sysv-generator/sysv-generator.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) --- systemd-219.orig/src/sysv-generator/sysv-generator.c +++ systemd-219/src/sysv-generator/sysv-generator.c @@ -42,7 +42,8 @@ typedef enum RunlevelType { RUNLEVEL_UP, - RUNLEVEL_DOWN + RUNLEVEL_DOWN, + RUNLEVEL_SYSINIT, } RunlevelType; static const struct { @@ -50,6 +51,9 @@ static const struct { const char *target; const RunlevelType type; } rcnd_table[] = { + /* SUSE style boot.d */ + { "boot.d", SPECIAL_SYSINIT_TARGET, RUNLEVEL_SYSINIT }, + /* Standard SysV runlevels for start-up */ { "rc1.d", SPECIAL_RESCUE_TARGET, RUNLEVEL_UP }, { "rc2.d", SPECIAL_RUNLEVEL2_TARGET, RUNLEVEL_UP }, @@ -65,7 +69,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 { @@ -83,7 +87,7 @@ typedef struct SysvStub { bool reload; } SysvStub; -const char *arg_dest = "/tmp"; +static const char *arg_dest = "/tmp"; static int add_symlink(const char *service, const char *where) { _cleanup_free_ char *from = NULL, *to = NULL; @@ -235,6 +239,10 @@ static bool usage_contains_reload(const static char *sysv_translate_name(const char *name) { char *r; + if (startswith(name, "boot.")) + /* Drop SuSE-style boot. prefix */ + name += 5; + r = new(char, strlen(name) + strlen(".service") + 1); if (!r) return NULL; @@ -864,10 +872,10 @@ static int set_dependencies_from_rcnd(Lo 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); - } r = set_ensure_allocated(&runlevel_services[i], NULL); if (r < 0) @@ -878,7 +886,8 @@ static int set_dependencies_from_rcnd(Lo 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, NULL); if (r < 0)