From c7b8a4e25cde8c2f32e514fdfe5280feca42e4ea Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 18 Feb 2015 14:00:37 -0800 Subject: Fix for SPACK-46: cleanup spack clean, spack restage. --- lib/spack/spack/cmd/clean.py | 29 ++++---------------------- lib/spack/spack/cmd/restage.py | 46 ++++++++++++++++++++++++++++++++++++++++++ lib/spack/spack/package.py | 21 ++++--------------- 3 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 lib/spack/spack/cmd/restage.py (limited to 'lib') diff --git a/lib/spack/spack/cmd/clean.py b/lib/spack/spack/cmd/clean.py index ec3b221988..c20136ebe5 100644 --- a/lib/spack/spack/cmd/clean.py +++ b/lib/spack/spack/cmd/clean.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2013, Lawrence Livermore National Security, LLC. +# Copyright (c) 2013-2014, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. @@ -23,45 +23,24 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from external import argparse -import subprocess import llnl.util.tty as tty import spack import spack.cmd -import spack.stage as stage -description = "Remove staged files for packages" +description = "Remove build stage and source tarball for packages." def setup_parser(subparser): - subparser.add_argument('-c', "--clean", action="store_true", dest='clean', - help="run make clean in the build directory (default)") - subparser.add_argument('-w', "--work", action="store_true", dest='work', - help="delete the build directory and re-expand it from its archive.") - subparser.add_argument('-d', "--dist", action="store_true", dest='dist', - help="delete the downloaded archive.") subparser.add_argument('packages', nargs=argparse.REMAINDER, help="specs of packages to clean") def clean(parser, args): if not args.packages: - tty.die("spack clean requires at least one package argument") + tty.die("spack clean requires at least one package spec.") specs = spack.cmd.parse_specs(args.packages, concretize=True) for spec in specs: package = spack.db.get(spec) - if args.dist: - package.do_clean_dist() - tty.msg("Cleaned %s" % package.name) - - elif args.work: - package.do_clean_work() - tty.msg("Restaged %s" % package.name) - - else: - try: - package.do_clean() - except subprocess.CalledProcessError, e: - tty.warn("Warning: 'make clean' didn't work. Consider 'spack clean --work'.") - tty.msg("Made clean for %s" % package.name) + package.do_clean() diff --git a/lib/spack/spack/cmd/restage.py b/lib/spack/spack/cmd/restage.py new file mode 100644 index 0000000000..e735a12c32 --- /dev/null +++ b/lib/spack/spack/cmd/restage.py @@ -0,0 +1,46 @@ +############################################################################## +# Copyright (c) 2013-2014, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://scalability-llnl.github.io/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License (as published by +# the Free Software Foundation) version 2.1 dated February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +from external import argparse + +import llnl.util.tty as tty + +import spack +import spack.cmd + +description = "Revert checked out package source code." + +def setup_parser(subparser): + subparser.add_argument('packages', nargs=argparse.REMAINDER, + help="specs of packages to restage") + + +def restage(parser, args): + if not args.packages: + tty.die("spack restage requires at least one package spec.") + + specs = spack.cmd.parse_specs(args.packages, concretize=True) + for spec in specs: + package = spack.db.get(spec) + package.do_restage() diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index bc8541a184..492af12053 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1047,26 +1047,13 @@ class Package(object): tree.unmerge(self.prefix, ignore=ignore) - def do_clean(self): - if self.stage.expanded_archive_path: - self.stage.chdir_to_source() - self.clean() - - - def clean(self): - """By default just runs make clean. Override if this isn't good.""" - # TODO: should we really call make clean, ro just blow away the directory? - make = build_env.MakeExecutable('make', self.parallel) - make('clean') - - - def do_clean_work(self): - """By default just blows away the stage directory and re-stages.""" + def do_restage(self): + """Reverts expanded/checked out source to a pristine state.""" self.stage.restage() - def do_clean_dist(self): - """Removes the stage directory where this package was built.""" + def do_clean(self): + """Removes the package's build stage and source tarball.""" if os.path.exists(self.stage.path): self.stage.destroy() -- cgit v1.2.3-60-g2f50