summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-03-23 22:38:31 -0700
committerGitHub <noreply@github.com>2018-03-23 22:38:31 -0700
commit998b5a6482e77cc17b1fca2e248d2bd3d8bf3a60 (patch)
treed1c9194796d3dd4aff733e66d27dac7caf3003c9 /lib
parent385622953dc3ddf733ff577f0ef00044c55bf72c (diff)
downloadspack-998b5a6482e77cc17b1fca2e248d2bd3d8bf3a60.tar.gz
spack-998b5a6482e77cc17b1fca2e248d2bd3d8bf3a60.tar.bz2
spack-998b5a6482e77cc17b1fca2e248d2bd3d8bf3a60.tar.xz
spack-998b5a6482e77cc17b1fca2e248d2bd3d8bf3a60.zip
Remove case consistency check at startup. (#7585)
- This was needed when we transitioned to all lowercase packages because git didn't handle case changes well on case-insensitive filesystems. - Now it just adds extra stat calls to startup, and we check for all-lowercase package names in tests, so we'll remove it. - people using really old versions of Spack can re-clone.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/hooks/case_consistency.py110
1 files changed, 0 insertions, 110 deletions
diff --git a/lib/spack/spack/hooks/case_consistency.py b/lib/spack/spack/hooks/case_consistency.py
deleted file mode 100644
index 54139cb039..0000000000
--- a/lib/spack/spack/hooks/case_consistency.py
+++ /dev/null
@@ -1,110 +0,0 @@
-##############################################################################
-# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
-# Produced at the Lawrence Livermore National Laboratory.
-#
-# This file is part of Spack.
-# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
-# LLNL-CODE-647188
-#
-# For details, see https://github.com/spack/spack
-# Please also see the NOTICE and LICENSE files 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 Lesser General Public License (as
-# published by the Free Software Foundation) version 2.1, 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 Lesser 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 __future__ import absolute_import
-
-import os
-import re
-import platform
-
-from llnl.util.filesystem import working_dir
-
-import spack
-from spack.cmd import spack_is_git_repo
-from spack.util.executable import which, ProcessError
-
-
-def pre_run():
- if platform.system() != "Darwin":
- return
-
- try:
- repo = spack.repo.get_repo('builtin')
- git_case_consistency_check(repo.packages_path)
- except spack.repository.UnknownNamespaceError:
- pass
-
-
-def git_case_consistency_check(path):
- """Re-sync case of files in a directory with git.
-
- On case-insensitive but case-preserving filesystems like Mac OS X,
- Git doesn't properly rename files that only had their case changed.
-
- This checks files in a directory against git and does a
- case-restoring rename (actually two renames, e.g.::
-
- name -> tmp -> NAME
-
- We use this in Spack to ensure package directories are named
- correctly.
-
- TODO: this check can probably be removed once package names have been
- TODO: lowercase for a long while.
-
- """
- # Don't bother fixing case if Spack isn't in a git repository
- if not spack_is_git_repo():
- return
-
- git = which('git', required=False)
- if not git:
- return
-
- with working_dir(path):
- try:
- git_filenames = git('ls-tree', '--name-only', 'HEAD', output=str)
- git_filenames = set(re.split(r'\s+', git_filenames.strip()))
- except ProcessError:
- return # Ignore errors calling git
-
- lower_to_mixed = {}
- for fn in git_filenames:
- lower = fn.lower()
- mixed = lower_to_mixed.setdefault(lower, [])
- mixed.append(fn)
-
- # Iterate through all actual files and make sure their names are
- # the same as corresponding names in git
- actual_filenames = os.listdir('.')
- for actual in actual_filenames:
- lower = actual.lower()
-
- # not tracked by git
- if lower not in lower_to_mixed:
- continue
-
- # Don't know what to do with multiple matches
- if len(lower_to_mixed[lower]) != 1:
- continue
-
- # Skip if case is already correct
- git_name = lower_to_mixed[lower][0]
- if git_name == actual:
- continue
-
- # restore case with two renames
- tmp_name = actual + '.spack.tmp'
- os.rename(actual, tmp_name)
- os.rename(tmp_name, git_name)