/usr/bin/adt-build-lxc is in autopkgtest 2.14.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #!/bin/sh
# adt-build-lxc is part of autopkgtest
# autopkgtest is a tool for testing Debian binary packages
#
# autopkgtest is Copyright (C) 2006-2014 Canonical Ltd.
#
# Build or update a container with the debian or ubuntu LXC template
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# See the file CREDITS for a full list of credits information (often
# installed as /usr/share/doc/autopkgtest/CREDITS).
set -e
DISTRO="$1"
RELEASE="$2"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 debian|ubuntu <release>" >&2
exit 1
fi
NAME="adt-${RELEASE}"
# fall back for older LXC option name
LXCDIR=`lxc-config lxc.lxcpath` || LXCDIR=`lxc-config lxcpath` || LXCDIR=/var/lib/lxc
LXC_ARGS="-t $DISTRO -- -r $RELEASE"
export HTTP_PROXY=${HTTP_PROXY:=apt}
setup() {
# add deb-src
sed -i '/^deb/ { p; s/^deb/deb-src/}' $LXCDIR/$1/rootfs/etc/apt/sources.list
lxc-start -d -n $1
# wait until it is booted: lxc-attach works and we get a numeric runlevel
timeout=60
while [ $timeout -ge 0 ]; do
timeout=$((timeout - 1))
sleep 1
O=`lxc-attach -n $1 runlevel 2>/dev/null` || continue
[ "$O" = "${O%[0-9]}" ] || break
done
[ $timeout -ge 0 ] || {
echo "Timed out waiting for container to boot" >&2
lxc-stop -k -n $1 || true
lxc-destroy -n $1 || true
exit 1
}
lxc-attach -n $1 apt-get update
lxc-stop -n $1
}
if [ ! -e $LXCDIR/$NAME ]; then
# first-time run: just create the container
lxc-create -n $NAME $LXC_ARGS
setup $NAME
else
# create a new rootfs in a temp container
lxc-create -n ${NAME}.new $LXC_ARGS -F
setup ${NAME}.new
# replace the original rootfs
rsync -aHAXS --numeric-ids --delete $LXCDIR/${NAME}.new/rootfs $LXCDIR/${NAME}/rootfs
lxc-destroy -n ${NAME}.new
fi
|