push_goroot revision f637a050cc27b206824d7b1262d2aa9de0668bef
1#!/bin/bash
2set -e -o pipefail
3
4# This script copies a locally built GOROOT to a remote device.
5#
6# Usage: push_goroot <target>...
7#
8# This script can work with both ChromeOS/Android devices.
9#
10# It uses "target_tmpdir" to figure out where to copy GOROOT on the device.
11# It uses "target_sh" to remotely execute commands on the device.
12# It uses "target_cp" to transfer files to the device.
13
14goroot="$(target_tmpdir)/go"
15for target in "$@"
16do
17	echo -n "pushing to ${target} ... "
18	target_sh ${target} "rm -rf ${goroot}"
19	target_sh ${target} "mkdir -p ${goroot}/pkg"
20
21	pkgdir="$(go_${target} env GOOS)_$(go_${target} env GOARCH)"
22	if [[ -d "pkg/${pkgdir}_shared" ]]
23	then
24		target_cp "pkg/${pkgdir}_shared" ${target}:${goroot}/pkg
25		target_sh ${target} "ln -s ${pkgdir}_shared ${goroot}/pkg/${pkgdir}"
26	else
27		target_cp "pkg/${pkgdir}" ${target}:${goroot}/pkg
28	fi
29
30	target_cp "src" ${target}:${goroot}
31	target_cp "lib" ${target}:${goroot}
32	target_cp "test" ${target}:${goroot}
33	echo "done"
34done
35