Py2deb
(→Setup a build_myapp.py code snippet) |
(→Future) |
||
Line 93: | Line 93: | ||
== Future == | == Future == | ||
- | + | IMHO, the following features would be nice for py2deb: | |
- | + | * Support for Pre-/Postinstall scripts (might already be hidden inside, but no info available) | |
- | + | ||
- | * Support for Pre-/Postinstall scripts | + | |
- | + | ||
[[Category:Development]] | [[Category:Development]] |
Revision as of 16:19, 7 March 2009
On the maemo platform, software is distributed using the Debian package system. If you don't develop in Scratchbox, but directly on the device, you need a tool to properly put together your software for distribution as such a .deb package. For this, you can either use PyPackager or py2deb, both developed by Khertan:
- Use PyPackager to build a .deb package for redistribution in maemo.org/downloads, on your private homepage or wherever
- Use Py2Deb to prepare a package structure suitable for autobuilder, so that users can later download it directly from the Extras repository using the Application Manager of the tablets.
Using PyPackager is quite easy and is covered in the linked article. The maemo fork of Py2Deb however is a bit trickier to use - this article explains my experience in repackaging mClock for the autobuilder.
Contents |
Install py2deb
Install python2.5-py2deb (it can be found in the extras-devel repository)
Prerequisites
Create a folder /myapp under your /MyDocs/myapp/src folder (e.g. "/mclock/src"). It will contain:
- A subfolder /src that contains all your source files in a folder structure which corresponds to the way your app files will install on the device (.e.g /src/usr/mclock)
- The icon for your software package (e.g. mclock.png, 26x26 pixels), the one that will be visible for your package in the application manager.
- A copy of the "build_myapp.py" file, named and edited to your needs (e.g. build_mclock.py) as seen below
Setup a build_myapp.py code snippet
#!/usr/bin/python2.5 # -*- coding: utf-8 -*- ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published ## by the Free Software Foundation; version 2 only. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## import py2deb import os
if __name__ == "__main__": try: os.chdir(os.path.dirname(sys.argv[0])) except: pass print
p=py2deb.Py2deb("mclock") #This is the package name and MUST be in lowercase! (using e.g. "mClock" fails miserably...) p.description="A simple clock for maemo, incl. a day/night world map.\nPress D-Pad or bottom left to switch view mode.\nESC to exit.\nLeft/right D-Pad (or touching l/r border of screen)\nto change season." p.author="Tom Waelti" p.mail="twaelti@gmail.com" p.depends = "python2.5 (>= 2.5.1-1osso5), python2.5-osso, python2.5-gnome (>= 2.18.0-1osso3), python2.5-pygame" p.section="user/other" p.icon = "/home/user/MyDocs/mclock/mClock.png" p.arch="all" #should be all for python, any for all arch p.urgency="low" #not used in maemo onl for deb os p.distribution="diablo" p.repository="extras-devel" version = "0.5.7" #Version of your software, e.g. "1.2.0" or "0.8.2" build = "2" #Build number, e.g. "1" for the first build of this version of your software. Increment for later re-builds of the same version of your software. #Text with changelog information to be displayed under "Details" changeloginformation = "Fixed (large) icon." dir_name = "src" #Name of the folder containing your package source files (e.g. usr\share\icons\hicolor\scalable\myappicon.svg, usr\lib\myapp\somelib.py). We suggest to leave it named src in all projects and will refer to that in the wiki article on maemo.org
for root, dirs, files in os.walk(dir_name): real_dir = root[len(dir_name):] fake_file = [] for f in files: fake_file.append(root + os.sep + f + "|" + f) if len(fake_file) > 0: p[real_dir] = fake_file
print p #Since October 2008, package signing isn't required by autobuilder anymore. Therefore DSC can be set to false r = p.generate(version,build,changelog=changeloginformation,tar=True,dsc=True,changes=True,build=False,src=True)
When editing the .section, make sure to use an allowed section - otherwise autobuilder will give a warning.
Run your build_myapp.py code
Open "X Terminal" on your device and change directory into your folder (e.g. "cd /home/user/MyDocs/mclock"). Then run your code using the FULL PATH to your buildmyapp.py (e.g. "python /home/user/MyDocs/mclock/build_mclock.py" in Xterm). py2deb will now package your files. In the process, it might also ask about (or complain if its missing) your PGP/GPG passphrase so that it can sign your source package - this can however safely be ignored, as autobuilder doesn't require package signing anymore since late 2008. Once this is done successfully, your /MyDocs/myapp folder will contain a number of new files, e.g.
- mclock_0.5.6-2.changes (the changelog)
- mclock_0.5.6-2.dsc (the package description)
- mclock_0.5.6-2.tar.gz (the packed source files)
Upload to autobuilder
Check this section to learn about uploading to autobuilder. Using the webbased assistant is probably the easiest way to get started.
Track autobuilder
A few moments/minutes after your upload, autobuilder will try to build your package. Once it has finished (or failed :-), you will get an email with the result of the autobuild as the subject (e.g. "[diablo]: mclock 0.5.6-2 OK") and some log details in the message body. It will also include a link to the detailed logs (e.g. for [ "https://garage.maemo.org/builder/diablo/mclock_0.5.6-2/" mClock]) so that you can learn more about any errors etc.
Test your package
If your build was OK, you can now refresh your Application Manager (make sure that you did add and enable the extras-devel repository!) and install your application from there. Ask some friends in the maemo community (mailing lists, ITT, IRC) to test your package.
Promote your package
Once testing provided good results, you are ready to promote your package, meaning that it will now become available in the "real" extras repository.
Future
IMHO, the following features would be nice for py2deb:
- Support for Pre-/Postinstall scripts (might already be hidden inside, but no info available)