# 5. Работа с пакетом

Once you have the source package branch in a shared repository, you’ll want to create additional branches for the fixes or other work you plan to do. You’ll want to base your branch off the package source branch for the distro release that you plan to upload to. Usually this is the current development release, but it may be older releases if you’re backporting to an SRU for example.

## 5.1. Branching for a change

The first thing to do is to make sure your source package branch is up-to-date. It will be if you just checked it out, otherwise do this:

    $ cd tomboy.dev
    $ bzr pull

Any updates to the package that have uploaded since your checkout will now be pulled in. You do not want to make changes to this branch. Instead, create a branch that will contain just the changes you’re going to make. Let’s say you want to fix bug 12345 for the Tomboy project. When you’re in the shared repository you previously created for Tomboy, you can create your bug fix branch like this:

    $ bzr branch tomboy.dev bug-12345
    $ cd bug-12345

Now you can do all my work in the `bug-12345` directory. You make changes there as necessary, committing as you go along. This is just like doing any kind of software development with Bazaar. You can make intermediate commits as often as you like, and when your changes are finished, you will use the standard `dch` command (from the `devscripts` package):

    $ dch -i

Эта команда откроет редактор и добавит запись в файл debian/changelog.

При добавлении записи в `debian/changelog` вы должны включить тег исправления ошибки, который указывает, для какого сообщения об ошибке на Launchpad вы создали исправление. Этот текстовый тег имеет вполне определённый формат: `LP: #12345`. Пробел между `:` и `#` обязателен и, разумеется, вы должны указать номер реально существующей ошибке, которую вы исправляете. Ваш `debian/changelog` может выглядеть примерно так:

    tomboy (1.12.0-1ubuntu3) trusty; urgency=low

      * Don't fubar the frobnicator. (LP: #12345)

     -- Bob Dobbs <subgenius@example.com>  Mon, 10 Sep 2013 16:10:01 -0500

Commit with the normal:

    bzr commit

A hook in bzr-builddeb will use the debian/changelog text as the commit message and set the tag to mark bug #12345 as fixed.

Это работает только с bzr-builddeb 2.7.5 и bzr 2.4, для более старых версий используйте `debcommit`.

## 5.2. Сборка пакета

Along the way, you’ll want to build your branch so that you can test it to make sure it does actually fix the bug.

In order to build the package you can use the `bzr builddeb` command from the `bzr-builddeb` package. You can build a source package with:

    $ bzr builddeb -S

(`bd` — это псевдоним для `builddeb`.) Вы можете оставить пакет неподписанным, добавив к команде `-- -uc -us`.

Вы можете также использовать свои обычные инструменты, если они способны убирать каталоги `.bzr` из пакета, например:

    $ debuild -i -I

If you ever see an error related to trying to build a native package without a tarball, check to see if there is a `.bzr-builddeb/default.conf` file erroneously specifying the package as native. If the changelog version has a dash in it, then it’s not a native package, so remove the configuration file. Note that while `bzr builddeb` has a `--native` switch, it does not have a `--no-native` switch.

После того, как вы получили пакет исходного кода, можно собрать его как обычно, с помощью `pbuilder-dist` (или `pbuilder`, или sbuild).