From 90b0cd97b8bb624b86cd243da87da067947c57d1 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Wed, 3 Jul 2019 14:29:44 +0200 Subject: [PATCH] Fixed linking procedure for old ln versions --- build_declarations.sh | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/build_declarations.sh b/build_declarations.sh index 0c1e716..fb35634 100755 --- a/build_declarations.sh +++ b/build_declarations.sh @@ -5,8 +5,8 @@ cd "${BASEDIR}" file_paths=( "$(pwd ~)/../../Web-Client/shared/declarations" -# "$(pwd ~)/TeaSpeak/Web-Client/shared/declarations" -# "$(pwd ~)/../../TeaSpeak/Web-Client/shared/declarations" + "$(pwd ~)/TeaSpeak/Web-Client/shared/declarations" + "$(pwd ~)/../../TeaSpeak/Web-Client/shared/declarations" "app/dummy-declarations" #TODO Windows path ) @@ -15,8 +15,10 @@ files=( # "exports_loader.d.ts;imports_shared_loader.d.ts" ) +support_rel_linking=$(ln --help 2>&1 | grep -e "--relative" >/dev/null && echo "1" || echo "0") +support_rel_linking=0 + path_target="./modules/renderer/imports" -path_found=0 { mkdir -p "${path_target}" @@ -46,7 +48,20 @@ path_found=0 rm "${path_target}/${dst_file}" fi - ln -rs "${path}/${src_file}" "${path_target}/${dst_file}" + + if [[ ${support_rel_linking} -ne 0 ]]; then + ln -rs "${path}/${src_file}" "${path_target}/${dst_file}" + else + _source=$(realpath "${path}/${src_file}") + _current_dir=$(pwd) + cd ${path_target} + [[ $? -ne 0 ]] && { + echo "Failed to enter target directory" + exit 1; + } + ln -s "${_source}" "${dst_file}" + cd ${_current_dir} + fi echo "Linking \"${path_target}/${dst_file}\" to \"${path}/${src_file}\"" cp "${path}/${src_file}" "${path_target}/copy_${dst_file}" @@ -74,7 +89,19 @@ if [[ ${path_found} -eq 0 ]]; then exit 1 fi - ln -rs "${path_target}/copy_${dst_file}" "${path_target}/${dst_file}" + if [[ ${support_rel_linking} -ne 0 ]]; then + ln -rs "${path_target}/copy_${dst_file}" "${path_target}/${dst_file}" + else + _source=$(realpath "${path_target}/copy_${dst_file}") + _current_dir=$(pwd) + cd ${path_target} + [[ $? -ne 0 ]] && { + echo "Failed to enter target directory" + exit 1; + } + ln -s "${_source}" "${dst_file}" + cd ${_current_dir} + fi echo "Linking \"${path_target}/${dst_file}\" to \"${path_target}/copy_${dst_file}\"" done path_found=1