Diff for "Packaging/SourceBuilds/BzrBuilder"

Not logged in - Log In / Register

Differences between revisions 3 and 4
Revision 3 as of 2010-11-11 19:46:48
Size: 5978
Editor: 122-63-10-108
Comment: s/edge//
Revision 4 as of 2011-03-24 11:59:21
Size: 3231
Editor: host217-44-165-42
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[https://launchpad.net/bzr-builder|bzr-builder]] is a bzr plugin that helps you in setting
up [[Packaging/SourceBuilds]].
~-[[FrontPage|Launchpad Help]] > [[Packaging]] > [[Packaging/SourceBuilds|Daily builds]] > bzr-build -~
Line 4: Line 3:
== Installation == <<Include(Packaging/SourceBuilds/Header)>>
Line 6: Line 5:
You can install it using the PPA at ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>||

= Overview =

bzr-builder is the Bazaar plugin that helps you set up [[Packaging/SourceBuilds|daily builds in Launchpad]]. You need to install it locally to test your recipes and builds before you send them to Launchpad.

= Installation =

The easiest way to install bzr-builder, and keep it updated, is using the PPA at:
Line 10: Line 17:
or by running Alternatively, you can pull down the branch from Launchpad and install it in your Bazaar plugins directory:
Line 17: Line 24:
You can check it is installed by running To check if it is install and running, enter:
Line 23: Line 30:
and looking for "builder" in the listed plugins. Looking for "builder" in the listed plugins.
Line 25: Line 32:
== Getting Help == = Getting help =
Line 27: Line 34:
Help for the plugin is available by running Help for the plugin is available by running:
Line 33: Line 40:
and help for the individual commands is available as Help for the individual commands is available as:
Line 40: Line 47:
== Recipes == = Recipes =
Line 42: Line 49:
bzr-builder works with "recipes" that are descriptions of the steps needed to
construct a package from the various bzr branches. You create one by writing a
text file with a certain format.
bzr-builder works with "recipes" that are descriptions of the steps needed to construct a package from the various Bazaar branches.
Line 46: Line 51:
The start of the file always looks similar to [[Packaging/SourceBuilds/Recipes|Read our guide to writing recipes]].
Line 48: Line 53:
{{{
# bzr-builder format 0.2 deb-version 1.0+{time}
}}}
== Running commands in recipes ==
Line 52: Line 55:
The `# bzr-builder format 0.2` is the same for each, and just specifies the version
of the format in use. The current format is `0.2`, and is increased as the format
changes.
Sometimes you may need run a partircular command in order to prepare a branch for packaging.
Line 56: Line 57:
`deb-version 1.0+{time}` specifies the version to use for the generated package.
`{time}` here is a substitution variable, more information on those will be given
later.
bzr-builder supports this through the ```run``` command.
Line 60: Line 59:
The next line specifies the branch to base the package on: '''Note:''' Launchpad does not support the ```run``` command.
Line 62: Line 61:
{{{
lp:bzr
}}}

This says that we will use the trunk of the `bzr` project.

Then there is any number of other lines to specify other branches to include. The
usual way to do this is to use the `merge` keyword to specify a simple merge of
the branch.

{{{
merge fix-build lp:~bzr/bzr/fix-build
}}}

`fix-build` is the id of the branch within this file, it doesn't have to be the same
as any part of the branch URL, but it has to be unique within the file.
`lp:~bzr/bzr/fix-build` is again the location of the branch. What we are doing here is
merging in a branch that we know we need in order to fix the build, but that hasn't landed
in `lp:bzr` yet.

The other way to include code is to use the `nest` keyword.

{{{
nest pyfoo lp:pyfoo foo
}}}

The `nest` keyword specifies nesting another branch, instead of merging it. In this case
we are nesting `lp:pyfoo` in to `lp:bzr`. We are using `pyfoo` to refer to it in the file,
and we want it nested in the `foo` directory, so we specify that last.

It is possible to act on the nested branch in the same way as with the main branch. Any
lines that are indented by two spaces under a `nest` line will act on the nested branch, e.g.

{{{
  merge branding lp:~bob/pyfoo/ubuntu-branding
}}}

would merge the `ubuntu-branding` branch in to `foo`.

The resulting branch needs to already have the `debian` directory in place
with the packaging in it, as it can't be auto-generated. Therefore you will
often need to merge one or more packaging branches:

{{{
merge packaging lp:~bzr/bzr/packaging
}}}

In total this recipe would look like

{{{
# bzr-builder format 0.2 deb-version 1.0+{time}
lp:bzr
merge fix-build lp:~bzr/bzr/fix-build
nest pyfoo lp:pyfoo foo
  merge branding lp:~bob/pyfoo/ubuntu-branding
merge packaging lp:~bzr/bzr/packaging
}}}

=== Specifying revisions ===

Sometimes you want to specify a specific revision of a branch to use,
rather than the tip. You can do this by including a revision specifier
at the end of any branch line, e.g.

{{{
merge packaging lp:~bzr/bzr/packaging revno:2355
}}}

or, for the first branch line

{{{
lp:bzr tag:1.0
}}}

would mean that every time the recipe was used it would use the "1.0"
tag from that branch.

=== Version numbers ===

The `deb-version` specifier allow you to specify a version number for the
resulting package, but it's not very useful if it is only ever a single
version number, as you need it to increase.

The example above (`1.0+{time}`), use a substitution variable. This will
be replaced when the version number is needed with the current date
and time (UTC). This will ensure that later packages get higher version
numbers.

There is a second variable that you can use as well: `{revno}`. This will
be replaced the revision number of the revision that was used from the
primary branch. You can use the revision number of any branch by using
`{revno:<branch id>}`.

You can use as many substitution variables as you like, e.g.

{{{
  deb-version 1.0+{revno}-0ubuntu0+{revno:packaging}+{time}
}}}

Which would expand to something like

{{{
  deb-version 1.0+4264-0ubuntu0+2145+200907201627
}}}

=== Running Commands ===

Sometimes it is necessary to run a command in order to prepare a branch
for packaging, and bzr-builder supports this. If you add
Let's say you need to run ```autoreconf -i``` at some point during the build process. You'd add the following line to your recipe:
Line 176: Line 67:
at one point in the recipe it will run the command (`autoreconf -i` here)
when it reaches that point while building the package.
When bzr-builder reaches that point in the recipe it will run that command.
Line 179: Line 69:
It is recommended to avoid arbitrary network access, as you do not
know the environment in which the command will be run.
If you place a ```run``` command in a ```nest``` section of a recipe &mdash; i.e. indented by two spaces below a ```nest``` command &mdash; the command will be run in the nested location.
Line 182: Line 71:
Note that `run` can also be used in `nest` sections, where it will be
run in the nested location.
For example:
Line 190: Line 78:
would run `cat control` in the `debian` directory.

The command is passed through the shell, so you can use shell constructs.
The command is passed through the shell, so you can use shell constructs, such as:
Line 198: Line 84:
If the command exits with a non-zero error code then it will stop the
building of the package.
If the command exits with a non-zero error code then it will stop the building of the package.
Line 201: Line 86:
== Building the recipe == = Building the recipe =
Line 209: Line 94:
This will perform the steps specified in `package.recipe`. It will create
`working-dir` and put the resulting source tree and the source package
there.
This will perform the steps specified in `package.recipe`. It will create `working-dir` and put the resulting source tree and the source package there.
Line 213: Line 96:
You can examine the unpacked source tree and then build the source package
and install the results.
You can examine the unpacked source tree and then build the source package and install the results.

= Next steps =

There's more in the [[Packaging/SourceBuildsdaily builds knowledge base]].

||<tablestyle="width: 100%;" style="width: 50%;"> ~-[[Packaging/SourceBuilds/Recipes|< Recipes in detail]] -~ ||<style="width: 50%; text-align: right;"> ~- [[Packaging/SourceBuilds/KnowledgeBase|More help in the daily builds knowledgebase >]] -~ ||

Launchpad Help > Packaging > Daily builds > bzr-build

lp-diamond-16.png Source package recipes in Launchpad

Home

Getting Started

Knowledge Base

List of Daily Builds

Overview

bzr-builder is the Bazaar plugin that helps you set up daily builds in Launchpad. You need to install it locally to test your recipes and builds before you send them to Launchpad.

Installation

The easiest way to install bzr-builder, and keep it updated, is using the PPA at:

Alternatively, you can pull down the branch from Launchpad and install it in your Bazaar plugins directory:

$ mkdir -p ~/.bazaar/plugins/
$ bzr branch lp:bzr-builder ~/.bazaar/plugins/builder

To check if it is install and running, enter:

$ bzr plugins -v

Looking for "builder" in the listed plugins.

Getting help

Help for the plugin is available by running:

$ bzr help builder

Help for the individual commands is available as:

$ bzr help build
$ bzr help dailydeb

Recipes

bzr-builder works with "recipes" that are descriptions of the steps needed to construct a package from the various Bazaar branches.

Read our guide to writing recipes.

Running commands in recipes

Sometimes you may need run a partircular command in order to prepare a branch for packaging.

bzr-builder supports this through the run command.

Note: Launchpad does not support the run command.

Let's say you need to run autoreconf -i at some point during the build process. You'd add the following line to your recipe:

run autoreconf -i

When bzr-builder reaches that point in the recipe it will run that command.

If you place a run command in a nest section of a recipe — i.e. indented by two spaces below a nest command — the command will be run in the nested location.

For example:

nest packaging lp:~team/project/ubuntu debian
  run cat control

The command is passed through the shell, so you can use shell constructs, such as:

run touch a && touch b

If the command exits with a non-zero error code then it will stop the building of the package.

Building the recipe

In order to build the recipe you need to use the bzr dailydeb command.

$ bzr dailydeb package.recipe working-dir

This will perform the steps specified in package.recipe. It will create working-dir and put the resulting source tree and the source package there.

You can examine the unpacked source tree and then build the source package and install the results.

Next steps

There's more in the Packaging/SourceBuildsdaily builds knowledge base.

< Recipes in detail

More help in the daily builds knowledgebase >

Packaging/SourceBuilds/BzrBuilder (last edited 2012-04-18 00:16:57 by cpc15-haye17-2-0-cust47)