-
Notifications
You must be signed in to change notification settings - Fork 10
/
make.bash
executable file
·63 lines (51 loc) · 1.58 KB
/
make.bash
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
#!/bin/bash
# Copyright 2016 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# This script uses Anita (an automated NetBSD installer) for setting up
# the VM. It needs the following things on the build host:
# - qemu
# - cdrtools
# - GNU tar (not BSD tar)
# - Python 3
# - python-pexpect
# - coreutils (for sha1sum)
set -e -x
ANITA_VERSION=2.11
ARCH=${1:-amd64}
RELEASE=${2:-netbsd-10}
DISK_SIZE=${3:-4G}
# Must use GNU tar. On NetBSD, tar is BSD tar and gtar is GNU.
TAR=tar
if which gtar > /dev/null; then
TAR=gtar
fi
SHA1SUM=sha1sum
if which gsha1sum > /dev/null; then
SHA1SUM=gsha1sum
fi
PYTHON=
for cmd in python3 python; do
if which ${cmd} > /dev/null; then
PYTHON=${cmd}
break
fi
done
WORKDIR=work-${RELEASE}-${ARCH}
# Remove WORKDIR unless -k (keep) is given.
if [ "$1" != "-k" ]; then
rm -rf ${WORKDIR}
fi
# Download and build anita (automated NetBSD installer).
if ! ${SHA1SUM} -c anita-${ANITA_VERSION}.tar.gz.sha1; then
curl -vO http://www.gson.org/netbsd/anita/download/anita-${ANITA_VERSION}.tar.gz
${SHA1SUM} -c anita-${ANITA_VERSION}.tar.gz.sha1 || exit 1
fi
${TAR} xfz anita-${ANITA_VERSION}.tar.gz
cd anita-${ANITA_VERSION}
${PYTHON} setup.py build
cd ..
env PYTHONPATH=${PWD}/anita-${ANITA_VERSION} ${PYTHON} mkvm.py ${ARCH} ${RELEASE} ${DISK_SIZE}
echo "Archiving wd0.img (this may take a while)"
${TAR} --format=oldgnu -Szcf netbsd-${ARCH}-gce.tar.gz --transform s,${WORKDIR}/wd0.img,disk.raw, ${WORKDIR}/wd0.img
echo "Done. GCE image is netbsd-${ARCH}-gce.tar.gz."