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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
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
Changes
1
Show 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 @@
...
@@ -30,6 +30,7 @@
import
sys
import
sys
import
glob
import
glob
import
os
import
os
from
fnmatch
import
fnmatchcase
import
six.moves.configparser
as
configparser
import
six.moves.configparser
as
configparser
from
slapos.cli.command
import
check_root_user
from
slapos.cli.command
import
check_root_user
...
@@ -92,7 +93,8 @@ def _prune(
...
@@ -92,7 +93,8 @@ def _prune(
logger
,
software_root
,
shared_root
,
ignored_shared_parts
)
logger
,
software_root
,
shared_root
,
ignored_shared_parts
)
# recursively look in instance
# 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
,
'*'
,
'*'
)):
for
shared_part
in
glob
.
glob
(
os
.
path
.
join
(
shared_root
,
'*'
,
'*'
)):
if
shared_part
not
in
ignored_shared_parts
:
if
shared_part
not
in
ignored_shared_parts
:
...
@@ -112,7 +114,7 @@ def _prune(
...
@@ -112,7 +114,7 @@ def _prune(
def
_prune_loop
(
logger
,
shared_root
,
software_root
,
instance_root
,
dry_run
):
def
_prune_loop
(
logger
,
shared_root
,
software_root
,
instance_root
,
dry_run
):
ignored_shared_parts
=
set
(
[]
)
ignored_shared_parts
=
set
()
while
True
:
while
True
:
pruned
=
list
(
pruned
=
list
(
_prune
(
_prune
(
...
@@ -123,9 +125,9 @@ def _prune_loop(logger, shared_root, software_root, instance_root, dry_run):
...
@@ -123,9 +125,9 @@ def _prune_loop(logger, shared_root, software_root, instance_root, dry_run):
ignored_shared_parts
,
ignored_shared_parts
,
dry_run
,
dry_run
,
))
))
ignored_shared_parts
.
update
(
pruned
)
if
not
pruned
:
if
not
pruned
:
break
break
ignored_shared_parts
.
update
(
pruned
)
def
do_prune
(
logger
,
options
,
dry_run
):
def
do_prune
(
logger
,
options
,
dry_run
):
...
@@ -219,14 +221,12 @@ def readSlaposCfg(logger, path):
...
@@ -219,14 +221,12 @@ def readSlaposCfg(logger, path):
def
getUsageSignatureFromSoftwareAndSharedPart
(
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
"""Look in all softwares and shared parts to collect the signatures
that are used.
that are used.
`ignored_shared_parts` is useful during dry-run, we want to ignore
`ignored_shared_parts` is useful during dry-run, we want to ignore
already the parts that we are about to delete.
already the parts that we are about to delete.
"""
"""
if
ignored_shared_parts
is
None
:
ignored_shared_parts
=
set
([])
signatures
=
{}
signatures
=
{}
for
installed_cfg
in
glob
.
glob
(
os
.
path
.
join
(
software_root
,
'*'
,
for
installed_cfg
in
glob
.
glob
(
os
.
path
.
join
(
software_root
,
'*'
,
'.installed.cfg'
)):
'.installed.cfg'
)):
...
@@ -239,10 +239,12 @@ def getUsageSignatureFromSoftwareAndSharedPart(
...
@@ -239,10 +239,12 @@ def getUsageSignatureFromSoftwareAndSharedPart(
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
logger
.
debug
(
"Skipping script %s that could not be decoded"
,
script
)
logger
.
debug
(
"Skipping script %s that could not be decoded"
,
script
)
if
shared_root
:
if
shared_root
:
for
shared_signature
in
glob
.
glob
(
os
.
path
.
join
(
shared_root
,
'*'
,
'*'
,
for
shared_part
in
glob
.
glob
(
os
.
path
.
join
(
shared_root
,
'*'
,
'*'
)):
'.*signature'
)):
if
shared_part
not
in
ignored_shared_parts
:
if
not
any
(
shared_signature
.
startswith
(
ignored_shared_part
)
for
x
in
os
.
listdir
(
shared_part
):
for
ignored_shared_part
in
ignored_shared_parts
):
if
x
==
'.buildout-shared.json'
or
\
with
open
(
shared_signature
)
as
f
:
fnmatchcase
(
x
,
'.*signature'
):
signatures
[
shared_signature
]
=
f
.
read
()
x
=
os
.
path
.
join
(
shared_part
,
x
)
with
open
(
x
)
as
f
:
signatures
[
x
]
=
f
.
read
()
return
signatures
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