From 33d3f33b3ca7dd2ce616b8182d588d0743c2f124 Mon Sep 17 00:00:00 2001 From: Ian Stakenvicius Date: Mon, 26 Oct 2015 15:20:58 -0400 Subject: Implement "want" dependency The want dependency is similar to the use dependency. If a service script, for example called service1, adds "want service2" to its depend function, OpenRC will attempt to start service2, if it exists on the system, when service1 is started. However, service1 will start regardless of the status of service2. X-Gentoo-Bug: 406021 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406021 --- src/librc/librc-depend.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/librc') diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c index d7a8ae14..c9c06ad1 100644 --- a/src/librc/librc-depend.c +++ b/src/librc/librc-depend.c @@ -192,7 +192,9 @@ valid_service(const char *runlevel, const char *service, const char *type) if (!runlevel || strcmp(type, "ineed") == 0 || - strcmp(type, "needsme") == 0) + strcmp(type, "needsme") == 0 || + strcmp(type, "iwant") == 0 || + strcmp(type, "wantsme") == 0) return true; if (rc_service_in_runlevel(service, runlevel)) @@ -543,6 +545,7 @@ rc_deptree_order(const RC_DEPTREE *deptree, const char *runlevel, int options) types = rc_stringlist_new(); rc_stringlist_add(types, "ineed"); rc_stringlist_add(types, "iuse"); + rc_stringlist_add(types, "iwant"); rc_stringlist_add(types, "iafter"); services = rc_deptree_depends(deptree, types, list, runlevel, RC_DEP_STRICT | RC_DEP_TRACE | options); @@ -648,6 +651,7 @@ typedef struct deppair static const DEPPAIR deppairs[] = { { "ineed", "needsme" }, { "iuse", "usesme" }, + { "iwant", "wantsme" }, { "iafter", "ibefore" }, { "ibefore", "iafter" }, { "iprovide", "providedby" }, @@ -844,6 +848,7 @@ rc_deptree_update(void) /* If we're after something, remove us from the before list */ if (strcmp(type, "iafter") == 0 || strcmp(type, "ineed") == 0 || + strcmp(type, "iwant") == 0 || strcmp(type, "iuse") == 0) { if ((dt = get_deptype(depinfo, "ibefore"))) rc_stringlist_delete(dt->services, depend); @@ -957,6 +962,7 @@ rc_deptree_update(void) /* Phase 5 - Remove broken before directives */ types = rc_stringlist_new(); rc_stringlist_add(types, "ineed"); + rc_stringlist_add(types, "iwant"); rc_stringlist_add(types, "iuse"); rc_stringlist_add(types, "iafter"); TAILQ_FOREACH(depinfo, deptree, entries) { -- cgit v1.2.3