Merge pull request #754 from epfl-scitas/fixes/issue_216

fix : module files are deleted on uninstall (fixes #216)
This commit is contained in:
Todd Gamblin 2016-04-06 16:03:11 -07:00
commit feee268970
3 changed files with 10 additions and 10 deletions

View File

@ -22,21 +22,16 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import sys
import os import os
import shutil import shutil
import argparse import sys
import llnl.util.tty as tty import llnl.util.tty as tty
from llnl.util.lang import partition_list
from llnl.util.filesystem import mkdirp
import spack.cmd import spack.cmd
from llnl.util.filesystem import mkdirp
from spack.modules import module_types from spack.modules import module_types
from spack.util.string import * from spack.util.string import *
from spack.spec import Spec
description ="Manipulate modules and dotkits." description ="Manipulate modules and dotkits."
@ -98,7 +93,6 @@ def module_refresh():
cls(spec).write() cls(spec).write()
def module(parser, args): def module(parser, args):
if args.module_command == 'refresh': if args.module_command == 'refresh':
module_refresh() module_refresh()

View File

@ -211,7 +211,11 @@ def use_name(self):
def remove(self): def remove(self):
mod_file = self.file_name mod_file = self.file_name
if os.path.exists(mod_file): if os.path.exists(mod_file):
shutil.rmtree(mod_file, ignore_errors=True) try:
os.remove(mod_file) # Remove the module file
os.removedirs(os.path.dirname(mod_file)) # Remove all the empty directories from the leaf up
except OSError:
pass # removedirs throws OSError on first non-empty directory found
class Dotkit(EnvModule): class Dotkit(EnvModule):

View File

@ -17,7 +17,7 @@ def _mock_install(self, spec):
def _mock_remove(self, spec): def _mock_remove(self, spec):
specs = spack.installed_db.query(spec) specs = spack.installed_db.query(spec)
assert(len(specs) == 1) assert len(specs) == 1
spec = specs[0] spec = specs[0]
spec.package.do_uninstall(spec) spec.package.do_uninstall(spec)
@ -71,6 +71,8 @@ def setUp(self):
self._mock_install('mpileaks ^zmpi') self._mock_install('mpileaks ^zmpi')
def tearDown(self): def tearDown(self):
for spec in spack.installed_db.query():
spec.package.do_uninstall(spec)
super(MockDatabase, self).tearDown() super(MockDatabase, self).tearDown()
shutil.rmtree(self.install_path) shutil.rmtree(self.install_path)
spack.install_path = self.spack_install_path spack.install_path = self.spack_install_path