The Irish Penguin Watching Open Source unfold across Ireland

22Nov/100

Getting Pyzeemote running on MeeGo

Pyzeemote allows a Zeemote controller to communicate with a running application over D-Bus. We're going to get it running on MeeGo today. All in all, getting this working will involve the following components
- Python drivers for the Zeemote device (provided by Pyzeemote)
- A daemon which listens for Pyzeemote events and shepherds them onto the application over D-Bus (provided by Pyzeemote)
- A test suite which tells you if everything is working correctly (provided by Pyzeemote)
- Bluetooth python bindings (provided by 3rd party library PyBluez)

PRE-REQUISITES

The MeeGo machine these steps were carried out on was a Leveno IdeaPad, which had the MeeGo core repository disabled and the MeeGo test and devel repos enabled - as outlined at our earlier guide Installing Ruby and Rubygems on MeeGo. You may need to do this as well, as these repositories are likely the source of some of the libraries used in this guide. Furthermore you will need to install packages for building python bluezy bindings

sudo zypper install gcc make python-devel bluez-libs-devel

PYZEEMOTE INSTALLATION STEPS

* Create a directory pyzee in your home directory

mkdir pyzee

* Download pyzeemote source on Google Code using svn
* If you don't have svn you can just use the Browse functionality of Google Code and download (the raw version) of the following files manually:

pyzeemote-test.py, zeemote_listener.py, README

* Whether you use svn or Browse simply ensure that you have the above 3 files at the top level of your pyzee directory

* Download bluezy python bindings (PyBluez-0.18.tar.gz) which will work on MeeGo from PyBluez on Google Code
* Move the PyBluez-0.18.tar.gz to the top level of your pyzee directory
* Change directory to the pyzee directory

cd ~/pyzee

* Extract the PyBluez-0.18 contents

tar -zxvf PyBluez-0.18.tar.gz

* Change directory to the PyBluez-0.18 directory

cd PyBluez-0.18

* Build the python bluetooth bindings by running

python setup.py build

* Change directory back up one level so that you're inside the top level of the pyzee directory

cd ..

* Create a symlink to the freshly built bluetooth python bindings, so that they'll be found when we run pyzeemote

ln -s PyBluez-0.18/build/lib.linux-i686-2.6/bluetooth

* Fire up the pyzeemote daemon (you shouldn't see any output) using

python zeemote_listener.py

You shouldn't see any output if things went correctly. If you get the following then there is a problem with the bluetooth python bindings built in the last steps
---------------------------------------------------
Traceback (most recent call last):
File "zeemote_listener.py", line 39, in <module>
from bluetooth import *
ImportError: No module named bluetooth
---------------------------------------------------
You'll have to figure out why this is. Perhaps the symlink wasn't created correctly or it was created in the wrong place?

* Run the pyzeemote test suite

python pyzeemote-test.py

* You should see it say
Trying to find a Zeemote device...
* Try to click some buttons on your zeemote device. If successful, you should see output at the command line as you do so. Congrats, it's working!

20Nov/100

Installing Ruby on Rails on MeeGo with SQLite

This post will go through installing Ruby on Rails 2.3.2 on MeeGo - though it should likely work for any version of Rails, including Rails 3 (though the actual Rails commands at the end of this guide will be a little different). Firstly go through the Installing Ruby and Rubygems on MeeGo guide to get at least Ruby 1.8.7 on your system and then carry out the following steps.

PRE-REQUISITES

* The above guide requires you to disable the core repository and then enable the devel and testing repositories. I found that when following the below steps, I would get an error trying to install sqlite3 gem itself - saying that the sqlite3.h header could not be found. I had to run the following commands first

# Update all packages on the system

sudo zypper update

# Then the chrome browser would not work saying

[declan@declan-desktop grr]$ chromium-browser
/usr/lib/chromium-browser/chromium-browser: error while loading shared libraries: libicuuc.so.42: cannot open shared object file: No such file or directory

# To fix this, I had to update chromium-browser separately

sudo zypper update chromium

Ok, so onto the actual install steps for Rails and SQLite3...

RAILS INSTALLATION

#Install ruby and sqlite development headers (as we'll be using sqlite as our backend)

sudo zypper install ruby-devel

sudo zypper install sqlite-devel

# Install tools for building C-based gems

sudo zypper install make # Not 100% sure that make is needed

sudo zypper install gcc

# Install sqlite3 gem for ruby

sudo zypper install sqlite3-ruby

# Install Rails

sudo gem install rails -v 2.3.2

# Create a new Rails application
rails grr

# Create a thing (ok, more correctly called a resource) in Rails

cd grr

./script/generate Animal name:string

# Create the database

rake db:migrate

# Fire up the Rails web server

./script/server

# And then browse to your site in the web browser - http://localhost:3000/animals

Hurrah! Everything works! (At least I hope it did!). Happy Rails development!

18Nov/100

Installing Ruby and Rubygems on Meego

Thanks to some great people on the Meego mailing lists I can happily show you how to get recent versions of Ruby and Rubygems running on your beloved MeeGo. The steps I present here are simply extracted from the guide at http://wiki.meego.com/Quality/QA-tools/TDriver

Once the more recent Ruby releases (1.8.7 and higher) gain more traction in MeeGo they will likely move into the core repository. So, be sure to see if they are there before changing adding/removing repositories as it outlined here.

Warning: You need to disable the MeeGo core repository and enable the testing and development repositories so be sure that you're happy to do this before continuing.

Steps:

#Remove the MeeGo core repo
sudo zypper rr core

# Enable the testing repo
sudo zypper ar http://download.meego.com/live/Trunk:/Testing/standard/Trunk:Testing.repo

# Enable the dev repo
sudo zypper ar http://download.meego.com/live/devel:/quality/testing/devel:quality.repo

If you run into trouble remove this last repo with the command. If you do so you will be able to go no further.

sudo zypper rr devel_quality

# Install Ruby 1.8.7
sudo zypper install ruby

# Install rubygems
sudo zypper install rubygems

Yay! You're done! This guide would likely not have happened unless the MeeGo conference and its sponsors had not given away free MeeGo netbooks to the smiling attendees. Well done guys! And thank you!

9Oct/100

Will there be a red carpet for Nokia at The Appys?

Just heard about this new awards ceremony The Appys! It will hand out the accolades to what it judges to be best mobile applications out there for a range of devices. As a long time Maemo fan and now MeeGo fan I'll be interested to see many apps are submitted for Nokia and its Ovi store.

Alas, my own humble efforts developing Qt on Rails apps aren't quite ready for entry. If you want to send in your own or vote on an app then today's deadline day! I just hope there's not too much in the way of gushing winners doing emotional acceptance speeches when the curtains come down on this one!

10Aug/101

Ruby Bindings for Qt: Building QtRuby on MeeGo and creating an RPM

MeeGo is great. What could make it even better? More Ruby :-) So what better way to achieve this than by getting the Ruby bindings for Qt up and running on MeeGo. So here's a Work In Progress guide...

Pre-requisites
Get the MeeGo SDK running on your machine under Xephyr http://wiki.meego.com/MeeGo_SDK_with_Xephyr
I'll assume that you can successfully run the meego-sdk-chroot command and are now at a MeeGo console. Here's what we need to do to build QtRuby...

The Guide
Install cmake:
zypper in cmake

Pull down the kdebindings source code from svn:
svn checkout -N svn://anonsvn.kde.org/home/kde/trunk
cd trunk
svn up -N KDE
cd KDE
svn up kdelibs kdebindings
# The above should be all you need to do but if you have problems then maybe try reading http://en.opensuse.org/openSUSE:KDE_developers_guide

Copy the kdebindings/qtruby directory to your meego home directory in the <meego_sdk_directory>, the latter will be something like /home/yourusername/meego-sdk-0524/home/meego/ depending on where you installed the MeeGo SDK earlier.

Copy the file kdebindings/CMakeLists.txt.qtruby to /home/meego/qtruby/CMakeLists.txt (yes, this will overwrite the old file. This is ok, we don't want to build all of kdebindings, just qtruby)

cd <meego_sdk_directory>/home/meego/qtruby

Edit the new CMakeLists.txt, underneath the line "include (MacroOptionalFindPackage)" add the lines:
include (MacroOptionalAddBindings)
include (MacroLogFeature)
include (CheckCXXSourceCompiles)

Also, just before the line "add_subdirectory(smoke)" add the ine:
add_subdirectory(generator)

Finally, if you want to be able to build an RPM (or any other package type supported by the CPack tool), add the following line as the very last line in the CMakeLists.txt file:
include(CPack)

Ok now we need to create a cmake/modules directory
mkdir -p qtruby/cmake/modules

cd qtruby

As the CMakeLists.txt file says in the commented section, we need to copy some files we need from the KDE related directories (this is because we are building QtRuby standalone instead of as part of the all-encompasing kdebindings module). Note, you need to change the location of kdelibs in the next command to wherever you pulled down the subversion directory

cp kdelibs/cmake/modules/FindQt4.cmake ./cmake/modules/
cp kdelibs/cmake/modules/FindRUBY.cmake ./cmake/modules/
cp kdelibs/cmake/modules/MacroOptionalFindPackage.cmake ./cmake/modules/
cp kdelibs/cmake/modules/MacroPushRequiredVars.cmake ./cmake/modules/

Additionally you will need to copy the following files

cp kdelibs/cmake/modules/Qt4Macros.cmake ./cmake/modules/
cp kdelibs/cmake/modules/Qt4ConfigDependentSettings.cmake ./cmake/modules/
cp kdelibs/cmake/modules/HandleImportedTargetsInCMakeRequiredLibraries.cmake ./cmake/modules/
cp kdelibs/cmake/modules/MacroLogFeature.cmake ./cmake/modules/
cp kdelibs/cmake/modules/CheckCXXSourceCompiles.cmake ./cmake/modules/

And also copy these from kdebindings

cp kdebindings/cmake/modules/MacroOptionalAddBindings.cmake ./cmake/modules/
cp -r kdebindings/ruby .
cp -r kdebindings/smoke .
cp -r kdebindings/generator .

Now we are going to create a qtruby_build directory so that we can do an out-of-source build of qtruby. If you don't know what an out-of-source build is, don't worry!
cd ..
mkdir qtruby_build
cd qtruby_build

Create a file called cmake_qtruby. Copy and paste the long commented cmake command in CMakeLists.txt to this file (you can exclude the make and make install commands)

At the end of the last line of this command add a backslash (so that you can continue the command on the next line) and then add the line:
../qtruby

Then change the cmake command options
-DRUBY_EXECUTABLE=/usr/bin/ruby
-DRUBY_INCLUDE_PATH=/usr/lib/ruby/1.8/i386-linux/

At the end of this step the file should look something like

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DRUBY_EXECUTABLE=/usr/bin/ruby \
-DRUBY_INCLUDE_PATH=/usr/lib/ruby/1.8/i386-linux/ \
-Wno-dev \
-DENABLE_SMOKE=on \
-DENABLE_QTRUBY=on \
-DENABLE_QTWEBKIT_SMOKE=off \
-DENABLE_QTSCRIPT_SMOKE=off \
-DENABLE_QTUITOOLS_SMOKE=off \
-DENABLE_QTTEST_SMOKE=off \
-DENABLE_PHONON_SMOKE=off \
-DENABLE_QSCI_SMOKE=off \
-DENABLE_QWT_SMOKE=off \
-DENABLE_KDE_SMOKE=off \
-DENABLE_KDEVPLATFORM_SMOKE=off \
-DENABLE_KHTML_SMOKE=off \
-DENABLE_KTEXTEDITOR_SMOKE=off \
-DENABLE_SOLID_SMOKE=off \
-DENABLE_PLASMA_SMOKE=off \
-DENABLE_QTWEBKIT_RUBY=off \
-DENABLE_QTUITOOLS_RUBY=off \
-DENABLE_QTSCRIPT=off \
-DENABLE_QTTEST=off \
-DENABLE_PHONON_RUBY=off \
-DENABLE_QSCINTILLA_RUBY=off \
-DENABLE_QWT_RUBY=off \
-DENABLE_SOPRANO_RUBY=off \
-DENABLE_KDEVPLATFORM_RUBY=off \
-DENABLE_KORUNDUM_RUBY=off \
-DENABLE_KHTML_RUBY=off \
-DENABLE_KTEXTEDITOR_RUBY=off \
-DENABLE_SOLID_RUBY=off \
-DENABLE_KROSSRUBY=off \
-DENABLE_PLASMA_RUBY=off \
-DENABLE_QIMAGEBLITZ_SMOKE=off \
../qtruby

Make this command executable and run it
chmod u+x cmake_qtruby
./cmake_qtruby

This should go off prepare your qtruby_build directory for compiling. Once it is finished, you should be able to install by any one of the following methods

RPM-based Install
You will need to have added the include(CPack) to the CMakeLists.txt file as outlined earlier before running cmake. You also now need to install the following:
zypper install rpm-build
zypper install meego-rpm-config # Maybe you dont need this but I installed it anyway

Now all you need to do is run 'make package' and then 'cpack -G RPM' to build the RPM. You will find that the generated RPM install is called kdebindings-0.1.1-Linux.rpm. That's because we were originally pulled all our qtruby code out of the kdebindings codebase - you can customize the package name, version and much much more by passing parameters to the cpack command when generating the rpm. You can check what values were used to build the package by viewing the CPackSourceConfig.cmake file. As I was just building this rpm for personal use, I didn't bother changing any package details. Tut! Tut! Anyway, once you have an rpm you are happy with, simply install the QtRuby bindings on your system via:
rpm -i <your_generated_rpm_name>

Note: If you want to see the RPM spec file generated, have a look at _CPack_Packages/Linux/RPM/SPECS/kdebindings.spec

Deb-based Install (and other package types)
This is pretty much identical to the RPM-based Install. The difference is to use 'cpack -G DEB' instead of 'cpack -G RPM'

Source-based Install
All need to do 'make' and 'make install' to get the QtRuby bindings installed onto your system. Not quite as easy to undo as an package based installation though!

Testing that everything works
I only tested the RPM package installation method. I found that when running the rbqtapi command I got the following error

/usr/lib/ruby/site_ruby/1.8/i386-linux/qtruby4.so: libsmokeqtcore.so.3: cannot open shared object file: No such file or directory - /usr/lib/ruby/site_ruby/1.8/i386-linux/qtruby4.so (LoadError)
from /usr/lib/ruby/site_ruby/1.8/Qt4.rb:5
from /usr/local/bin/rbqtapi:6:in `require'
from /usr/local/bin/rbqtapi:6

This was because some of the qtruby libraries installed into /usr/local/lib which my MeeGo system does not check for libraries by default. I changed this by adding the file /etc/ld.so.conf.d/qtruby-i386.conf which simply contained the line:
/usr/local/lib
And then running the ldconfig command. Then the rbqtapi command worked happily!

This guide still needs some polish. We'll get to that eventually, but hopefully it may be of some use in getting the Ruby and Qt playing real nice together on MeeGo!