From aaf9561924991c5c79618e1837b0ad1e0673f225 Mon Sep 17 00:00:00 2001 From: Itai Ferber Date: Sat, 12 Oct 2024 13:41:44 -0400 Subject: [PATCH] dev-lang/swift: add support for app-eselect/eselect-swift Signed-off-by: Itai Ferber --- dev-lang/swift/swift-5.10.1-r1.ebuild | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/dev-lang/swift/swift-5.10.1-r1.ebuild b/dev-lang/swift/swift-5.10.1-r1.ebuild index 3440d11832..f855522a24 100644 --- a/dev-lang/swift/swift-5.10.1-r1.ebuild +++ b/dev-lang/swift/swift-5.10.1-r1.ebuild @@ -64,6 +64,7 @@ RESTRICT="strip" RDEPEND=" ${PYTHON_DEPS} + >=app-eselect/eselect-swift-1.0 >=dev-db/sqlite-3 >=dev-libs/icu-69 >=dev-libs/libedit-20221030 @@ -268,6 +269,27 @@ src_install() { # `swift ` calls `swift-` directly.) local bin for bin in swift swiftc sourcekit-lsp; do - dosym -r "${dest_dir}/usr/bin/${bin}" "/usr/bin/${bin}" + # We only install versioned symlinks; non-versioned links are maanged + # via `eselect swift`. + dosym -r "${dest_dir}/usr/bin/${bin}" "/usr/bin/${bin}-${PV}" done } + +pkg_postinst() { + # If we're installing the latest version of Swift, then update symlinks to + # it. (We don't want to call `eselect swift update` unconditionally in case + # we're installing an older version of Swift, and the user has intentionally + # selected a version other than the latest.) + if ! has_version ">${CATEGORY}/${P}"; then + eselect swift update + fi +} + +pkg_postrm() { + # We don't want to leave behind symlinks pointing to this Swift version on + # removal. + local eselect_swift_version="$(eselect swift show)" + if [[ "${eselect_swift_version}" == *"${P}" ]]; then + eselect swift update + fi +}