Diff for "SbuildLVMHowto"


Differences between revisions 13 and 14
Revision 13 as of 2007-05-23 21:20:31
Size: 8029
Editor: sites
Comment: be consistant about release
Revision 14 as of 2007-07-10 16:21:21
Size: 8025
Editor: sites
Comment:
Deletions are marked like this. Additions are marked like this.
Line 90: Line 90:
 {{{sbuild -d gutsy ''PACKAGE''_*.dsc}}}  {{{sbuild -d gutsy PACKAGE_*.dsc}}}

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 [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

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, 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:

  • 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.sh storagevg gutsy

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

  • mk-sbuild-lv.sh --arch i386 storagevg gutsy

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

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 }}}

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

Using sbuild

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

  • schroot -c gutsy -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 gutsy-source -u root

To build a package in your schroot, use sbuild:

  • sbuild -d gutsy PACKAGE_*.dsc

Previous Instructions

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 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)