commit:     788aa343d562ec5b320b759121fcd1046fc59c79
Author:     Itai Ferber <itai <AT> itaiferber <DOT> net>
AuthorDate: Sat Dec 13 03:11:59 2025 +0000
Commit:     Itai Ferber <itai <AT> itaiferber <DOT> net>
CommitDate: Sat Dec 13 12:43:41 2025 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=788aa343

dev-lang/swift-bin: new package, add 5.10.1-r5, 6.2.3

Signed-off-by: Itai Ferber <itai <AT> itaiferber.net>

 dev-lang/swift-bin/Manifest                   |   2 +
 dev-lang/swift-bin/metadata.xml               |  25 +++++++
 dev-lang/swift-bin/swift-bin-5.10.1-r5.ebuild |  78 ++++++++++++++++++++
 dev-lang/swift-bin/swift-bin-6.2.3.ebuild     | 101 ++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)

diff --git a/dev-lang/swift-bin/Manifest b/dev-lang/swift-bin/Manifest
new file mode 100644
index 0000000000..928cdfa10d
--- /dev/null
+++ b/dev-lang/swift-bin/Manifest
@@ -0,0 +1,2 @@
+DIST swift-5.10.1-r5.gpkg.tar 582103040 BLAKE2B 
c0b1868d2036af8d67c472d3da53f4c2377b903ee36452541d04e288da16d12747b5485a302f04a85e6004be00c32f3cd2d510068e0ff1b838e8b365f603e616
 SHA512 
f37381de83f2eb507db9f2403db126e796bbaa23481459bfb079ab9485bc4c8521ab0a4f382d5ae70e0d92a3cc2a9f994b53bf177d2c41466a36edc230b5f132
+DIST swift-6.2.3.gpkg.tar 732385280 BLAKE2B 
35d2e7f514ae519aba5fa11d918f114726740b855a4c237655eabe0e56241735bf9598d2c3a9162ea9b5252c32737a7c3e14f246ef3f0ef85a8cdc602dd55628
 SHA512 
b8d6e6383c41255f733e3fe0991cc5d38630b5d2e461c253b3f4af5e936752d6a76a44b7f8050b158ec37a070cc739e909935d6d8882bc07d569945a1d856703

diff --git a/dev-lang/swift-bin/metadata.xml b/dev-lang/swift-bin/metadata.xml
new file mode 100644
index 0000000000..e059c62b31
--- /dev/null
+++ b/dev-lang/swift-bin/metadata.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+  <maintainer type="person">
+    <email>[email protected]</email>
+    <name>Itai Ferber</name>
+  </maintainer>
+  <upstream>
+    <remote-id type="github">swiftlang/swift</remote-id>
+  </upstream>
+  <slots>
+    <slot name="0">
+      The original slot for swift-5.10.1; should no longer be used.
+    </slot>
+    <slot name="5">
+      The Swift 5 language, compiler, and tooling.
+    </slot>
+    <slot name="6">
+      The Swift 6 language, compiler, and tooling.
+    </slot>
+    <subslots>
+      Minor Swift versions.
+    </subslots>
+  </slots>
+</pkgmetadata>

diff --git a/dev-lang/swift-bin/swift-bin-5.10.1-r5.ebuild 
b/dev-lang/swift-bin/swift-bin-5.10.1-r5.ebuild
new file mode 100644
index 0000000000..145ebd23c0
--- /dev/null
+++ b/dev-lang/swift-bin/swift-bin-5.10.1-r5.ebuild
@@ -0,0 +1,78 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_COMPAT=( {15..19} )
+PYTHON_COMPAT=( python3_{11..14} )
+inherit llvm-r1 python-single-r1 unpacker
+
+DESCRIPTION="A high-level, general-purpose, multi-paradigm, compiled 
programming language"
+HOMEPAGE="https://www.swift.org";
+SWIFT_PF="${PF/-bin/}"
+SRC_URI="https://github.com/itaiferber/gentoo-distfiles/releases/download/${CATEGORY}/${SWIFT_PF}/${SWIFT_PF}.gpkg.tar";
+S="${WORKDIR}"
+
+LICENSE="Apache-2.0 GPL-2"
+SLOT="5/10"
+KEYWORDS="~amd64"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RESTRICT="strip"
+
+RDEPEND="
+       ${PYTHON_DEPS}
+       !dev-lang/swift:5
+       !~dev-lang/swift-5.10.1:0
+       >=app-arch/zstd-1.5
+       >=app-eselect/eselect-swift-1.0-r1
+       >=dev-db/sqlite-3
+       >=dev-libs/icu-69
+       >=dev-libs/libedit-20221030
+       >=dev-libs/libxml2-2.11.5
+       >=net-misc/curl-8.4
+       >=sys-libs/ncurses-6
+       >=virtual/zlib-1.3:=
+       dev-lang/python
+       $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}=')
+"
+
+QA_PREBUILT="*"
+PKG_PREINST_SWIFT_INTENTIONALLY_SET='true'
+
+src_unpack() {
+       unpack_gpkg "${SWIFT_PF}.gpkg.tar"
+}
+
+src_install() {
+       mv "${SWIFT_PF}/image/usr" "${ED}"
+}
+
+pkg_preinst() {
+       # After installation, we ideally want the system to have the latest 
Swift
+       # version set -- but if the system already has a Swift version set and 
it
+       # isn't the latest version, that's likely an intentional decision that 
we
+       # don't want to override.
+       local current_swift_version="$(eselect swift show | tail -n1 | xargs)"
+       local latest_swift_version="$(eselect swift show --latest | tail -n1 | 
xargs)"
+       [[ "${current_swift_version}" == '(unset)' ]] \
+               || [[ "${current_swift_version}" == "${latest_swift_version}" 
]] \
+               && PKG_PREINST_SWIFT_INTENTIONALLY_SET='false'
+}
+
+pkg_postinst() {
+       # If the system doesn't have Swift intentionally set to an older 
version, we
+       # can update to the latest.
+       if [[ "${PKG_PREINST_SWIFT_INTENTIONALLY_SET}" == 'false' ]]; then
+               eselect swift update
+       fi
+}
+
+pkg_postrm() {
+       # We don't want to leave behind symlinks pointing to this Swift version 
on
+       # removal.
+       local current_swift_version="$(eselect swift show | tail -n1 | xargs)"
+       if [[ "${current_swift_version}" == "${P}" ]]; then
+               eselect swift update
+       fi
+}

diff --git a/dev-lang/swift-bin/swift-bin-6.2.3.ebuild 
b/dev-lang/swift-bin/swift-bin-6.2.3.ebuild
new file mode 100644
index 0000000000..8530fe0f42
--- /dev/null
+++ b/dev-lang/swift-bin/swift-bin-6.2.3.ebuild
@@ -0,0 +1,101 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_COMPAT=( {15..19} )
+PYTHON_COMPAT=( python3_{11..14} )
+inherit llvm-r1 python-single-r1 unpacker
+
+DESCRIPTION="A high-level, general-purpose, multi-paradigm, compiled 
programming language"
+HOMEPAGE="https://www.swift.org";
+SWIFT_PF="${PF/-bin/}"
+SRC_URI="https://github.com/itaiferber/gentoo-distfiles/releases/download/${CATEGORY}/${SWIFT_PF}/${SWIFT_PF}.gpkg.tar";
+S="${WORKDIR}"
+
+LICENSE="Apache-2.0 GPL-2"
+SLOT="6/2"
+KEYWORDS="~amd64"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RESTRICT="strip"
+
+RDEPEND="
+       ${PYTHON_DEPS}
+       !~dev-lang/swift-5.10.1:0
+       !dev-lang/swift:6/2
+       >=app-arch/zstd-1.5
+       >=app-eselect/eselect-swift-1.0-r1
+       >=dev-db/sqlite-3
+       >=dev-libs/icu-69
+       >=dev-libs/libedit-20221030
+       >=dev-libs/libxml2-2.11.5
+       >=net-misc/curl-8.9.1
+       >=sys-libs/ncurses-6
+       >=virtual/zlib-1.3.1:=
+       dev-lang/python
+       $(llvm_gen_dep 'llvm-core/lld:${LLVM_SLOT}=')
+"
+
+QA_PREBUILT="*"
+PKG_PREINST_SWIFT_INTENTIONALLY_SET='true'
+
+src_unpack() {
+       unpack_gpkg "${SWIFT_PF}.gpkg.tar"
+}
+
+src_install() {
+       mv "${SWIFT_PF}/image/usr" "${ED}"
+}
+
+pkg_preinst() {
+       # After installation, we ideally want the system to have the latest 
Swift
+       # version set -- but if the system already has a Swift version set and 
it
+       # isn't the latest version, that's likely an intentional decision that 
we
+       # don't want to override.
+       local current_swift_version="$(eselect swift show | tail -n1 | xargs)"
+       local latest_swift_version="$(eselect swift show --latest | tail -n1 | 
xargs)"
+       [[ "${current_swift_version}" == '(unset)' ]] \
+               || [[ "${current_swift_version}" == "${latest_swift_version}" 
]] \
+               && PKG_PREINST_SWIFT_INTENTIONALLY_SET='false'
+}
+
+pkg_postinst() {
+       # If the system doesn't have Swift intentionally set to an older 
version, we
+       # can update to the latest.
+       if [[ "${PKG_PREINST_SWIFT_INTENTIONALLY_SET}" == 'false' ]]; then
+               eselect swift update
+       fi
+
+       # We also want to provide a stable directory which matches our SLOT to 
avoid
+       # revdep breakages, as patch updates use the same SLOT but otherwise 
move
+       # the install location on disk.
+       #
+       # See https://bugs.gentoo.org/957730
+       #
+       # We do this in `pkg_postinst` instead of calling `dosym` in 
`src_install`
+       # because when upgrading from a major version to a patch version, the 
major
+       # version is still on disk while the patch version is being installed, 
so
+       # the existing directory is in use and the symlink fails to install.
+       local major_ver="$(ver_cut 1-2)"
+       if [[ "${PV}" != "${major_ver}" ]]; then
+               local libdir="${EROOT}/usr/$(get_libdir)"
+               ln -fsT "${libdir}/${P}" "${libdir}/${PN}-${major_ver}" || die
+       fi
+}
+
+pkg_postrm() {
+       # We don't want to leave behind symlinks pointing to this Swift version 
on
+       # removal.
+       local current_swift_version="$(eselect swift show | tail -n1 | xargs)"
+       if [[ "${current_swift_version}" == "${P}" ]]; then
+               eselect swift update
+       fi
+
+       # If we installed a SLOT symlink, we also want to remove it here.
+       local major_ver="$(ver_cut 1-2)"
+       local link="${EROOT}/usr/$(get_libdir)/${PN}-${major_ver}"
+       if [[ -L "${link}" && "${PV}" != "${major_ver}" ]]; then
+               rm "${link}"
+       fi
+}

Reply via email to