From 124b5fc296687331f5456bcd3db647efe3747ed2 Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Thu, 9 Nov 2017 16:38:12 -0600 Subject: deal with case where symbolic links are copied (#6178) * deal with case where symbolic links are copied * Suggested changes --- lib/spack/llnl/util/filesystem.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index eb4f6e3bf2..36be87580c 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -196,6 +196,11 @@ def change_sed_delimiter(old_delim, new_delim, *filenames): def set_install_permissions(path): """Set appropriate permissions on the installed file.""" +# If this points to a file maintained in a Spack prefix, it is assumed that +# this function will be invoked on the target. If the file is outside a +# Spack-maintained prefix, the permissions should not be modified. + if os.path.islink(path): + return if os.path.isdir(path): os.chmod(path, 0o755) else: @@ -203,6 +208,10 @@ def set_install_permissions(path): def copy_mode(src, dest): + """Set the mode of dest to that of src unless it is a link. + """ + if os.path.islink(dest): + return src_mode = os.stat(src).st_mode dest_mode = os.stat(dest).st_mode if src_mode & stat.S_IXUSR: -- cgit v1.2.3-60-g2f50