Diff for "Packaging/DailyBuilds/Recipes/Draft"

Not logged in - Log In / Register

Differences between revisions 1 and 2
Revision 1 as of 2011-03-23 12:18:07
Size: 6910
Editor: host217-44-165-42
Comment:
Revision 2 as of 2020-07-27 10:52:39
Size: 0
Comment: Superseded by https://help.launchpad.net/Packaging/SourceBuilds/Recipes
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
~-[[FrontPage|Launchpad Help]] > [[Packaging]] > [[Packaging/DailyBuilds|Daily builds]] > Recipes -~


||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>||

= Overview =

A bzr-builder "recipe" is a description of the steps needed to construct a package from a set of Bazaar branches. Its format specifies:

 * Which branch to use for the source code: trunk branch, beta branch, etc.
 * Which branch to use for the packaging information: separate branch, Ubuntu branch, etc.
 * The correct package version (so people can still upgrade to the new stable version when it's released.
 * What to modify to make the source build properly.

= Writing a recipe =

Recipes have a simple format.

'''Note:''' you can find an uncomplicated example in the [[Packaging/DailyBuilds/GettingStarted|getting started]] guide.

They always start with a line similar to this:

{{{
# bzr-builder format 0.2 deb-version 1.0+{revno}
}}}

Let's take a look at this in more detail:

 * ```# bzr-builder format 0.2``` specifies which recipe format we're using. The current format is 0.2.
 * ```deb-version 1.0+{revno}``` specifies the version to give the package we're building. ```{revno}``` is a substitution variable; more on which later.
 
== Specifying the branches ==
 
The next line of a recipe specifies which branch to base the package on:

{{{
lp:bzr
}}}

This says that we will use the trunk of the ```bzr``` project in Launchpad. This could just as easily be any other branch in Launchpad, using the short format that you can find on any branch overview page.

Next, you can specify any number of other branches to include. There are two ways to include those branches additional branches:

 * merge: this specifies a simple ```bzr merge``` of the two branches.
 * nest: inserts the content of the second branch into a specific location within the main branch.

=== Merging ===

Most often you'll use the "merge" command:

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

Here ```fix-build``` is a unique short name that we'll use to refer to this branch throughout the recipe. The short name can be anything you like, so long as it is unique to this branch within this recipe.

```lp:~bzr/bzr/fix-build``` is the location of the branch.

In this example, the branch ''fix-build'' fixes a problem in the trunk that prevents it from building. This branch could be anything: stand-alone packaging information, some other modification to the branch that's not yet present in the trunk and so on.

=== Nesting ===

Nesting works in a similar way but has more scope:

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

The ```nest``` keyword puts the contents of one branch into a specific location in another branch, instead of merging it.

In this case, we are nesting the contents of ```lp:pyfoo``` in a new ```foo``` directory in the ```lp:bzr``` branch. Again, we've given the branch a short name, ```pyfoo```, that we can use to refer to it throughout the recipe.

You can also act on the nested branch in the same way as you can the main branch: you can merge and nest other branches in your nested branch.

Here's how:

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

Any lines that are indented by two spaces, and are directly below your ```nest``` line, will act on the nested branch. In this example, the ```ubuntu-branding``` branch will be merged into ```pyfoo``` before it is nested in your primary branch.

=== Packaging information ===

One of the branches that you include in your recipe must include packaging information in the ```debian``` directory. You can include this from another branch, that includes packaging information only, using a merge or a nest:

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


== What our recipe looks like ==

Adding up all the lines above, our full recipe would look like this:

{{{
# bzr-builder format 0.2 deb-version 1.0+{revno}
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. For example:

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

Similarly for the main branch:

{{{
lp:bzr revno:1234
}}}

Bazaar allows you to tag a certain revision with an easily memorable name. You can request a specific tagged revision like this:

{{{
lp:bzr tag:2.0
}}}

Here, the recipe would use the revision that has the tag "2.0".

== Version numbers and substitution variables ==

In the first line of the recipe, we specified a version number for the package we want to build, using:

{{{
deb-version 1.0+{revno}
}}}

Rather than specify a fixed version number, we need it to increase every time the package is built. To allow for this, you can use a two substitution variables.

||<tablestyle="border: none;" rowstyle="background-color: #2a2929; font-weight: bold; color: #f6bc05; padding: 2px 5px 2px 5px;">Variable||Purpose||
||{time}||Replaced by the date and time (UTC) when the package was built.||
||{revno}||Replaced by the revision number of the primary branch.||
||{revno:<branch id>}||Replaced by the revision number of the branch you specify, using the short name specified elsewhere in the recipe.||
||{debupstream}||Replaced by the upstream portion of the version number taken from ```debian/changelog``` in the final tree. For example: if the version is ```1.0-1```, this would evaluate to ```1.0```.||

The advantages of using {revno} and/or {time}:

 * '''{revno}:''' if you want to ensure there's a new package version number whenever the contents of the branch has changed. This is particularly useful if you specfiy a {revno} for each branch in your recipe.
 * '''{time}:''' if you want the package version to increase whether or not the contents of one of more of the branches has changed.

You can use as many substitution variables as you like. For example:

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

Here the ```packaging``` in ```revno:packaging``` refers to the short name we gave the branch we're using for packaging.

This example would generate a package version something like:

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

= Next steps =

Let's look at [[Packaging/DailyBuilds/BzrBuilder|bzr-builder in more detail]].

||<tablestyle="width: 100%;"> ~-[[Packaging/DailyBuilds/GettingStarted|< Daily builds getting started]] -~ ||<style="text-align: right;"> ~- [[Packaging/DailyBuilds/BzrBuilder|bzr-builder in detail >]] -~ ||