commit: aaf9561924991c5c79618e1837b0ad1e0673f225 Author: Itai Ferber <itai <AT> itaiferber <DOT> net> AuthorDate: Sat Oct 12 17:41:44 2024 +0000 Commit: David Roman <davidroman96 <AT> gmail <DOT> com> CommitDate: Sun Oct 13 01:31:25 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=aaf95619
dev-lang/swift: add support for app-eselect/eselect-swift Signed-off-by: Itai Ferber <itai <AT> itaiferber.net> 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 3440d1183..f855522a2 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 <command>` calls `swift-<command>` 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 +}