TOra with Oracle support on Debian squeeze

21 02 2011

This is a situation that I have faced more than once: new computer, new OS install, new job, or just something that broke and I needed to start over.

It happened again around september last year, when I joined ThoughtWorks: I had to compile TOra from sources to get Oracle support in it. I am a Debian user, so the TOra that can be installed from the repositories does not offer native support for Oracle for licensing (and freedom) reasons. The same feature is present in the package distributed by Ubuntu.

If you are also trying to get Oracle support in TOra, bear with me. But before I get to the actual compilation walkthrough, note that I am running Debian squeeze 64-bit, so you may need to adapt some paths if you’re running 32-bit.

Also, whenever I post commands to be issued, pay attention to the prompt character. If it’s a dollar sign ($), the command can be run as a normal user; if it’s a pound sign (#), then that command must be run as root.

Ready? Let’s get our hands dirty, then.

1. Getting and installing the Oracle software

The first step is to actually get a basic Oracle client and sdk installed. Head over to the Instant Client download page (64-bit|32-bit). You might need to create a user before downloading anything from there.

To me, the easiest way to get these installed is to download the RPMs and converting them with alien. The packages you’ll need are:

  • Instant Client Package – Basic or Basic Lite (This is the client that will handle the connections to the server. The difference between the versions is that the Basic Lite one is only in English and its filesize is smaller);
  • Instant Client Package – SQL*Plus (Excellent for testing the installation and running PL/SQL scripts from the CLI);
  • Instant Client Package – SDK (Needed for compiling TOra).

Once you have downloaded the packages, head to the directory where you saved them and execute the following line of code (you need to have fakeroot, alien and rpm installed beforehand):

$ for n in $(ls oracle-*.rpm); do fakeroot alien $n; done;

Then, as root (or using sudo):

# dpkg -i *.deb

The installation will be split into two separate trees: one for the binary blobs, and one for the SDK. The binaries are placed under /usr/lib/oracle/<version>/client[64], while the SDK is under /usr/include/oracle/<version>/client[64]. I am using Oracle version 11.2 64-bit, so my dirs are:

  • /usr/lib/oracle/11.2/client64
  • /usr/include/oracle/11.2/client64

From now on, these are the directories that I will be using on the post. Please adapt whenever necessary.

Next step is to create a symbolic link inside the libs dir that will point to the SDK:

# ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/include

Now, add some environment variables to your ~/.bashrc file:

export ORACLE_BASE=/usr/lib/oracle/11.2
export ORACLE_HOME=$ORACLE_BASE/client64
export TNS_ADMIN=/etc/oracle
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/include/oracle/11.2/client64:/usr/lib/oracle/11.2/client64/lib

Note that the last variable is pointing to /etc/oracle. You can point this to whatever directory you want. This variable tells the Oracle client where your TNSNAMES.ORA file is located (if you have one), so point it to wherever you will put the file.

Now, either open a new bash session, or just source your .bashrc file to initialise the variables:

$ source ~/.bashrc

2. Getting, building and installing TOra

Now you’ll probably want to get the TOra sources from your package manager, so first create a directory where the sources will be downloaded to and enter it. Then get the sources and dependencies:

$ apt-get source tora
(...) Sources downloaded

And as root:

# apt-get build-dep tora

Debian squeeze has TOra version 2.1.2, so:

$ cd tora-2.1.2
$ dpkg-buildpackage -us -uc -rfakeroot

Wait until compilation finishes. If all goes well, you’ll find a .deb package waiting to be installed in the parent directory:

$ cd ..
# dpkg -i tora_2.1.2-1_amd64.deb ## as root!

After installing the package, it’s time to try out and see if you have Oracle support. Run the software

$ tora

If it complains about not being able to load, you have to install the package libaio1 and try again.

Now, check that you see Oracle in the Connection Provider dropdown:

If so, compilation and installation is finished. Now it’s time to put a TNSNAMES.ORA in the $TNS_ADMIN directory and restart the software.

It’s also a good idea to put the package on hold, so that it does not get overwritten by the distro package during your next update:

# echo "tora hold" | dpkg --set-selections

Update per Matt Fischer’s suggestion: If aptitude is ignoring the “hold” command given to dpkg above, try

# aptitude hold tora

Update: If you get complaints about missing dependencies on, please refer to the comment by mehturt on August 10 2011 below.

You’re ready to rock!


pdo_oci the Debian way (as much as possible)

31 03 2009

If you need generic instructions on how to compile a PHP5 module on Debian, please follow this link.

For pdo_oci you need to depart a bit from the canonical way. Follow these instructions in order to get a nicely built and installable debian package for it. Note that you need to have an Oracle client properly installed and configured for this module to be useful.

Below is a simple cake recipe for achieving that. Please modify according to your needs.

mkdir -p ~/src/php5
cd ~/src/php5
apt-get source php5
cd php5-5.2.6.dfsg.1/ext/pdo_oci
pecl package package2.xml

These steps will have generated a PDO_OCI-1.0.1.tgz archive. Now you want to make this package debian-ready. Begin by issuing the following command (found in the package dh-make-php):

dh-make-pecl --only 5 PDO_OCI-1.0.1.tgz

Now comes the magic. Enter the newly created directory php-pdo-oci-1.0.1 and edit the file debian/rules:

cd php-pdo-oci-1.0.1
vi debian/rules

Find the line that declares the constant PECL_PKG_NAME and change it from




Now look for the block

configure-stamp-v4 configure-stamp-v5:

There, right after the line that says

$(PHPIZE)$*; \

insert these lines:

sed -e 's/prefix\/include\/php\/ext/prefix\/include\/php5\/ext/' configure > /tmp/pdo_oci-configure; \
cp /tmp/pdo_oci-configure ./configure; \

Save the file and proceed with package creation:

dpkg-buildpackage -rfakeroot -us -uc

If no errors are reported, you will have just created a debian package into .. for pdo_oci ready to be installed by dpkg.

UPDATE: If you are having problems with your Oracle libs and/or includes not being found, try installing the instantclient packages (alien them from the RPMs found on Oracle’s downloads website). Here I am using the 11.2 x86_64 client. If yours differ, please adjust the paths accordingly.

First, make a symbolic link:

# cd /usr/lib/oracle/11.2/client64
# ln -s /usr/include/oracle/11.2/client64 ./include

Then, set some environment variables:

export ORACLE_BASE=/usr/lib/oracle/11.2
export ORACLE_HOME=$ORACLE_BASE/client64

And you should be good to go!

Ardour in need of support from the community

8 02 2009

This will be a quick post on a subject that I think needs great attention from the music and the FOSS communities.

Ardour ( is a fantastic free DAW (Digital Audio Workstation) software. It aims to meet and supercede commercial DAW features, like Cubase, Logic and others. It already is a great tool (the latest one that I have used was 2.0 — current stable release is 2.7.1 while 3.0 is already in the works) and many people of the FOSS community benefit from it.

It just came to me today as sad news that the company that was supporting the project, SAE, is now discontinuing this much needed support, leaving Paul, Ardour’s lead developer, in need for a job and thus less attentious to the project.

Many people are already moving fingers to help the project, but it certainly needs much more help. One way to help is to spread the word (like I am doing, as I currently don’t have the means to support financially the project), another is to make donations or to subscribe to their donation plan. More info can be found in their home page.

Please do not let the best FOSS DAW die.

Compiling PHP5 modules in Debian

14 01 2009


This post explains my first attempts in getting PDO_OCI installed in Debian. Even though it works and has served me quite well for some time, now I’ve found a way to make actual .deb packages of these modules so I can save them for later use (or distribution, as long as their source code goes along) and have them installed in a sane way via the package manager.

So, first things first. You have to download php5 source (apt-get source php5) and its build dependencies (apt-get build-dep php5). Next thing is to build the extension you need.

I’ll take PDO for an example.

First, enter the extension’s directory:
cd php5-5.2.6.dfsg.1/ext/pdo
Now, look for a .xml file in this directory. In this case, it is called package2.xml. It contains the extension’s package description. Now, build a .tgz of the extension:
pecl package package2.xml
It will generate a PDO-1.0.3.tgz file. Now, create a Debian package source for this archive:
dh-make-pecl --only 5 PDO-1.0.3.tgz
The –only 5 parameter tells the script builder to make only the php5 package (not php4). Next step is to build the package:
cd php-pdo-1.0.3
fakeroot debian/rules binary

If all goes well, there’s a ../php5-pdo_1.0.3-1_i386.deb file, ready to be installed!

One more try on the mach64

8 03 2008

Still tryin to get DRI and Composite on my mach64, I bumped on this site: I have somewhat adapted some of the steps to simplify and better organise things.

First thing is to get the latest xf86-video-ati driver from and untar it to ~/src. If you have no such directory, create it first.

Then, get the headers for your running kernel and the build-essential: apt-get install linux-headers-`uname -r` build-essential.

Create a ~/src/drm-git directory and run git clone git:// from inside it. This will get the latest drm drivers from upstream.

$ cd drm/linux-core

$ make DRM_MODULES=”mach64″

$ sudo cp *.ko /lib/modules/`uname -r`/kernel/drivers/char/drm/

$ sudo depmod -a

$ sudo modprobe mach64


$ cd ~/src/xf86-video-ati-6.8.0

$ ./configure –prefix=/usr

$ make

$ sudo make install

$ sudo /etc/init.d/gdm restart

(to be continued…)

$ glxinfo | grep direct
direct rendering: No (If you want to find out why, try setting LIBGL_DEBUG=verbose)

$ LIBGL_DEBUG=verbose glxinfo
name of display: :0.0
libGL: XF86DRIGetClientDriverName: 6.7.0 mach64 (screen 0)
libGL: OpenDriver: trying /usr/X11R6/lib/modules/dri/
libGL error: dlopen /usr/X11R6/lib/modules/dri/ failed (/usr/X11R6/lib/modules/dri/ cannot open shared object file: No such file or directory)
libGL error: unable to find driver:
display: :0 screen: 0
direct rendering: No (If you want to find out why, try setting LIBGL_DEBUG=verbose)

The file is in the package libgl1-mesa-dri. If you don’t have it installed, aptitude install libgl1-mesa-dri. This might not be enough, though, as the dri libs are not in /usr/X11R6/lib/modules/dri, but rather in /usr/lib/dri. What I did to correct this issue was to check that /usr/X11R6/lib/modules/dri was empty, then:

$ sudo rmdir /usr/X11R6/lib/modules/dri
$ sudo ln -s /usr/lib/dri /usr/X11R6/lib/modules/dri

And finaly:

$ glxinfo | grep direct
DISPATCH ERROR! _glapi_add_dispatch failed to add glAreTexturesResident!
DISPATCH ERROR! _glapi_add_dispatch failed to add glGenTextures!
DISPATCH ERROR! _glapi_add_dispatch failed to add glIsTexture!
do_wait: drmWaitVBlank returned -1, IRQs don’t seem to be working correctly.
direct rendering: Yes

Yay! That’s it! Now, to get the transparent terminal…

How to get the C-Cedilla on GNOME

4 03 2008

I have been through a lot of trouble to get c-cedilla (cê-cedilha, in portuguese) as the default for ‘ + c (accute accent + c) on GNOME. In case you don’t know what I am talking about, this is what the character looks like: ç.

Turns out that if I set my language to portuguese, I do get the cedilla by default. The problem is that I really prefer to have my system in english, and with this language I get this character by default: ć.

After reading a bit, I found the gtk-query-immodules-2.0 command, which I have used this way:

$ gtk-query-immodules-2.0 | grep cedilla
"cedilla" "Cedilla" "gtk20" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa"

This tells me which languages will have the c-cedilla behaviour by default. After some more research I found this link which pointed me to the file /usr/lib/gtk-2.0/2.10.0/immodule-files.d/libgtk2.0-0.immodules. I have edited the cedilla section of this file by adding


to the end of the languages array, like this:

"cedilla" "Cedilla" "gtk20" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa:en"

This should be enough. When I restart X I will post the results here.

Update: Yes, it did! Just as a reminder, it is also necessary to choose the international variant of your keyboard. To do that, go to System / Preferences / Keyboard, open the Layouts tab, click on Add and choose your layout (United Kingdom, in my case) and Variation: International (with dead keys).

DRI on an old ATI mach64 card

4 03 2008

So, here I go trying to get some transparency on my old laptop. I have done it in the past, so I know it is posible.

The laptop is a VM7000 made by RM. It has a Coppermine Celeron 500MHz and it had originally 128MB of RAM. I have recently increased that to 256, which is the maximum it supports.

The video card, according to lspci, is a “VGA compatible controller: ATI Technologies Inc 3D Rage LT Pro (rev dc)”. It uses the mach64 driver. My goal here is to get DRI working on it so I can have drop shadows and real translucency for the terminal windows (I know it is rather useless, but it looks cool).

The system is an up-to-date Debian Lenny. To achieve this objective, I am mostly being guided by this thread on the Ubuntu Forums:

So far, I have accomplished steps 1 – 5. The script in the mach64 directory has given trouble. First, by looking at the dri.log file generated by the script, I have found that it is trying to find a linux/config.h in the kernel headers directory. It is not there because it has been deprecated. By following this tip I have managed to get past all the config.h errors by substituting it by autoconf.h in all files that were trying to include it.

This, though, has led me to another error, a quite esoteric one: “error: size of array ‘type name’ is negative”.

After reading this I have decided to recompile my kernel with


I know that the solution mentioned in the link is about x64 and this laptop is definitely not 64 bit, but I guess it’s worth the shot. It might just work.

Update: No, it didn’t. After recompiling the kernel, the script of mach64 still gave the same error. I’ll keep trying and will keep posting the results here.