1 #!/bin/bash 2 set -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 14 goroot="$(target_tmpdir)/go" 15 for target in "$@" 16 do 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" 34 done 35