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: