Sunday, March 23, 2003

Getting punch working on a Zaurus


As threatened earlier I'm writing up my experiences on how to get a midp applicaiton called Punch up and running

on the Zaurus. If you haven't seen Punch before its well worth a look, it is a time management application that simply allows you to "punch" in and out of projects. At the end of a week you can get elapsed hours on the projects you are working on. I find it extremely useful for sorting out my weekly timesheets, so getting it working on the Zaurus was a priority for me.


The Java development environment provided with the Zaurus is Personal Java as oppposed to MIDP, so the first step was to get a working MIDP environment

running. Step forward Me4Se a library that provides exactly what we need i.e. an environment capable of running Midlets under Personal Java.


The first was to test running punch on my laptop under that environment. the bad news was that I got instant errors to do with persisting information. After

having a trace through the source and a word with Richard it turned out that this is a bug in Me4Se which he has reported. There is a simple work-around of creating the
directories that will be needed at run-time which I will come back too later.


Now I had a working version on my laptop, it was time to get a package together that would run on the Zaurus. I don't pretend to fully understand the full

package mechanism for ipk files, but I've managed to get something working after doing the following steps.


You need a file structure like the following :



control

./home/

./home/QtPalmtop/

./home/QtPalmtop/apps/

./home/QtPalmtop/apps/Jeode/

./home/QtPalmtop/apps/Jeode/punch.desktop

./home/QtPalmtop/pics/

./home/QtPalmtop/pics/punch.png

./home/QtPalmtop/java/

./home/QtPalmtop/java/punch.jar

./home/QtPalmtop/java/me4se.zip

./home/QtPalmtop/bin/

./home/QtPalmtop/bin/punch.sh




The control file contains the following information :





Package: Punch

Installed-Size: 146k

Filename: ./punch-cvm_1.0_arm.ipk

Version: 1.0

Architecture: Arm

Maintainer: Paul Goulbourn

Description: Puch Timekeeping Application

Section: Java



This file simply details what the application itself is/who maintains it etc.


The punch.desktop file simply contains a description of how the application is presented in the Zaurus and how to launch it i.e.




[Desktop Entry]

Comment=Java Punch Application

Exec=punch.sh

con=punch.png

Type=Application

Name=Punch



The remaining file I needed to create was the shell script to launch the file punch.sh :




#!/bin/sh

$QPEDIR/bin/evm -Xprogress:2900 -XappName=$0 -cp \ /home/QtPalmtop/java/punch.jar:/home/QtPalmtop/java/me4se.zip \ -Drms.dir=/home/root/Documents/rms org.me4se.MIDletRunner \ net.sourceforge.punch.midp.PunchClockMIDLet


evm is the Java runtime environment for the Zaurus, and rms.dir is the location that the Me4Se environment uses to store data.


The work-around discussed above comes into play here - You need to manually create the directories that the midplet uses to do this ensure that

/home/root/Documents/rms/Sys and /home/root/Documents/Project exist on the target Zaurus.


Now all we need to do is turn this directory structure into our ipk :




[c:\documents and settings\pgoulbou\desktop\punch\ipk]tar cvf control.tar ./control

./control



[c:\documents and settings\pgoulbou\desktop\punch\ipk]dos2unix .\home\QTPalmtop\bin\punch.sh



[c:\documents and settings\pgoulbou\desktop\punch\ipk]tar cvf data.tar ./home

./home/

./home/QtPalmtop/

./home/QtPalmtop/apps/

./home/QtPalmtop/apps/Jeode/

./home/QtPalmtop/apps/Jeode/punch.desktop

./home/QtPalmtop/pics/

./home/QtPalmtop/pics/punch.png

./home/QtPalmtop/java/

./home/QtPalmtop/java/punch.jar

./home/QtPalmtop/java/me4se.zip

./home/QtPalmtop/bin/

./home/QtPalmtop/bin/punch.sh



[c:\documents and settings\pgoulbou\desktop\punch\ipk]gzip control.tar



[c:\documents and settings\pgoulbou\desktop\punch\ipk]gzip data.tar



[c:\documents and settings\pgoulbou\desktop\punch\ipk]tar cvf punch.tgz ./control.tar.gz

./control.tar.gz



[c:\documents and settings\pgoulbou\desktop\punch\ipk]tar cvf punch.tgz ./control.tar.gz ./data.tar.gz

./control.tar.gz

./data.tar.gz



[c:\documents and settings\pgoulbou\desktop\punch\ipk]gzip punch.tgz

[c:\documents and settings\pgoulbou\desktop\punch\ipk]move punch.tgz punch.tar

C:\Documents and Settings\pgoulbou\Desktop\punch\ipk\punch.tgz -> C:\Documents and Settings\pgoulbou\Desktop\punch\ipk\punch.tar

1 file moved



[c:\documents and settings\pgoulbou\desktop\punch\ipk]gzip punch.tar



[c:\documents and settings\pgoulbou\desktop\punch\ipk]move punch.tar.gz punch-cvm_1.0_arm.ipk

C:\Documents and Settings\pgoulbou\Desktop\punch\ipk\punch.tar.gz -> C:\Documents and Settings\pgoulbou\Desktop\punch\ipk\punch-cvm_1.0_arm.ipk

1 file moved


This leaves us with an ipk file which can be installed directly onto a Zaurus. The punch application lives under the Jeode tab and is launched from the punch icon.


At some point I'd like to spend some time extending the punch project to run in native mode under Personal Java, and I believe Richard is doing some work on the synchronisation of Punch with server side components.

No comments: