Thursday, July 16, 2009

Getting the Palm Mojo SDK to work on 64-bit linux

This is my first post, and I hope you will find it helpful.

Today, Palm released the Mojo SDK to the public. Awesome! I've been meaning to try developing for a mobile platform and have been put off by the iPhone's price and the fact that it only runs on a Mac. Palm's SDK claims to be cross-platform, but the .deb package it has available for linux is built for i386 only. I have Ubuntu 9.04 (Jaunty) on my machine in x86-64 mode so I was really bummed when I wasnt allowed to install the package.

Determined to get it working I dug around in the package (any .deb can be opened as a .tar.gz) and found that most tools are just scripts, which shouldnt care about the platform they run under. Now how do I fool the installer to use the package they gave me? It turns out there is a file in each .deb that specifies which architecture the package is for. If you look inside the .deb you will find a file called control.tar.gz, and in that archive you will find a file called "control" which is just a list of properties, one of which is "Architecture". Change it from "i386" to "all" and you're all set!

Since the file is kind of deep in the .deb, its not trivial to edit the "control" file, so here is a script that will do it for you:

#!/bin/bash
packageName=$1
tempDir=`mktemp -d`
architecture="all"

# extract the files from the original package
mkdir $tempDir/DEBIAN
ar p $packageName control.tar.gz | tar -xz --directory $tempDir/DEBIAN
ar p $packageName data.tar.gz | tar -xz --directory $tempDir

# replace stuff
if [ -n "$controlFile" ]; then
cp $controlFile $tempDir/DEBIAN/control
fi
if [ -n "$architecture" ]; then
sed "s/Architecture:.*/Architecture: $architecture/g" < $tempDir/DEBIAN/control > $tempDir/DEBIAN/control2
mv $tempDir/DEBIAN/control2 $tempDir/DEBIAN/control
fi

# rebuild the package
dpkg --build $tempDir $packageName

# get rid of temporary working files
rm -rf $tempDir
To use it, save as debAllArch.sh and run it from the terminal:
./debAllArch.sh mojo.deb

8 comments:

  1. Hello,
    Good post. I can't seem to get it to work, though. I ran the script, but the architecture remains the same. Can you check the code and ensure that the i386 would be changed to all in the control file? I am not a programmer, just an intermediate linux user and don't understand the code in your script file.

    Respond to billbrab@gmail.com

    ReplyDelete
  2. Sorry, I forgot to put in a line (now line 4) that actually specified what architecture you want. Thanks for catching that Bill. It should be all set, but let me know if you continue to have problems.

    ReplyDelete
  3. Hey, thanks for putting this together. Worked flawlessly for me, and I'm glad you took the time to document your experience to save the rest of us some agony.

    ReplyDelete
  4. Great post, very helpful! I linked to it on my blog.

    ReplyDelete
  5. Cool...

    I found the same thing in the:

    palm-novacom_0.3-svn177284-hud9_i386.deb

    Will your script work for that, or can you write a version for it? Also, is there any reason you can't fix it and rename the package and distribute it as the 64 bit version - what's the license?

    ReplyDelete
  6. The script should work with any .deb. All it does is change the metadata in the .deb so that it is installable on all architectures. This works with Mojo since the software itself works on both 32- and 64-bit machines.

    Sadly, I dont have a place to host such a big file, otherwise I would have repackaged it.

    ReplyDelete
  7. >>I am not a programmer, just an intermediate linux user and don't understand the code in your script file.<<

    then what good will the sdk do you if you get it installed?

    ReplyDelete
  8. Thank you, Mr. Mike, for sharing this!

    ReplyDelete