diff options
author | Junichi Uekawa <dancer@coreduo.netfort.gr.jp> | 2007-06-23 22:10:23 +0900 |
---|---|---|
committer | Junichi Uekawa <dancer@coreduo.netfort.gr.jp> | 2007-06-23 22:10:23 +0900 |
commit | 0e501194042aac29a4407fd14c8977690f182079 (patch) | |
tree | f9ba4f6290fb375a86ad674a826b1fe739349633 /examples | |
parent | e03f24a4574e72f75c382211693bf4a694887ea8 (diff) | |
download | pbuilder-0e501194042aac29a4407fd14c8977690f182079.tar pbuilder-0e501194042aac29a4407fd14c8977690f182079.tar.gz |
* Bug fix: "pbuilder: Some sample (device-mapper) cow build scripts",
thanks to Kapil Hari Paranjape (Closes: #389884).
Include lvmpbuilder sample implementation.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/lvmpbuilder/README | 36 | ||||
-rwxr-xr-x | examples/lvmpbuilder/lvmbuilder | 88 | ||||
-rw-r--r-- | examples/lvmpbuilder/pbuilderrc | 71 | ||||
-rwxr-xr-x | examples/lvmpbuilder/sample_device_creator | 25 | ||||
-rwxr-xr-x | examples/lvmpbuilder/sample_setup_base | 34 |
5 files changed, 254 insertions, 0 deletions
diff --git a/examples/lvmpbuilder/README b/examples/lvmpbuilder/README new file mode 100644 index 0000000..d2a5cb0 --- /dev/null +++ b/examples/lvmpbuilder/README @@ -0,0 +1,36 @@ +The files in this directory (except pbuilderrc) were written by +(C) 2006 Kapil Hari Paranjape <kapil@imsc.res.in>. +They are placed in the public domain. You can do with them exactly as you wish. + +These are scripts to help pbuilder run with the device mapper or LVM. +(You do need "dmsetup" to be installed on your system.) + +I hope the files are reasonably well commented. If not please ask me. + +The rough order of things is as follows. + +1. Use a script like "sample_device_creator" to create two block +devices. The BASE device should have enough space to hold the basic +buildd environment (an unpacked base.tgz from pbuilder). The COW +device should have enough space to perform the build. + +2. You should edit your ~/.pbuilderrc and add two lines + BASEDEV=<fullpath of base device> + COWDEV=<fullpath of cow device> + +3. Use a script like "sample_setup_base" to setup the BASE device. +Essentially this ensures that BASE device has a working (ext2) file +system which has the entire chroot (e.g. just unpack base.tgz to this +device). In addition, the BASE device *must* be "e2fsck -f"'ed in +order that the resize works in the next step. Optionally you can set +the BASE device to be a read-only device after this step. + +4. Now you can run "lvmbuilder <dsc_filename>" to build your package. + (a) It ought to be faster than unpacking base.tgz + (b) It will make no changes to the BASE device. + +Hope this helps! +-- +Kapil Hari Paranjape +Thu, 28 Sep 2006 12:40:12 +0530 + diff --git a/examples/lvmpbuilder/lvmbuilder b/examples/lvmpbuilder/lvmbuilder new file mode 100755 index 0000000..788908e --- /dev/null +++ b/examples/lvmpbuilder/lvmbuilder @@ -0,0 +1,88 @@ +#!/bin/sh +#The files in this directory (except pbuilderrc) were written by +#(C) 2006 Kapil Hari Paranjape <kapil@imsc.res.in>. +#They are placed in the public domain. You can do with them exactly as you wish. + +# This assumes: +# A. +# You have added the following lines to you ~/.pbuilderrc +# BASEDEV=<path to your base device> +# COWDEV=<path to your cow device> +# +# B. +# That the BASE and COW device have been properly set up. +# Specifically, you must run: +# e2fsck -f $BASEDEV +# It is too painful to run this everytime! +# +# You can also run +# blockdev --setro $BASEDEV +# This tries to ensure that the $BASDEV remains pristine. +# +# C. +# It also assumes that /dev/mapper/{total,work} +# do not exist already. + + +if [ $# -lt 1 ] +then + echo You need to supply the name of the dsc file + exit 1 +fi + +PKGDSC=$1 + +# Source the pbuilderrc file +. /usr/lib/pbuilder/pbuilder-loadconfig + + +if [ -z "$BASEDEV" -o -z "$COWDEV" ] +then + echo Please define BASEDEV and COWDEV in your ~/.pbuilderrc file + exit 1 +fi + +# Size computations + +BASESIZE=$(blockdev --getsize $BASEDEV) +COWSIZE=$(blockdev --getsize $COWDEV) +TOTAL=$[ $COWSIZE + $BASESIZE ] + +## Create the total base device +# It consists of the base device extended by zeroes. +# The length of the zeroes is the size of the cow. +dd if=/dev/zero of=$COWDEV bs=4K count=16 + +( echo 0 $BASESIZE linear $BASEDEV 0 ; \ + echo $BASESIZE $COWSIZE zero ) | \ + dmsetup create total + +## Create the work device +# It is the snapshot device with the all writes +# going to the cow device. The file-system is resized +# to the maximum extent possible. +echo 0 $TOTAL snapshot /dev/mapper/total $COWDEV p 16 | \ + dmsetup create work + +resize2fs /dev/mapper/work + +mount /dev/mapper/work $BUILDPLACE + +# run build +pbuilder build --no-targz $PKGDSC + +## Check the status +# If pbuilder returned with +# an error then we must stop +# and be able to examine the work space. +[ $? != 0 ] && \ +( echo Error during build. $BUILDPLACE contains the build place. ; \ + exit 1 ) + +## Clean Up +umount $BUILDPLACE +dmsetup remove work +dmsetup remove total + +echo Done. + diff --git a/examples/lvmpbuilder/pbuilderrc b/examples/lvmpbuilder/pbuilderrc new file mode 100644 index 0000000..d8b50e0 --- /dev/null +++ b/examples/lvmpbuilder/pbuilderrc @@ -0,0 +1,71 @@ +# this is your configuration file for pbuilder. +# the file in /usr/share/pbuilder/pbuilderrc is the default template. +# /etc/pbuilderrc is the one meant for editing. +# +# read pbuilderrc.5 document for notes on specific options. + +BASETGZ=/var/cache/pbuilder/base.tgz +#EXTRAPACKAGES=gcc3.0-athlon-builder +#export DEBIAN_BUILDARCH=athlon +BUILDPLACE=/var/cache/pbuilder/build/ +#NONUSMIRRORSITE="http://ftp.jp.debian.org/debian-non-US" +#OTHERMIRROR="deb http://oak:9999/security/ sarge/updates/" +#OTHERMIRROR="deb file:/home/mirrors/debian/ testing main" +#MIRRORSITE=http://oak:9999/debian/ +MIRRORSITE=http://ftp.iitm.ac.in/debian/ +#export http_proxy=http://your-proxy:8080/ +USEPROC=yes +USEDEVPTS=yes +USEDEVFS=no +BUILDRESULT=/var/cache/pbuilder/result/ + +# specifying the distribution forces the distribution on "pbuilder update" +#DISTRIBUTION=etch +#specify the cache for APT +APTCACHE="/var/cache/pbuilder/aptcache/" +APTCACHEHARDLINK="no" +REMOVEPACKAGES="lilo" +#HOOKDIR="/usr/lib/pbuilder/hooks" +HOOKDIR="" + +# make debconf not interact with user +export DEBIAN_FRONTEND="noninteractive" + +DEBEMAIL="Kapil Hari Paranjape <kapil@imsc.res.in>" + +#for pbuilder debuild +BUILDSOURCEROOTCMD="fakeroot" +PBUILDERROOTCMD="sudo" + +#default is to build everything. Passed on to dpkg-buildpackage +#DEBBUILDOPTS="-b" +DEBBUILDOPTS="-k5416E5B8" + +#APT configuration files directory +APTCONFDIR="" + +# the username and ID used by pbuilder, inside chroot. Needs fakeroot, really +BUILDUSERID=1234 +BUILDUSERNAME=pbuilder + +# BINDMOUNTS is a space separated list of things to mount +# inside the chroot. +#BINDMOUNTS="/home " + +# Set the debootstrap variant to 'buildd' type. +DEBOOTSTRAPOPTS[0]='--variant=buildd' +# or work around bug in debootstrap 3.0.0 (314858) +# unset DEBOOTSTRAPOPTS + +# Set the PATH I am going to use inside pbuilder: default is "/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" +export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" + +# SHELL variable is used inside pbuilder by commands like 'su'; and they need sane values +export SHELL=/bin/bash + +# The name of debootstrap command. +DEBOOTSTRAP="debootstrap" + +# Extra variables for LVM build +BASEDEV=/dev/store/pbuilder +COWDEV=/dev/store/cow diff --git a/examples/lvmpbuilder/sample_device_creator b/examples/lvmpbuilder/sample_device_creator new file mode 100755 index 0000000..4c38810 --- /dev/null +++ b/examples/lvmpbuilder/sample_device_creator @@ -0,0 +1,25 @@ +#!/bin/sh +#The files in this directory (except pbuilderrc) were written by +#(C) 2006 Kapil Hari Paranjape <kapil@imsc.res.in>. +#They are placed in the public domain. You can do with them exactly as you wish. + +## Uncomment these lines after filling the +## full path of a device with at least 2G +# DISK=/dev/hda5 +## ...and... +## Comment these lines to use the actual device +## You entered above +LOOPTMP=$(mktemp /tmp/loop.XXXXXX) +dd if=/dev/zero of=$LOOPTMP bs=10M count=200 +DISK=$(losetup -f) +losetup $DISK $LOOPTMP + +# Possible steps to create base and cow devices +pvcreate $DISK +vgcreate pbuilder $DISK +lvcreate -L 500M -n base pbuilder +lvcreate -L 1.5G -n cow pbuilder + +echo BASEDEV=$(ls /dev/pbuilder/base) && \ +echo COWDEV=$(ls /dev/pbuilder/cow) + diff --git a/examples/lvmpbuilder/sample_setup_base b/examples/lvmpbuilder/sample_setup_base new file mode 100755 index 0000000..5ce5ce5 --- /dev/null +++ b/examples/lvmpbuilder/sample_setup_base @@ -0,0 +1,34 @@ +#!/bin/sh +#The files in this directory (except pbuilderrc) were written by +#(C) 2006 Kapil Hari Paranjape <kapil@imsc.res.in>. +#They are placed in the public domain. You can do with them exactly as you wish. + +# Source the pbuilderrc file +. /usr/lib/pbuilder/pbuilder-loadconfig + +echo $HOME : $BASEDEV : $COWDEV + +if [ -z "$BASEDEV" -o -z "$COWDEV" ] +then + echo Please define BASEDEV and COWDEV in the pbuilderrc file + exit 1 +fi + +# setup for creation +mke2fs -O dir_index $BASEDEV +mount $BASEDEV $BUILDPLACE + +# Use debootstrap to create +DISTRIBUTION=${DISTRIBUTION:-"sid"} +$DEBOOTSTRAP ${DEBOOTSTRAPOPTS[@]} $DISTRIBUTION $BUILDPLACE $MIRRORSITE + +# run update +pbuilder update --no-targz + +# finalise base +umount $BUILDPLACE +e2fsck -f $BASEDEV +blockdev --setro $BASEDEV + +echo Done. + |