aports/main/sqlite-tools/APKBUILD
Celeste b98152fa52 main/sqlite-tools: restore man page for -tcl subpackage
also, remove stdout-invalid-argument.patch
that is no longer needed for tests to pass
2025-05-31 03:45:10 +00:00

175 lines
3.9 KiB
Text

# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=sqlite-tools
pkgver=3.50.0
pkgrel=1
pkgdesc="Helper tools for SQLite"
url="https://www.sqlite.org/"
arch="all"
license="blessing"
makedepends="
autoconf
readline-dev
sqlite-dev~$pkgver
tcl-dev
"
checkdepends="bash"
subpackages="
sqlite-analyzer
sqlite-tcl:_tcl
sqlite-tcl-doc:_tcl_doc
"
# compute _ver
_a=${pkgver%%.*}
_b=${pkgver#"$_a".}
_b=${_b%%.*}
_c=${pkgver#"$_a"."$_b".}
_c=${_c%%.*}
case $pkgver in
*.*.*.*)_d=${pkgver##*.};;
*.*.*) _d=0;;
esac
[ $_b -lt 10 ] && _b=0$_b
[ $_c -lt 10 ] && _c=0$_c
[ $_d -lt 10 ] && _d=0$_d
_ver=${_a}${_b}${_c}$_d
# these variables depend on _ver being set
source="https://www.sqlite.org/2025/sqlite-src-$_ver.zip
teaish-sqlite-version.patch
"
builddir="$srcdir/sqlite-src-$_ver"
_tools="showdb showjournal showstat4 showwal sqldiff sqlite3_analyzer"
prepare() {
default_prepare
if [ -f "$startdir"/../sqlite/APKBUILD ]; then
_amalgamation=$(
_toolsver=$pkgver
# shellcheck disable=SC1091
. "$startdir"/../sqlite/APKBUILD
if [ "$_toolsver" != "$pkgver" ]; then
die "sqlite version mismatch ($_toolsver != $pkgver)"
fi
echo "$_amalgamation"
)
fi
# based on what tool/mkautoconfamal.sh does to build the TEA tarball
mkdir -vp autoconf/tea/generic
cat > autoconf/tea/generic/tclsqlite3.c <<-'HEADER'
#ifdef USE_SYSTEM_SQLITE
# include <sqlite3.h>
#else
#include "sqlite3.c"
#endif
HEADER
cat src/tclsqlite.c >> autoconf/tea/generic/tclsqlite3.c
ln -s ../autosetup autoconf/
sed -i 's|@TEAISH_POSTINST_PREREQUIRE@|lappend auto_path '"$builddir/usr/lib/tcl8.6"'|' autoconf/tea/Makefile.in
}
build() {
export CFLAGS="$CFLAGS $_amalgamation"
# configure options copied from main/sqlite
./configure \
--build="$CBUILD" \
--host="$CHOST" \
--prefix=/usr \
--enable-threadsafe \
--enable-readline \
--enable-session \
--enable-static \
--enable-fts3 \
--enable-fts4 \
--enable-fts5 \
--soname=legacy
msg "Building sqlite3_analyzer"
make sqlite3_analyzer \
LINK_TOOLS_DYNAMICALLY=1
local tool; for tool in ${_tools//sqlite3_analyzer}; do
msg "Building $tool"
${CC:-gcc} $CFLAGS $LDFLAGS \
-I "$builddir"/ext/misc \
-o $tool tool/$tool.c -lsqlite3
done
# test at the same optimization level as main/sqlite
if want_check; then
msg "Building testfixture"
make CFLAGS="${CFLAGS//-Os/-O2}" testfixture
fi
if subpackage_types_has tcl; then
msg "Building libtclsqlite3.so"
cd autoconf/tea
./configure \
--build="$CBUILD" \
--host="$CHOST" \
--prefix=/usr \
--with-system-sqlite \
--override-sqlite-version="$pkgver"
make
fi
}
check() {
# parallelize tests on slow archs with "testrunner"
# others run "tcltest" which has more detailed output
case "$CARCH" in
arm*|loongarch64|riscv64|s390x|x86)
make testrunner
;;
*)
make tcltest || make testrunner
;;
esac
}
package() {
install -Dvm755 $_tools -t "$pkgdir"/usr/bin/
if subpackage_types_has tcl; then
cd autoconf/tea
make DESTDIR="$pkgdir" install
install -Dvm644 license.terms \
-t "$pkgdir"/usr/share/licenses/sqlite-tcl/
install -Dvm644 doc/sqlite3.n \
-t "$pkgdir"/usr/share/man/mann/
fi
}
analyzer() {
pkgdesc="Analyze space utilization of SQLite database files"
amove usr/bin/sqlite3_analyzer
}
_tcl() {
pkgdesc="Sqlite Tcl Extension Architecture (TEA)"
amove usr/lib
}
_tcl_doc() {
default_doc
pkgdesc="Sqlite Tcl Extension Architecture (TEA) (documentation)"
install_if="docs sqlite-tcl=$pkgver-r$pkgrel"
}
sha512sums="
d1b14906011c22bdb1a77e2668aceb42ea912047d8c6358e68fd4097cdaf1dc932ad47f3e621b5242c0c30366a1ecea26c170cd21ff4153d4f0c91d4b9c9eb14 sqlite-src-3500000.zip
cdfb544cf27db40b466318f80943848b5fd0baf44ad8393655ab3061587519ee9cf88df410be2841abf5844bf209ce507b96cfdbe4537272a50219955d221c8f teaish-sqlite-version.patch
"