Linux HOWTOs

About | Home | Search


HOWTO: libdbi
Description: Database-independent abstraction layer in C
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# libdbi 0.9.0
# ============
# Get it
cd
test -f installed/libdbi-0.9.0.tar.gz && mv installed/libdbi-0.9.0.tar.gz .
test ! -f libdbi-0.9.0.tar.gz &&
 wget http://downloads.sf.net/libdbi/libdbi-0.9.0.tar.gz

# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "libdbi-0.*" -exec rm -r {} \;
tar xzvf ~/libdbi-0.9.0.tar.gz
cd libdbi-0.9.0
test $UID = 0 && chown -R root:root .

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
 ./configure --datadir=/usr/local --libdir=/usr/local/lib64

# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
 ./configure --datadir=/usr/local

# Build it
make

# Become root to install it
su

# Removed old version shared library files
rm -f /usr/local/lib*/libdbi.*

# Install it
make install
ldconfig

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+rw .

# Become yourself again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/libdbi-0.*.tar.*
mv libdbi-0.9.0.tar.gz installed/


# libdbi-drivers 0.9.0
# ====================
# Prerequisites:
# libdbi (above)
# MySQL or MariaDB
# SQLite
# PostgreSQL
# ...and other semi-completed ones - see the web site

# Get it
cd
test -f installed/libdbi-drivers-0.9.0.tar.gz &&
 mv installed/libdbi-drivers-0.9.0.tar.gz .
test ! -f libdbi-drivers-0.9.0.tar.gz &&
 wget http://downloads.sf.net/libdbi-drivers/libdbi-drivers-0.9.0.tar.gz

# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "libdbi-drivers-*" -exec rm -r {} \;
tar xzvf ~/libdbi-drivers-0.9.0.tar.gz
cd libdbi-drivers-0.9.0
test $UID = 0 && chown -R root:root .

# See README and './configure --help' for all of the various databases that
# are supported.
#
# I use --datadir below to get the docs in to /usr/local/doc, rather than
# the default of /usr/local/share/doc.  --docdir doesn't do it for
# whatever reason.
#
# If your MySQL is not installed under /usr/local/mysql (the
# source-installed default), you can leave off --with-mysql-dir below.

# I had to do this to be able to run make successfully with MySQL 5.5.21
( cd /usr/local/mysql/include/mysql ; ln -s ../mysql.h )

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
LDFLAGS=-L/usr/local/ssl/lib64 \
./configure --datadir=/usr/local --libdir=/usr/local/lib64 \
 --with-dbi-libdir=/usr/local/lib64 --with-sqlite3 --with-mysql

# Configure the build for anything else:
test $(uname -m) != 'x86_64' &&
./configure --datadir=/usr/local/doc --with-sqlite3 --with-mysql

# Build it
make

# Become root to install it
su

# Removed old shared library files
test -d /usr/local/lib64/bdb &&
 rm -f /usr/local/lib64/dbd/libdbd*
rm -f /usr/local/lib/bdb/libbdb*

# Install it
make install

# Become yourself again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/libdbi-drivers-*.tar.*
mv libdbi-drivers-0.9.0.tar.gz installed/


# If you ever want to uninstall libdbi, this should do it:
cd
su
test -d src/libdbi-0.* && ( cd src/libdbi-0.* ; make uninstall )
find /usr/doc -maxdepth 1 -type d -name "libdbi-0.*" -exec rm -r {} \;
find /usr/local/doc -maxdepth 1 -type d -name "libdbi-0.*" \
 -exec rm -r {} \;
rm -f /usr/local/lib/libdbi.* /usr/local/lib/pkgconfig/dbi.pc
test -d /usr/local/lib64 &&
 ( cd /usr/local/lib64
   rm -f libdbi.* pkgconfig/dbi.pc )
test -d /usr/local/include/dbi && rm -r /usr/local/include/dbi
find /usr/local/share/doc -maxdepth 1 -type d -name "libdbi-0.*" \
 -exec rm -r {} \;
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libdbi-0.*" -exec rm -r {} \;
rm -f ~/installed/libdbi-0.*.tar.*

# If you ever want to uninstall libdbi-drivers, this should do it:
cd
su
test -d src/libdbi-drivers-* && ( cd src/libdbi-drivers-* ; make uninstall )
find /usr/doc -maxdepth 1 -type d -name "libdbi-drivers-*" -exec rm -r {} \;
test -d /usr/local/lib/dbd && rm -r /usr/local/lib/dbd
test -d /usr/local/lib64/dbd && rm -r /usr/local/lib64/dbd
find /usr/local/share/doc -maxdepth 1 -type d -name "libdbi-drivers-*" \
 -exec rm -r {} \;
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libdbi-drivers-*" -exec rm -r {} \;
rm -f ~/installed/libdbi-drivers-*.tar.*

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>