summaryrefslogtreecommitdiff
path: root/tools/build-on-netbsd
blob: 0d4eb58be4d2f16f001e43c1dd0246bb6d3e0d6c (plain)
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
#!/bin/sh

fail() { echo "FAILED:" "$@" 1>&2; exit 1; }

PYTHON="${PYTHON:-python3}"
if [ ! $(which ${PYTHON}) ]; then
    echo "Please install python first."
    exit 1
fi
py_prefix=$(${PYTHON} -c 'import sys; print("py%d%d" % (sys.version_info.major, sys.version_info.minor))')

# Check dependencies:
depschecked=/tmp/c-i.dependencieschecked
pkgs="
   bash
   dmidecode
   ${py_prefix}-configobj
   ${py_prefix}-jinja2
   ${py_prefix}-oauthlib
   ${py_prefix}-requests
   ${py_prefix}-setuptools
   ${py_prefix}-netifaces
   ${py_prefix}-yaml
   ${py_prefix}-jsonschema
   sudo
"
[ -f "$depschecked" ] || pkg_add ${pkgs} || fail "install packages"

touch $depschecked

# Build the code and install in /usr/pkg/:
${PYTHON} setup.py build
${PYTHON} setup.py install -O1 --distro netbsd --skip-build --init-system sysvinit_netbsd
mv -v /usr/local/etc/rc.d/cloud* /etc/rc.d

# Enable cloud-init in /etc/rc.conf:
sed -i.bak -e "/^cloud.*=.*/d" /etc/rc.conf
echo '
# You can safely remove the following lines starting with "cloud"
cloudinitlocal="YES"
cloudinit="YES"
cloudconfig="YES"
cloudfinal="YES"' >> /etc/rc.conf

echo "Installation completed."