Ubuntu PPA/Automating Packaging

Forum rules
Warning !
Avoid using binary softwares from untrusted users.
Prefer compiling it yourself and verify sources.
Post Reply
josephbisch
Posts: 69
Joined: Sun Nov 23, 2014 3:34 pm
os: linux

Ubuntu PPA/Automating Packaging

Post by josephbisch »

For those that don't know, I've been working on packaging Namecoin for an Ubuntu PPA. You can see my git repository or the actual PPA (though as of posting this, I only have the version for Ubuntu Vivid uploaded and even that hasn't appeared on the frontend yet). That PPA I linked you to is under my personal Launchpad account. Indolering and myself both think that the PPA should remain unofficial for now, so that is why I have it under my personal account at this time.

In an attempt to reduce auditing, Indolering suggested that we somehow create a package where we download directly from GitHub. I said that that is not the typical way packaging is done, but that it is theoretically possible to create a package whose sole purpose is to download either the binary from GitHub or the source and proceed to build the source and install the binary. I think that the fact that a person can download the .tar.gz from GitHub, extract it, and run a diff between it and my packaging source and see that the only difference is the debian directory is sufficient.

Indolering said we need to automate everything, but I should keep my packaging up-to-date. I said that now that we have the debian directory created, we can probably write a script to automate the creation of the package. The script can download the .tar.gz, extract it, copy over the debian directory, and add the new version to debian/changelog. There might still need to be some level of human involvement if patches need to be added or deleted or something like that. Then the script can build the source package, sign it, and upload to the ppa automatically.

Now what I did:

I downloaded the latest .tar.gz from GitHub. I created a directory named "namecoin". I ran "git init" inside the namecoin directory. I ran "gbp import-orig --pristine-tar ../abc.tar.gz" when abc.tar.gz is the name of the file downloaded from GitHub (I will use abc.tar.gz for the rest of this post). That command imports the Namecoin source code into the git repository in the namecoin directory. If it prompts you, enter the name of the package (namecoin) and the version (that is the upstream version, so for example, 0.3.76). Next you will run "dh_make" to create the debian directory template. But first you have to temporarily rename the directory you are in, because the dh_make tool expects the version to be in the directory name. So run "cd ..; mv namecoin namecoin-0.3.76; cd namecoin-0.3.76". Then run "dh_make". You can rename the directory to "namecoin" after running dh_make, or leave it be.

Edit the files in the debian directory as you please and commit your changes as you please. You should be working on master. When I am done, I make a final commit changing the changelog from UNRELEASED to the version of Debian or Ubuntu I am releasing for. Then I do a final build with "git-buildpackage" that also creates a git tag "debian/version" where version is the version for the distro that I am packaging for.

This guide does not cover making separate branches for the different versions of Ubuntu (which you would want to do if you are targetting multiple versions of Ubuntu.

Building with git-buildpackage:

To build with git-buildpackage run "git-buildpackage --git-ignore-new --git-builder="debuild -S"". To also tag the release add "--git-tag". When tagging the release I leave off the "--git-ignore-new" so that I am alerted if there are uncommitted changes. To also build the binaries leave off the "--git-builder" part (that part causes you to only build the source package, not the binary packages).

How you can build the package:

First "git clone https://www.github.com/josephbisch/namecoin-ubuntu.git". Then cd into the resulting directory. Make sure you have git-buildpackage installed. Then Run "git-buildpackage" with some combination of the options above under the "Building with git-buildpackage" heading. If you want to install the binaries locally, make sure you leave off the "--git-builder" part. Then run "dpkg -i ../namecoin-qt....deb" or "dpkg -i ../namecoind....deb". You probably will have to manually install dependencies with apt-get, because dpkg doesn't get dependencies automatically. Then run namecoin-qt or namecoind as usual.

To upload to a ppa, first make sure you use the "--git-builder" part of the command. Also make sure the package is signed with your gpg key (it will be done at the end of the git-buildpackage command). Then run "dput ppa:username/ppaname ../file_name.changes.

josephbisch
Posts: 69
Joined: Sun Nov 23, 2014 3:34 pm
os: linux

Re: Ubuntu PPA/Automating Packaging

Post by josephbisch »

Going along with the idea of automating the builds, we can setup a private buildd instance for Debian and Ubuntu builds. That is if we have the server resources to do so.

The way the official Debian buildds work is the maintainer builds the source package and binary package for his particular architecture on his development computer. Then he uploads those, plus a few other files, to Debian. Buildd builds the binaries for the other systems.

While Debian themselves run servers for each architecture that Debian supports, I think we can cross compile if we want to support architectures for which we don't have servers.

You can read about buildd or how to setup buildd.

pmc
Posts: 73
Joined: Thu Oct 03, 2013 8:50 pm
Location: Germany
Contact:

Re: Ubuntu PPA/Automating Packaging

Post by pmc »

I'm not familiar with PPAs - is there a reason why your repo is not a fork of the namecoin repo? That would make auditing and updates easier IMO.

josephbisch
Posts: 69
Joined: Sun Nov 23, 2014 3:34 pm
os: linux

Re: Ubuntu PPA/Automating Packaging

Post by josephbisch »

I am using a tool called git-buildpackage, which helps with the importing of the source into the git repository and also helps with building the Debian/Ubuntu package from that git repository.

While it does seem to be possible with git-buildpackage that you could base the packaging git repository off of another git repository, like the Namecoin repository, it will make things a lot more difficult.

Nobody has given me a reason why doing a diff between the tarball downloaded from GitHub and my packaging source code is unreasonable. It certainly seems to me to be an easy way to audit that everything besides the debian directory is the same as the official Namecoin source code.

Post Reply