-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathmake-clean-vm
More file actions
executable file
·73 lines (66 loc) · 1.25 KB
/
make-clean-vm
File metadata and controls
executable file
·73 lines (66 loc) · 1.25 KB
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
#!/bin/sh
set -e
SUITE=xenial
ARCH=amd64
VMSW=KVM
if [ -n "$USE_LXC" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
VMSW=DOCKER
fi
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 xenial
--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
export LXC_SUITE=$SUITE
export LXC_ARCH=$ARCH
BASE=base-$SUITE-$ARCH
OUT=target-$SUITE-$ARCH
case $VMSW in
KVM)
qemu-img create -f qcow2 -o backing_file="$BASE.qcow2" "$OUT.qcow2"
;;
LXC)
cp -a --sparse=always $BASE $OUT
on-target -u root bash < target-bin/bootstrap-fixup
;;
VBOX)
VBoxManage snapshot "Gitian-${SUITE}-${ARCH}" restore "Gitian-Clean"
;;
DOCKER)
true #Docker doesn't need to do anything
;;
esac