Bzr

Experimenting with Bazaar (bzr)

The desktop team is considering using Bazaar (bzr) for packaging work. Some packages have been added to bzr to evaluate the workflow, but things like editing patches are not easy enough yet so there is no requirement to update bzr when uploading a new revision of one of those packages. You are welcome to try using bzr for packaging though and let us know what you think about it and make suggestions on changes we could do there.

Ensure that you have Bazaar Builddeb, package bzr-builddeb, installed on your computer, in addition to bzr.

You need to be member of the ubuntu-desktop team on launchpad to commit. You need be a known contributor to be added to the team since it gives you commit rights. Only the debian/ directory is stored in bzr (merge mode of bzr-builddeb).

List of the desktop team packages

You can see the list of packages available in our Bazaar repository here.

Adding a package using bzr

Below, "package_name" is the name of the source package and "userid" your username on launchpad. Launchpad require to use name of a registred product (called product_name) here; those are often, but not always identical (for example, the product "eel" is packaged as "eel2" in Ubuntu).

Please don't start adding all the desktop packages now, we want to try how bzr is working for us on a given set of package before switching.

  • apt-get source <package_name>

  • lsdiff -z *.diff.gz
    • → Ensure that this only adds files to the debian/ directory. If not, ping a ubuntu-desktop team member

  • mv package_name-<version> ubuntu

  • cd ubuntu
  • bzr init
  • mkdir .bzr-builddeb
  • echo -e '[BUILDDEB]\nmerge = True' > .bzr-builddeb/default.conf

  • bzr add debian .bzr-builddeb/default.conf
  • bzr clean-tree
  • Ensure that everything is correct:

$ ls -A
.bzr  .bzr-builddeb  debian
  • bzr commit -m "initial <package_name> import"

If you are a member of the ubuntu-desktop team: you can push it to lp:~ubuntu-desktop/<package_name>/ubuntu

Otherwise push it somewhere like in your personal LP code page: bzr push lp:~<userid>/<packgage_name>/ubuntu

Open a sponsor bug or ask for someone on #ubuntu-desktop for merging it into #ubuntu-desktop branch.

Getting a package

  • bzr branch lp:~ubuntu-desktop/package_name/ubuntu

Building a package

  • bzr branch lp:~ubuntu-desktop/package_name/ubuntu
  • cd ubuntu
  • bzr-buildpackage or bzr bd
    • If debian/watch is properly set, this will download the orig.tar.gz tarball for you.
    • you can add --builder pdebuild if you use pbuilder.

Building a source package

  • bzr branch lp:~ubuntu-desktop/package_name/ubuntu
  • cd ubuntu
  • bzr-buildpackage -S or bzr bd -S

Updating a package

How updates work

The idea is to make exactly one coherent change per commit. The debian/changelog must have the "UNRELEASED" distribution pocket while the package is modified, but not uploaded yet.

Please avoid using bzr specific commit messages. Always use "debcommit", which extracts the message from debian/changelog and uses it as bzr commit message.

First update

Warning /!\ if it's the first update just after the initial commit, you can proceed this step:

  • bzr branch lp:~ubuntu-desktop/package_name/ubuntu
  • Ensure that debian/watch is looking at unstable version if available. Otherwise, update it your debian/watch. (uscan --verbose --report to see what is the latest version corresponding to debian/watch regexp)
  • add in debian/control.in:
  • dch -vNewVersion -D UNRELEASED and edit changelog to reflect those changes:

  * debian/control.in:
    - add Vcs-Bzr tag
    - re-generate debian/control
  * Adapt debian/watch to get unstable version
  • debcommit

Other updates / Following

Warning /!\ Reminder: one change = one commit. Each time, make a change, edit the changelog (in UNRELEASED) and then commit it.

  • bzr branch lp:~ubuntu-desktop/package_name/ubuntu
  • Ensure that debian/watch is looking at unstable version if available. Otherwise, update it. (uscan --verbose --report to see what is the latest version corresponding to debian/watch regexp)
  • # do the traditional hack (One change!)

  • bzr status to ensure that everything that is listed is correct

  • dch -vNewVersion -D UNRELEASED and edit changelog. (if not already done. Otherwrise dch -{e,a})

  • Then, debcommit

  • Hack again in the next change of the package and commit it

(i) Modifying a package with a patch system is straightforward.

  • bzr bd-do will grab the upstream tarball, unpack it into a build area, and put you in a new shell. For more help, try bzr help bd-do.

  • You may now issue commands such as quilt push, make a change, and quilt refresh. In this example, this sequence will update the first patch in a package using quilt.

  • Exit the shell.
  • You may now use bzr status or bzr diff to inspect the changes, and commit them as describe above.

Final commits

  • Open debian/changelog with dch -{e,a} and put "New upstream version (LP: #BugNumber)" + copy the NEWS file

  • debcommit (it will copy then the changelog file and commit the branch)

Upload

If you are a member of the ubuntu-desktop team:

  • dch -r and save. (it will replace UNRELEASED by <current development version>)

  • debcommit -r (it will generate and commit message "releasing…" and add a tag corresponding to the version)
  • bzr push lp:~ubuntu-desktop/<package_name>/ubuntu

If you cannot upload the package yourself:

  • push it somewhere like in your personal LP code page:
    • bzr push lp:~<userid>/<packgage_name>/ubuntu

  • Open a sponsoring bug
  • The sponsor will pull/merge your branch into the official one an do above dch -r/debcommit -r.

Some tricks/tips

Access to the full tree of the current revision

  • If you want to see the full tree (with files coming from .orig.tar.gz) to retrieve automagically, for instance, the NEWS file from upstream, you can try: bzr bd-do. You will be dropped in a subshell

    • there, you can patch the files with dpatch/quilt/simple-patch-sys.
    • To exit :
      • exit 1 to exit without any changes taken into account.
      • exit 0 copy back changes in debian/ directory in the branch.
    • Note: It will automatically download the new .orig.tar.gz the first time, accordingly to debian/watch

Diff configure files between 2 version

If you need to diff (for instance configure files) to the previous version of the package, you can do:

  • bzr bd -e -r -1 (if the last bzr commit is the previous version, otherwise, you can use -2, -3...)
  • bzr bd-do
  • previous version is at ../<name_previous_version>

  • Note for packages using autotools (many of ubuntu desktop package does)
    • diff -u <oldversion>/configure.in build-area/<new-version>/configure.in to see impacts in configure.in (dependencies, etc.)

New files in bzr, or complains about missing patch (for instance) during the build

You can add some files to debian/ by bzr add ... or removing them executing bzr rm ...

quilt + bzr + autotools = <3

Let's imagine your machine is running a stable ubuntu version. When trying to autoconf, it tells you "hum... your version does not correspond to the one used for autoreconf, try autoreconf". But the requested version in only in the ubuntu unstable release!

Don't cry, there is a solution for you, using pbuilder and 2 tabs in your prefered terminal console. Here is a step by step process:

Warning /!\ This solution can appear as quite complexe for adding files using quilt instead of a classic find . -type f | xargs quilt add, but in some cases, autotools can create new file you will need in your patch and this method will not catch them contrary to the following - and more complicated - one.

pbuilder initialization

$ sudo pbuilder login
# echo "deb-src http://archive.ubuntu.com/ubuntu/ jaunty main restricted universe multiverse" >> /etc/apt/sources.list
# apt-get update
# apt-get install libtool gnome-common
# apt-get build-dep <your_package>
# useradd -u <your UID outside the chroot>
# su foo

-> the reason why of creating a user with your uid is that some autoconf tools use cache directories and they will belong to root, so, you will have some errors like: bzr: ERROR: [Errno 13] Permission denied: '../build-area/<package-version>/autom4te.cache/output.0'

And then, having to remove them manually.

outside the chroot, bindmount the full tree

$ export QUILT_PATCHES=debian/patches
$ echo "" > debian/patches/70_autotools.patch
$ bzr bd-do
$ quilt push -f 70_autotools.patch (or the autotools patch)
$ sudo mount --bind . /var/cache/pbuilder/build/<ID of your "pbuilder login" environment>/mnt/
$ touch ../dummy

inside the chroot, first autoconf launch

$ cd /mnt
$ autoconf / autoreconf
$ cd ..

outside the chroot, reset the environment

$ find . -type f -newer ../dummy > ../listquiltadd
(remove all cache files like autom4te.cache/* in this file)
$ sudo umount .
$ exit 1 (do not update anything!)

Go now for the true update!

$ bzr bd-do
$ quilt push -f 70_autotools.patch
$ sudo mount --bind . /var/cache/pbuilder/build/<ID of your "pbuilder login" environment>/mnt/
$ cat ../listquiltadd  | xargs quilt add

inside the chroot, second and final autoconf launch

$ cd /mnt
$ autoconf / autoreconf
$ cd ..

outside the chroot, refreshing the patch

$ quilt refresh
$ quilt pop -a
$ sudo umount .
$ exit 0

inside the chroot, exiting it

$ exit 0

Never forget listing missing files

dh_install --list-missing to see files that may miss you in the debian package if you don't handle them properly

Uploads to the team archive for sponsoring

You can read https://help.launchpad.net/PPA about how to use the team archive; we will use this for sponsoring.

DesktopTeam/Bzr (last edited 2010-12-07 23:38:55 by achiang)