Files
swift-mirror/utils/darwin-installer-scripts/postinstall
Yuta Saito 86700b63b1 [installer] Do not follow an existing symbolic link when overwriting
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.
2023-06-20 10:32:11 +00:00

17 lines
649 B
Bash
Executable File

#!/usr/bin/env bash
#===--- postinstall - Creates symlink after installing xctoolchain ----------===#
#
## This source file is part of the Swift.org open source project
##
## Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
## Licensed under Apache License v2.0 with Runtime Library Exception
##
## See https://swift.org/LICENSE.txt for license information
## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
#===------------------------------------------------------------------------===#
INSTALLED_TOOLCHAIN=$2
ln -fhs "${INSTALLED_TOOLCHAIN}" "${INSTALLED_TOOLCHAIN%/*}/swift-latest.xctoolchain"