8.107. SQLite-3.49.1

8.107.1. Introduction to SQLite

The SQLite package is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

Approximate build time: 0.3 SBU
Required disk space: 123 MB

8.107.2. Installation of SQLite

Create the PKGBUILD for the SQLite package with the following commands:

mkdir /sources/sqlite
cd /sources/sqlite
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="sqlite"
pkgver="3.49.1"
pkgrel="1"
_docver="3490100"
pkgdesc="The SQLite package is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine."
arch=('x86'
      'x86_64')
url="https://sqlite.org/"
license=('GPL3')
groups=('core')
depends=('glibc')
makedepends=('bash'
             'binutils'
             'coreutils'
             'gcc'
             'grep'
             'libarchive'
             'make'
             'sed')
source=('https://sqlite.org/2022/sqlite-autoconf-3490100.tar.gz'
        'https://sqlite.org/2022/sqlite-doc-3490100.zip')
md5sums=('8d77d0779bcd9993eaef33431e2e0c30'
         '8d3e207489b544a8687e3faf8db26291')
noextract=("${pkgname}-doc-${_docver}.zip") 

prepare(){
  cd "${pkgname}-autoconf-${_docver}"
  unzip -q ../sqlite-doc-.zip
}

build(){
  cd "${pkgname}-autoconf-${_docver}"
  ./configure --prefix=/usr         \
              --disable-static      \
              --enable-fts{4,5}     \
              CPPFLAGS="${CPPFLAGS} \
                        -D SQLITE_ENABLE_COLUMN_METADATA=1 \
                        -D SQLITE_ENABLE_UNLOCK_NOTIFY=1   \
                        -D SQLITE_ENABLE_DBSTAT_VTAB=1     \
                        -D SQLITE_SECURE_DELETE=1"
  make
}

package(){
  cd "${pkgname}-autoconf-${_docver}"
  make DESTDIR="${pkgdir}" install
  install -vdm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
  cp -Rv "${pkgname}-doc-${_docver}"/* \
         "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp sqlite-3.49.1-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/sqlite-3.49.1-1-$(uname -m).pkg.tar.xz

Update the local cache and install the SQLite package:

pacman -Syu
pacman -S sqlite --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/sqlite
cp PKGBUILD /srv/pacman/source/LFS/sqlite
cd /sources
rm -rf sqlite

8.107.3. Command Explanations

--enable-fts5: This switch enables support for version 5 of the full text search extension.

CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_TOKENIZER=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_SECURE_DELETE -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1": Applications such as SeaMonkey require these options to be turned on. The only way to do this is to include them in the CFLAGS. By default, these are set to "-g -O2" so we specify that to preserve those settings. You may, of course, wish to omit the '-g' if you do not wish to create debugging information. For further information on what can be specified see http://www.sqlite.org/compile.html.

8.107.4. Contents

Installed Program: sqlite3
Installed Library: libsqlite3.so
Installed Directory: /usr/share/doc/sqlite-3.49.1

Short Descriptions

sqlite3

A terminal-based front-end to the SQLite library that can evaluate queries interactively and display the results.

libsqlite3.so

contains the SQLite API functions.