Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ebrains-spack-builds
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matvey Loshakov
ebrains-spack-builds
Commits
ab8a62c5
Commit
ab8a62c5
authored
2 years ago
by
Eleni Mathioulaki
Browse files
Options
Downloads
Patches
Plain Diff
add cleanup script that uninstalls old versions of packages
parent
c41ff139
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
operations/cleanup_script.py
+35
-0
35 additions, 0 deletions
operations/cleanup_script.py
with
35 additions
and
0 deletions
operations/cleanup_script.py
0 → 100644
+
35
−
0
View file @
ab8a62c5
# ensure compatability with Spack v0.18.0
try
:
from
spack.package_base
import
PackageStillNeededError
except
:
from
spack.package
import
PackageStillNeededError
needed
=
set
()
# keep packages that are part of an environment
for
e
in
spack
.
environment
.
all_environments
():
needed
.
update
(
e
.
all_hashes
())
# also keep packages that provide compilers (and their dependencies)
for
c
in
spack
.
compilers
.
all_compiler_specs
():
pkg_spec
=
spack
.
compilers
.
pkg_spec_for_compiler
(
c
)
needed
.
update
([
dep
.
dag_hash
()
for
pkg
in
spack
.
store
.
db
.
query
(
pkg_spec
)
for
dep
in
pkg
.
traverse
()])
installed
=
{
spec
.
dag_hash
():
spec
for
spec
in
spack
.
store
.
db
.
query
()}
to_remove
=
set
(
installed
)
-
needed
# this will try to uninstall ANY package that is not part of an environment
# including test dependencies
# for a list of all the packages that will be uninstalled:
print
(
'
The following packages will be uninstalled:
'
)
print
(
'
\n
'
.
join
(
sorted
([
installed
[
h
].
short_spec
+
'
(
'
+
h
+
'
)
'
for
h
in
to_remove
])))
# iteratively uninstall packages with no dependents
while
to_remove
:
# print('New iteration')
for
hash
in
to_remove
.
copy
():
spec
=
installed
[
hash
]
try
:
spec
.
package
.
do_uninstall
()
to_remove
.
discard
(
hash
)
except
PackageStillNeededError
:
pass
# print('Not ready to remove', spec.short_spec, 'in this iteration')
This diff is collapsed.
Click to expand it.
Preview
0%
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