Skip to content
Snippets Groups Projects
Commit 7b14481f authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

displays service tree origin for @optsdepends and @extdepends field

parent 3cc0b80e
No related branches found
No related tags found
No related merge requests found
......@@ -96,10 +96,10 @@
<tt>depends</tt>&nbsp;: displays the <em>service's</em> dependencies.
</li>
<li>
<tt>optsdepends</tt>&nbsp;: displays the <em>service's</em> optional dependencies.
<tt>extdepends</tt>&nbsp;: displays the <em>service's</em> external dependencies.
</li>
<li>
<tt>extdepends</tt>&nbsp;: displays the <em>service's</em> external dependencies.
<tt>optsdepends</tt>&nbsp;: displays the <em>service's</em> optional dependencies.
</li>
<li>
<tt>start</tt>&nbsp;: displays the <em>service's</em> start script.
......@@ -138,8 +138,8 @@
Live : %%livedir%%/tree/0/boot/servicedirs/00
Dependencies : system-hostname mount-run populate-run mount-tmp populate-tmp mount-proc mount-sys
populate-sys mount-dev mount-pts mount-shm populate-dev mount-cgroups
Optional dependencies : None
External dependencies : None
Optional dependencies : None
Start script : None
Stop script : None
Environment source : None
......@@ -149,6 +149,14 @@
Log file : None
</pre>
</p>
<br>
<p>
<b>Note</b>: the <em>Optional dependencies</em> and <em>External dependencies</em> also displays the name of the tree where the service is currently enabled after the <tt>colon(:)</tt> mark if any:
<pre>
External dependencies : dbus-session@obarun:base gvfsd:desktop
Optional dependencies : picom@obarun:desktop
</pre>
</p>
<p>
By default the dependency graph is rendered in the order of execution. In this example the <em>'oneshot' system-hostname</em> is the first executed
service and <em>'oneshot' mount-cgroups</em> is the last one when it finishes. You can reverse the rendered order with the <tt>-r</tt> option.</p>
......
......@@ -78,12 +78,12 @@
*depends*
Displays the _service_'s dependencies.
*optsdepends*
Displays the _service_'s optional dependencies.
*extdepends*
Displays the _service_'s external dependencies.
*optsdepends*
Displays the _service_'s optional dependencies.
*start*
Displays the _service_'s start script.
......@@ -122,8 +122,8 @@ Dependencies : system-hostname mount-run populate-run mount-tmp
populate-tmp mount-proc mount-sys populate-sys
mount-dev mount-pts mount-shm populate-dev
mount-cgroups
Optional dependencies : None
External dependencies : None
Optional dependencies : None
Start script : None
Stop script : None
Environment source : None
......@@ -131,7 +131,16 @@ Environment file : None
Log name : None
Log destination : None
Log file : None
```
*Note*: the *Optional dependencies* and *External dependencies* also displays
the name of the tree where the service is currently enabled after the *colon(:)* mark if any:
```
External dependencies : dbus-session@obarun:base gvfsd:desktop
Optional dependencies : picom@obarun:desktop
```
By default the dependency graph is rendered in the order of execution. In
......
......@@ -52,6 +52,7 @@ static unsigned int GRAPH = 0 ;
static char const *const *ENVP ;
static unsigned int nlog = 20 ;
static stralloc src = STRALLOC_ZERO ;
static stralloc home = STRALLOC_ZERO ;// /var/lib/66/system or ${HOME}/system
static wchar_t const field_suffix[] = L" :" ;
static char fields[INFO_NKEY][INFO_FIELD_MAXLEN] = {{ 0 }} ;
......@@ -88,8 +89,8 @@ info_opts_map_t const opts_sv_table[] =
{ .str = "source", .svfunc = &info_display_source, .id = 6 },
{ .str = "live", .svfunc = &info_display_live, .id = 7 },
{ .str = "depends", .svfunc = &info_display_deps, .id = 8 },
{ .str = "optsdepends", .svfunc = &info_display_optsdeps, .id = 9 },
{ .str = "extdepends", .svfunc = &info_display_extdeps, .id = 10 },
{ .str = "extdepends", .svfunc = &info_display_extdeps, .id = 9 },
{ .str = "optsdepends", .svfunc = &info_display_optsdeps, .id = 10 },
{ .str = "start", .svfunc = &info_display_start, .id = 11 },
{ .str = "stop", .svfunc = &info_display_stop, .id = 12 },
{ .str = "envat", .svfunc = &info_display_envat, .id = 13 },
......@@ -134,8 +135,8 @@ static inline void info_help (void)
" source: displays the source of the service's frontend file\n"
" live: displays the service's live directory\n"
" depends: displays the service's dependencies\n"
" optsdepends: displays the service's optional dependencies\n"
" extdepends: displays the service's external dependencies\n"
" optsdepends: displays the service's optional dependencies\n"
" start: displays the service's start script\n"
" stop: displays the service's stop script\n"
" envat: displays the source of the environment file\n"
......@@ -410,27 +411,83 @@ static void info_display_deps(char const *field, ss_resolve_t *res)
stralloc_free(&salist) ;
}
static void info_display_with_source_tree(stralloc *list,ss_resolve_t *res)
{
size_t pos = 0, lpos = 0, newlen = 0 ;
stralloc svlist = STRALLOC_ZERO ;
stralloc ntree = STRALLOC_ZERO ;
stralloc src = STRALLOC_ZERO ;
stralloc tmp = STRALLOC_ZERO ;
char *treename = 0 ;
if (!auto_stra(&src,home.s)) log_die_nomem("stralloc") ;
newlen = src.len ;
if (!sastr_dir_get(&ntree,home.s,SS_BACKUP + 1,S_IFDIR))
log_dieu(LOG_EXIT_SYS,"get list of trees of: ",home.s) ;
for (pos = 0 ; pos < ntree.len ; pos += strlen(ntree.s + pos) + 1)
{
svlist.len = 0 ;
src.len = newlen ;
treename = ntree.s + pos ;
if (!auto_stra(&src,treename,SS_SVDIRS,SS_RESOLVE))
log_die_nomem("stralloc") ;
if (!sastr_dir_get(&svlist,src.s,SS_MASTER + 1,S_IFREG))
log_dieu(LOG_EXIT_SYS,"get contents of tree: ",src.s) ;
for (lpos = 0 ; lpos < list->len ; lpos += strlen(list->s + lpos) + 1)
{
char *name = list->s + lpos ;
if (sastr_cmp(&svlist,name) >= 0)
{
if (!stralloc_cats(&tmp,name) ||
!stralloc_cats(&tmp,":") ||
!stralloc_catb(&tmp,treename,strlen(treename) +1))
log_die_nomem("stralloc") ;
}
}
}
list->len = 0 ;
for (pos = 0 ; pos < tmp.len ; pos += strlen(tmp.s + pos) + 1)
if (!stralloc_catb(list,tmp.s + pos,strlen(tmp.s + pos) + 1))
log_die_nomem("stralloc") ;
stralloc_free (&svlist) ;
stralloc_free (&ntree) ;
stralloc_free (&src) ;
stralloc_free (&tmp) ;
}
static void info_display_optsdeps(char const *field, ss_resolve_t *res)
{
stralloc salist = STRALLOC_ZERO ;
if (NOFIELD) info_display_field_name(field) ;
else field = 0 ;
if (!res->noptsdeps) goto empty ;
if (!sastr_clean_string(&salist,res->sa.s + res->optsdeps))
log_dieu(LOG_EXIT_SYS,"build dependencies list") ;
info_display_with_source_tree(&salist,res) ;
if (REVERSE)
if (!sastr_reverse(&salist))
log_dieu(LOG_EXIT_SYS,"reverse dependencies list") ;
info_display_list(field,&salist) ;
goto freed ;
empty:
if (!bprintf(buffer_1,"%s%s%s\n",log_color->warning,"None",log_color->off))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
freed:
stralloc_free(&salist) ;
}
......@@ -438,24 +495,29 @@ static void info_display_optsdeps(char const *field, ss_resolve_t *res)
static void info_display_extdeps(char const *field, ss_resolve_t *res)
{
stralloc salist = STRALLOC_ZERO ;
if (NOFIELD) info_display_field_name(field) ;
else field = 0 ;
if (!res->nextdeps) goto empty ;
if (!sastr_clean_string(&salist,res->sa.s + res->extdeps))
log_dieu(LOG_EXIT_SYS,"build dependencies list") ;
info_display_with_source_tree(&salist,res) ;
if (REVERSE)
if (!sastr_reverse(&salist))
log_dieu(LOG_EXIT_SYS,"reverse dependencies list") ;
info_display_list(field,&salist) ;
goto freed ;
empty:
if (!bprintf(buffer_1,"%s%s%s\n",log_color->warning,"None",log_color->off))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
freed:
stralloc_free(&salist) ;
}
......@@ -697,8 +759,8 @@ int main(int argc, char const *const *argv, char const *const *envp)
"Source",
"Live",
"Dependencies",
"Optional dependencies" ,
"External dependencies" ,
"Optional dependencies" ,
"Start script",
"Stop script",
"Environment source",
......@@ -763,7 +825,7 @@ int main(int argc, char const *const *argv, char const *const *envp)
if (!stralloc_cats(&src,SS_SYSTEM) ||
!stralloc_0(&src)) log_die_nomem("stralloc") ;
src.len-- ;
if (!scan_mode(src.s,S_IFDIR))
{
log_info("no tree exist yet") ;
......@@ -772,6 +834,8 @@ int main(int argc, char const *const *argv, char const *const *envp)
if (!stralloc_cats(&src,"/")) log_die_nomem("stralloc") ;
newlen = src.len ;
if (!stralloc_copy(&home,&src) ||
!stralloc_0(&home)) log_die_nomem("stralloc") ;
if (!tname)
{
......@@ -839,6 +903,7 @@ int main(int argc, char const *const *argv, char const *const *envp)
freed:
ss_resolve_free(&res) ;
stralloc_free(&src) ;
stralloc_free(&home) ;
stralloc_free(&satree) ;
return 0 ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment