Showing posts with label debian package. Show all posts
Showing posts with label debian package. Show all posts

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