-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
2 changed files
with
49 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,51 +4,69 @@ | |
# license that can be found in the LICENSE file. | ||
|
||
|
||
# install.sh sets up a newly created Corellium iPhone device. | ||
# Set HOST to root@<ip> where <ip> is the device ssh | ||
# address. | ||
# Setting up a Corellium iPhone device | ||
# | ||
# Put a builder key in `buildkey`. | ||
# install.sh sets up a newly created Corellium iPhone device. Before executing | ||
# install.sh, one must prepare the following steps: | ||
# | ||
# Use `bootstrap.bash` from the Go standard distribution and build a | ||
# ios/arm64 bootstrap toolchain with cgo enabled and the compiler set | ||
# to the clang wrapper from $GOROOT/misc/ios: | ||
# 1. A public key must be added to the device's /root/.ssh/authorized_keys file. | ||
# 2. A builder key file `buildkey` in the same folder as `install.sh`. | ||
# 3. Use `bootstrap.bash` from the Go standard distribution and build a | ||
# ios/arm64 bootstrap toolchain with cgo enabled and the compiler set | ||
# to the clang wrapper from $GOROOT/misc/ios: | ||
# | ||
# GOOS=ios GOARCH=arm64 CGO_ENABLED=1 CC_FOR_TARGET=$(pwd)/../misc/ios/clangwrap.sh ./bootstrap.bash | ||
# GOOS=ios GOARCH=arm64 CGO_ENABLED=1 CC_FOR_TARGET=$(pwd)/../misc/ios/clangwrap.sh ./bootstrap.bash | ||
# | ||
# Put it in `go-ios-arm64-bootstrap.tbz`. | ||
# | ||
# Finally, install.sh assumes an iPhone SDK in `iPhoneOS.sdk`. | ||
# 4. Put `go-ios-arm64-bootstrap.tbz` in the same folder as `install.sh`. | ||
# 5. Finally, put an iPhone SDK in `iPhoneOS.sdk` in the same folder as `install.sh`. | ||
# It can be found from Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk. | ||
|
||
# Set HOST to [email protected] where 10.11.1.1 is the device ssh address in Corellium. | ||
[email protected] | ||
|
||
ios() { | ||
ssh "$HOST" "$@" | ||
} | ||
|
||
# Install necessary toolchains. | ||
ios apt-get update | ||
ios apt-get upgrade | ||
ios apt install -y --allow-unauthenticated git tmux rsync org.coolstar.iostoolchain ld64 com.linusyang.localeutf8 | ||
|
||
# Run builder at boot. | ||
scp files/org.golang.builder.plist $HOST:/Library/LaunchDaemons/ | ||
ios launchctl load -w /Library/LaunchDaemons/org.golang.builder.plist | ||
scp files/builder.sh $HOST:/var/root | ||
# Codesign necessary binaries. | ||
ios ldid -S /usr/bin/git | ||
ios ldid -S /usr/bin/tmux | ||
ios ldid -S /usr/bin/rsync | ||
|
||
# Upload Go bootstrap toolchain and related files. | ||
scp go-ios-arm64-bootstrap.tbz $HOST:/var/root | ||
ios tar xjf go-ios-arm64-bootstrap.tbz | ||
scp buildkey $HOST:/var/root/.gobuildkey-host-ios-arm64-corellium-ios | ||
scp files/profile $HOST:/var/root/.profile | ||
rsync -va iPhoneOS.sdk $HOST:/var/root/ | ||
|
||
# Dummy sign Go bootstrap toolchain. | ||
ios find go-ios-arm64-bootstrap -executable -type f| ios xargs -n1 ldid -S | ||
|
||
ios mkdir -p /var/root/bin | ||
|
||
# Build wrappers on the host. | ||
# Build wrappers on the host, and sign them. | ||
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 | ||
CGO_ENABLED=1 GOOS=ios CC=$(go env GOROOT)/misc/ios/clangwrap.sh GOARCH=arm64 go build -o arwrap files/arwrap.go | ||
ios mkdir -p /var/root/bin | ||
scp arwrap $HOST:/var/root/bin/ar | ||
scp clangwrap $HOST:/var/root/bin/clangwrap | ||
# Dummy sign them. | ||
|
||
# Codesign everything. | ||
ios find go-ios-arm64-bootstrap -executable -type f | ios xargs -n1 ldid -S | ||
ios ldid -S /var/root/bin/clangwrap | ||
ios ldid -S /var/root/bin/ar | ||
|
||
# Run builder at boot. | ||
scp files/org.golang.builder.plist $HOST:/Library/LaunchDaemons/ | ||
ios launchctl load -w /Library/LaunchDaemons/org.golang.builder.plist | ||
scp files/builder.sh $HOST:/var/root | ||
|
||
# Install buildlet. | ||
ios HOME=/var/root \ | ||
CC=$HOME/bin/clangwrap \ | ||
GO_BUILDER_ENV=host-ios-arm64-corellium-ios \ | ||
GOROOT_BOOTSTRAP=$HOME/go-ios-arm64-bootstrap \ | ||
PATH=$HOME/bin:$PATH $GOROOT_BOOTSTRAP/bin/go install -v golang.org/x/build/cmd/buildlet@latest | ||
|
||
ios reboot |