<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Jamu on Launchpad Blog</title>
    <link>https://blog.launchpad.net/authors/jamu/</link>
    <description>News and updates from the Launchpad team</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 07 Nov 2007 19:04:27 +0000</lastBuildDate>
    <atom:link href="https://blog.launchpad.net/feed/authors/jamu/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Introducing AutoPPA!</title>
      <link>https://blog.launchpad.net/ppa/introducing-autoppa/</link>
      <pubDate>Wed, 07 Nov 2007 19:04:27 +0000</pubDate>
      <dc:creator>Jamu Kakar</dc:creator>
      <guid isPermaLink="false">https://blog.launchpad.net/?p=29</guid>
      <description>&lt;p&gt;Launchpad&amp;rsquo;s &lt;a href=&#34;https://help.launchpad.net/PPAQuickStart&#34;&gt;Personal Package Archives&lt;/a&gt; (PPA) service takes a great deal of pain out of the packaging process. The days of maintaining system images for package builds are thankfully behind us, but preparing sources to upload to PPA can still be a tedious task.  I&amp;rsquo;m primarily responsible for building packages for the Landscape client.  There are several factors which make handling source uploads manually problematic:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Subtle differences between the various releases of Ubuntu we support require slightly different &lt;code&gt;debian/control&lt;/code&gt; files to build packages for different releases.&lt;/li&gt;
&lt;li&gt;The pool-based APT repository that PPA publishes requires release-specific package version numbers in &lt;code&gt;debian/changelog&lt;/code&gt;. Also, the changelog needs to include the name of the Ubuntu release the build is targeted at.&lt;/li&gt;
&lt;li&gt;I need to build packages often, weekly or bi-weekly and need to be able to roll out bug fix packages as quickly as possible.&lt;/li&gt;
&lt;li&gt;The process needs to be sufficiently simple that someone else can easily step in and take care of it if I&amp;rsquo;m not around.&lt;/li&gt;
&lt;li&gt;I need to produce packages for all officially supported Ubuntu releases.  At present this includes Dapper through Gutsy.  In a few weeks we&amp;rsquo;ll start building packages for hardy.  As time goes on we&amp;rsquo;ll have even more releases to support.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Automation to the rescue!  AutoPPA is an application that automates the process of preparing and uploading signed sources to PPA.  A project using AutoPPA for automated source uploads needs to meet some criteria:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It must be stored in a local Bazaar branch.&lt;/li&gt;
&lt;li&gt;It must include a debian directory with valid packaging files.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;setting-up-autoppa&#34;&gt;Setting up AutoPPA&lt;/h4&gt;
&lt;p&gt;The first thing we need to do is install and configure AutoPPA.  Add the following deb lines to your &lt;code&gt;/etc/apt/sources.list&lt;/code&gt; (replace the Ubuntu release name with whatever is appropriate for your system):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;deb http://ppa.launchpad.net/autoppa/ubuntu gutsy universe
deb-src http://ppa.launchpad.net/autoppa/ubuntu gutsy universe
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then, update and install autoppa.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sudo apt-get update
sudo apt-get install autoppa
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now, let&amp;rsquo;s assume we are building packages for the fictitious supertool Python application.  For the sake of this example, we&amp;rsquo;ll assume that the branch to build from is stored at &lt;code&gt;~/src/supertool/trunk&lt;/code&gt; and has Debian package files already in place.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s start by setting up &lt;code&gt;~/.autoppa.conf&lt;/code&gt;.  This configuration file contains per-project configuration settings that are unlikely to change often.  Here&amp;rsquo;s a sample:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[supertool]
email = Jamshed Kakar &amp;lt;jamshed.kakar@canonical.com&amp;gt;
branch = /home/jkakar/src/supertool/trunk
repository = /home/jkakar/src/supertool
ppa = supertool-ppa
releases = dapper edgy feisty gutsy
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &amp;rsquo;email&amp;rsquo; field specifies the e-mail address to use in the changelog.  The &amp;lsquo;branch&amp;rsquo; field specifies the location of the Bazaar branch that code will be built from.  The &amp;lsquo;repository&amp;rsquo; field specifies the location where temporary branches will be created.  The &amp;lsquo;ppa&amp;rsquo; field specifies the name of the PPA to upload to, as defined in &lt;code&gt;~/.dput.cf&lt;/code&gt;.  Finally, the &amp;lsquo;releases&amp;rsquo; field is a space-separated list of Ubuntu releases to prepare packages for.  The configuration file can contain as many stanzas as you have projects to build with AutoPPA.  Note that the name of the stanza must be the same as the name of the source package, as specified in debian/control.&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;re not quite ready to generate and upload signed sources.  There are two more things we need to deal with first.  The first is dealing with subtle differences in &lt;code&gt;debian/control&lt;/code&gt; because of differences between Ubuntu releases.  For a Python application, one of these is the reliance on python-support on dapper and python-central for edgy and newer.  AutoPPA provides a simple file-template replacement mechanism to deal with this.  Any files that end in &lt;code&gt;.autoppa&lt;/code&gt; will be specially processed with output written to a file without the &lt;code&gt;.autoppa&lt;/code&gt; extension.  There is currently a single special directive, &lt;code&gt;AUTOPPA_INCLUDE(...):&lt;/code&gt;, that is handled specially when encountered.  If the following lines are defined in &lt;code&gt;debian/control.autoppa&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;AUTOPPA_INCLUDE(dapper):Build-Depends: debhelper, python-support,
lsb-release
AUTOPPA_INCLUDE(edgy,feisty,gutsy):Build-Depends: debhelper,
python-central, lsb-release
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then the following will be included in &lt;code&gt;debian/control&lt;/code&gt; for Dapper:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Build-Depends: debhelper, python-support, lsb-release
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and for Edgy, Feisty and Gutsy:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Build-Depends: debhelper, python-central, lsb-release
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This allows us to have a single set of sources despite requiring minor differences for different Ubuntu releases.  The obvious question is, why not just use an OR in the Build-Depends list?  The answer is that sbuild, used by PPA to perform package builds, doesn&amp;rsquo;t handle ORs. There are also other cases where this kind of simple processing is handy.&lt;/p&gt;
&lt;p&gt;The second thing we may want is version replacement.  Any file, not just those that end in &lt;code&gt;.autoppa&lt;/code&gt;, that include the special &lt;code&gt;AUTOPPA_VERSION()&lt;/code&gt; string will be replaced with the version generated for the build.  In Python code the following idiom can be used to assign the version to a local, for example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;VERSION = &amp;#34;AUTOPPA_VERSION(devel)&amp;#34;[len(&amp;#34;AUTOPPA_VERSION(&amp;#34;):-1]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When AutoPPA is run it will replace the &amp;lsquo;devel&amp;rsquo; portion of that magic symbol with whatever version has been generated for the build.&lt;/p&gt;
&lt;p&gt;Finally, Seahorse and devscripts needs to be configured to handle automatic GPG signing.  You&amp;rsquo;ll need to import your GPG key into Seahorse and enable password caching.  In order for Debian&amp;rsquo;s devscripts to work with Seahorse you&amp;rsquo;ll also need to do the following:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;cp /usr/share/devscripts/conf.default ~/.devscripts.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Edit &lt;code&gt;~/.devscripts&lt;/code&gt;, find the &amp;lsquo;&lt;code&gt;# DEBUILD_PRESERVE_ENVVARS=&amp;quot;&amp;quot;&lt;/code&gt;&amp;rsquo; line and&lt;br&gt;
replace it with:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;DEBUILD_PRESERVE_ENVVARS=&amp;#34;DISPLAY&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Phew.  Thankfully all that is initial setup that you&amp;rsquo;ll hopefully never have to think about it again.&lt;/p&gt;
&lt;h4 id=&#34;using-autoppa&#34;&gt;Using AutoPPA&lt;/h4&gt;
&lt;p&gt;Now that everything is set up for our fictitious project, we can use AutoPPA to generate signed sources and upload them for building by PPA.  It&amp;rsquo;s accomplished with a single command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;autoppa supertool-1.0.0-supertool1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first thing that will happen is that &lt;code&gt;$EDITOR&lt;/code&gt; will be opened to collect changelog details.  Once you&amp;rsquo;ve provided details for the changelog everything else should Just Work(tm).  AutoPPA will do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a build branch based on the source branch you specified in &lt;code&gt;~/.autoppa.conf&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;For each Ubuntu release you&amp;rsquo;ve specified to build for:
&lt;ul&gt;
&lt;li&gt;Files will be processed such that any &lt;code&gt;.autoppa&lt;/code&gt; files are processed and &lt;code&gt;AUTOPPA_VERSION()&lt;/code&gt; symbols are updated.  The version generated, using the sample above will be, &lt;code&gt;supertool-1.0.0-&amp;lt;release&amp;gt;1-supertool1&lt;/code&gt;.  This ensure a unique per-release version string.&lt;/li&gt;
&lt;li&gt;The modifications made for the release will be committed as a revision in the temporary build branch and signed sources will be generated.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;When signed sources have been generated for all the specified Ubuntu releases:
&lt;ul&gt;
&lt;li&gt;They will all be uploaded to the specified PPA.&lt;/li&gt;
&lt;li&gt;The build branch will be merged back to the source branch, with the changelog as the commit message.&lt;/li&gt;
&lt;li&gt;The merged revision will be tagged with the version, &lt;code&gt;1.0.0-supertool1&lt;/code&gt; in this case.&lt;/li&gt;
&lt;li&gt;Signed sources and the build branch will be deleted.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now all we need to do is wait for PPA to build our packages!  If you have more than one project setup in &lt;code&gt;~/.autoppa.conf&lt;/code&gt; you can specify multiple builds using a single command, such as:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;autoppa supertool-1.0.0-supertool1 awesometool-1.0.0-awesometool1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That&amp;rsquo;s it!  I hope AutoPPA turns out to be useful to others!&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
