#!/bin/bash

set -e
set -u

mkdir -p ${BOSH_INSTALL_TARGET}/src
mv * ${BOSH_INSTALL_TARGET}/src
mv ${BOSH_INSTALL_TARGET}/src .
mkdir -p ${BOSH_INSTALL_TARGET}/bin

source /var/vcap/packages/golang-*-linux/bosh/compile.env


pushd src/code.cloudfoundry.org
go build -o "${BOSH_INSTALL_TARGET}/bin/bandwidth" github.com/containernetworking/plugins/plugins/meta/bandwidth
go build -o "${BOSH_INSTALL_TARGET}/bin/host-local" github.com/containernetworking/plugins/plugins/ipam/host-local
go build -o "${BOSH_INSTALL_TARGET}/bin/silk-cni" -ldflags="-extldflags=-Wl,--allow-multiple-definition" code.cloudfoundry.org/silk/cmd/silk-cni
go build -o "${BOSH_INSTALL_TARGET}/bin/cni-teardown" code.cloudfoundry.org/cni-teardown
go build -o "${BOSH_INSTALL_TARGET}/bin/cni-wrapper-plugin" code.cloudfoundry.org/cni-wrapper-plugin
popd
