Making the SQLite moduleSubmitted by mtesauro on Sat, 04/25/2009 - 23:56 |
Get the source for SQLite
Go to the website for SQLite and you'll see a link to the downloads page where you can get the latest source. At the time of this writing, that's sqlite-amalgamation-3.6.4.tar.gz. We need SQLite for the libsqlite library - used by w3af.
I used wget to download the source directly onto the Live CD:
# mkdir working
# cd working/
# wget http://www.sqlite.org/sqlite-amalgamation-3.6.4.tar.gz
--2008-10-26 20:39:32-- http://www.sqlite.org/sqlite-amalgamation-3.6.4.tar.gz
Resolving www.sqlite.org... 67.18.92.124
[snip]
2008-10-26 20:39:36 (315 KB/s) - `sqlite-amalgamation-3.6.4.tar.gz' saved [1242663/1242663]
Compile the source and create a Slackware package
Since we've got the source into a running version of the Live CD, we can then do the compilation there to make sure the Live CD has all the necessary dependencies. First, unpack the source and run configure to make sure we've got the needed dependencies. If that works, go ahead and run make.
# tar -xzvf sqlite-amalgamation-3.6.4.tar.gz
# cd sqlite-3.6.4/
# ./configure
[ no problems]
# make
No problems so far. Lets try checkinstall and see if it can make a Slackware package for us. If so, its quite easy to convert that to a .lzm package for SLAX & the Live CD:
# checkinstall -S --install=no
[ fails ]
Here's where things get weird. I've not been successful running checkinstall after make. It keeps dying rather quickly. However, if I do a make install then run the checkinstall command, I get a valid package. Its inelegant but it works. I've not had the free time to try and figure out why.
# make install
# checkinstall -S --install=no
[snip]
**********************************************************************
Done. The new package has been saved to
/root/working/sqlite-3.6.4/sqlite-3.6.4-i386-1.tgz
You can install it in your system anytime using:
installpkg sqlite-3.6.4-i386-1.tgz
**********************************************************************
The program 'checkinstall' will run "make install" for you and, with the command line switches above, it will create a Slackware package and not actually install the program thanks to --install=no.
Create a module from the Slackware package
This is the easy part.
# cp sqlite-3.6.4-i386-1.tgz /root
# cd /root
# tgz2lzm sqlite-3.6.4-i386-1.tgz sqlite-3.6.4.lzm
Copy that .lzm file off the Live CD system (USB drive, scp, ...) so that you don't loose the progress so far.
Test the new modules
Since I had to do a "make install" before I used checkinstall, I'm going to 'reboot' the Live CD to make sure it works as expected on a fresh Live CD boot. Once you've got a fresh Live CD booted, SLAX will allow you to add modules to a running system. Before going on, you should install the modules and make sure it works like expected. Check out the page Add modules to a running system [PAGE NOT MADE] to see how to do this. Verify that SQLite works as expected:
# sqlite3 -version
3.6.4
# sqlite3 -help
Usage: sqlite3 [OPTIONS] FILENAME [SQL]
FILENAME is the name of an SQLite database. A new database is created
if the file does not previously exist.
OPTIONS include:
-init filename read/process named file
-echo print commands before execution
-[no]header turn headers on or off
-bail stop after hitting an error
-interactive force interactive I/O
-batch force batch I/O
-column set output mode to 'column'
-csv set output mode to 'csv'
-html set output mode to HTML
-line set output mode to 'line'
-list set output mode to 'list'
-separator 'x' set output field separator (|)
-nullvalue 'text' set text string for NULL values
-version show SQLite version
The one thing I don't like about this is that there isn't a sqlite binary - its sqlite3. I'm lazy and to save that future keystroke, I'm going to type a bit more to add the symbolic link into the .lzm package:
# mkdir fakeroot
# lzm2dir sqlite-3.6.4.lzm fakeroot/
# mkdir fakeroot/usr/bin
# cd fakeroot/usr/bin/
# ln -s ../local/bin/sqlite3 sqlite
# cd /root
# dir2lzm fakeroot/ sqlite-3.6.4.lzm
I went ahead and removed the earlier module and added in the new version to make sure it was OK:
# which sqlite
/usr/bin/sqlite
# sqlite -version
3.6.4
If everything goes as expected, you'll need to add this module to the ISO image. Since we've created the module in the Live CD, you'll need to move it off to a "real" computer. I save both the .lzm modules as well as the Slackware package. The Slackware package is at /root/working/sqlite-3.6.4/sqlite-3.6.4-i386-1.tgz and the newest module will be in the same directory if you've followed the above instructions. You can use a USB drive, scp or whatever to get the files off the Live CD.
Add the modules to the ISO build directory
Also cake
$ cp -i sqlite-3.6.4.lzm ../contents/slax/base/
$ chmod 775 ../contents/slax/base/sqlite-3.6.4.lzm
This assumes your sqlite module was moved into your working directory. See Creating the base Live CD from SLAX (Create a Working Directory section)
Clean up and archive
Once you've got a working module, lets clean up a bit.
$ $ mkdir ./completed_modules/sqlite
$ mv sqlite-3.6.4.lzm ./completed_modules/sqlite/
$ mv sqlite-3.6.4-i386-1.tgz ./completed_modules/sqlite/
$ mv temp/sqlite-amalgamation-3.6.4.tar.gz ./completed_modules/sqlite/
$ rm -rf ./temp/*
