Friday, February 29, 2008

Symbol Variants - MacOSX

Up until now it has been impossible to run kinterbasdb against SuperServer builds of Firebird for MacOSX on Tiger (10.4). When you try and import kinterbasdb into Python the following error occurs:
Symbol not found fputs$UNIX2003
This is a bit of a problem.
Reading around the issue indicates that symbol usage between MacOSX 10.4 and 10.5 has changed because of the introduction of
UNIX cconformance.
This article on explains why we might see UNIX2003 symbols.
Basically anything compiled on 10.5 will use the new conforming UNIX2003 sysmbols where appropriate.
However we shouldn't be seeing these symbols if we compile everything with
--mmacosx-version-min=10.4 and/or set MACOSX_DEPLOYMENT_TARGET=10.4
So why when we try and run kinterbasdb on 10.4 we have a problem?
A nm -a libfbclient.dylib shows that there are 4 UNIX2003 symbols in the library...
and I had no idea where they were coming from.
It seems that we have a link problem, and the only way to make sure that they do not get pulled in to the libfbclient library is to insist that the linker links against the 10.4 sdk.
A small change to prefix.darwin_i386 seems to solve the problem
Add LD_FLAGS+=-isysroot /Developer/SDKs/MacOSX10.4u.sdk
Why the linker ignores the flag/environment variable is a mystery to solve another day.

Thursday, February 21, 2008

Firebird and MacOSX Uninstalls

MacOSX doesn't have an uninstall utility.
I use the following script to clean up Firebird installs on Leopard.
It should work on Tiger as well.
Would it make sense to include this in the Firebird package, along with a similar script for earlier versions of MacOSX (pre 10.4 for the powerpc builds)

echo "Clean Services"
echo "Clean User"
dscl localhost -delete /Local/Default/Users/firebird
echo "Clean Group"
dscl localhost -delete /Local/Default/Groups/firebird
if [ -f "/Library/StartupItems/Firebird" ]; then
echo "Remove SuperServer StartupItem"
rm -fr /Library/StartupItems/Firebird
if [ -f "/Library/LaunchDaemons/org.firebird.gds.plist" ]; then
echo "Remove Launchd"
launchctl unload /Library/LaunchDaemons/org.firebird.gds.plist
rm /Library/LaunchDaemons/org.firebird.gds.plist
echo "Remove Framework"
rm -fr /Library/Frameworks/Firebird.framework
echo "Remove Receipt"
rm -fr /Library/Receipts/Firebird*.pkg

#Add the following for Firebird V2.5
echo "Remove /tmp/firebird"
rm -fr /tmp/firebird

Tuesday, February 19, 2008

Python, kinterbasdb and 64bit MacOSX 10.5

Now we have 64bit builds of Firebird 2.1 for MacOSX 10.5, we have issues trying to test them properly using the Firebird QMTest QA suite. This QA suite relies on Python and kinterbasdb. Currently Philippe Makowski has been able to run the tests from a 64bit Linux client. But is unable to run the tests locally. Well currently the python framework that comes with MacOSX 10.5 is only 32bit and this forces a 32bit build of kinterbasdb, since the build environment of kinterbasdb uses distutils to use the same compile switches as python. So I thought I would have a look at the issue and see if I could build a 64bit version of kinterbasdb for MacOSX 10.5.

This is how I did it...

1. Download the source distribution of Python
2. Edit and change line 817, so it looks like this
BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd -arch x86_64"
3. Make sure that (just in case)
a, CFLAGS, CXXFLAGS and LDFLAGS are exported with -arch x86_64
e.g. export CFLAGS='-arch x86_64'
4. autoconf
5. ./configure --disable-toolbox-glue
This disables Carbon as its only 32bit and you will get compile errors if you don't
We are not building a framework, or a universal binary just a simple standalone version of 64bit python. So do not enable those options.
6. make
You may get a warning/errors possibly in some of the extensions e.g.
ld warning in /System/Library/Frameworks/TK.framework/Tk missing required architecture x86_64 in file.
I guess you would have to download the relevant code and rebuild these as 64bit if you need them. But since we are only interested in kinterbasdb I guess I can afford to ignore it.
A check on the built python.exe shows that it is Mach-O 64 bit executable.

Now we need to build kinterbas db using this python.exe
1. Download kinterbasdb from sourceforge
-> 2. Replace in the kinterbasdb source the with this one :
Note I forgot to add this step when I wrote the original instructions.
3. Make sure you have the 64bit Firebird 2.1 for MacOSX installed
4. Make sure you are running as root
su and log in
export CFLAGS, CXXFLAGS and LDFLAGS ='-arch x86_64'
The install option will want to put the kinterbasdb in /usr/local/lib/python2.5
Although I suspect you can change this by using a different --prefix when you build python
5. pathtojustbuilt64bitpython/python.exe install
pathtojustbuilt64bitpython/python.exe build
if you just want to build it.
6. You can check what you have installed by
file /usr/local/lib/python2.5/site-packages/kinterbasdb/
Mach-O 64bit bundle x86_64

Now we can test it...
create a database using isql
>>> import kinterbasdb;kinterbasdb.init(type_conv=200)
Don't use mx.DateTime use the default python DateTime
>>> con = kinterbasdb.connect(dsn='localhost:/pathtodd/test.fdb', user='sysdba', password='masterkey')

It works ....

Tuesday, February 12, 2008

Testing and Debugging the Service Manager on MacOSX

For Classic - SuperServer is easy.

export PATH

In one terminal session:
gsec -user xxx -password -xxx -database localhost:/Library/Frameworks/Firebird.framework/Resources/English.lproj/var/security2.fdb
This will start a remote connection to gsec via the service manager...
ps -eaf | grep fb
and look for the running fb_inet_server

In the other
cd /Library/Frameworks/Firebird.framework/Resources/bin
gdb ./fb_inet_server --pid=
Set the pid to the running fb_inet_server
gdb> break svc.cpp:2461
set an appropriate break point - in this case when vfork starts
gdb> continue

In the original session
gsec> display

In the gdb session the debugger should break when vfork is called in svc.cpp

Now do what you need to - to walk through the code.

If all is working properly, try doing a backup using the service manager...
gbak -v -b -user xxxx -password xxxx /Users/pbeach/databases/test.fdb /Users/pbeach/databases/test.fbk -se localhost:service_mgr

Friday, February 8, 2008

Adding a User to a Group using dscl

How to add a user to the Firebird group on MacOS using dscl

dscl localhost append /Local/Default/Groups/firebird GroupMembership pbeach
dscl . append Groups/firebird GroupMembership pbeach

Sunday, February 3, 2008

Nine Below Zero

Non Technical for a change:

2nd Feb 2008 + Cafe Francaise@Chinon + Nine Below Zero
* (Rhythm + Blues) + 150 people = Superb gig.