Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Let's assume I have a working application written in C, C++ or Python. I want to create a Launchpad PPA so others can easily install it from a package. Please give step by step instructions for doing this from beginning to end. (Or provide a link that does the same ;)

  • Does the programming language matter? (Could it be a bash script?)
  • Do I need to add anything to my build?
  • Where should the build install itself to?
  • How do I define dependencies?
  • How do I use dependencies?
  • How do I create a .deb?
  • What do I need to do before uploading to Launchpad?
share|improve this question
    
I'm asking this question because I occasionally recommend that FLOSS projects to create a PPA (so I can install them easily :) - I'd like to be able to point them to a thorough resource or be able to do it myself. –  d3vid Mar 1 '11 at 12:51

2 Answers 2

up vote 20 down vote accepted

That's a very wide question. I'll try to answer as much as I can, but it definitely WON'T be a step-by-step instruction. This is because there is no step-by-step algorithm for creating a package. The way you'll do it depends on many factors, mostly on the type of package (application, library), the structure of source, and many details.

Luckily, there is a thorough guide at http://packaging.ubuntu.com

I'll try to help you a bit with understanding the whole process, so when you'll be a bit more familiar with it. The Packaging Guide includes resources for additional help.


First of all you should realize that creating a package (a .deb file) is a separate process from creating a PPA. Creating a PPA is a matter of going to your Launchpad's profile and clicking "Create a new PPA" link. That's all. It's created, it works, but it's empty. To upload a package you must first create one. But let me first answer some of your minor questions.

  • The programing language DOES NOT matter at all. It can be a C++ application, Bash script, Brainfuck Hello World, a single README file, or a set of cool photos. Packages may contain any file. During installation the package gets extracted to the root ("/") of your filesystem. This way they can put some files in the binaries folder, add some wallpapers to the GNOME default set, or provide user with a Bash script.
  • You DO need to add something to the source. It must be a top-level directory named "debian". There will be some files with the package details - they will be used to define what type the package is, etc.
  • Dependencies are listed in one of this files (amongst other details). Where to get them from? They are simply other packages that your application uses. The developer of the application WILL know what libraries and resources his program requires, so he shouldn't have much trouble with listing them.
    • Some tools used to build a package (pbuilder) can fill in the dependencies automatically, probably by determining what your app requires during compilation.
  • It is also highly recommended to use AutoTools. That's other thing you may need to add, but probably almost every piece of software uses them already. AutoTools is a set of extremely helpful programs - automake, autoconf and autoscan to name a few. When you compile&install a program with the famous ./configure && make && make install then the autotools are used to automatically deal with the source, to prepare other resources included with the source to installation, and to extract the result of the compilation to appropriate place (to answer your question: The build will extract to MANY separate places. The binaries will go to /usr/local/bin, the docs to /usr/local/share/docs etc. Moreover, a binaries from a package will go to even different places, f.e. the binaries to /usr/bin. How to deal with this complicated directories layout? Use AutoTools - it will care about it automatically, and that's why they are so useful).

Building a .deb package may look as a really complicated process, but it's not that difficult. I highly recommend you the official Ubuntu guide to creating packages: http://packaging.ubuntu.com

It's HUGE, but you'll see you can probably skip most parts of that text (depending on what package you are going to build). Basically, packaging process consists of these parts (all are clearly explained in The Guide):

  1. Init some tools used to build packages.
  2. Get the source
  3. Create the ./debian directory and fill it with required data
  4. Build the package with debuild [That should create a set of files, including *.dsc, *_source.build, *_source.changes, which are responsible for the data about the package, and how to deal with it (you will also have a source .tar.gz)]
  5. Test whether everything works by running pbuilder locally (it will take all these files mentioned above and try to combine them into a .deb package, by automatically building the source with the help of AutoTools - that's why they are crucial for packaging [frankly speaking - not - you can get along without them or with some alternatives, but that's the very easiest approach, and other may require some advanced setup, as you'll need to instruct the builder how to build the source (using ./debian/rules file) - but that's not for beginners]) - if you just want to get a .deb package, it's done.

Now you'll have to upload it to your PPA, which is explained on this help page: https://help.launchpad.net/Packaging/PPA/Uploading

  1. Use dput to upload these files to Launchpad
  2. Launchpad will run pbuilder on their computers, and generate packages in a clean environment
  3. Finally, the packages should appear in the PPA.

As you see creating a PPA is not that straightforward. But don't be frightened, it's also not that difficult. Moreover, I recommend you not to encourage developers to use a PPA, as probably they won't listen to you, since they would need to do some additional job (and if they wanted to they would have done it already), but you may want to try to support Ubuntu developers and the whole community and provide them with packages you've prepared :)

I wish you good luck with creating packages, hope you'll find my answer helpful :)

Your friend, Rafał Cieślak

share|improve this answer
    
How can you create a non-Launchpad PPA, hosted on your own infrastructure? Is it just a simple web server with the appropriate directory structure? –  Prof. Moriarty May 16 '11 at 9:58
  • Before you can upload your package, you'll need to set it up for .deb packaging, see the Ubuntu PackagingGuide.

  • Once you can build a package for your software, see Launchpad's PPA documentation. It will guide you from PPA creation to uploading your package.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.