From 86700b63b13cf0529b55de489246c1ad08495121 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 24 Nov 2020 13:16:58 +0900 Subject: [PATCH] [installer] Do not follow an existing symbolic link when overwriting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without `-h` option, `ln` command makes a symbolic link under the existing link destination like `Toolchains/swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain/`. ``` $ ln -fs swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain swift-latest.xctoolchain $ ln -fs swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain swift-latest.xctoolchain $ tree |-- swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain |   |-- swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain -> swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain |-- swift-DEVELOPMENT-SNAPSHOT-YY.xctoolchain |-- swift-latest.xctoolchain -> swift-DEVELOPMENT-SNAPSHOT-XX.xctoolchain ``` So we should not follow the existing symbolic link even if it already exists. --- utils/darwin-installer-scripts/postinstall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/darwin-installer-scripts/postinstall b/utils/darwin-installer-scripts/postinstall index 8f00806645e..e9750f04e95 100755 --- a/utils/darwin-installer-scripts/postinstall +++ b/utils/darwin-installer-scripts/postinstall @@ -13,4 +13,4 @@ INSTALLED_TOOLCHAIN=$2 -ln -fs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain" +ln -fhs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain"