User:Jebba/Package Building HOWTO

=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...

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

ssh -C flauta.freemoe.org /scratchbox/login echo 'export DEBFULLNAME="Jeff Moe"' >> ~/.bashrc echo 'export DEBEMAIL="moe@blagblagblag.org"' >> ~/.bashrc . ~/.bashrc echo $DEBEMAIL ; echo $DEBFULLNAME
 * 1) log in to development/SDK server:
 * 1) Enter scratchbox
 * 1) Set up your full name for debianization (enter your name, not mine!):
 * 1) Set up email address for debianization (enter your email, not mine!):
 * 1) Re-read bashrc to drag in above:
 * 1) Check that all looks cool:

Package Setup
Now do the actual creation of the package:

mkdir -p ~/foo/freemoe cd ~/foo/freemoe wget http://foo.googlecode.com/files/foo-1.2.3.tar.bz2 tar jxf foo-1.2.3.tar.bz2 tar zcf foo-1.2.3.tar.gz foo-1.2.3 cd foo-1.2.3 less COPYING dh_make --single \ --copyright gpl \ --file ../foo-1.2.3.tar.gz echo auto > debian/optify
 * 1) Set up some dirs for workingspace:
 * 1) go there
 * 1) grab source from upstream
 * 1) Untar the source
 * 1) Upstream doesn't have .gz in this case, \
 * 2) so re-tar because the version of debhelper in Maemo 5 doesn't support .bz2 (!)
 * 1) Enter source dir
 * 1) Check WTF the LICENSE is
 * 1) Initial setup of package
 * 1) Set up for maemo-optification:

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


 * In the Description:, lines MUST be preceded by a space. Blank lines must have a space and then a period.


 * Check this to find a valid Section:

fakeroot apt-get update fakeroot apt-cache search bar fakeroot apt-get install bar
 * Figuring out Build-Depends: is currently left as an exercise for the reader. Hints:

Here is a sample debian/control:

Source: foo Section: user/multimedia Priority: extra Maintainer: Jeff Moe  Build-Depends: debhelper (>= 5), autotools-dev, maemo-optify Standards-Version: 3.7.2 Package: foo Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} 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!

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  Tue, 22 Dec 2009 17:00:02 -0300

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.

X86
Now see if it works in x86:

sb-conf select FREMANTLE_X86 cd ~/foo/freemoe/foo-1.2.3 dpkg-buildpackage -rfakeroot -b -uc
 * 1) Switch to X86
 * 1) Go to the correct dir:
 * 1) Compile!

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):

cd ~/foo/freemoe maemo-optify-deb foo_1.2.3-1_i386.deb maemo-optify-deb foo_1.2.3-1_all.deb for i in *.deb do echo $i maemo-optify-deb $i done dpkg -c foo_1.2.3-1_i386.deb
 * 1) Go to correct dir
 * 1) Optify X86 package:
 * 1) Optify non-binary package (if any):
 * 1) Or if you have a bunch of packages and you're lazy, just
 * 1) Check optification results:

Test in scratchbox
You can test your package in the scratchbox:

fakeroot dpkg -i foo_1.2.3-1_i386.deb foo
 * 1) Install in scratchbox
 * 1) Run it!

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

ARMEL
sb-conf select FREMANTLE_ARMEL cd ~/foo/freemoe/foo-1.2.3 dpkg-buildpackage -rfakeroot -b -uc
 * 1) Switch to ARMEL
 * 1) Go to the correct dir:
 * 1) Compile!

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):

cd ~/foo/freemoe maemo-optify-deb foo_1.2.3-1_armel.deb maemo-optify-deb foo_1.2.3-1_all.deb for i in *.deb do echo $i maemo-optify-deb $i done dpkg -c foo_1.2.3-1_armel.deb
 * 1) Go to correct dir
 * 1) Optify ARMEL package:
 * 1) Optify non-binary package (if any):
 * 1) Or if you have a bunch of packages and you're lazy, just
 * 1) Check optification results:

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

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

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

logout mkdir -p /var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1 mkdir -p /var/www/users/jebba/dists/unstable/main/binary-armel mkdir -p /var/www/users/jebba/dists/unstable/main/binary-i386 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/ cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.diff.gz \ /var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/ cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.dsc \ /var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/ cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*.changes \ /var/www/users/jebba/dists/unstable/main/source/foo_1.2.3-1/ cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*_armel.deb \ /var/www/users/jebba/dists/unstable/main/binary-armel/ cp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*_i386.deb \ /var/www/users/jebba/dists/unstable/main/binary-i386/ cd /var/www/users/jebba/ dpkg-scanpackages dists/unstable/main/binary-armel /dev/null \ | gzip -9c > dists/unstable/main/binary-armel/Packages.gz dpkg-scanpackages dists/unstable/main/binary-i386 /dev/null \ | gzip -9c > dists/unstable/main/binary-i386/Packages.gz dpkg-scansources dists/unstable/main/source /dev/null \ | gzip -9c > dists/unstable/main/source/Sources.gz
 * 1) Exit from scratchbox
 * 1) Create source dir on web server:
 * 1) Create binary dirs on web server:
 * 1) Copy over orig tarball:
 * 1) Copy over diff:
 * 1) Copy over dsc:
 * 1) Copy over changes:
 * 1) Copy over ARMEL binary:
 * 1) Copy over X86 binary:
 * 1) Regenerate repository headers:
 * 1) Binary ARMEL Packages
 * 1) Binary X86 Packages
 * 1) Source Packages

Install Package
Install the sucker.

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:

scp -p /scratchbox/users/jebba/home/jebba/foo/freemoe/*_armel.deb \ 10.0.0.2:MyDocs/ ssh user@10.0.0.2 sudo gainroot dpkg -i /home/user/MyDocs/foo_1.2.3-1_armel.deb
 * 1) copy file to N900
 * 1) ssh into N900
 * 1) Install .deb

Testing via personal repo
If you have your own repo, enable it, ala:

sudo gainroot vim /etc/apt/sources.list deb http://www.freemoe.org/users/jebba unstable main apt-get update -o dir::cache=/home/user/MyDocs/.apt-archive-cache apt-get install -o dir::cache=/home/user/MyDocs/.apt-archive-cache foo
 * 1) edit sources to enable personal repo:
 * 1) In my case, I add the line:
 * 1) Update repo
 * 1) Install package

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

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.

cd /scratchbox/users/jebba/home/jebba/foo/freemoe Uh, just run this script:
 * 1) go to the dir, from outside the scratchbox
 * 2) (if your ~/.ssh key isn't in the scratchbox)

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@garage.maemo.org:/var/www/extras-devel/incoming-builder/fremantle/
 * 1) !/bin/sh

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


 * Builder directory


 * Package queue


 * Packages (search)