|
4 | 4 | # license that can be found in the LICENSE file.
|
5 | 5 |
|
6 | 6 |
|
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 |
10 | 8 | #
|
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: |
12 | 11 | #
|
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: |
16 | 17 | #
|
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 |
18 | 19 | #
|
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 | + |
22 | 26 |
|
23 | 27 | ios() {
|
24 | 28 | ssh "$HOST" "$@"
|
25 | 29 | }
|
26 | 30 |
|
| 31 | +# Install necessary toolchains. |
27 | 32 | ios apt-get update
|
| 33 | +ios apt-get upgrade |
28 | 34 | ios apt install -y --allow-unauthenticated git tmux rsync org.coolstar.iostoolchain ld64 com.linusyang.localeutf8
|
29 | 35 |
|
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 |
34 | 40 |
|
| 41 | +# Upload Go bootstrap toolchain and related files. |
35 | 42 | scp go-ios-arm64-bootstrap.tbz $HOST:/var/root
|
36 | 43 | ios tar xjf go-ios-arm64-bootstrap.tbz
|
37 | 44 | scp buildkey $HOST:/var/root/.gobuildkey-host-ios-arm64-corellium-ios
|
38 | 45 | scp files/profile $HOST:/var/root/.profile
|
39 | 46 | rsync -va iPhoneOS.sdk $HOST:/var/root/
|
40 | 47 |
|
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. |
47 | 49 | 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
|
48 | 50 | 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 |
49 | 52 | scp arwrap $HOST:/var/root/bin/ar
|
50 | 53 | 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 |
52 | 57 | ios ldid -S /var/root/bin/clangwrap
|
53 | 58 | 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 | + |
54 | 72 | ios reboot
|
0 commit comments