From 0781671a77220a2b87be2de7e6415efc7947a75c Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 15 Feb 2018 20:13:00 +0000
Subject: sqlite: update to 3.22.0

---
 abs/extra/sqlite/PKGBUILD | 135 +++++++++++++++++++++++++++-------------------
 1 file changed, 80 insertions(+), 55 deletions(-)

diff --git a/abs/extra/sqlite/PKGBUILD b/abs/extra/sqlite/PKGBUILD
index 062789e..1e09121 100644
--- a/abs/extra/sqlite/PKGBUILD
+++ b/abs/extra/sqlite/PKGBUILD
@@ -1,70 +1,108 @@
-# $Id: PKGBUILD 161621 2012-06-12 15:12:59Z andyrtr $
+# $Id$
 # Maintainer: Andreas Radke <andyrtr@archlinux.org>
 # Contributor: Tom Newsom <Jeepster@gmx.co.uk>
 
 pkgbase="sqlite"
-pkgname=('sqlite' 'sqlite-tcl' 'sqlite-doc') 
-_amalgamationver=3071300
-_amalgamationver2=${_amalgamationver/00/}
-_docver=${_amalgamationver}	#3070700
-#pkgver=${_amalgamationver2//0/.}
-pkgver=3.7.13
+pkgname=('sqlite' 'sqlite-tcl' 'sqlite-doc' 'sqlite-analyzer')
+_srcver=3220000
+_docver=${_srcver}
+#_docver=3080001
+pkgver=3.22.0
 pkgrel=1
 pkgdesc="A C library that implements an SQL database engine"
-arch=('i686' 'x86_64')
-license=('custom')
+arch=('x86_64')
+license=('custom:Public Domain')
 url="http://www.sqlite.org/"
-makedepends=('tcl' 'readline')
-source=( # tarball containing the amalgamation for SQLite >= 3.7.5 together with a configure script and makefile for building it; includes now also the Tcl Extension Architecture (TEA)
-	http://www.sqlite.org/sqlite-autoconf-$_amalgamationver.tar.gz
-	#http://www.sqlite.org/sqlite-doc-${_amalgamationver}.zip
-	http://www.sqlite.org/sqlite-doc-${_docver}.zip
-	license.txt)
-options=('!libtool' '!emptydirs')
-md5sums=('c97df403e8a3d5b67bb408fcd6aabd8e'
-         '16a003d5a619a6c725e3d81cf5aaba2a'
-         'c1cdbc5544034d9012e421e75a5e4890')
+makedepends=('tcl' 'readline' 'zlib')
+source=(https://www.sqlite.org/2018/sqlite-src-${_srcver}.zip
+        https://www.sqlite.org/2018/sqlite-doc-${_docver}.zip
+        license.txt)
+options=('!emptydirs' '!makeflags') # json extensions breaks parallel build
+sha1sums=('2bc86f2c63868cebd0db913843b919d62d284094'
+          '4cbcc5c5029b8e355fa1e5c563a15b91f7ea7ced'
+          'f34f6daa4ab3073d74e774aad21d66878cf26853')
+
+prepare() {
+  cd sqlite-src-$_srcver
+#  autoreconf -vfi
+}
 
 build() {
-  export CFLAGS="$CFLAGS -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_SECURE_DELETE"
+  export CPPFLAGS="$CPPFLAGS -DSQLITE_ENABLE_COLUMN_METADATA=1 \
+                             -DSQLITE_ENABLE_UNLOCK_NOTIFY \
+                             -DSQLITE_ENABLE_DBSTAT_VTAB=1 \
+                             -DSQLITE_ENABLE_FTS3_TOKENIZER=1 \
+                             -DSQLITE_SECURE_DELETE \
+                             -DSQLITE_MAX_VARIABLE_NUMBER=250000 \
+                             -DSQLITE_MAX_EXPR_DEPTH=10000"
 
   # build sqlite
-  cd "$srcdir"/sqlite-autoconf-$_amalgamationver
-  ./configure --prefix=/usr \
-	--disable-static
-  make
-  
-  # build the tcl extension    
-  cd "$srcdir"/sqlite-autoconf-$_amalgamationver/tea
+  cd sqlite-src-$_srcver
   ./configure --prefix=/usr \
-	--with-system-sqlite
+	--disable-static \
+	--disable-amalgamation \
+	--enable-fts3 \
+	--enable-fts4 \
+	--enable-fts5 \
+	--enable-rtree \
+	--enable-json1 \
+	TCLLIBDIR=/usr/lib/sqlite$pkgver
   make
-
+  # build additional tools
+  make showdb showjournal showstat4 showwal sqldiff sqlite3_analyzer
 }
 
 package_sqlite() {
- 
+
  pkgdesc="A C library that implements an SQL database engine"
- depends=('readline')
+ depends=('readline' 'zlib')
  provides=("sqlite3=$pkgver")
  replaces=("sqlite3")
- 
-  cd ${srcdir}/sqlite-autoconf-$_amalgamationver
+
+  cd sqlite-src-$_srcver
   make DESTDIR=${pkgdir} install
-  
-  # license
-  install -D -m644 ${srcdir}/license.txt ${pkgdir}/usr/share/licenses/${pkgname}/license.txt
+
+  install -m755 showdb showjournal showstat4 showwal sqldiff ${pkgdir}/usr/bin/
+
+  # install manpage
+  install -m755 -d ${pkgdir}/usr/share/man/man1
+  install -m644 sqlite3.1 ${pkgdir}/usr/share/man/man1/
+
+  # license - no linking required because pkgbase=pkgname
+  install -D -m644 ${srcdir}/license.txt ${pkgdir}/usr/share/licenses/${pkgbase}/license.txt
+
+  # split out tcl extension
+  mkdir $srcdir/tcl
+  mv $pkgdir/usr/lib/sqlite* $srcdir/tcl
 }
 
 package_sqlite-tcl() {
- 
+
  pkgdesc="sqlite Tcl Extension Architecture (TEA)"
  depends=('sqlite')
  provides=("sqlite3-tcl=$pkgver")
  replaces=("sqlite3-tcl")
- 
-  cd ${srcdir}/sqlite-autoconf-$_amalgamationver/tea
-  make DESTDIR=${pkgdir} install
+
+  install -m755 -d ${pkgdir}/usr/lib
+  mv $srcdir/tcl/* ${pkgdir}/usr/lib
+
+  # install manpage
+  install -m755 -d ${pkgdir}/usr/share/man/mann
+  install -m644 ${srcdir}/sqlite-src-$_srcver/autoconf/tea/doc/sqlite3.n ${pkgdir}/usr/share/man/mann/
+
+  # link license
+  install -m755 -d ${pkgdir}/usr/share/licenses
+  ln -sf /usr/share/licenses/${pkgbase} "${pkgdir}/usr/share/licenses/${pkgname}"
+}
+
+package_sqlite-analyzer() {
+
+ pkgdesc="An analysis program for sqlite3 database files"
+ depends=('sqlite' 'tcl')
+
+  cd sqlite-src-$_srcver
+  install -m755 -d ${pkgdir}/usr/bin
+  install -m755 sqlite3_analyzer ${pkgdir}/usr/bin/
 }
 
 package_sqlite-doc() {
@@ -73,21 +111,8 @@ package_sqlite-doc() {
  #arch=('any') - not yet supported
  provides=("sqlite3-doc=$pkgver")
  replaces=("sqlite3-doc")
- 
-  #cd ${srcdir}/sqlite-doc-${_amalgamationver}
-  cd ${srcdir}/sqlite-doc-${_docver}
+
+  cd sqlite-doc-${_docver}
   mkdir -p ${pkgdir}/usr/share/doc/${pkgbase}
   cp -R *  ${pkgdir}/usr/share/doc/${pkgbase}/
-  
-  # fix permissions and remove obsolete files; https://bugs.archlinux.org/task/24605
-  find ${pkgdir} -type f -perm 755 -exec ls -lha {} \;
-  find ${pkgdir} -type f -perm 755 -exec chmod 644 {} \;
-
-  find ${pkgdir} -type f -name '*~' -exec ls -lha {} \;
-  find ${pkgdir} -type d -name '*~' -exec ls -lha {} \;
-  find ${pkgdir} -name '*~' -exec rm -f {} \;
-
-  find ${pkgdir} -type f -name '.~*' -exec ls -lha {} \; # /build/pkg/sqlite-doc/usr/share/doc/sqlite/images/fileformat/.~lock.indexpage.odg#
-  find ${pkgdir} -type d -name '.~*' -exec ls -lha {} \;
-  find ${pkgdir} -name '.~*' -exec rm -f {} \;
 }
-- 
cgit v0.12

