Pbuilder
Ori.livneh (Talk | contribs) |
Ori.livneh (Talk | contribs) m (Removed notice about Ragweed deprecation. It's common knowledge by this point.) |
||
| (13 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | + | '''Pbuilder''' is a tool for automatically building and packaging binaries in a clean chroot of an arbitrary Debian / Ubuntu distribution. By abstracting away the particulars of your environment, it helps ensure that your packages install correctly on other machines. | |
| − | + | ||
| − | == | + | == Prerequisites == |
| − | + | The following instructions presume that you already have a source package (<tt>.dsc</tt> file) and are looking to build and package binaries. If you have not yet created a source package, you will need to do so first. If your project is in Gerrit, you should use [[git-buildpackage]]. You may also find it helpful to read the [[APT repository|overview of the packaging workflow]]. | |
| − | + | == Setting up your environment == | |
| + | Start by getting your hands on a Labs instance with a <tt>misc::package-builder</tt> Puppet role (you can add this role if necessary). This will drop a clean install image in <tt>/var/cache/pbuilder/''distribution''.tgz</tt>. (Alternately, you can create a clean install image manually using <tt>pbuilder create</tt>.) | ||
| − | + | Create a <tt>packaging/</tt> directory in your home directory and copy the image there. Next, configure some useful defaults in <tt>~/.pbuilderrc</tt> (creating it if it does not exist): | |
| − | === | + | <syntaxhighlight lang="ini"> |
| − | + | DEBEMAIL="Your Name <your.email@wikimedia.org>" | |
| + | BASETGZ="/home/yourname/packaging/precise.tgz" # Path must be canonical and absolute | ||
| + | APTCONFDIR="/etc/apt" # Use host environment's apt config -- see below for caveat | ||
| + | DEBBUILDOPTS="-sa" # Include source -- required for inclusion in Wikimedia repo | ||
| + | </syntaxhighlight> | ||
| − | + | Note: whenever BASETGZ is not recognized, you can pass the full pass to the tgz using --basetgz: | |
| + | pbuilder build --basetgz /var/cache/pbuilder/precise.tgz some.dsc | ||
| + | |||
| + | The <tt>APTCONFDIR</tt> copies your apt configuration to the build environment. This will add the Wikimedia apt repositories, which allows your package to have dependencies on other packages in our repository. However, this only works if your host is running the same distribution as the one you are targeting. If you added the APTCONFDIR line, you should update the image, which will complete the build environment's apt configuration: | ||
| + | |||
| + | # sudo pbuilder update --override-config | ||
| + | |||
| + | If you are targeting a different distribution or wish to include other repositories, you can declare them in <tt>pbuilderrc</tt> (see <tt>man pbuilderrc</tt>), or you can configure your build environment in an interactive session, by running <tt>pbuilder login --save-after-login</tt> and making the required modifications by hand. | ||
| + | |||
| + | == Build == | ||
| + | When you are ready to build a package, use: | ||
| + | |||
| + | # sudo pbuilder build ''package.dsc'' | ||
| + | |||
| + | If you would like to use a different base image, you can specify it using the <tt>--basetgz</tt> command-line argument. (Other defaults are similarly overridable -- see the man page for pbuilder.) | ||
If all goes well, you'll find the resulting package(s) in <tt>/var/cache/pbuilder/result</tt>. | If all goes well, you'll find the resulting package(s) in <tt>/var/cache/pbuilder/result</tt>. | ||
| + | == Upload to repository == | ||
| + | The final step is to upload your package for inclusion in the repository. This is done using [[Reprepro]]. | ||
| + | |||
| + | == Tips == | ||
| + | === Targeting different archs === | ||
Create a new distribution image using another filename: | Create a new distribution image using another filename: | ||
| − | # pbuilder create --distribution | + | # pbuilder create --distribution precise --debootstrapopts --arch --debootstrapopts i386 \ |
| − | Then to build a 32 bit package: | + | --basetgz ~/packaging/base-i386.tgz |
| + | |||
| + | Then, to build a 32 bit package: | ||
# linux32 pbuilder build --basetgz /var/cache/pbuilder/base-i386.tgz --debbuildopts "-sa" ''package.dsc'' | # linux32 pbuilder build --basetgz /var/cache/pbuilder/base-i386.tgz --debbuildopts "-sa" ''package.dsc'' | ||
The <tt>debbuildopts</tt> argument forces the inclusion of the package source, a requirement for inclusion in the Wikimedia repository. | The <tt>debbuildopts</tt> argument forces the inclusion of the package source, a requirement for inclusion in the Wikimedia repository. | ||
=== Modifying the base image === | === Modifying the base image === | ||
| − | + | As noted earlier, the easiest way to change something in the base image is via an interactive session: | |
# pbuilder login --save-after-login | # pbuilder login --save-after-login | ||
| + | This will drop you into an interactive session in the target environment. You can make whatever modifications you need; once you log out, the environment's image will be rebuilt with your modifications. | ||
== External documentation == | == External documentation == | ||
| − | * [http://pbuilder.alioth.debian.org/pbuilder-doc.pdf | + | * [https://wiki.ubuntu.com/PbuilderHowto Pbuilder Howto] (Ubuntu-specific) |
| + | * [http://pbuilder.alioth.debian.org/pbuilder-doc.pdf Pbuilder documentation] (PDF) | ||
| + | * [http://manpages.ubuntu.com/manpages/precise/man8/pbuilder.8.html pbuilder man page] | ||
| + | * [http://manpages.ubuntu.com/manpages/precise/en/man5/pbuilderrc.5.html pbuilderrc man page] | ||
| + | |||
[[Category:Ubuntu]] [[Category:Package management]] | [[Category:Ubuntu]] [[Category:Package management]] | ||
Latest revision as of 04:52, 4 February 2013
Pbuilder is a tool for automatically building and packaging binaries in a clean chroot of an arbitrary Debian / Ubuntu distribution. By abstracting away the particulars of your environment, it helps ensure that your packages install correctly on other machines.
Contents |
[edit] Prerequisites
The following instructions presume that you already have a source package (.dsc file) and are looking to build and package binaries. If you have not yet created a source package, you will need to do so first. If your project is in Gerrit, you should use git-buildpackage. You may also find it helpful to read the overview of the packaging workflow.
[edit] Setting up your environment
Start by getting your hands on a Labs instance with a misc::package-builder Puppet role (you can add this role if necessary). This will drop a clean install image in /var/cache/pbuilder/distribution.tgz. (Alternately, you can create a clean install image manually using pbuilder create.)
Create a packaging/ directory in your home directory and copy the image there. Next, configure some useful defaults in ~/.pbuilderrc (creating it if it does not exist):
DEBEMAIL="Your Name <your.email@wikimedia.org>" BASETGZ="/home/yourname/packaging/precise.tgz" # Path must be canonical and absolute APTCONFDIR="/etc/apt" # Use host environment's apt config -- see below for caveat DEBBUILDOPTS="-sa" # Include source -- required for inclusion in Wikimedia repo
Note: whenever BASETGZ is not recognized, you can pass the full pass to the tgz using --basetgz:
pbuilder build --basetgz /var/cache/pbuilder/precise.tgz some.dsc
The APTCONFDIR copies your apt configuration to the build environment. This will add the Wikimedia apt repositories, which allows your package to have dependencies on other packages in our repository. However, this only works if your host is running the same distribution as the one you are targeting. If you added the APTCONFDIR line, you should update the image, which will complete the build environment's apt configuration:
# sudo pbuilder update --override-config
If you are targeting a different distribution or wish to include other repositories, you can declare them in pbuilderrc (see man pbuilderrc), or you can configure your build environment in an interactive session, by running pbuilder login --save-after-login and making the required modifications by hand.
[edit] Build
When you are ready to build a package, use:
# sudo pbuilder build package.dsc
If you would like to use a different base image, you can specify it using the --basetgz command-line argument. (Other defaults are similarly overridable -- see the man page for pbuilder.)
If all goes well, you'll find the resulting package(s) in /var/cache/pbuilder/result.
[edit] Upload to repository
The final step is to upload your package for inclusion in the repository. This is done using Reprepro.
[edit] Tips
[edit] Targeting different archs
Create a new distribution image using another filename:
# pbuilder create --distribution precise --debootstrapopts --arch --debootstrapopts i386 \
--basetgz ~/packaging/base-i386.tgz
Then, to build a 32 bit package:
# linux32 pbuilder build --basetgz /var/cache/pbuilder/base-i386.tgz --debbuildopts "-sa" package.dsc
The debbuildopts argument forces the inclusion of the package source, a requirement for inclusion in the Wikimedia repository.
[edit] Modifying the base image
As noted earlier, the easiest way to change something in the base image is via an interactive session:
# pbuilder login --save-after-login
This will drop you into an interactive session in the target environment. You can make whatever modifications you need; once you log out, the environment's image will be rebuilt with your modifications.
[edit] External documentation
- Pbuilder Howto (Ubuntu-specific)
- Pbuilder documentation (PDF)
- pbuilder man page
- pbuilderrc man page