chiark / gitweb /
sysv: properly handle Provides LSB header
authorLennart Poettering <lennart@poettering.net>
Thu, 1 Apr 2010 19:30:40 +0000 (21:30 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Apr 2010 19:30:40 +0000 (21:30 +0200)
service.c
unit.c
unit.h

index 149a791b05f62a8ca76b3a7c732a90f88c8c75ef..1aeb5fbf2b637cec04661b081500db891f8bc26e 100644 (file)
--- a/service.c
+++ b/service.c
@@ -370,7 +370,13 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         if (r == 0)
                                                 continue;
 
-                                        r = unit_add_name(u, m);
+                                        if (unit_name_to_type(m) == UNIT_SERVICE)
+                                                r = unit_add_name(u, m);
+                                        else {
+                                                if ((r = unit_add_dependency_by_name_inverse(u, UNIT_REQUIRES, m)) >= 0)
+                                                        r = unit_add_dependency_by_name(u, UNIT_BEFORE, m);
+                                        }
+
                                         free(m);
 
                                         if (r < 0)
@@ -568,7 +574,7 @@ static int service_init(Unit *u) {
                 return r;
         }
 
-        /* Load a classic init script as a fallback, if we couldn*t find anything */
+        /* Load a classic init script as a fallback, if we couldn't find anything */
         if (r == 0)
                 if ((r = service_load_sysv(s)) <= 0) {
                         service_done(u);
diff --git a/unit.c b/unit.c
index 673aac184f671a5ca5767f4e166afb787bc1a7d8..036c01648c6e017ee4d832e67d74a20e1c359fe9 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -978,6 +978,19 @@ int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name) {
         return 0;
 }
 
+int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name) {
+        Unit *other;
+        int r;
+
+        if ((r = manager_load_unit(u->meta.manager, name, &other)) < 0)
+                return r;
+
+        if ((r = unit_add_dependency(other, d, u)) < 0)
+                return r;
+
+        return 0;
+}
+
 int set_unit_path(const char *p) {
         char *cwd, *c;
         int r;
diff --git a/unit.h b/unit.h
index 4b3b6fb644a9006dc19455bfa2295bd225f3e842..df8f2a208a6881c25f0824d9a26a15e1019d8b67 100644 (file)
--- a/unit.h
+++ b/unit.h
@@ -249,6 +249,7 @@ void unit_free(Unit *u);
 int unit_add_name(Unit *u, const char *name);
 int unit_add_dependency(Unit *u, UnitDependency d, Unit *other);
 int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name);
+int unit_add_dependency_by_name_inverse(Unit *u, UnitDependency d, const char *name);
 
 int unit_add_cgroup(Unit *u, CGroupBonding *b);
 int unit_add_cgroup_from_text(Unit *u, const char *name);