golang.org/x/build@v0.0.0-20240506185731-218518f32b70/env/corellium/android/install.sh (about) 1 #!/bin/bash 2 # Copyright 2022 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 # Setting up a Corellium Android device 7 # 8 # install.sh sets up newly installed Android Corellium device. Before 9 # executing install.sh, one must prepare the following steps: 10 # 11 # 1. Connect to the device with "adb connect 10.11.1.1:5001" where 12 # 10.11.1.1 is the device adb address in Corellium. 13 # 2. Put a valid builder key as `buildkey` file in the same folder as 14 # `install.sh`. 15 16 curl -o com.termux.apk "https://f-droid.org/repo/com.termux_118.apk" 17 curl -o com.termux.boot.apk "https://f-droid.org/repo/com.termux.boot_7.apk" 18 19 adb install com.termux.apk 20 21 # Run Termux to set up filesystem. 22 adb shell monkey -p com.termux -c android.intent.category.LAUNCHER 1 23 24 adb install com.termux.boot.apk 25 26 # Run boot app once to enable run-on-boot. 27 adb shell monkey -p com.termux.boot -c android.intent.category.LAUNCHER 1 28 29 adb root 30 31 echo "waiting for the Termux filesystem..." 32 while adb shell ls /data/data/com.termux/files/home 2> /dev/null ; [ $? -ne 0 ]; do 33 sleep 1 34 done 35 36 adb push buildkey /data/data/com.termux/files/home/.gobuildkey-host-android-arm64-corellium-android 37 adb push files/exec.sh /data/data/com.termux 38 adb push files/clangwrap.go /data/data/com.termux/files/home 39 adb push files/builder.sh /data/data/com.termux/files/home 40 adb push files/profile /data/data/com.termux/files/home/.profile 41 adb shell chmod +x /data/data/com.termux/exec.sh 42 adb shell chmod +x /data/data/com.termux/files/home/builder.sh 43 # Get Termux username. 44 USER=$(adb shell stat -c "%U" /data/data/com.termux) 45 46 termux() { 47 adb shell su "$USER" /data/data/com.termux/exec.sh "$@" 48 } 49 50 termux mkdir -p /data/data/com.termux/files/home/tmpdir 51 # Run builder at boot. 52 termux mkdir -p /data/data/com.termux/files/home/.termux/boot 53 adb push files/run-builder-at-boot /data/data/com.termux/files/home/.termux/boot 54 termux pkg up 55 termux pkg install -y openssh tmux ndk-multilib clang git golang lld 56 termux go build clangwrap.go 57 58 # Move the arm 32-bit sysroot so 32-bit arm binaries use the Android 59 # system libraries at runtime, not those in the build sysroot. If 60 # we don't, runtime linking fails. 61 termux mv /data/data/com.termux/files/usr/arm-linux-androideabi /data/data/com.termux/files/home/arm-linux-androideabi 62 63 termux /system/bin/reboot