Add spack purge --cache to purge local archive cache.
This commit is contained in:
parent
bc1320d83a
commit
c996632113
3 changed files with 30 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
/var/spack/stage
|
||||
/var/spack/cache
|
||||
*.pyc
|
||||
/opt/
|
||||
*~
|
||||
|
|
|
@ -22,9 +22,31 @@
|
|||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
import spack
|
||||
import spack.stage as stage
|
||||
|
||||
description = "Remove all temporary build files and downloaded archives"
|
||||
description = "Remove temporary build files and/or downloaded archives"
|
||||
|
||||
|
||||
def setup_parser(subparser):
|
||||
subparser.add_argument(
|
||||
'-s', '--stage', action='store_true', default=True,
|
||||
help="Remove all temporary build stages (default).")
|
||||
subparser.add_argument(
|
||||
'-c', '--cache', action='store_true', help="Remove cached downloads.")
|
||||
subparser.add_argument(
|
||||
'-a', '--all', action='store_true',
|
||||
help="Remove all of the above.")
|
||||
|
||||
|
||||
def purge(parser, args):
|
||||
# Special case: no flags.
|
||||
if not any((args.stage, args.cache, args.all)):
|
||||
stage.purge()
|
||||
return
|
||||
|
||||
# handle other flags with fall through.
|
||||
if args.stage or args.all:
|
||||
stage.purge()
|
||||
if args.cache or args.all:
|
||||
spack.cache.destroy()
|
||||
|
|
|
@ -858,6 +858,9 @@ def fetcher(self, targetPath, digest):
|
|||
url = "file://" + join_path(self.root, targetPath)
|
||||
return CacheURLFetchStrategy(url, digest)
|
||||
|
||||
def destroy(self):
|
||||
shutil.rmtree(self.root, ignore_errors=True)
|
||||
|
||||
|
||||
class FetchError(spack.error.SpackError):
|
||||
|
||||
|
|
Loading…
Reference in a new issue