Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Anders Blomdell
mio
Commits
184f4025
Commit
184f4025
authored
4 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Add dependency check
parent
00e855d9
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mio.py
+14
-1
14 additions, 1 deletion
src/mio.py
src/mio/analyze.py
+74
-0
74 additions, 0 deletions
src/mio/analyze.py
src/mio/util.py
+21
-0
21 additions, 0 deletions
src/mio/util.py
with
109 additions
and
1 deletion
src/mio.py
+
14
−
1
View file @
184f4025
...
...
@@ -8,6 +8,7 @@ import mio.transform
import
mio.parser
import
mio.repository
import
mio.node
import
mio.analyze
import
argparse
import
os
import
os.path
...
...
@@ -182,6 +183,10 @@ if __name__ == '__main__':
action
=
"
append
"
,
nargs
=
'
*
'
,
default
=
None
,
metavar
=
"
TARGET
"
,
help
=
"
print dependency tree for TARGET
"
)
optParser
.
add_argument
(
"
--dependency-check
"
,
action
=
"
append
"
,
nargs
=
'
*
'
,
default
=
None
,
metavar
=
"
TARGET
"
,
help
=
"
check dependencies for TARGET
"
)
optParser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
action
=
"
count
"
,
dest
=
"
verbose
"
,
default
=
0
,
...
...
@@ -310,6 +315,14 @@ if __name__ == '__main__':
pass
pass
if
options
.
dependency_check
!=
None
:
# Flatten list
targets
=
[
i
for
l
in
options
.
dependency_check
for
i
in
l
]
if
len
(
targets
)
==
0
:
tree
=
parse
(
'
hostinfo.xml
'
)
targets
=
[
h
.
name
[
0
]
for
h
in
tree
.
_group_
]
mio
.
analyze
.
dependency_check
(
rules
,
options
,
targets
)
if
options
.
dependency_tree
!=
None
:
def
dump_tree
(
name
,
indent
=
0
):
def
command_or_script
(
cos
,
prefix
=
''
):
...
...
@@ -317,7 +330,6 @@ if __name__ == '__main__':
print
(
"
%s [%s command] %s
"
%
(
(
'
'
*
indent
,
prefix
,
cos
.
command
[
0
])))
pass
pass
if
cos
.
script
[
0
]
!=
None
:
print
(
"
%s [%s script] %s
"
%
(
(
'
'
*
indent
,
prefix
,
cos
.
script
[
0
])))
...
...
@@ -327,6 +339,7 @@ if __name__ == '__main__':
tree
=
rules
.
get
(
name
)
for
p
in
tree
.
_pre_
:
command_or_script
(
p
,
'
pre
'
)
pass
if
not
options
.
noyum
:
for
r
in
tree
.
_rpm_
:
print
(
"
%s[r] %s
"
%
(
'
'
*
(
indent
+
1
),
r
.
name
[
0
]))
...
...
This diff is collapsed.
Click to expand it.
src/mio/analyze.py
0 → 100644
+
74
−
0
View file @
184f4025
import
os
import
mio.util
from
mio.node
import
*
def
get_dependencies
(
rules
,
name
,
path
,
dependencies
=
None
,
exclude
=
[]):
result
=
dependencies
or
dict
()
if
group_node
(
name
)
in
exclude
:
# Exclude this group
return
result
def
add_dependency
(
dest
,
kind
,
source
=
''
):
if
not
dest
in
result
:
result
[
dest
]
=
dict
()
pass
if
not
(
kind
,
source
)
in
result
[
dest
]:
result
[
dest
][(
kind
,
source
)]
=
set
()
pass
result
[
dest
][(
kind
,
source
)].
add
(
path
)
pass
tree
=
rules
.
get
(
name
)
for
s
in
tree
.
_symlink_
:
if
symlink_node
(
s
.
name
[
0
],
s
)
in
exclude
:
# Exclude symlink
continue
if
s
.
delete
[
0
]
==
'
yes
'
:
add_dependency
(
s
.
name
[
0
],
'
delete
'
)
pass
else
:
add_dependency
(
s
.
name
[
0
],
'
symlink
'
,
s
.
value
[
0
])
pass
pass
for
f
in
tree
.
_file_
:
if
file_node
(
f
.
name
[
0
],
f
)
in
exclude
:
# Exclude file
continue
if
f
.
delete
[
0
]
==
'
yes
'
:
add_dependency
(
f
.
name
[
0
],
'
delete
'
)
pass
elif
f
.
source
[
0
]
==
''
:
add_dependency
(
f
.
name
[
0
],
'
chmod
'
)
pass
else
:
src
=
os
.
path
.
normpath
(
'
%s/%s
'
%
(
f
.
files
[
0
:],
f
.
source
[
0
]
or
f
.
name
[
0
]))
add_dependency
(
f
.
name
[
0
],
'
file
'
,
src
)
pass
pass
for
d
in
tree
.
_dependency_
:
result
=
get_dependencies
(
rules
=
rules
,
name
=
d
.
name
[
0
],
path
=
path
+
(
d
.
name
[
0
],),
dependencies
=
result
,
exclude
=
mio
.
util
.
exclusion_closure
(
exclude
,
d
))
pass
return
result
def
dependency_check
(
rules
,
options
,
targets
):
errors
=
0
for
t
in
targets
:
dep
=
get_dependencies
(
rules
,
t
,
(
t
,))
for
dk
in
[
k
for
k
in
sorted
(
dep
)
if
len
(
dep
[
k
])
>
1
]:
errors
+=
1
print
(
t
)
print
(
'
%s
'
%
dk
)
for
sk
in
sorted
(
dep
[
dk
]):
print
(
'
%s
'
%
str
(
sk
))
for
p
in
sorted
(
dep
[
dk
][
sk
]):
print
(
'
%s
'
%
str
(
p
))
pass
pass
if
errors
:
raise
Exception
(
'
Dependency check failed
'
)
pass
This diff is collapsed.
Click to expand it.
src/mio/util.py
+
21
−
0
View file @
184f4025
...
...
@@ -3,6 +3,7 @@ import os
import
pwd
import
re
from
mio.log
import
log
,
NORMAL
,
VERBOSE
from
mio.node
import
*
try
:
# Python 2
...
...
@@ -119,3 +120,23 @@ def owner(decl):
def
group
(
decl
):
return
decl
.
group
[
0
:]
def
exclusion_closure
(
exclude
,
target
):
if
not
target
.
_exclude_
:
return
exclude
else
:
result
=
list
(
exclude
)
# Create exclusion closure
for
e
in
target
.
_exclude_
:
for
(
key
,
value
)
in
e
.
_attribute
.
items
():
if
key
==
'
dependency
'
:
result
.
append
(
group_node
(
value
))
elif
key
==
'
file
'
:
result
.
append
(
file_node
(
value
))
elif
key
==
'
dir
'
:
result
.
append
(
dir_node
(
value
))
elif
key
==
'
rpm
'
:
result
.
append
(
rpm_node
(
value
))
elif
key
==
'
symlink
'
:
result
.
append
(
symlink_node
(
value
))
else
:
raise
BadExclude
(
e
,
key
)
return
result
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