Neue Software paketieren¶
Auch wenn bereits tausende Pakete in den Ubuntu-Archiven vorhanden sind, gibt es noch immer sehr viele Programme, die nicht dort zu finden sind. Wenn es ein neues interessantes Programm gibt, das eine größere Verbreitung haben sollte, möchten Sie vielleicht versuchen ein Paket für Ubuntu zu erzeugen oder ein PPA einzurichten. Dieser Leitfaden hilft Ihnen Schritt für Schritt dabei die neuen Softwarepakete zu erstellen.
Sie sollten als erstes den :doc:`Vorbereitung<./getting-set-up>`s-Artikle lesen, um Ihre Entwicklungsumgebung vorzubereiten.
Das Programm überprüfen¶
The first stage in packaging is to get the released tar from upstream (we call the authors of applications “upstream”) and check that it compiles and runs.
This guide will take you through packaging a simple application called GNU Hello which has been posted on GNU.org.
Falls du die nötigen Werkzeuge zur Erstellung noch nicht hast, lass uns sicherstellen, dass sie bereitgestellt werden. Ebenso wird mit fehlenden Abhängigkeiten verfahren.
Build-Werkzeuge installieren
$ sudo apt-get install build-essential
Das Hauptpaket herunterladen
$ wget -O hello-2.7.tar.gz "http://ftp.gnu.org/gnu/hello/hello-2.7.tar.gz"
Jetzt entpacke das Hauptpaket
$ tar xf hello-2.7.tar.gz
$ cd hello-2.7
Diese Anwendung nutzt das autoconf-Build-System, also wollen wir ./configure ausführen, um uns für das Kompilieren vorzubereiten.
Dies wird die benötigten Erstellungsabhängigkeiten überprüfen. Um hello als einfaches Beispiel zu nehmen, build-essential sollte alles bereitstellen was wir brauchen. An komplexeren Programmen wird dieser Befehl scheitern, wenn du nicht die benötigten Bibliotheken und Entwicklungsdateien besitzt. Installiere die benötigten Pakete und Entwicklungsdateien bis der Befehl erfolgreich ausgeführt wird.:
$ ./configure
Jetzt kannst Du den Quelltext kompilieren:
$ make
Wenn das Kompilieren erfolgreich war, können Sie folgende Anwendung installieren und starten:
$ sudo make install
$ hello
Ein Paket starten¶
bzr-builddeb includes a plugin to create a new package from a template. The plugin is a wrapper around the dh_make command. You should already have these if you installed packaging-dev. Run the command providing the package name, version number, and path to the upstream tarball:
$ sudo apt-get install dh-make
$ cd ..
$ bzr dh-make hello 2.7 hello-2.7.tar.gz
When it asks what type of package type s for single binary. This will import the code into a branch and add the debian/ packaging directory. Have a look at the contents. Most of the files it adds are only needed for specialist packages (such as Emacs modules) so you can start by removing the optional example files:
$ cd hello/debian
$ rm *ex *EX
Du solltest nun jede der Dateien anpassen.
In debian/changelog change the version number to an Ubuntu version: 2.7-0ubuntu1 (upstream version 2.7, Debian version 0, Ubuntu version 1). Also change unstable to the current development Ubuntu release such as precise.
Much of the package building work is done by a series of scripts called debhelper. The exact behaviour of debhelper changes with new major versions, the compat file instructs debhelper which version to act as. You will generally want to set this to the most recent version which is 8.
control contains all the metadata of the package. The first paragraph describes the source package. The second and following paragraphs describe the binary packages to be built. We will need to add the packages needed to compile the application to Build-Depends:. For hello, make sure that it includes at least:
Build-Depends: debhelper (>= 8.0.0)
Sie müssen außerdem eine Beschreibung der Anwendung das Feld Description: eintragen.
copyright muss ausgefüllt werden um der Lizenz des Upstreams gerecht zu werden. Der Datei hello/COPYING nach ist das die GNU GPL 3 oder neuer.
docs enthält alle Dokumentationsdateien des Upstreams, die deiner Meinung nach in dem entgültigen Paket enthalten sein sollten.
README.source und README.Debian werden nur benötigt, wenn dein Paket nicht nur Standardfunktionen hat. Das trifft hier nicht zu, also können sie gelöscht werden.
source/format kann beibehalten werden, es beschreibt das Versionsformat des Quellpakets und sollte 3.0 (quilt) sein.
rules is the most complex file. This is a Makefile which compiles the code and turns it into a binary package. Fortunately most of the work is automatically done these days by debhelper 7 so the universal % Makefile target just runs the dh script which will run everything needed.
All of these file are explained in more detail in the overview of the debian directory article.
Schlussendlich kommitte den Code zu deinem Paketier-Zweig:
$ bzr commit -m "Initial commit of Debian packaging."
Das Paket bauen¶
Now we need to check that our packaging successfully compiles the package and builds the .deb binary package:
$ bzr builddeb -- -us -uc
$ cd ../../
bzr builddeb is a command to build the package in its current location. The -us -uc tell it there is no need to GPG sign the package. The result will be placed in ...
Du kannst Dir den Inhalt eines Paketes mit folgendem Befehl ansehen:
$ lesspipe hello_2.7-0ubuntu1_amd64.deb
Installiere das Paket und prüfe ob es funktioniert:
$ sudo dpkg --install hello_2.7-0ubuntu1_amd64.deb
Nächste Schritte¶
Even if it builds the .deb binary package, your packaging may have bugs. Many errors can be automatically detected by our tool lintian which can be run on both the source .dsc metadata file and the .deb binary package:
$ lintian hello_2.7-0ubuntu1.dsc
$ lintian hello_2.7-0ubuntu1_amd64.deb
Ein Beschreibung von jedem ausgegebenen Problem kann auf der lintian website gefunden werden.
After making a fix to the packaging you can rebuild using -nc “no clean” without having to build from scratch:
$ bzr builddeb -- -nc -us -uc
Having checked that the package builds locally you should ensure it builds on a clean system using pbuilder. Since we are going to upload to a PPA (Personal Package Archive) shortly, this upload will need to be signed to allow Launchpad to verify that the upload comes from you (you can tell the upload will be signed because the -us and -uc flags are not passed to bzr builddeb like they were before). For signing to work you need to have set up GPG. If you haven’t set up pbuilder-dist or GPG yet, do so now:
$ bzr builddeb -S
$ cd ../build-area
$ pbuilder-dist precise build hello_2.7-0ubuntu1.dsc
When you are happy with your package you will want others to review it. You can upload the branch to Launchpad for review:
$ bzr push lp:~<lp-username>/+junk/hello-package
Uploading it to a PPA will ensure it builds and give an easy way for you and others to test the binary packages. You will need to set up a PPA in Launchpad and then upload with dput:
$ dput ppa:<lp-username> hello_2.7-0ubuntu1.changes
Sehen Sie auch Hochladen für mehr Informationen.
You can ask for reviews in #ubuntu-motu IRC channel, or on the MOTU mailing list. There might also be a more specific team you could ask such as the GNU team for more specific questions.
Zur Einbindung einsenden¶
There are a number of paths that a package can take to enter Ubuntu. In most cases, going through Debian first can be the best path. This way ensures that your package will reach the largest number of users as it will be available in not just Debian and Ubuntu but all of their derivatives as well. Here are some useful links for submitting new packages to Debian:
- Debian Mentors FAQ - debian-mentors is for the mentoring of new and prospective Debian Developers. It is where you can find a sponsor to upload your package to the archive.
- Work-Needing and Prospective Packages - Information on how to file “Intent to Package” and “Request for Package” bugs as well as list of open ITPs and RFPs.
- Debian Developer’s Reference, 5.1. New packages - The entire document is invaluable for both Ubuntu and Debian packagers. This section documents processes for submitting new packages.
In some cases, it might make sense to go directly into Ubuntu first. For instance, Debian might be in a freeze making it unlikely that your package will make it into Ubuntu in time for the next release. This process is documented on the “New Packages” section of the Ubuntu wiki.