• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)/goroot"
15for target in "$@"
16do
17	echo -n "pushing goroot to ${target} ... "
18	target_sh ${target} "rm -rf ${goroot}"
19	target_sh ${target} "mkdir -p ${goroot}/pkg"
20
21	cd "$(go_${target} env GOROOT)"
22	pkgdir="pkg/$(go_${target} env GOOS)_$(go_${target} env GOARCH)"
23	target_cp "${pkgdir}" ${target}:${goroot}/pkg
24
25	target_cp "src" ${target}:${goroot}
26	target_cp "lib" ${target}:${goroot}
27	[[ -d test ]] && target_cp "test" ${target}:${goroot}
28	echo "done"
29done
30