phase1: ccache.sh: avoid creating nested symlink
authorJo-Philipp Wich <jo@mein.io>
Mon, 23 Jan 2017 13:21:41 +0000 (14:21 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 23 Jan 2017 13:21:41 +0000 (14:21 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
phase1/ccache.sh

index 61590f2a0ce5e9afeb498af44b47ed996efd3e23..46081f3b202b87d1f616bc8c71c5d6da5ea61961 100755 (executable)
@@ -11,9 +11,11 @@ grep -sq compiler_check "$HOME/.ccache/ccache.conf" || \
        echo "compiler_check = %compiler% -dumpmachine; %compiler% -dumpversion" >> "$HOME/.ccache/ccache.conf"
 
 for dir in $(make --no-print-directory val.TOOLCHAIN_DIR val.STAGING_DIR val.STAGING_DIR_HOST V=s | grep staging_dir/); do
-       mkdir -p "$dir"
-       test -L "$dir/ccache" || rm -rf "$dir/ccache"
-       ln -s "$HOME/.ccache" "$dir/ccache"
+       if [ ! -L "$dir/ccache" ]; then
+               mkdir -vp "$dir"
+               rm -vrf "$dir/ccache"
+               ln -vs "$HOME/.ccache" "$dir/ccache"
+       fi
 done
 
 ./staging_dir/host/bin/ccache -s 2>/dev/null