Diff for "SbuildLVMHowto"


Differences between revisions 15 and 16
Revision 15 as of 2007-07-23 15:12:30
Size: 8021
Editor: d235-228-172
Comment:
Revision 16 as of 2008-02-14 16:58:30
Size: 9167
Editor: dsl-207-112-70-57
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Introduction == = Introduction =
Line 5: Line 5:
The script [http://people.ubuntu.com/~kees/scripts/mk-sbuild-lv.sh mk-sbuild-lv.sh] is used to initialize each schroot. It was written based on the original implementation of this How-To, and incorporates additional recommendations from sbuild-setup(7).

The following assume you want to install ''gutsy''. If you need a ''dapper'', ''edgy'', or ''feisty'' chroot, then exchange ''gutsy'' with the appropriate distribtion.

== LVM requirements ==
The script mk-sbuild-lv is used to initialize each schroot. It was written based on the original implementation of this How-To, and incorporates additional recommendations from sbuild-setup(7). It is part of the ubuntu-dev-tools package.

The following assume you want to install ''hardy''. If you need a ''dapper'', ''edgy'', ''feisty'' or ''gutsy'' chroot, then exchange ''hardy'' with the appropriate distribution.

= LVM requirements =
Line 13: Line 13:
{{{sudo vgs}}}

== Getting started ==

It is recommended you run under Gutsy
, which has a slightly patched version of schroot. If you're running in Feisty or earlier, please see Debian bug [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391319 #391319] for a patch to clean up stale processes running in the schroot.

The first time you run {{{mk-sbuild-lv.sh}}}, it will attempt to get everything set up for first-time use. It performs the following steps:
{{{
sudo vgs
}}}

= Getting started =

It is recommended you run under
Gutsy or a later release, which has a slightly patched version of schroot. If you're running in Feisty or earlier, please see Debian bug [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391319 #391319] for a patch to clean up stale processes running in the schroot.

The first time you run {{{mk-sbuild-lv}}}, it will attempt to get everything set up for first-time use:
{{{
mk-sbuild-lv
}}}

It performs the following steps:
Line 27: Line 33:
== Adding a schroot == = Adding a schroot =
Line 31: Line 37:
 {{{mk-sbuild-lv.sh storagevg gutsy}}} {{{
mk-sbuild-lv storagevg hardy
}}}
Line 35: Line 43:
 {{{mk-sbuild-lv.sh --arch i386 storagevg gutsy}}} {{{
mk-sbuild-lv --arch i386 storagevg hardy
}}}
Line 38: Line 48:
Line 46: Line 55:
=== Alternate sources.list === There are other options available:
{{{
mk-sbuild-lv --help
}}}

== Alternate sources.list ==
Line 58: Line 72:
=== Alternate schroot.conf entry === This can be combined with an apt proxy (such as apt-cacher, apt-proxy, apt-cacher-ng) or even a local ubuntu mirror (managed with debmirror, but requires a lot of disk space). It will greatly speed up the build process as packages will only be fetched once from the network and then served from the local cache.

The alternate sources.list file can also be specified on the command line using {{{--source-template}}}.

Another useful option is {{{--debootstrap-mirror}}}: it can be used to specify which mirror debootstrap should use when creating the initial chroot.

== Alternate schroot.conf entry ==
Line 78: Line 98:
== Using sbuild == More information about the available options can be found in the schroot.conf man page:

{{{
man schroot.conf
}}}

= Using sbuild =
Line 82: Line 108:
 {{{schroot -c gutsy -u root}}} {{{
schroot -c hardy -u root
}}}
Line 86: Line 114:
 {{{schroot -c gutsy-source -u root}}} {{{
schroot -c hardy-source -u root
}}}
Line 90: Line 120:
 {{{sbuild -d gutsy PACKAGE_*.dsc}}}




= Previous Instructions =
{{{
sbuild -d hardy PACKAGE_*.dsc
}}}

= Keeping your chroots up-to-date =

You can use the following shell script to update all your chroots:

{{{
for d in `schroot -l | grep -- -source`
do
        schroot -c $d -u root apt-get update
        schroot -c $d -u root apt-get dist-upgrade
done
}}}

Drop it in {{{/etc/cron.daily/}}} and you'll always have up-to-date chroots !

= Instructions for Dapper =

Introduction

This document describes the steps to setup a chroot with schroot on an LVM LV, so that you can build packages on an LVM LV snapshot. It tries to provide an alternative to [http://wiki.ubuntu.com/PbuilderHowto PbuilderHowto]. It assumes a passing understanding of LVM, and having an available VG to work with.

The script mk-sbuild-lv is used to initialize each schroot. It was written based on the original implementation of this How-To, and incorporates additional recommendations from sbuild-setup(7). It is part of the ubuntu-dev-tools package.

The following assume you want to install hardy. If you need a dapper, edgy, feisty or gutsy chroot, then exchange hardy with the appropriate distribution.

LVM requirements

For the schroots to be useful, you will need a good bit of free space in your VG. By default, each schroot takes 5G, and each time you run an sbuild, it will temporarily allocate 4G for filesystem change in the LVM snapshot until the sbuild finishes. To see available VG space:

sudo vgs

Getting started

It is recommended you run under Gutsy or a later release, which has a slightly patched version of schroot. If you're running in Feisty or earlier, please see Debian bug [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391319 #391319] for a patch to clean up stale processes running in the schroot.

The first time you run mk-sbuild-lv, it will attempt to get everything set up for first-time use:

mk-sbuild-lv

It performs the following steps:

  • installs the required packages (you will be prompted for your password for the sudo)
  • starts an editor on your ~/.sbuildrc (you need to fill in $mailto and $maintainer_name)
  • adds your current user id to the "sbuild" group (so you can run sbuild/schroot correctly)

After this finishes, you must re-log-in!

Adding a schroot

To create a schroot, run the script with two arguments, the VG you want to allocate the LV into, and the release to install:

mk-sbuild-lv storagevg hardy

If you have an amd64 host and you want to have i386 schroots, you can add the optional --arch option:

mk-sbuild-lv --arch i386 storagevg hardy

This will do the following steps:

  • allocates a LV named "$RELEASE_chroot" (with "-$ARCH" appended if not the native arch)
  • makes an ext3 on the LV
  • runs debootstrap on the LV for the specified release

  • installs a default source.lists
  • installs a default schroot.conf entry
  • updates packages, installs build-essential and keyring, drops debconf to Noninteractive, and builds some needed symlinks

There are other options available:

mk-sbuild-lv --help

Alternate sources.list

If you want to use a different sources.list, you can create ~/.mk-sbuild-lv.sources where RELEASE will be automatically replaced by the release being installed:

{{{deb http://archive.ubuntu.com/ubuntu RELEASE main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu RELEASE main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu RELEASE-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu RELEASE-updates main restricted universe multiverse deb http://security.ubuntu.com/ubuntu RELEASE-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu RELEASE-security main restricted universe multiverse }}}

This can be combined with an apt proxy (such as apt-cacher, apt-proxy, apt-cacher-ng) or even a local ubuntu mirror (managed with debmirror, but requires a lot of disk space). It will greatly speed up the build process as packages will only be fetched once from the network and then served from the local cache.

The alternate sources.list file can also be specified on the command line using --source-template.

Another useful option is --debootstrap-mirror: it can be used to specify which mirror debootstrap should use when creating the initial chroot.

Alternate schroot.conf entry

If you want to use a different schroot.conf entry template, you can create ~/.mk-sbuild-lv.schroot.conf where CHROOT_NAME, CHROOT_PATH will be automatically replaced by the configured items:

[CHROOT_NAME]
type=lvm-snapshot
description=CHROOT_NAME
priority=3
groups=sbuild,root,admin
root-groups=root,sbuild,admin
source-groups=sbuild,root,admin
source-root-groups=root,sbuild,admin
device=CHROOT_PATH
mount-options=-o noatime
lvm-snapshot-options=--size 4G
run-setup-scripts=true
run-exec-scripts=true

More information about the available options can be found in the schroot.conf man page:

man schroot.conf

Using sbuild

Once the schroot is built, you can enter a snapshot with:

schroot -c hardy -u root

To make modifications to the snapshot origin LV you can append "-source" to the name of the schroot. Any changes made will appear in all subsequence schroot snapshots:

schroot -c hardy-source -u root

To build a package in your schroot, use sbuild:

sbuild -d hardy PACKAGE_*.dsc

Keeping your chroots up-to-date

You can use the following shell script to update all your chroots:

for d in `schroot -l | grep -- -source`
do 
        schroot -c $d -u root apt-get update
        schroot -c $d -u root apt-get dist-upgrade
done

Drop it in /etc/cron.daily/ and you'll always have up-to-date chroots !

Instructions for Dapper

Installing required packages on dapper

You need a very recent version of schroot. I used version 0.2.8-1ubuntu1 for this Howto.

Just install the following packages on a dapper system:

apt-get install schroot sbuild

creating lvm volumes

in order to create an lvm volume, you first need to prepare one or more partitions (or other block devices) for use as physical volume:

pvcreate /dev/md1

Then you add these physical volumes to a new volume group:

vgcreate data00 /dev/md1

Once this is done, you can now create a new logical volume. The following commands creates a new logical volume 'dapper_chroot' with the size of 5GB in a volumegroup called 'data00':

lvcreate -n dapper_chroot -L 5g data00

you can now create a filesystem on it and mount it:

mkfs -t ext3 /dev/data00/dapper_chroot
mount /dev/data00/dapper_chroot /mnt

bootstrapping a base system

Now you can bootstrap your favorite distribution on that:

debootstrap dapper /mnt http://archive.ubuntu.com/ubuntu

Perhaps you want your /etc/sudoers and sources.list copied into that chroot, so that you can easily become root inside:

sudo cp /etc/sudoers /mnt/etc
sudo cp /etc/apt/sources.list /mnt/etc/apt

Unmount this temporary mountpoint now, schroot will mount it itself:

umount /mnt

configuring schroot

edit '/etc/schroot/schroot.conf' to contain this stanza:

[dapper]
type=lvm-snapshot
description=Ubuntu Dapper
priority=3
groups=sbuild,root,admin
root-groups=root,sbuild,admin
source-groups=sbuild,root,admin
source-root-groups=root,sbuild,admin
device=/dev/data00/dapper_chroot
mount-options=-o noatime
lvm-snapshot-options=--size 1G
run-setup-scripts=true
run-exec-scripts=true

Entering the chroot

If you want to change the 'original' chroot, you can chroot into that with the following command:

schroot -c dapper-source

All changes you make there are persistent. So if you want to upgrade that chroot, use the following commands:

schroot -c dapper-source -u root -- apt-get update
schroot -c dapper-source -u root -- apt-get -y dist-upgrade 
schroot -c dapper-source -u root -- apt-get install build-essential ubuntu-minimal fakeroot devscripts

To enter the chroot on an lvm snapshot, use this command:

schroot -c dapper

Thanks to the session scripts, some directories, like /home, /proc, /sys and /tmp are mounted for you. You can modify/add session scripts in /etc/schroot/setup.d/*

sbuild

For proper support for schroot, make sure you are in the system group 'sbuild'.

Create a file called '~/.sbuildrc' with the following contents:

# Mail address where logs are sent to (mandatory, no default!)
$mailto = "root";

# Name to use as override in .changes files for the Maintainer: field
# (mandatory, no default!).
$maintainer_name='Reinhard Tartler <siretart@tauware.de>';

# Chroot behaviour; possible values are "split" (apt and dpkg are run
# from the host system) and "schroot" (all package operations are done in
# the chroot with schroot, but the chroot must allow networking)
$chroot_mode = "schroot";

# don't remove this, Perl needs it:
1;

building packages

You can build now packages with the following command on lvm snapshots:

sbuild -d dapper package_1.2.3-4.dsc

If anything goes wrong, use parameters '-v -D' to debug.

Good Luck!

CategoryDocumentation

SbuildLVMHowto (last edited 2020-06-10 05:08:52 by rozzin)