Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
7b14481f
Commit
7b14481f
authored
4 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
displays service tree origin for @optsdepends and @extdepends field
parent
3cc0b80e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/html/66-inservice.html
+11
-3
11 additions, 3 deletions
doc/html/66-inservice.html
doc/man/66-inservice.1.scd
+14
-5
14 additions, 5 deletions
doc/man/66-inservice.1.scd
src/66/66-inservice.c
+80
-15
80 additions, 15 deletions
src/66/66-inservice.c
with
105 additions
and
23 deletions
doc/html/66-inservice.html
+
11
−
3
View file @
7b14481f
...
...
@@ -96,10 +96,10 @@
<tt>
depends
</tt>
: displays the
<em>
service's
</em>
dependencies.
</li>
<li>
<tt>
opts
depends
</tt>
: displays the
<em>
service's
</em>
optio
nal dependencies.
<tt>
ext
depends
</tt>
: displays the
<em>
service's
</em>
exter
nal dependencies.
</li>
<li>
<tt>
ext
depends
</tt>
: displays the
<em>
service's
</em>
exter
nal dependencies.
<tt>
opts
depends
</tt>
: displays the
<em>
service's
</em>
optio
nal dependencies.
</li>
<li>
<tt>
start
</tt>
: 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>
...
...
This diff is collapsed.
Click to expand it.
doc/man/66-inservice.1.scd
+
14
−
5
View file @
7b14481f
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/66/66-inservice.c
+
80
−
15
View file @
7b14481f
...
...
@@ -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
=
"
opts
depends"
,
.
svfunc
=
&
info_display_
opts
deps
,
.
id
=
9
},
{
.
str
=
"
ext
depends"
,
.
svfunc
=
&
info_display_
ext
deps
,
.
id
=
10
},
{
.
str
=
"
ext
depends"
,
.
svfunc
=
&
info_display_
ext
deps
,
.
id
=
9
},
{
.
str
=
"
opts
depends"
,
.
svfunc
=
&
info_display_
opts
deps
,
.
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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment