gitian-builder/libexec/make-clean-vm

66 lines
1.1 KiB
Plaintext
Raw Normal View History

2012-04-22 05:44:00 +00:00
#!/bin/sh
set -e
SUITE=lucid
ARCH=amd64
2013-02-08 16:50:34 +00:00
VMSW=KVM
if [ -n "$USE_LXC" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
VMSW=VBOX
fi
2012-04-22 05:44:00 +00:00
usage() {
echo "Usage: ${0##*/} [OPTION]..."
echo "Make a clean copy of the base client."
echo
cat << EOF
--help display this help and exit
--suite U build suite U instead of lucid
--arch A build architecture A (e.g. i386) instead of amd64
EOF
}
if [ $# != 0 ] ; then
while true ; do
case "$1" in
--help|-h)
usage
exit 0
;;
--suite|-s)
SUITE="$2"
shift 2
;;
--arch|-a)
ARCH="$2"
shift 2
;;
--*)
echo "unrecognized option $1"
exit 1
;;
*)
break
;;
esac
done
fi
2012-04-22 18:55:05 +00:00
BASE=base-$SUITE-$ARCH
OUT=target-$SUITE-$ARCH
2012-04-22 05:44:00 +00:00
2013-02-08 16:50:34 +00:00
case $VMSW in
KVM)
qemu-img create -f qcow2 -o backing_file="$BASE.qcow2" "$OUT.qcow2"
2013-02-08 16:50:34 +00:00
;;
LXC)
2012-04-22 18:55:05 +00:00
cp -a $BASE $OUT
on-target -u root bash < target-bin/bootstrap-fixup
2013-02-08 16:50:34 +00:00
;;
VBOX)
VBoxManage snapshot "Gitian-${SUITE}-${ARCH}" restore "Gitian-Clean"
;;
esac