aboutsummaryrefslogtreecommitdiff
path: root/go/push_goroot
blob: 0d7706e15b443dd03ca2ff3cb6dd6e6b5e89c46b (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
#!/bin/bash
set -e -o pipefail

# This script copies a locally built GOROOT to a remote device.
#
# Usage: push_goroot <target>...
#
# This script can work with both ChromeOS/Android devices.
#
# It uses "target_tmpdir" to figure out where to copy GOROOT on the device.
# It uses "target_sh" to remotely execute commands on the device.
# It uses "target_cp" to transfer files to the device.

goroot="$(target_tmpdir)/goroot"
for target in "$@"
do
	echo -n "pushing goroot to ${target} ... "
	target_sh ${target} "rm -rf ${goroot}"
	target_sh ${target} "mkdir -p ${goroot}/pkg"

	cd "$(go_${target} env GOROOT)"
	pkgdir="pkg/$(go_${target} env GOOS)_$(go_${target} env GOARCH)"
	target_cp "${pkgdir}" ${target}:${goroot}/pkg

	target_cp "src" ${target}:${goroot}
	target_cp "lib" ${target}:${goroot}
	[[ -d test ]] && target_cp "test" ${target}:${goroot}
	echo "done"
done