This is a short hands-on tutorial on creating SQLite 3 RPM packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL).

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.” — source

NOTE: The commands on this guide were tested on both CentOS 6.2 and Scientific Linux 6.2 (2.6.32-220.17.1.el6.x86_64) virtual machines, using the SQLite 3.7.12.

To build the RPM packages we first need to setup an RPM development environment as described on the article: How to set up a build environment for RPM packages on Enterprise Linux.

Once the development environment is correctly setup, login as as root and install the additional required packages:

$ su root
# yum install ncurses-devel readline-devel glibc-devel
# exit

Log in as makerpm user and create the following SPEC file on ~/rpmbuild/SPECS:

$ cd ~/rpmbuild/SPECS
$ touch sqlite.spec
$ cat > sqlite.spec

Copy and paste the following code:

%define realver 3071200
%define docver 3071200
%define rpmver 3.7.12

Summary:		Library that implements an embeddable SQL database engine
Name:			sqlite
Version:		%{rpmver}
Release:		1%{?dist}
License:		Public Domain
Group:			Applications/Databases
Source0:		sqlite-autoconf-%{realver}.tar.gz

BuildRequires:	ncurses-devel readline-devel glibc-devel

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

SQLite is a C library that implements an SQL database engine. A large
subset of SQL92 is supported. A complete database is stored in a
single disk file. The API is designed for convenience and ease of use.
Applications that link against SQLite can enjoy the power and
flexibility of an SQL database without the administrative hassles of
supporting a separate database server.  Version 2 and version 3 binaries
are named to permit each to be installed on a single host

%package devel
Summary: Development tools for the sqlite3 embeddable SQL database engine
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig

%description devel
This package contains the header files and development documentation
for %{name}. If you like to develop programs using %{name}, you will need
to install %{name}-devel.

%setup -n %{name}-autoconf-%{realver}



make clean

%defattr(-, root, root)

%files devel
%defattr(-, root, root)
%exclude %{_libdir}/*.la

* Thu May 17 2012 Nicola Asuni - 3.7.12-1
- First version or autoconf.

Press [Ctrl]-[D] to end.

Copy the SQLite source code to the ~/rpmbuild/SOURCES:

$ cd ~/rpmbuild/SOURCES
$ wget

The SQLite source file is a tarball containing the amalgamation for SQLite 3.7.12 together with a configuration script and makefile for building it.

To create the RPM packages you can use the following commands:

$ cd ~/rpmbuild/SPECS
$ QA_RPATHS=$[ 0x0001|0x0010 ] rpmbuild -ba sqlite.spec

You should now find the RPM packages at ~/rpmbuild/RPMS/$(uname -m).
The sqlite-devel package contains the header files required to embed the SQLite on other programs.

To install them you can type:

$cd ~/rpmbuild/RPMS/x86_64/
$su root
#rpm -U --force sqlite-3.7.12-1.el6.x86_64.rpm sqlite-devel-3.7.12-1.el6.x86_64.rpm

Nicola Asuni Systems Engineer

Nicola focused on designing, building and integrating the backend for our application platforms, including automatic deployment, monitoring and backups.