From b369891eafef79721c35e829ce2e4cc85bb82e9f Mon Sep 17 00:00:00 2001
From: Celeste <20312-Celeste@users.gitlab.alpinelinux.org>
Date: Sat, 28 Sep 2024 06:14:28 +0000
Subject: [PATCH] testing/tcl9: new aport

https://www.tcl-lang.org/software/tcltk/9.0.html
---
 testing/tcl9/APKBUILD                       | 86 +++++++++++++++++++++
 testing/tcl9/tclsqlite-include-stdint.patch | 10 +++
 2 files changed, 96 insertions(+)
 create mode 100644 testing/tcl9/APKBUILD
 create mode 100644 testing/tcl9/tclsqlite-include-stdint.patch

diff --git a/testing/tcl9/APKBUILD b/testing/tcl9/APKBUILD
new file mode 100644
index 000000000000..5b75f07a5cb7
--- /dev/null
+++ b/testing/tcl9/APKBUILD
@@ -0,0 +1,86 @@
+# Maintainer: Celeste <cielesti@protonmail.com>
+pkgname=tcl9
+pkgver=9.0.0
+pkgrel=0
+_major=${pkgver%.*}
+pkgdesc="The Tcl scripting language, version 9"
+url="https://www.tcl-lang.org/"
+arch="all"
+license="TCL"
+depends="tzdata"
+depends_dev="
+	$pkgname=$pkgver-r$pkgrel
+	zip
+	"
+makedepends="
+	$depends_dev
+	bsd-compat-headers
+	sqlite-dev
+	zlib-dev
+	"
+subpackages="$pkgname-dev $pkgname-doc"
+source="https://downloads.sourceforge.net/sourceforge/tcl/tcl$pkgver-src.tar.gz
+	tclsqlite-include-stdint.patch
+	"
+builddir="$srcdir/tcl$pkgver/unix"
+options="net" # tests require networking
+
+prepare() {
+	local builddir="$srcdir/tcl$pkgver"
+
+	default_prepare
+}
+
+build() {
+	case "$CARCH" in
+		arm*|x86)	_64bit="--disable-64bit" ;;
+		*)		_64bit="--enable-64bit"  ;;
+	esac
+
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
+		--sysconfdir=/etc \
+		--mandir=/usr/share/man \
+		--localstatedir=/var \
+		--with-system-sqlite \
+		--disable-rpath \
+		--disable-zipfs \
+		$_64bit
+	make
+}
+
+check() {
+	# thread-4.5 and thread-5.2 are suppressed because they test UB
+	# lseq-1.27 is suppressed as it gets stuck in a loop on non-x86
+	make test TESTFLAGS="-verbose pbtels -skip 'thread-4.5 thread-5.2 lseq-1.27'"
+}
+
+package() {
+	make INSTALL_ROOT="$pkgdir" install install-private-headers
+
+	ln -sf tclsh$_major "$pkgdir"/usr/bin/tclsh9
+	install -Dm644 ../license.terms \
+		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+
+	# remove buildroot traces
+	find "$pkgdir" -name '*Config.sh' -print0 |
+		xargs -0 sed -i -e "s#${srcdir}#/usr/src#"
+
+	# prevent conflict with main/sqlite-tools
+	rm -v "$pkgdir"/usr/bin/sqlite3_analyzer
+}
+
+dev() {
+	default_dev
+
+	local file; find "$pkgdir" -name '*Config.sh' | while read -r file; do
+		amove "${file#"$pkgdir"}"
+	done
+}
+
+sha512sums="
+d7c1527b0346081df43a0df76ddac01d7a2bf6f626a0f1bed3db77bbd4efaa645dd2ff7c16354522ee9150d82581466b4b59718d3b10fda51de2ec03ed9459ad  tcl9.0.0-src.tar.gz
+9bfe2946baedeedbb70c6c18273b137772b0539e5ce6a0aea04f6df59ff463eb6b4da93723d8b84d7faf0861a18e0e82038582c457e959284b3cf314c18ca7cb  tclsqlite-include-stdint.patch
+"
diff --git a/testing/tcl9/tclsqlite-include-stdint.patch b/testing/tcl9/tclsqlite-include-stdint.patch
new file mode 100644
index 000000000000..e2c28f387f9c
--- /dev/null
+++ b/testing/tcl9/tclsqlite-include-stdint.patch
@@ -0,0 +1,10 @@
+--- a/pkgs/sqlite3.45.3/generic/tclsqlite3.c
++++ b/pkgs/sqlite3.45.3/generic/tclsqlite3.c
+@@ -74,6 +74,7 @@
+ #   endif
+ # endif /* SQLITE_PTRSIZE */
+ # if defined(HAVE_STDINT_H)
++#   include <stdint.h>
+     typedef uintptr_t uptr;
+ # elif SQLITE_PTRSIZE==4
+     typedef unsigned int uptr;
-- 
GitLab