summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-03-25 02:40:44 -0700
committerGabe Black <gabeblack@google.com>2017-03-26 17:40:57 +0000
commit9f3615d9c996e5ee627d4f470f7a3440a91bc39d (patch)
treeb4c675dd5a2f9bdbfa5a2939d9953a2db0847c19 /SConstruct
parentd82e59f74bdb2fb9b5e770a0cc9a1e7c649fbd81 (diff)
downloadgem5-9f3615d9c996e5ee627d4f470f7a3440a91bc39d.tar.xz
scons: Collapse symlinks when installing git hooks.
When naively computing the relative path between the git hooks directory and a hook we want to install, that will generally start with a few ".." path components to work back out of the .git directory into the working directory.' If the hooks directory is actually a symlink, then following ".." directory entries won't get us back to where we came from, they'll take us to the actual parent directory of hooks. The relative path we computed would then try to go forward from this other directory using a path that would have worked in the working directory, hopefully going somewhere that doesn't exist, but potentially going to a totally unrelated file with the same relative path. To avoid this problem, we should expand any symlinks in both the hooks directory path, and the path to the hook script. That way, any ".." components will go where we'd expect them to, and the relative path will actually go from hooks to the script we expect. Change-Id: I64d51bc817351f89b1d60eceaf450cc0a4553415 Reviewed-on: https://gem5-review.googlesource.com/2542 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'SConstruct')
-rwxr-xr-xSConstruct4
1 files changed, 2 insertions, 2 deletions
diff --git a/SConstruct b/SConstruct
index fbc52ccd5..ce53a51c0 100755
--- a/SConstruct
+++ b/SConstruct
@@ -407,8 +407,8 @@ def install_git_style_hooks():
# and the hooks directory is not a symlink to an absolute path.
if hook.is_under(main.root) and not abs_symlink_hooks:
script_path = os.path.relpath(
- script.get_abspath(),
- hook.Dir(".").get_abspath())
+ os.path.realpath(script.get_abspath()),
+ os.path.realpath(hook.Dir(".").get_abspath()))
else:
script_path = script.get_abspath()