Ubuntu PPA/Automating Packaging
Posted: Fri Dec 19, 2014 2:23 am
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.
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.