Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
fef02529
Commit
fef02529
authored
Sep 21, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prune: add support for new name of signature files
parent
f97375bd
Pipeline
#17687
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
slapos/cli/prune.py
slapos/cli/prune.py
+14
-12
No files found.
slapos/cli/prune.py
View file @
fef02529
...
...
@@ -30,6 +30,7 @@
import
sys
import
glob
import
os
from
fnmatch
import
fnmatchcase
import
six.moves.configparser
as
configparser
from
slapos.cli.command
import
check_root_user
...
...
@@ -92,7 +93,8 @@ def _prune(
logger
,
software_root
,
shared_root
,
ignored_shared_parts
)
# recursively look in instance
signatures
.
update
(
getUsageSignaturesFromSubInstance
(
logger
,
instance_root
,
set
([])))
signatures
.
update
(
getUsageSignaturesFromSubInstance
(
logger
,
instance_root
,
set
()))
for
shared_part
in
glob
.
glob
(
os
.
path
.
join
(
shared_root
,
'*'
,
'*'
)):
if
shared_part
not
in
ignored_shared_parts
:
...
...
@@ -112,7 +114,7 @@ def _prune(
def
_prune_loop
(
logger
,
shared_root
,
software_root
,
instance_root
,
dry_run
):
ignored_shared_parts
=
set
(
[]
)
ignored_shared_parts
=
set
()
while
True
:
pruned
=
list
(
_prune
(
...
...
@@ -123,9 +125,9 @@ def _prune_loop(logger, shared_root, software_root, instance_root, dry_run):
ignored_shared_parts
,
dry_run
,
))
ignored_shared_parts
.
update
(
pruned
)
if
not
pruned
:
break
ignored_shared_parts
.
update
(
pruned
)
def
do_prune
(
logger
,
options
,
dry_run
):
...
...
@@ -219,14 +221,12 @@ def readSlaposCfg(logger, path):
def
getUsageSignatureFromSoftwareAndSharedPart
(
logger
,
software_root
,
shared_root
,
ignored_shared_parts
=
None
):
logger
,
software_root
,
shared_root
,
ignored_shared_parts
=
()
):
"""Look in all softwares and shared parts to collect the signatures
that are used.
`ignored_shared_parts` is useful during dry-run, we want to ignore
already the parts that we are about to delete.
"""
if
ignored_shared_parts
is
None
:
ignored_shared_parts
=
set
([])
signatures
=
{}
for
installed_cfg
in
glob
.
glob
(
os
.
path
.
join
(
software_root
,
'*'
,
'.installed.cfg'
)):
...
...
@@ -239,10 +239,12 @@ def getUsageSignatureFromSoftwareAndSharedPart(
except
UnicodeDecodeError
:
logger
.
debug
(
"Skipping script %s that could not be decoded"
,
script
)
if
shared_root
:
for
shared_signature
in
glob
.
glob
(
os
.
path
.
join
(
shared_root
,
'*'
,
'*'
,
'.*signature'
)):
if
not
any
(
shared_signature
.
startswith
(
ignored_shared_part
)
for
ignored_shared_part
in
ignored_shared_parts
):
with
open
(
shared_signature
)
as
f
:
signatures
[
shared_signature
]
=
f
.
read
()
for
shared_part
in
glob
.
glob
(
os
.
path
.
join
(
shared_root
,
'*'
,
'*'
)):
if
shared_part
not
in
ignored_shared_parts
:
for
x
in
os
.
listdir
(
shared_part
):
if
x
==
'.buildout-shared.json'
or
\
fnmatchcase
(
x
,
'.*signature'
):
x
=
os
.
path
.
join
(
shared_part
,
x
)
with
open
(
x
)
as
f
:
signatures
[
x
]
=
f
.
read
()
return
signatures
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment