Launchpad ppa tips

November 8th, 2009 by bodhi.zazen

This is the first in my HOTU series (Hackers of the Universe).

Disclaimer: Let me say, I am not a developer, I am learning and *trying* to do the right thing.

As background, I have dabbled in packaging .deb and have used several ppa (Personal Package Archive), but recently found myself wanting to actually package a ppa.

Although there are several sources of information on how to package a .deb and how to use a ppa, I found the documents difficult to work through and thus would like to pass on these few tips to others who are starting to learn packaging and ppa.

I will use my package, zenix-apparmor-profiles as an example. This is a very simple .deb, or so I thought …

My ppa is here

First, if you wish to package .deb an use a ppa, I strongly suggest you read through the available documentation. I will point out some nuances, but nothing replaces the requisite reading.

How to GPG

Ubuntu Packaging Guide

Launchpad PPA Guide

Basically, you will create your source code locally, GPG sign your source code, upload your source code to your LP PPA, and LP will build the deb and sign them with a second GPG key (Launchpad automatically generates this second GPG key for you).

Create a launchpad account

Obviously, you first must create an account on launchpad.

GPG Key

You will need to generate a GPG key. There are many ways to do this and there are some gui tools that *may* help you, however I strongly suggest you use gpg from the command line.

You will then use this GPG key to sign your packages locally.

OK, I admit, GPG is confusing. A few tips I found …

In my case , my LP GPG key is 01171EC0 , but I needed to export the key from my desktop and import it to my development environment. Exporting the key was bad enough, but importing the key requires you trust the key.

To import a key:

gpg –import 01171EC0

You should see the following output while executing the above command.:

gpg: Total number processed: 1
gpg:               imported: 1

To then mark the newly imported GPG key as trusted:

gpg –edit 01171EC0

At the gpg command prompt, enter trust and select 5 (ultimate).
quit gpg

You may now use the key for encryption and signing.

Packaging

Ah, packaging …

There is simply no way to avoid familiarizing yourself with packaging and you will need to read the Ubuntu Packaging Guide.

A few tips:

  1. If you are working with source code, the original archive (tar.gz) will be foo-version.tar.gz

    for example zenix-apparmor-profiles-1.0.tar.gz

    Make a copy of the original source code to work with (see below).

  2. When making an archive (tar) of your source code:
    • The archive must be named package_version.orig.tar.gz
    • Using my package as an example, the archive is called
      zenix-apparmor-profiles_1.0.orig.tar.gz
    • The conversion of the dash ( – ) to an underscore ( _ ) in the archive name is critical.
  3. The archive (zenix-apparmor-profiles_1.0.orig.tar.gz does NOT contain the debian/ directory, only the source code.
  4. The debian directory contains package information, installation, and is where all the “magic” occurs, be sure to understand this directory.
    As a brief overview of these important files in the debian directory :
    • control – This file is used by apt (apt-get) to resolve dependencies.
    • changelog – documents changes to each version.
    • rules – This is basically a make file, with a number of helper scripts.
    • copyright – As the name implies, copyright information (GPL).
  5. If you want a generic package for all arch (i368, amd64), use “all” in the control file rather then “any”.
    • Architecture all
  6. You must prepare your package for uploading.

    debuild -S -sa

    • As your package builds , watch for and correct any warnings or error messages you get.
    • You will use the gpg key specified in the debian/changelog file, at the bottom (very last line in the file).
  7. As the necessary files are generated (.dsc), you will be asked to enter your password for your gpg key.
  8. The .deb itself it built on launchpad. You may build the .deb locally with

    debuild -b

Upload your package

This is fairly straight forward. You will upload your source code and LP will build the deb, signing them with a second GPG key. This second GPG key is automatically generated by launchpad and is used by others to verify the packages in your ppa.

Upload your source code with dput

The syntax is : dput ppa:your_project/ppa your_package_version\~ppa1_source_changes

Using my ppa as an example :

dput ppa:zenix-shravaka/ppa zeniz-apparmor-profiles_1.0\~ppa5_source.changes

Check your email to make sure the package is accepted. The deb will be built on launchpad and is then available in your ppa (as is the .dsc and source code in a tar.gz) . If there are any problems you will receive an error message from launchpad.

Using your ppa

Others can then user your ppa and install your .deb !!

When adding a ppa, be sure to import the key as root (sudo)

See also : Launchpad ppa guide

Using my zenix apparmor ppa as an example:

Add this to your sources.list

deb http://ppa.launchpad.net/zenix-shravaka/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/zenix-shravaka/ppa/ubuntu karmic main

Import the key (note the key is not from launchapd and not the one I used above to sign the package):

sudo gpg –keyserver keyserver.ubuntu.com –recv-keys 56B4D532

You should see the following output while executing the above command.

gpg: Total number processed: 1
gpg:               imported: 1

If you import the key as a user (without sudo) or if you still get an error message with apt-get

** The LP documentation skips this step !!!

gpg –armor –export 56B4D532 | sudo apt-key add -

You should see the following output while executing the above command.

OK

You can then install the package with :

sudo apt-get update

sudo apt-get install zenix-apparmor-profiles

I apologize for the lengthy post, but I hope this help others as they learn how to use the launchpad ppa.

Of course, comments and feedback welcome as I am still very new to packaging.

StumbleUpon

Posted in Linux

5 Comments »

  1. Checkout Giftwrap (random blogpost about it at http://www.stefanoforenza.com/giftwrap-helps-you-create-debs/ ).

    It’s a frontend GUI for creating debs that seems to work rather nicely.

    Comment by Bugsbane — November 8, 2009 @ 4:42 pm

  2. The one other useful command I use for packaging for PPAs is “dch”, i.e. with
    dch –distribution karmic –newversion 0.6-8.2ubuntu2~ppa1

    you can specify the new version that you would like to give to the package and it will automatically open the changelog-file and do all the adding for you so you can describe what you did.

    With only “dch” it will simply raise the last version number by one.

    Dominik.

    Comment by Dominik — November 8, 2009 @ 4:58 pm

  3. A good program I found for packaging is called “Quickly” (you may have heard of it :) ): https://wiki.ubuntu.com/Quickly

    This made the packaging for me a very easy task indeed, and takes care of uploading to ppa’s etc. It’s still very new, and has a few shortcomings… but is growing quite rapidly I’m finding :)

    For me, packaging and uploading my basic pygtk app I can simply do the following:
    ~$ quickly save Added new magic
    ~$ quickly share # does packaging and uploading to my ppa

    Comment by Philip Peitsch — November 8, 2009 @ 6:11 pm

  4. [...] here:  Bodhi.Zazen: Launchpad ppa tips Share and [...]

    Pingback by Bodhi.Zazen: Launchpad ppa tips | TuxWire : The Linux Blog — November 9, 2009 @ 7:05 am

  5. Great post Bodhi :) I should try this some time

    Comment by Nigel Babu — November 17, 2009 @ 8:16 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment