mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-19 12:51:29 +00:00
merge from trunk
This commit is contained in:
commit
b5d36d7794
5
debian/changelog
vendored
5
debian/changelog
vendored
@ -17,8 +17,11 @@ ubuntu-dev-tools (0.93) UNRELEASED; urgency=low
|
|||||||
[ Kees Cook ]
|
[ Kees Cook ]
|
||||||
* requestsync: add -C to allow manually adding changelog when missing
|
* requestsync: add -C to allow manually adding changelog when missing
|
||||||
(LP: #518574).
|
(LP: #518574).
|
||||||
|
* mk-sbuild: clean up and make slight adjustments to new lvm/aufs logic.
|
||||||
|
* mk-sbuild.1: update documentation to reflect alternative config file
|
||||||
|
names for distro and schroot type overrides.
|
||||||
|
|
||||||
-- Emmet Hikory <persia@ubuntu.com> Tue, 09 Feb 2010 11:38:48 +0900
|
-- Kees Cook <kees@ubuntu.com> Tue, 09 Feb 2010 00:14:26 -0800
|
||||||
|
|
||||||
ubuntu-dev-tools (0.92) lucid; urgency=low
|
ubuntu-dev-tools (0.92) lucid; urgency=low
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.TH MK\-SBUILD "1" "08 February 2010" "ubuntu-dev-tools"
|
.TH MK\-SBUILD "1" "09 February 2010" "ubuntu-dev-tools"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
mk\-sbuild \- creates chroots via schroot and sbuild
|
mk\-sbuild \- creates chroots via schroot and sbuild
|
||||||
@ -40,8 +40,9 @@ official Ubuntu repositories for the supported architectures).
|
|||||||
Enable distro-specific logic. Currently known distros: "ubuntu" (default)
|
Enable distro-specific logic. Currently known distros: "ubuntu" (default)
|
||||||
and "debian".
|
and "debian".
|
||||||
.TP
|
.TP
|
||||||
.B \-\-volume-group
|
.B \-\-vg
|
||||||
Specify a volume group, and subsequently use lvm-snapshot rather than aufs mounts.
|
Specify a volume group, and subsequently use SCHROOT_TYPE of "lvm-snapshot"
|
||||||
|
rather than "directory" (via aufs) mounts.
|
||||||
|
|
||||||
.SH ENVIRONMENT VARIABLES
|
.SH ENVIRONMENT VARIABLES
|
||||||
.TP
|
.TP
|
||||||
@ -58,25 +59,30 @@ Lines to append to schroot entries.
|
|||||||
Do not include the \-updates pocket in the installed sources.list.
|
Do not include the \-updates pocket in the installed sources.list.
|
||||||
.TP
|
.TP
|
||||||
.B SOURCE_CHROOTS_DIR
|
.B SOURCE_CHROOTS_DIR
|
||||||
use SOURCE_CHROOTS_DIR as home of schroot source directories. (default /srv/chroots)
|
use SOURCE_CHROOTS_DIR as home of schroot source directories. (default
|
||||||
|
/var/lib/schroot/chroots)
|
||||||
|
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.TP
|
.TP
|
||||||
.B $HOME/.mk\-sbuild.rc
|
.B $HOME/.mk\-sbuild.rc
|
||||||
Sourced for environment variables (defined above).
|
Sourced for environment variables (defined above).
|
||||||
.TP
|
.TP
|
||||||
.B $HOME/.mk\-sbuild.sources
|
.B $HOME/.mk\-sbuild.sources[.$DISTRO]
|
||||||
Can contain a customized sources.list.
|
Can contain a customized sources.list.
|
||||||
It will be read when creating the schroot.
|
It will be read when creating the schroot.
|
||||||
|
If a file with ".ubuntu" or ".debian" is found (based on the \-\-distro
|
||||||
|
argument) that file will use used instead.
|
||||||
See sources.list(5) for more details on the format.
|
See sources.list(5) for more details on the format.
|
||||||
.TP
|
.TP
|
||||||
.B $HOME/.mk\-sbuild.schroot.conf
|
.B $HOME/.mk\-sbuild.schroot.conf[.$SCHROOT_TYPE]
|
||||||
Can contain a customized configuration section to be inserted into
|
Can contain a customized configuration section to be inserted into
|
||||||
/etc/schroot/schroot.conf.
|
/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.
|
||||||
See schroot.conf(5) for more details on the format.
|
See schroot.conf(5) for more details on the format.
|
||||||
.SH USING THE CHROOTS
|
.SH USING THE CHROOTS
|
||||||
.TP
|
.TP
|
||||||
To CHANGE the golden image: \fBschroot \-c ${CHROOT_NAME}\-source \-u root\fR
|
To CHANGE the golden image: \fBsudo schroot \-c ${CHROOT_NAME}\-source \-u root\fR
|
||||||
.TP
|
.TP
|
||||||
To ENTER an image snapshot: \fBschroot \-c ${CHROOT_NAME}\fR
|
To ENTER an image snapshot: \fBschroot \-c ${CHROOT_NAME}\fR
|
||||||
.TP
|
.TP
|
||||||
|
86
mk-sbuild
86
mk-sbuild
@ -1,6 +1,6 @@
|
|||||||
# !/bin/bash
|
# !/bin/bash
|
||||||
#
|
#
|
||||||
# Copyright 2006-2009 (C) Canonical Ltd.
|
# Copyright 2006-2010 (C) Canonical Ltd.
|
||||||
# Author: Kees Cook <kees@ubuntu.com>
|
# Author: Kees Cook <kees@ubuntu.com>
|
||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
@ -19,7 +19,8 @@
|
|||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
#
|
#
|
||||||
# This script creates LVM snapshot chroots via schroot and sbuild.
|
# This script creates chroots designed to be used in a snapshot mode
|
||||||
|
# (either with LVM or aufs) with schroot and sbuild.
|
||||||
# Much love to "man sbuild-setup", https://wiki.ubuntu.com/PbuilderHowto,
|
# Much love to "man sbuild-setup", https://wiki.ubuntu.com/PbuilderHowto,
|
||||||
# and https://help.ubuntu.com/community/SbuildLVMHowto.
|
# and https://help.ubuntu.com/community/SbuildLVMHowto.
|
||||||
#
|
#
|
||||||
@ -93,8 +94,8 @@ fi
|
|||||||
# Set up configurable defaults (loaded after option processing)
|
# Set up configurable defaults (loaded after option processing)
|
||||||
LV_SIZE="5G"
|
LV_SIZE="5G"
|
||||||
SNAPSHOT_SIZE="4G"
|
SNAPSHOT_SIZE="4G"
|
||||||
SOURCE_CHROOTS_DIR=/srv/chroot
|
SOURCE_CHROOTS_DIR="/var/lib/schroot/chroots"
|
||||||
SOURCE_CHROOTS_TGZ=/var/lib/schroot/tarballs
|
SOURCE_CHROOTS_TGZ="/var/lib/schroot/tarballs"
|
||||||
|
|
||||||
function usage()
|
function usage()
|
||||||
{
|
{
|
||||||
@ -103,19 +104,20 @@ function usage()
|
|||||||
echo " --arch=ARCH What architecture to select"
|
echo " --arch=ARCH What architecture to select"
|
||||||
echo " --name=NAME Base name for the schroot (arch is appended)"
|
echo " --name=NAME Base name for the schroot (arch is appended)"
|
||||||
echo " --personality=PERSONALITY What personality to use (defaults to match --arch)"
|
echo " --personality=PERSONALITY What personality to use (defaults to match --arch)"
|
||||||
|
echo " --vg=VG use LVM snapshots, with group VG"
|
||||||
echo " --debug Turn on script debugging"
|
echo " --debug Turn on script debugging"
|
||||||
echo " --skip-updates Do not include -updates pocket in sources.list"
|
echo " --skip-updates Do not include -updates pocket in sources.list"
|
||||||
echo " --source-template=FILE Use FILE as the sources.list template"
|
echo " --source-template=FILE Use FILE as the sources.list template"
|
||||||
echo " --debootstrap-mirror=URL Use URL as the debootstrap source"
|
echo " --debootstrap-mirror=URL Use URL as the debootstrap source"
|
||||||
echo " --distro=DISTRO Install specific distro (defaults to 'ubuntu')"
|
echo " --distro=DISTRO Install specific distro (defaults to 'ubuntu')"
|
||||||
echo " --volume-group=VG use LVM snapshots, with group VG"
|
|
||||||
echo " --type=SCHROOT_TYPE Define the schroot type"
|
echo " --type=SCHROOT_TYPE Define the schroot type"
|
||||||
|
echo " 'ubuntu'(default), or 'debian'"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Configuration (via ~/.mk-sbuild.rc)"
|
echo "Configuration (via ~/.mk-sbuild.rc)"
|
||||||
echo " SOURCE_CHROOTS_DIR directory to store source chroots"
|
|
||||||
echo " SOURCE_CHROOTS_TGZ directory to store source chroot tarballs"
|
|
||||||
echo " LV_SIZE Size of source LVs (default ${LV_SIZE})"
|
echo " LV_SIZE Size of source LVs (default ${LV_SIZE})"
|
||||||
echo " SNAPSHOT_SIZE Size of snapshot LVs (default ${SNAPSHOT_SIZE})"
|
echo " SNAPSHOT_SIZE Size of snapshot LVs (default ${SNAPSHOT_SIZE})"
|
||||||
|
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 " SCHROOT_CONF_SUFFIX Lines to append to schroot.conf entries"
|
||||||
echo " SKIP_UPDATES Enable --skip-updates"
|
echo " SKIP_UPDATES Enable --skip-updates"
|
||||||
echo " TEMPLATE_SOURCES A template for sources.list"
|
echo " TEMPLATE_SOURCES A template for sources.list"
|
||||||
@ -127,7 +129,7 @@ function usage()
|
|||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:,distro:,volume-group:,type:" -- "$@"`
|
OPTS=`getopt -o '' --long "help,debug,skip-updates,arch:,name:,source-template:,debootstrap-mirror:,personality:,distro:,volume-group:,vg:,type:" -- "$@"`
|
||||||
eval set -- "$OPTS"
|
eval set -- "$OPTS"
|
||||||
|
|
||||||
VG=""
|
VG=""
|
||||||
@ -175,7 +177,7 @@ while :; do
|
|||||||
DISTRO="$2"
|
DISTRO="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--volume-group)
|
--volume-group|--vg)
|
||||||
VG="$2"
|
VG="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
@ -218,6 +220,7 @@ if [ -r ~/.mk-sbuild.rc ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SCHROOT_TYPE" ]; then
|
if [ -z "$SCHROOT_TYPE" ]; then
|
||||||
|
# To build the LV, we need to know which volume group to use
|
||||||
if [ -n "$VG" ]; then
|
if [ -n "$VG" ]; then
|
||||||
SCHROOT_TYPE=lvm-snapshot
|
SCHROOT_TYPE=lvm-snapshot
|
||||||
else
|
else
|
||||||
@ -247,24 +250,27 @@ case "$SCHROOT_TYPE" in
|
|||||||
if [ ! -d "${SOURCE_CHROOTS_DIR}" ]; then
|
if [ ! -d "${SOURCE_CHROOTS_DIR}" ]; then
|
||||||
sudo mkdir -p "${SOURCE_CHROOTS_DIR}"
|
sudo mkdir -p "${SOURCE_CHROOTS_DIR}"
|
||||||
fi
|
fi
|
||||||
|
# Set up some variables for use in the paths and names
|
||||||
|
CHROOT_PATH="${SOURCE_CHROOTS_DIR}/${CHROOT_NAME}"
|
||||||
;;
|
;;
|
||||||
"tarball"| "file")
|
"file")
|
||||||
if [ ! -d "$SOURCE_CHROOTS_TGZ" ]; then
|
if [ ! -d "$SOURCE_CHROOTS_TGZ" ]; then
|
||||||
sudo mkdir -p "$SOURCE_CHROOTS_TGZ"
|
sudo mkdir -p "$SOURCE_CHROOTS_TGZ"
|
||||||
fi
|
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
|
echo 'unknown source type!?' >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Is the specified release known to debootstrap?
|
# Is the specified release known to debootstrap?
|
||||||
|
variant_opt="--variant=buildd"
|
||||||
if [ ! -r "/usr/share/debootstrap/scripts/$RELEASE" ]; then
|
if [ ! -r "/usr/share/debootstrap/scripts/$RELEASE" ]; then
|
||||||
echo "Specified release not known to debootstrap" >&2
|
echo "Specified release not known to debootstrap" >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
variant_opt="--variant=buildd"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BUILD_PKGS="build-essential fakeroot devscripts apt-utils"
|
BUILD_PKGS="build-essential fakeroot devscripts apt-utils"
|
||||||
@ -368,15 +374,14 @@ case "$SCHROOT_TYPE" in
|
|||||||
sudo mount "$CHROOT_PATH" "$MNT"
|
sudo mount "$CHROOT_PATH" "$MNT"
|
||||||
;;
|
;;
|
||||||
"directory")
|
"directory")
|
||||||
CHROOT_PATH="${SOURCE_CHROOTS_DIR}/${CHROOT_NAME}"
|
|
||||||
MNT="${CHROOT_PATH}"
|
MNT="${CHROOT_PATH}"
|
||||||
if [ -d "${MNT}" ]; then
|
if [ -d "${MNT}" ]; then
|
||||||
echo "${MNT} exists. exiting"; exit 1;
|
echo "E: ${MNT} already exists; aborting" >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
sudo mkdir -p "${MNT}"
|
sudo mkdir -p "${MNT}"
|
||||||
;;
|
;;
|
||||||
"tarball"|"file")
|
"file")
|
||||||
CHROOT_PATH="${SOURCE_CHROOTS_TGZ}/${CHROOT_NAME}.tgz"
|
|
||||||
MNT=`mktemp -d -t schroot-XXXXXX`
|
MNT=`mktemp -d -t schroot-XXXXXX`
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -413,56 +418,46 @@ cat "$TEMP_SOURCES" | sed -e "s|RELEASE|$RELEASE|g" | \
|
|||||||
rm -f "$TEMP_SOURCES"
|
rm -f "$TEMP_SOURCES"
|
||||||
# Copy the timezone (comment this out if you want to leave the chroot at UTC)
|
# Copy the timezone (comment this out if you want to leave the chroot at UTC)
|
||||||
sudo cp /etc/localtime /etc/timezone "$MNT"/etc/
|
sudo cp /etc/localtime /etc/timezone "$MNT"/etc/
|
||||||
# Create an LVM-snapshot-based schroot entry for this LV
|
# Create a schroot entry for this chroot
|
||||||
TEMP_SCHROOTCONF=`mktemp -t schrootconf-XXXXXX`
|
TEMP_SCHROOTCONF=`mktemp -t schrootconf-XXXXXX`
|
||||||
TEMPLATE_SCHROOTCONF=~/.mk-sbuild.schroot.conf
|
TEMPLATE_SCHROOTCONF=~/.mk-sbuild.schroot.conf
|
||||||
TYPED_TEMPLATE_SCHROOTCONF="${TEMPLATE_SCHROOTCONF}.${SCHROOT_CONF_TYPE}"
|
TYPED_TEMPLATE_SCHROOTCONF="${TEMPLATE_SCHROOTCONF}.${SCHROOT_TYPE}"
|
||||||
|
|
||||||
if [ -r "${TEMPLATE_SCHROOT}" ]; then
|
if [ -r "${TYPED_TEMPLATE_SCHROOTCONF}" ]; then
|
||||||
cat "$TEMPLATE_SCHROOTCONF" > "$TEMP_SCHROOTCONF"
|
|
||||||
elif [ -r "${TYPED_TEMPLATE_SCHROOTCONF}" ]; then
|
|
||||||
cat "${TYPED_TEMPLATE_SCHROOTCONF}" > "$TEMP_SCHROOTCONF"
|
cat "${TYPED_TEMPLATE_SCHROOTCONF}" > "$TEMP_SCHROOTCONF"
|
||||||
|
elif [ -r "${TEMPLATE_SCHROOT}" ]; then
|
||||||
|
cat "$TEMPLATE_SCHROOTCONF" > "$TEMP_SCHROOTCONF"
|
||||||
else
|
else
|
||||||
case "$SCHROOT_TYPE" in
|
|
||||||
"lvm-snapshot")
|
|
||||||
cat > "$TEMP_SCHROOTCONF" <<EOM
|
cat > "$TEMP_SCHROOTCONF" <<EOM
|
||||||
[CHROOT_NAME]
|
[CHROOT_NAME]
|
||||||
type=lvm-snapshot
|
|
||||||
description=CHROOT_NAME
|
description=CHROOT_NAME
|
||||||
priority=3
|
priority=3
|
||||||
groups=sbuild,root,admin
|
groups=sbuild,root,admin
|
||||||
root-groups=root,sbuild,admin
|
root-groups=root,sbuild,admin
|
||||||
device=CHROOT_PATH
|
|
||||||
mount-options=-o noatime
|
|
||||||
lvm-snapshot-options=--size SNAPSHOT_SIZE
|
|
||||||
# Uncomment these lines to allow "sbuild" and "admin" users to access
|
# Uncomment these lines to allow "sbuild" and "admin" users to access
|
||||||
# the -source chroots directly (useful for automated updates, etc).
|
# the -source chroots directly (useful for automated updates, etc).
|
||||||
#source-root-users=root,sbuild,admin
|
#source-root-users=root,sbuild,admin
|
||||||
#source-root-groups=root,sbuild,admin
|
#source-root-groups=root,sbuild,admin
|
||||||
|
type=SCHROOT_TYPE
|
||||||
|
EOM
|
||||||
|
case "$SCHROOT_TYPE" in
|
||||||
|
"lvm-snapshot")
|
||||||
|
cat >> "$TEMP_SCHROOTCONF" <<EOM
|
||||||
|
device=CHROOT_PATH
|
||||||
|
mount-options=-o noatime
|
||||||
|
lvm-snapshot-options=--size SNAPSHOT_SIZE
|
||||||
EOM
|
EOM
|
||||||
;;
|
;;
|
||||||
"directory")
|
"directory")
|
||||||
cat > "${TEMP_SCHROOTCONF}" <<EOM
|
cat >> "${TEMP_SCHROOTCONF}" <<EOM
|
||||||
[CHROOT_NAME]
|
|
||||||
type=directory
|
|
||||||
union-type=aufs
|
union-type=aufs
|
||||||
directory=CHROOT_PATH
|
directory=CHROOT_PATH
|
||||||
description=CHROOT_NAME
|
|
||||||
priority=3
|
|
||||||
groups=sbuild,root,admin
|
|
||||||
root-groups=root,sbuild,admin
|
|
||||||
EOM
|
EOM
|
||||||
;;
|
;;
|
||||||
"tarball"|"file")
|
"file")
|
||||||
cat > "$TEMP_SCHROOTCONF" << EOM
|
cat >> "$TEMP_SCHROOTCONF" << EOM
|
||||||
[CHROOT_NAME]
|
|
||||||
type=file
|
|
||||||
union-type=aufs
|
union-type=aufs
|
||||||
file=CHROOT_PATH
|
file=CHROOT_PATH
|
||||||
description=CHROOT_NAME
|
|
||||||
priority=3
|
|
||||||
groups=sbuild,root,admin
|
|
||||||
root-groups=root,sbuild,admin
|
|
||||||
EOM
|
EOM
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -477,6 +472,7 @@ cat "$TEMP_SCHROOTCONF" | sed \
|
|||||||
-e "s|CHROOT_NAME|$CHROOT_NAME|g" \
|
-e "s|CHROOT_NAME|$CHROOT_NAME|g" \
|
||||||
-e "s|CHROOT_PATH|$CHROOT_PATH|g" \
|
-e "s|CHROOT_PATH|$CHROOT_PATH|g" \
|
||||||
-e "s|SNAPSHOT_SIZE|$SNAPSHOT_SIZE|g" \
|
-e "s|SNAPSHOT_SIZE|$SNAPSHOT_SIZE|g" \
|
||||||
|
-e "s|SCHROOT_TYPE|$SCHROOT_TYPE|g" \
|
||||||
| \
|
| \
|
||||||
sudo bash -c "cat >> /etc/schroot/schroot.conf"
|
sudo bash -c "cat >> /etc/schroot/schroot.conf"
|
||||||
rm -f "$TEMP_SCHROOTCONF"
|
rm -f "$TEMP_SCHROOTCONF"
|
||||||
@ -505,7 +501,7 @@ if [ ! -r /dev/stderr ]; then ln -s /proc/self/fd/2 /dev/stderr; fi
|
|||||||
apt-get clean
|
apt-get clean
|
||||||
rm /finish.sh
|
rm /finish.sh
|
||||||
EOM
|
EOM
|
||||||
sudo chmod +x "$MNT"/finish.sh
|
sudo chmod a+x "$MNT"/finish.sh
|
||||||
|
|
||||||
case "$SCHROOT_TYPE" in
|
case "$SCHROOT_TYPE" in
|
||||||
"lvm-snapshot")
|
"lvm-snapshot")
|
||||||
@ -514,7 +510,7 @@ case "$SCHROOT_TYPE" in
|
|||||||
;;
|
;;
|
||||||
"directory")
|
"directory")
|
||||||
;;
|
;;
|
||||||
"tarball"|"file")
|
"file")
|
||||||
(cd "$MNT" && sudo tar czf "$CHROOT_PATH" .)
|
(cd "$MNT" && sudo tar czf "$CHROOT_PATH" .)
|
||||||
sudo rm -r "$MNT"
|
sudo rm -r "$MNT"
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user