Skip to content

Commit 2349f06

Browse files
changkungopherbot
authored andcommitted
env/corellium: update setup scripts
Change-Id: Idb4febcab45131bd5461dbb4536646ae703d3866 Reviewed-on: https://go-review.googlesource.com/c/build/+/519095 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Changkun Ou <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent b87b3bc commit 2349f06

File tree

2 files changed

+49
-27
lines changed

2 files changed

+49
-27
lines changed

env/corellium/android/install.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
# Use of this source code is governed by a BSD-style
44
# license that can be found in the LICENSE file.
55

6-
7-
# install.sh sets up newly installed Android Corellium device.
8-
# Connect to the device with "adb connect <ip>:5001" where
9-
# <ip> is the device adb address.
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:
1010
#
11-
# place a valid builder key in the `buildkey` file.
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`.
1215

1316
curl -o com.termux.apk "https://f-droid.org/repo/com.termux_118.apk"
1417
curl -o com.termux.boot.apk "https://f-droid.org/repo/com.termux.boot_7.apk"
@@ -48,6 +51,7 @@ termux mkdir -p /data/data/com.termux/files/home/tmpdir
4851
# Run builder at boot.
4952
termux mkdir -p /data/data/com.termux/files/home/.termux/boot
5053
adb push files/run-builder-at-boot /data/data/com.termux/files/home/.termux/boot
54+
termux pkg up
5155
termux pkg install -y openssh tmux ndk-multilib clang git golang lld
5256
termux go build clangwrap.go
5357

env/corellium/ios/install.sh

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,69 @@
44
# license that can be found in the LICENSE file.
55

66

7-
# install.sh sets up a newly created Corellium iPhone device.
8-
# Set HOST to root@<ip> where <ip> is the device ssh
9-
# address.
7+
# Setting up a Corellium iPhone device
108
#
11-
# Put a builder key in `buildkey`.
9+
# install.sh sets up a newly created Corellium iPhone device. Before executing
10+
# install.sh, one must prepare the following steps:
1211
#
13-
# Use `bootstrap.bash` from the Go standard distribution and build a
14-
# ios/arm64 bootstrap toolchain with cgo enabled and the compiler set
15-
# to the clang wrapper from $GOROOT/misc/ios:
12+
# 1. A public key must be added to the device's /root/.ssh/authorized_keys file.
13+
# 2. A builder key file `buildkey` in the same folder as `install.sh`.
14+
# 3. Use `bootstrap.bash` from the Go standard distribution and build a
15+
# ios/arm64 bootstrap toolchain with cgo enabled and the compiler set
16+
# to the clang wrapper from $GOROOT/misc/ios:
1617
#
17-
# GOOS=ios GOARCH=arm64 CGO_ENABLED=1 CC_FOR_TARGET=$(pwd)/../misc/ios/clangwrap.sh ./bootstrap.bash
18+
# GOOS=ios GOARCH=arm64 CGO_ENABLED=1 CC_FOR_TARGET=$(pwd)/../misc/ios/clangwrap.sh ./bootstrap.bash
1819
#
19-
# Put it in `go-ios-arm64-bootstrap.tbz`.
20-
#
21-
# Finally, install.sh assumes an iPhone SDK in `iPhoneOS.sdk`.
20+
# 4. Put `go-ios-arm64-bootstrap.tbz` in the same folder as `install.sh`.
21+
# 5. Finally, put an iPhone SDK in `iPhoneOS.sdk` in the same folder as `install.sh`.
22+
# It can be found from Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk.
23+
24+
# Set HOST to [email protected] where 10.11.1.1 is the device ssh address in Corellium.
25+
2226

2327
ios() {
2428
ssh "$HOST" "$@"
2529
}
2630

31+
# Install necessary toolchains.
2732
ios apt-get update
33+
ios apt-get upgrade
2834
ios apt install -y --allow-unauthenticated git tmux rsync org.coolstar.iostoolchain ld64 com.linusyang.localeutf8
2935

30-
# Run builder at boot.
31-
scp files/org.golang.builder.plist $HOST:/Library/LaunchDaemons/
32-
ios launchctl load -w /Library/LaunchDaemons/org.golang.builder.plist
33-
scp files/builder.sh $HOST:/var/root
36+
# Codesign necessary binaries.
37+
ios ldid -S /usr/bin/git
38+
ios ldid -S /usr/bin/tmux
39+
ios ldid -S /usr/bin/rsync
3440

41+
# Upload Go bootstrap toolchain and related files.
3542
scp go-ios-arm64-bootstrap.tbz $HOST:/var/root
3643
ios tar xjf go-ios-arm64-bootstrap.tbz
3744
scp buildkey $HOST:/var/root/.gobuildkey-host-ios-arm64-corellium-ios
3845
scp files/profile $HOST:/var/root/.profile
3946
rsync -va iPhoneOS.sdk $HOST:/var/root/
4047

41-
# Dummy sign Go bootstrap toolchain.
42-
ios find go-ios-arm64-bootstrap -executable -type f| ios xargs -n1 ldid -S
43-
44-
ios mkdir -p /var/root/bin
45-
46-
# Build wrappers on the host.
48+
# Build wrappers on the host, and sign them.
4749
CGO_ENABLED=1 GOOS=ios CC=$(go env GOROOT)/misc/ios/clangwrap.sh GOARCH=arm64 go build -o clangwrap -ldflags="-X main.sdkpath=/var/root/iPhoneOS.sdk" files/clangwrap.go
4850
CGO_ENABLED=1 GOOS=ios CC=$(go env GOROOT)/misc/ios/clangwrap.sh GOARCH=arm64 go build -o arwrap files/arwrap.go
51+
ios mkdir -p /var/root/bin
4952
scp arwrap $HOST:/var/root/bin/ar
5053
scp clangwrap $HOST:/var/root/bin/clangwrap
51-
# Dummy sign them.
54+
55+
# Codesign everything.
56+
ios find go-ios-arm64-bootstrap -executable -type f | ios xargs -n1 ldid -S
5257
ios ldid -S /var/root/bin/clangwrap
5358
ios ldid -S /var/root/bin/ar
59+
60+
# Run builder at boot.
61+
scp files/org.golang.builder.plist $HOST:/Library/LaunchDaemons/
62+
ios launchctl load -w /Library/LaunchDaemons/org.golang.builder.plist
63+
scp files/builder.sh $HOST:/var/root
64+
65+
# Install buildlet.
66+
ios HOME=/var/root \
67+
CC=$HOME/bin/clangwrap \
68+
GO_BUILDER_ENV=host-ios-arm64-corellium-ios \
69+
GOROOT_BOOTSTRAP=$HOME/go-ios-arm64-bootstrap \
70+
PATH=$HOME/bin:$PATH $GOROOT_BOOTSTRAP/bin/go install -v golang.org/x/build/cmd/buildlet@latest
71+
5472
ios reboot

0 commit comments

Comments
 (0)