2018-11-20

Updating a PPA package

Last time I told you I could successfully create a source package for Ubuntu, with automatic building on Ubuntu servers. But what happens when a new version of the software is released and you want to update the package? This is the case where you followed Ubuntu package guide and you have setup a Bazaar repository on Launchpad. I will use PngOptimizer as an example of course.

Create a working directory:

mkdir ppa_update
cd ppa_update

Get the source code from your Bazaar repository on your Launchpad account. "lp:" is a shortcut for Launchpad address.

bzr branch lp:~psydk/+junk/pngoptimizer-pack
cd pngoptimizer-pack

Merge the content of pngoptimizer-pack with the new version of pngoptimizer. I got a zip file from GitHub to do that. I did the merge manually, but it looks like there are ways to do it automatically. They gave me errors so for now I have to use a manual process. Overwrite files that changed, add new ones and remove old ones.

bzr add some-new-file.cpp
bzr remove deprecated-file.txt

Look at the changes, check that they look good:

bzr status

One last change: updating the changelog file in the debian/ directory. To easily add an entry with the current date, and open a text editor to fine-tune the entry, use this command:

dch -i

In the text editor that opens, you have the opportunity to set the new version. That version is important as it will be reused to create the package file name.

Here is the added entry with the current state of my Bazaar repository:

pngoptimizer (2.6~beta.2-0ubuntu2) UNRELEASED; urgency=medium

  *

 -- Hadrien Nilsson <hadrien@psydk.org>  Mon, 19 Nov 2018 22:11:04 +0100

Let's say I made a new beta version of PngOptimizer on GitHub, I will change the entry as follow:

pngoptimizer (2.6~beta.3-0ubuntu1) bionic; urgency=medium

  * Update from Git (commit 1f2ec94)

 -- Hadrien Nilsson <hadrien@psydk.org>  Mon, 19 Nov 2018 22:11:04 +0100
  • I used ~beta.3 (the tilde is important, I used to use a "-" character but it has another meaning for packages) and I reset the number after "ubuntu".
  • I changed UNRELEASED to my current version of Ubuntu: "bionic" (Ubuntu 18.04). I am not sure if this is the correct process though.
  • I put a comment explaining the change. As I track all changes through commits on GitHub, I put the minimal information required.

When you are done, save and exit the text editor. You are ready to commit your changes:

bzr commit -m "Update from Git"

Rebuild the package to test that everything is ok:

bzr builddeb -S --split

--split is important otherwise builddeb will look for a tar.gz of the source code, which makes no sense as the source code is already there in the Bazaar repository.

Go back in the parent directory and look at the content, you'll see new files and a new directory:

cd ..
ls

New content:

build-area/
pngoptimizer_2.6~beta.3-0ubuntu1.debian.tar.xz
pngoptimizer_2.6~beta.3-0ubuntu1.dsc
pngoptimizer_2.6~beta.3-0ubuntu1_source.buildinfo
pngoptimizer_2.6~beta.3-0ubuntu1_source.changes
pngoptimizer_2.6~beta.3.orig.tar.gz

You can now test the creation of the .deb package. At one moment, the commands may ask for your password. I still don't understand why but it only did once, maybe to install a needed package.

Here "bionic" is the version of Ubuntu I am running:

pbuilder-dist bionic build pngoptimizer_2.6~beta.3-0ubuntu1.dsc

If everything goes well, you will find plenty of new files in this directory: $HOME/pbuilder/bionic_result, all starting with pngoptimizer_2.6~beta.3.

The deb file is among them: pngoptimizer_2.6~beta.3-0ubuntu1_amd64.deb

As it looks good, you can now push the changes you made in your Bazaar repository to the Launchpad server:

cd pngoptimizer-pack
bzr push lp:~psydk/+junk/pngoptimizer-pack

Now go to your Launchpad account, and launch builds for your updated Bazaar repository. I choose the two latest stable versions of Ubuntu (16.04 and 18.04), the current unstable (18.10) and the version in progress (19.04).

Wait for the builds to complete. If they all go well, wait for about one hour for apt update to be aware of the change. You will then be able to upgrade to the new version.