Ubuntu logo

Packaging Guide

4. Получение исходного кода

4.1. URL пакетов исходного кода

Bazaar предоставляет несколько очень удобных сокращений для доступа к веткам исходного кода с Launchpad для пакетов как Ubuntu, так и Debian.

Чтобы сослаться на ветки исходного кода, используйте:

ubuntu:package

где package — имя пакета, который вам нужен. Этот URL ссылается на пакеты в текущей разрабатываемой версии Ubuntu. Чтобы сослаться на ветку Tomboy в разрабатываемой версии, нужно использовать:

ubuntu:tomboy

To refer to the version of a source package in an older release of Ubuntu, just prefix the package name with the release’s code name. E.g. to refer to Tomboy’s source package in Quantal use:

ubuntu:quantal/tomboy

Поскольку первые буквы кодовых имён не повторяются, можно сократить имя выпуска:

ubuntu:m/tomboy

Похожую схему можно использовать для доступа к веткам исходного кода в Debian, хотя здесь нет сокращений для имён выпусков Debian. Чтобы получить доступ к ветке Tomboy в текущем разрабатываемом выпуске Debian, используйте:

debianlp:tomboy

and to access Tomboy in Debian Wheezy use:

debianlp:wheezy/tomboy

4.2. Получение исходного кода

Каждый пакет исходного кода в Ubuntu связан с веткой исходного кода на Launchpad. Launchpad автоматически обновляет эти ветки исходного кода, хотя процесс не полностью «защищён от дурака».

Есть несколько вещей, которые мы сделаем в первую очередь, чтобы сделать рабочий процесс более эффективным впоследствии. После того, как вы освоите процесс, вы узнаете, когда имеет смысл пропускать эти этапы.

4.2.1. Creating a shared repository

Say that you want to work on the Tomboy package, and you’ve verified that the source package is named tomboy. Before actually branching the code for Tomboy, create a shared repository to hold the branches for this package. The shared repository will make future work much more efficient.

Воспользуйтесь для этого командой bzr init-repo, передав ей имя каталога, который вы хотите использовать:

$ bzr init-repo tomboy

Вы увидите, что в вашей текущей рабочей области создан каталог tomboy. Перейдите в него для продолжения работы:

$ cd tomboy

4.2.2. Получение ветки trunk

Мы используем команду bzr branch для создания локальной ветки пакета. Целевой каталог назовём tomboy.dev, просто потому, что так легче запомнить:

$ bzr branch ubuntu:tomboy tomboy.dev

Каталог tomboy.dev представляет собой версию Tomboy в разрабатываемой версии Ubuntu, и вы всегда можете перейти в этот каталог и выполнить bzr pull для получения любых будущих обновлений.

4.2.3. Проверка актуальности версии

When you do your bzr branch you will get a message telling you if the packaging branch is up to date. For example:

$ bzr branch ubuntu:tomboy
Most recent Ubuntu version: 1.8.0-1ubuntu1.2
Packaging branch status: CURRENT
Branched 86 revisions.

Occasionally the importer fails and packaging branches do not match what is in the archive. A message saying:

Packaging branch status: OUT-OF-DATE

means the importer has failed. You can find out why on http://package-import.ubuntu.com/status/ and file a bug on the UDD project to get the issue resolved.

4.2.4. Tar-файл из апстрима

Получить tar из апстрима можно с помощью:

bzr get-orig-source

This will try a number of methods to get the upstream tar, firstly by recreating it from the upstream-x.y tag in the bzr archive, then by downloading from the Ubuntu archive, lastly by running debian/rules get-orig-source. The upstream tar will also be recreated when using bzr to build the package:

bzr builddeb

The builddeb plugin has several configuration options.

4.2.5. Получение ветки для определённого выпуска

When you want to do something like a stable release update (SRU), or you just want to examine the code in an old release, you’ll want to grab the branch corresponding to a particular Ubuntu release. For example, to get the Tomboy package for Quantal do:

$ bzr branch ubuntu:m/tomboy quantal

4.2.6. Импорт пакета исходного кода Debian

If the package you want to work on is available in Debian but not Ubuntu, it’s still easy to import the code to a local bzr branch for development. Let’s say you want to import the newpackage source package. We’ll start by creating a shared repository as normal, but we also have to create a working tree to which the source package will be imported (remember to cd out of the tomboy directory created above):

$ bzr init-repo newpackage
$ cd newpackage
$ bzr init debian
$ cd debian
$ bzr import-dsc http://ftp.de.debian.org/debian/pool/main/n/newpackage/newpackage_1.0-1.dsc

As you can see, we just need to provide the remote location of the dsc file, and Bazaar will do the rest. You’ve now got a Bazaar source branch.