User:Jebba/Package Building HOWTO

Contents

[edit] Package Building HOWTO

Here's how to build a "standard" ./configuresque package for Maemo 5, using "foo" as an example. This is a command line application...

[edit] Environment

First set up your initial environment in the scratchbox to save future keystrokes. This only has to be set up once.

# log in to development/SDK server:
ssh -C flauta.freemoe.org

# Enter scratchbox
/scratchbox/login

# Set up your full name for debianization (enter your name, not mine!):
echo 'export DEBFULLNAME="Jeff Moe"' >> ~/.bashrc

# Set up email address for debianization (enter your email, not mine!):
 echo 'export DEBEMAIL="moe@blagblagblag.org"' >> ~/.bashrc

# Re-read bashrc to drag in above:
. ~/.bashrc
 
# Check that all looks cool:
echo $DEBEMAIL ; echo $DEBFULLNAME

[edit] Package Setup

Now do the actual creation of the package:

# Set up some dirs for workingspace:
mkdir -p ~/foo/freemoe

# go there
cd ~/foo/freemoe

# grab source from upstream
wget http://foo.googlecode.com/files/foo-1.2.3.tar.bz2

# Untar the source
tar jxf foo-1.2.3.tar.bz2

# Upstream doesn't have .gz in this case, \
# so re-tar because the version of debhelper in Maemo 5 doesn't support .bz2 (!)
tar zcf foo-1.2.3.tar.gz foo-1.2.3

# Enter source dir
cd foo-1.2.3

# Check WTF the LICENSE is
less COPYING

# Initial setup of package
dh_make --single \
  --copyright gpl \
  --file ../foo-1.2.3.tar.gz

# Set up for maemo-optification:
echo auto > debian/optify

[edit] debian/control

debian/control defines info about the package that is read in such places as the application installer.

  • Don't put libraries and other non-user packages in the user section!
  • In the Description:, lines MUST be preceded by a space. Blank lines must have a space and then a period.
  • Figuring out Build-Depends: is currently left as an exercise for the reader. Hints:
fakeroot apt-get update
fakeroot apt-cache search bar
fakeroot apt-get install bar
Here is a sample debian/control:
Source: foo
Section: user/multimedia
Priority: extra
Maintainer: Jeff Moe <moe@blagblagblag.org>
Build-Depends: debhelper (>= 5), autotools-dev, maemo-optify
Standards-Version: 3.7.2

Package: foo
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
XB-Maemo-Display-Name: Foo Package Name in the App Manager
XB-Maemo-Display-Name-pl_PL: Polish translation of the name in the App Manager
XB-Description: Foo does everything you want.
 Foo does everything. It is fantastic.
 .
 Be sure to explore all of Foo, especially the clone x-fade tool.
 .
 There is so much to Foo!
XB-Description-pl_PL: Polish translation of the description
XB-Maemo-Upgrade-Description: upgrade description shows up in place of the standard one when a user updates a package
XB-Maemo-Upgrade-Description-pl_PL: Polish translation of the description
XSBC-Bugtracker: Mandatory field if you want to enter Extras, put bugtracker URL here.
XB-Maemo-Icon-26:
Put a base64 encoded 48x48px image here.
This means "uuencode -m icon.png icon.png > icon.png.en", then paste the
output here, but do not forget to put a white space at the beginning of each line containing the icon-encoded text.

[edit] debian/changelog

Edit changelog:

dch -i

Edit debian/changelog to read:

foo (1.2.3-1) unstable; urgency=low

 * Initial release for Maemo 5 (Nokia N900).

-- Jeff Moe <moe@blagblagblag.org>  Tue, 22 Dec 2009 17:00:02 -0300

[edit] Build Binary X86 Package

Now you're ready to actually build the package. This may help you find out what the Build-Depends: are as well.

[edit] X86

Now see if it works in x86:

# Switch to X86
sb-conf select FREMANTLE_X86

# Go to the correct dir:
cd ~/foo/freemoe/foo-1.2.3

# Compile!
dpkg-buildpackage -rfakeroot -b -uc


[edit] Optify .deb

If that all went cool, "optify" the package (am I doing this right?--I was doing it differently before, but this was recommended by upstream and is how the Maemo builder box does it):

# Go to correct dir
cd ~/foo/freemoe
 
# Optify X86 package:
maemo-optify-deb foo_1.2.3-1_i386.deb

# Optify non-binary package (if any):
maemo-optify-deb foo_1.2.3-1_all.deb

# Or if you have a bunch of packages and you're lazy, just
for i in *.deb
 do echo $i
 maemo-optify-deb $i
done

# Check optification results:
dpkg -c foo_1.2.3-1_i386.deb

[edit] Test in scratchbox

You can test your package in the scratchbox:

# Install in scratchbox
fakeroot dpkg -i foo_1.2.3-1_i386.deb

# Run it!
foo

[edit] Build Binary ARMEL Package

Now you're ready to actually build the package that will run on the phone.

[edit] ARMEL

# Switch to ARMEL
sb-conf select FREMANTLE_ARMEL

# Go to the correct dir:
cd ~/foo/freemoe/foo-1.2.3

# Compile!
dpkg-buildpackage -rfakeroot -b -uc


[edit] Optify .deb

If that all went cool, "optify" the package (am I doing this right?--I was doing it differently before, but this was recommended by upstream and is how the Maemo builder box does it):

# Go to correct dir
cd ~/foo/freemoe

# Optify ARMEL package:
maemo-optify-deb foo_1.2.3-1_armel.deb
 
# Optify non-binary package (if any):
maemo-optify-deb foo_1.2.3-1_all.deb

# Or if you have a bunch of packages and you're lazy, just
for i in *.deb
 do echo $i
 maemo-optify-deb $i
done

# Check optification results:
dpkg -c foo_1.2.3-1_armel.deb


[edit] Build Source Package

Build a source package for uploading to builder (I'm not 100% this is the optimal command, but worksforme).

# cd to dir
cd ~/foo/freemoe/foo-1.2.3
dpkg-buildpackage -rfakeroot -S -uc -us -sa

[edit] Put Package in Personal Repository

Now that it's all built and cool, copy the file over to your N900. I put it in my own repo and install it with apt on my N900. You don't have to set up a repo to do all this, but it's nice

# Exit from scratchbox
logout

# Create source dir on web server:
mkdir -p /var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1

# Create binary dirs on web server:
mkdir -p /var/www/users/jebba/dists/unstable/main/binary-armel
mkdir -p /var/www/users/jebba/dists/unstable/main/binary-i386

# Copy over orig tarball:
cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.diff.orig.tar.gz \
/var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/

# Copy over diff:
cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.diff.gz \
/var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/

# Copy over dsc:
cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.dsc \
/var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/

# Copy over changes:
cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.changes \
/var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/

# Copy over ARMEL binary:
cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*_armel.deb \
/var/www/users/jebba/dists/unstable/main/binary-armel/

# Copy over X86 binary:
cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*_i386.deb \
/var/www/users/jebba/dists/unstable/main/binary-i386/

# Regenerate repository headers:
cd /var/www/users/jebba/

# Binary ARMEL Packages
dpkg-scanpackages dists/unstable/main/binary-armel /dev/null \
| gzip -9c > dists/unstable/main/binary-armel/Packages.gz

# Binary X86 Packages
dpkg-scanpackages dists/unstable/main/binary-i386 /dev/null \
| gzip -9c > dists/unstable/main/binary-i386/Packages.gz

# Source Packages
dpkg-scansources dists/unstable/main/source /dev/null \
| gzip -9c > dists/unstable/main/source/Sources.gz

[edit] Install Package

Install the sucker.

[edit] Testing via manual copying

If you don't have your own personal repository, do something like this, where 10.0.0.2 is the IP address of your N900:

# copy file to N900
scp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*_armel.deb \
10.0.0.2:MyDocs/

# ssh into N900
ssh user@10.0.0.2

# Install .deb
sudo gainroot
dpkg -i /home/user/MyDocs/foo_1.2.3-1_armel.deb

[edit] Testing via personal repo

If you have your own repo, enable it, ala:

# edit sources to enable personal repo:
sudo gainroot
vim /etc/apt/sources.list

# In my case, I add the line:
deb http://www.freemoe.org/users/jebba unstable main

# Update repo
apt-get update -o dir::cache=/home/user/MyDocs/.apt-archive-cache

# Install package
apt-get install -o dir::cache=/home/user/MyDocs/.apt-archive-cache foo

[edit] Test Package

Now time to actually test it. Just run it :)

foo

Also helpful commands, like:

dpkg -I foo
dpkg -l foo
dpkg -l | grep foo
dpkg -L foo

[edit] Upload to Builder

If your package works well, time to upload to Maemo's builder to put it in extras-devel. Note, you'll need to have set up an ssh key on garage to do this.

# go to the dir, from outside the scratchbox
# (if your ~/.ssh key isn't in the scratchbox)
cd /scratchbox/users/jebba/home/jebba/foo/freemoe

Uh, just run this script:

#!/bin/sh

echo
echo "Uploading:"
ls *.tar.gz *.diff.gz *.changes *.dsc
echo

echo -n "All look ok? ctrl-c to quit " ; read ok
echo

scp -p *.tar.gz *.diff.gz *.changes *.dsc \
jebba@drop.maemo.org:/var/www/extras-devel/incoming-builder/fremantle/

[edit] Chill

Now just wait for the package to finish. You can repeatedly hit <reload> in your browser, or ctrl-5 here:

[edit] sources.list

Here's a sample sources.list you can use which has a bit more than the defaults:

# This is default upstream, but mirror is much faster
# SDK
#deb http://repository.maemo.org/ fremantle/sdk free
#deb-src http://repository.maemo.org/ fremantle/sdk free
# Tools
#deb http://repository.maemo.org/ fremantle/tools free
#deb-src http://repository.maemo.org/ fremantle/tools free

# This is default upstream, but mirror is much faster
# Extras
#deb http://repository.maemo.org/extras/ fremantle free
#deb-src http://repository.maemo.org/extras/ fremantle free
# Extras-Testing
#deb http://repository.maemo.org/extras-testing/ fremantle free
#deb-src http://repository.maemo.org/extras-testing/ fremantle free
# Extras-Devel
#deb http://repository.maemo.org/extras-devel/ fremantle free
#deb-src http://repository.maemo.org/extras-devel/ fremantle free

# This is a local mirror
# SDK
deb http://espejo.freemoe.org/repository.maemo.org/ fremantle/sdk free
deb-src http://espejo.freemoe.org/repository.maemo.org/ fremantle/sdk free
# Tools
deb http://espejo.freemoe.org/repository.maemo.org/ fremantle/tools free
deb-src http://espejo.freemoe.org/repository.maemo.org/ fremantle/tools free

# This is a local mirror
# Extras
deb http://espejo.freemoe.org/repository.maemo.org/extras/ fremantle free
deb-src http://espejo.freemoe.org/repository.maemo.org/extras/ fremantle free
# Extras-Testing
deb http://espejo.freemoe.org/repository.maemo.org/extras-testing/ fremantle free
deb-src http://espejo.freemoe.org/repository.maemo.org/extras-testing/ fremantle free
# Extras-Devel
deb http://espejo.freemoe.org/repository.maemo.org/extras-devel/ fremantle free
deb-src http://espejo.freemoe.org/repository.maemo.org/extras-devel/ fremantle free

# good luck with these
#deb https://downloads.maemo.nokia.com/fremantle/apps/ ./
#deb https://downloads.maemo.nokia.com/fremantle/mr0 ./

# Non-free crap, you need a majick key (substitute 000000)
#deb http://repository.maemo.org/ fremantle/00000000000000000000000000000000 nokia-binaries

# This is jebba's repo
#deb http://www.freemoe.org/users/jebba unstable main
#deb-src http://www.freemoe.org/users/jebba unstable main

# These are debian repos. Handy to grab source packages if they exist alreay
# Etch
#deb-src http://ftp.us.debian.org/debian/ etch main contrib
# Etch Backports
#deb-src http://www.backports.org/debian etch-backports main contrib
# Stable Lenny
#deb-src http://ftp.us.debian.org/debian/ lenny main contrib
# Testing Squeeze
#deb-src http://ftp.us.debian.org/debian/ squeeze main contrib
# Unstable Sid
#deb-src http://ftp.us.debian.org/debian/ sid main contrib

# mozilla / firefox / fennec
#deb http://moff.mozilla.com/ chinook release
#deb-src http://moff.mozilla.com/ chinook release

# ubuntu for mer
#deb-src http://ports.ubuntu.com/ubuntu-ports jaunty main restricted universe multiverse

[edit] See Also