mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
* mk-sbuild: automatically install qemu-kvm-extras-static if requested
* mk-sbuild: conditionally install lvm2 only for lv-snapshot schroots * mk-sbuild: rationalise architecture variables * mk-sbuild: Generalise --type support and add "file" SCHROOT_TYPE * mk-sbuild.1: Document the --type argument
This commit is contained in:
commit
47be819276
7
debian/changelog
vendored
7
debian/changelog
vendored
@ -5,6 +5,11 @@ ubuntu-dev-tools (0.93) UNRELEASED; urgency=low
|
||||
|
||||
[ Emmet Hikory ]
|
||||
* Support qemu-arm-static -> qemu-kvm-extras-static transition
|
||||
* mk-sbuild: automatically install qemu-kvm-extras-static if requested
|
||||
* mk-sbuild: conditionally install lvm2 only for lv-snapshot schroots
|
||||
* mk-sbuild: rationalise architecture variables
|
||||
* mk-sbuild: Generalise --type support and add "file" SCHROOT_TYPE
|
||||
* mk-sbuild.1: Document the --type argument
|
||||
|
||||
[ Loïc Minier ]
|
||||
* Demote qemu-kvm-extras-static to a Suggests since most people don't build
|
||||
@ -17,7 +22,7 @@ ubuntu-dev-tools (0.93) UNRELEASED; urgency=low
|
||||
* mk-sbuild.1: update documentation to reflect alternative config file
|
||||
names for distro and schroot type overrides.
|
||||
|
||||
-- Kees Cook <kees@ubuntu.com> Tue, 09 Feb 2010 00:14:26 -0800
|
||||
-- Emmet Hikory <persia@ubuntu.com> Tue, 09 Feb 2010 22:08:56 +0900
|
||||
|
||||
ubuntu-dev-tools (0.92) lucid; urgency=low
|
||||
|
||||
|
@ -41,8 +41,11 @@ Enable distro-specific logic. Currently known distros: "ubuntu" (default)
|
||||
and "debian".
|
||||
.TP
|
||||
.B \-\-vg
|
||||
Specify a volume group, and subsequently use SCHROOT_TYPE of "lvm-snapshot"
|
||||
rather than "directory" (via aufs) mounts.
|
||||
Specify a volume group, and subsequently use a default SCHROOT_TYPE of
|
||||
"lvm-snapshot" rather than "directory" (via aufs) mounts.
|
||||
.TP
|
||||
.B \-\-type
|
||||
Specify a SCHROOT_TYPE. Supported values are "directory" (default if --vg not specified), "lvm-snapshot" (default if --vg specified), and "file".
|
||||
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
.TP
|
||||
@ -61,6 +64,10 @@ Do not include the \-updates pocket in the installed sources.list.
|
||||
.B SOURCE_CHROOTS_DIR
|
||||
use SOURCE_CHROOTS_DIR as home of schroot source directories. (default
|
||||
/var/lib/schroot/chroots)
|
||||
.TP
|
||||
.B SOURCE_CHROOTS_TGZ
|
||||
use SOURCE_CHROOTS_TGZ as home of schroot source tarballs. (default
|
||||
/var/lib/schroot/tarballs)
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
@ -77,8 +84,8 @@ See sources.list(5) for more details on the format.
|
||||
.B $HOME/.mk\-sbuild.schroot.conf[.$SCHROOT_TYPE]
|
||||
Can contain a customized configuration section to be inserted into
|
||||
/etc/schroot/schroot.conf.
|
||||
If a file with ".lvm-snapshot" or ".directory" is found (based on the presence
|
||||
of the \-\-vg argument) that file will use used instead.
|
||||
If a file with ".lvm-snapshot", ".directory", or ".file" is found (based on the
|
||||
values of the \-\-vg and \-\-type arguments) that file will use used instead.
|
||||
See schroot.conf(5) for more details on the format.
|
||||
.SH USING THE CHROOTS
|
||||
.TP
|
||||
|
116
mk-sbuild
116
mk-sbuild
@ -37,10 +37,10 @@ if [ -w /etc/passwd ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Perform once-only things to initially set up for using sbuild+schroot+lvm
|
||||
# Perform once-only things to initially set up for using sbuild+schroot
|
||||
if [ ! -w /var/lib/sbuild ]; then
|
||||
# Load all the packages you'll need to do work
|
||||
sudo apt-get install sbuild schroot debootstrap lvm2
|
||||
sudo apt-get install sbuild schroot debootstrap
|
||||
# Add self to the sbuild group
|
||||
sudo adduser "$USER" sbuild
|
||||
|
||||
@ -95,6 +95,7 @@ fi
|
||||
LV_SIZE="5G"
|
||||
SNAPSHOT_SIZE="4G"
|
||||
SOURCE_CHROOTS_DIR="/var/lib/schroot/chroots"
|
||||
SOURCE_CHROOTS_TGZ="/var/lib/schroot/tarballs"
|
||||
|
||||
function usage()
|
||||
{
|
||||
@ -110,11 +111,13 @@ function usage()
|
||||
echo " --debootstrap-mirror=URL Use URL as the debootstrap source"
|
||||
echo " --distro=DISTRO Install specific distro:"
|
||||
echo " 'ubuntu'(default), or 'debian'"
|
||||
echo " --type=SCHROOT_TYPE Define the schroot type"
|
||||
echo ""
|
||||
echo "Configuration (via ~/.mk-sbuild.rc)"
|
||||
echo " LV_SIZE Size of source LVs (default ${LV_SIZE})"
|
||||
echo " SNAPSHOT_SIZE Size of snapshot LVs (default ${SNAPSHOT_SIZE})"
|
||||
echo " SOURCE_CHROOTS_DIR Directory to put aufs source chroots into"
|
||||
echo " SOURCE_CHROOTS_DIR Directory to store directory source chroots"
|
||||
echo " SOURCE_CHROOTS_TGZ Directory to store file source chroots"
|
||||
echo " SCHROOT_CONF_SUFFIX Lines to append to schroot.conf entries"
|
||||
echo " SKIP_UPDATES Enable --skip-updates"
|
||||
echo " TEMPLATE_SOURCES A template for sources.list"
|
||||
@ -126,7 +129,7 @@ function usage()
|
||||
if [ -z "$1" ]; then
|
||||
usage
|
||||
fi
|
||||
OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:,distro:,volume-group:,vg:" -- "$@"`
|
||||
OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:,distro:,volume-group:,vg:,type:" -- "$@"`
|
||||
eval set -- "$OPTS"
|
||||
|
||||
VG=""
|
||||
@ -139,9 +142,6 @@ while :; do
|
||||
shift
|
||||
;;
|
||||
--arch)
|
||||
# By default, use the native architecture.
|
||||
arch_opt="--arch=$2"
|
||||
arch_suffix="-$2"
|
||||
CHROOT_ARCH="$2"
|
||||
if [ "$2" = "i386" ] || [ "$2" = "lpia" ] && [ -z "$personality" ];
|
||||
then
|
||||
@ -181,6 +181,10 @@ while :; do
|
||||
VG="$2"
|
||||
shift 2
|
||||
;;
|
||||
--type)
|
||||
SCHROOT_TYPE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -191,7 +195,7 @@ while :; do
|
||||
esac
|
||||
done
|
||||
|
||||
# We need to know the release to debootstrap
|
||||
# To build the chroot, we need to know which release of Ubuntu to debootstrap
|
||||
RELEASE="$1"
|
||||
if [ -z "$RELEASE" ]; then
|
||||
usage
|
||||
@ -202,28 +206,30 @@ if [ -z "$name" ]; then
|
||||
name="$RELEASE"
|
||||
fi
|
||||
|
||||
CHROOT_NAME="${name}${arch_suffix}"
|
||||
|
||||
# By default, use the native architecture.
|
||||
HOST_ARCH=$(dpkg --print-architecture)
|
||||
if [ -z "$CHROOT_ARCH" ]; then
|
||||
CHROOT_ARCH=$HOST_ARCH
|
||||
CHROOT_ARCH="$HOST_ARCH"
|
||||
fi
|
||||
|
||||
CHROOT_NAME="${name}-${CHROOT_ARCH}"
|
||||
|
||||
# Load customizations
|
||||
if [ -r ~/.mk-sbuild.rc ]; then
|
||||
. ~/.mk-sbuild.rc
|
||||
fi
|
||||
|
||||
SRC_TYPE="union"
|
||||
SCHROOT_CONF_TYPE="directory"
|
||||
if [ -z "$SCHROOT_TYPE" ]; then
|
||||
# To build the LV, we need to know which volume group to use
|
||||
if [ -n "${VG}" ]; then
|
||||
SRC_TYPE="lvm"
|
||||
SCHROOT_CONF_TYPE="lvm-snapshot"
|
||||
if [ -n "$VG" ]; then
|
||||
SCHROOT_TYPE=lvm-snapshot
|
||||
else
|
||||
SCHROOT_TYPE=directory
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$SRC_TYPE" in
|
||||
"lvm")
|
||||
case "$SCHROOT_TYPE" in
|
||||
"lvm-snapshot")
|
||||
# Make sure LVM tools that operate on the snapshots have needed module
|
||||
if ! sudo dmsetup targets | grep -q ^snapshot; then
|
||||
sudo modprobe dm_snapshot
|
||||
@ -231,17 +237,28 @@ case "$SRC_TYPE" in
|
||||
fi
|
||||
|
||||
# Set up some variables for use in the paths and names
|
||||
CHROOT_LV="${name}_chroot${arch_suffix}"
|
||||
CHROOT_LV="${name}_chroot-${CHROOT_ARCH}"
|
||||
CHROOT_PATH="/dev/$VG/$CHROOT_LV"
|
||||
|
||||
# Does the specified VG exist? (vgdisplay doesn't set error codes...)
|
||||
if [ `sudo vgdisplay -c "$VG" | wc -l` -eq 0 ]; then
|
||||
echo "Volume group ${VG} does not appear to exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
"union")
|
||||
"directory")
|
||||
if [ ! -d "${SOURCE_CHROOTS_DIR}" ]; then
|
||||
sudo mkdir -p "${SOURCE_CHROOTS_DIR}"
|
||||
fi
|
||||
# Set up some variables for use in the paths and names
|
||||
CHROOT_PATH="${SOURCE_CHROOTS_DIR}/${CHROOT_NAME}"
|
||||
;;
|
||||
"file")
|
||||
if [ ! -d "$SOURCE_CHROOTS_TGZ" ]; then
|
||||
sudo mkdir -p "$SOURCE_CHROOTS_TGZ"
|
||||
fi
|
||||
# Set up some variables for use in the paths and names
|
||||
CHROOT_PATH="${SOURCE_CHROOTS_TGZ}/${CHROOT_NAME}.tgz"
|
||||
;;
|
||||
*)
|
||||
echo 'unknown source type!?' >&2
|
||||
@ -335,18 +352,19 @@ debian)
|
||||
esac
|
||||
|
||||
DEBOOTSTRAP_COMMAND=debootstrap
|
||||
# Use qemu-arm-static / build-arm-chroot for foreign armel chroots
|
||||
# Use qemu-kvm-extras-static / build-arm-chroot for foreign armel chroots
|
||||
if [ "$CHROOT_ARCH" = 'armel' ] && [ ! "$HOST_ARCH" = 'armel' ] ; then
|
||||
if [ -f "/usr/bin/build-arm-chroot" ]; then
|
||||
DEBOOTSTRAP_COMMAND=build-arm-chroot
|
||||
else
|
||||
echo 'Please install qemu-arm-static to use foreign armel chroots' >&2
|
||||
exit 1
|
||||
if [ ! -f "/usr/bin/build-arm-chroot" ]; then
|
||||
sudo apt-get install qemu-kvm-extras-static
|
||||
fi
|
||||
DEBOOTSTRAP_COMMAND=build-arm-chroot
|
||||
fi
|
||||
|
||||
case "$SRC_TYPE" in
|
||||
"lvm")
|
||||
case "$SCHROOT_TYPE" in
|
||||
"lvm-snapshot")
|
||||
# Install lvm2 if missing
|
||||
dpkg -l lvm2 > /dev/null || sudo apt-get install lvm2
|
||||
|
||||
# Allocate the "golden" chroot LV
|
||||
sudo lvcreate -n "$CHROOT_LV" -L "$LV_SIZE" "$VG"
|
||||
sudo mkfs -t ext4 "$CHROOT_PATH"
|
||||
@ -355,8 +373,7 @@ case "$SRC_TYPE" in
|
||||
MNT=`mktemp -d -t schroot-XXXXXX`
|
||||
sudo mount "$CHROOT_PATH" "$MNT"
|
||||
;;
|
||||
"union")
|
||||
CHROOT_PATH="${SOURCE_CHROOTS_DIR}/${CHROOT_NAME}"
|
||||
"directory")
|
||||
MNT="${CHROOT_PATH}"
|
||||
if [ -d "${MNT}" ]; then
|
||||
echo "E: ${MNT} already exists; aborting" >&2
|
||||
@ -364,10 +381,12 @@ case "$SRC_TYPE" in
|
||||
fi
|
||||
sudo mkdir -p "${MNT}"
|
||||
;;
|
||||
"file")
|
||||
MNT=`mktemp -d -t schroot-XXXXXX`
|
||||
esac
|
||||
|
||||
# debootstrap the chroot
|
||||
sudo $DEBOOTSTRAP_COMMAND $arch_opt $variant_opt "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://archive.ubuntu.com/ubuntu}"
|
||||
sudo "$DEBOOTSTRAP_COMMAND" --arch="$CHROOT_ARCH" $variant_opt "$RELEASE" "$MNT" "${DEBOOTSTRAP_MIRROR:-http://archive.ubuntu.com/ubuntu}"
|
||||
|
||||
# Update the package sources
|
||||
TEMP_SOURCES=`mktemp -t sources-XXXXXX`
|
||||
@ -402,7 +421,7 @@ sudo cp /etc/localtime /etc/timezone "$MNT"/etc/
|
||||
# Create a schroot entry for this chroot
|
||||
TEMP_SCHROOTCONF=`mktemp -t schrootconf-XXXXXX`
|
||||
TEMPLATE_SCHROOTCONF=~/.mk-sbuild.schroot.conf
|
||||
TYPED_TEMPLATE_SCHROOTCONF="${TEMPLATE_SCHROOTCONF}.${SCHROOT_CONF_TYPE}"
|
||||
TYPED_TEMPLATE_SCHROOTCONF="${TEMPLATE_SCHROOTCONF}.${SCHROOT_TYPE}"
|
||||
|
||||
if [ -r "${TYPED_TEMPLATE_SCHROOTCONF}" ]; then
|
||||
cat "${TYPED_TEMPLATE_SCHROOTCONF}" > "$TEMP_SCHROOTCONF"
|
||||
@ -410,7 +429,6 @@ elif [ -r "${TEMPLATE_SCHROOT}" ]; then
|
||||
cat "$TEMPLATE_SCHROOTCONF" > "$TEMP_SCHROOTCONF"
|
||||
else
|
||||
cat > "$TEMP_SCHROOTCONF" <<EOM
|
||||
|
||||
[CHROOT_NAME]
|
||||
description=CHROOT_NAME
|
||||
priority=3
|
||||
@ -420,20 +438,29 @@ root-groups=root,sbuild,admin
|
||||
# the -source chroots directly (useful for automated updates, etc).
|
||||
#source-root-users=root,sbuild,admin
|
||||
#source-root-groups=root,sbuild,admin
|
||||
type=SCHROOT_CONF_TYPE
|
||||
type=SCHROOT_TYPE
|
||||
EOM
|
||||
if [ "${SRC_TYPE}" = "lvm" ]; then
|
||||
case "$SCHROOT_TYPE" in
|
||||
"lvm-snapshot")
|
||||
cat >> "$TEMP_SCHROOTCONF" <<EOM
|
||||
device=CHROOT_PATH
|
||||
mount-options=-o noatime
|
||||
lvm-snapshot-options=--size SNAPSHOT_SIZE
|
||||
EOM
|
||||
elif [ "${SRC_TYPE}" = "union" ]; then
|
||||
;;
|
||||
"directory")
|
||||
cat >> "${TEMP_SCHROOTCONF}" <<EOM
|
||||
union-type=aufs
|
||||
directory=CHROOT_PATH
|
||||
EOM
|
||||
fi
|
||||
;;
|
||||
"file")
|
||||
cat >> "$TEMP_SCHROOTCONF" << EOM
|
||||
union-type=aufs
|
||||
file=CHROOT_PATH
|
||||
EOM
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -z "$personality" ]; then
|
||||
echo "personality=$personality" >> "$TEMP_SCHROOTCONF"
|
||||
@ -445,7 +472,7 @@ cat "$TEMP_SCHROOTCONF" | sed \
|
||||
-e "s|CHROOT_NAME|$CHROOT_NAME|g" \
|
||||
-e "s|CHROOT_PATH|$CHROOT_PATH|g" \
|
||||
-e "s|SNAPSHOT_SIZE|$SNAPSHOT_SIZE|g" \
|
||||
-e "s|SCHROOT_CONF_TYPE|$SCHROOT_CONF_TYPE|g" \
|
||||
-e "s|SCHROOT_TYPE|$SCHROOT_TYPE|g" \
|
||||
| \
|
||||
sudo bash -c "cat >> /etc/schroot/schroot.conf"
|
||||
rm -f "$TEMP_SCHROOTCONF"
|
||||
@ -476,10 +503,19 @@ rm /finish.sh
|
||||
EOM
|
||||
sudo chmod a+x "$MNT"/finish.sh
|
||||
|
||||
if [ "$SRC_TYPE" = "lvm" ]; then
|
||||
case "$SCHROOT_TYPE" in
|
||||
"lvm-snapshot")
|
||||
sudo umount "$MNT"
|
||||
rmdir "$MNT"
|
||||
fi
|
||||
;;
|
||||
"directory")
|
||||
;;
|
||||
"file")
|
||||
(cd "$MNT" && sudo tar czf "$CHROOT_PATH" .)
|
||||
sudo rm -r "$MNT"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Run finalization script on the "golden" copy via schroot.
|
||||
sudo schroot -c "$CHROOT_NAME"-source -u root /finish.sh
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user