-
-
Notifications
You must be signed in to change notification settings - Fork 155
/
Makefile
198 lines (165 loc) · 8.23 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
REPO=blacktop
NAME=ipsw
CUR_VERSION=$(shell gh release view --json tagName -q '.tagName')
CUR_COMMIT=$(shell git rev-parse --short HEAD)
LOCAL_VERSION=$(shell svu current)
NEXT_VERSION=$(shell svu patch)
.PHONY: build-deps
build-deps: ## Install the build dependencies
@echo " > Installing build deps"
brew install gh go git goreleaser zig unicorn libusb
.PHONY: dev-deps
dev-deps: download
@echo " > Installing Go dev tools"
@go mod download
@go install github.com/caarlos0/[email protected]
@go install github.com/go-swagger/go-swagger/cmd/swagger@latest
@go install github.com/goreleaser/goreleaser@latest
@go install github.com/spf13/cobra-cli@latest
@go install golang.org/x/perf/cmd/benchstat@latest
@go install golang.org/x/tools/cmd/stringer@latest
.PHONY: x86-brew
x86-brew: ## Install the x86_64 homebrew on Apple Silicon
mkdir /tmp/homebrew
cd /tmp; curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
sudo mv /tmp/homebrew /usr/local/homebrew
arch -x86_64 /usr/local/homebrew/bin/brew install unicorn libusb
.PHONY: setup
setup: build-deps dev-deps ## Install all the build and dev dependencies
.PHONY: dry_release
dry_release: ## Run goreleaser without releasing/pushing artifacts to github
@echo " > Creating Pre-release Build ${NEXT_VERSION}"
@GOROOT=$(shell go env GOROOT) goreleaser build --id darwin_extras_build --clean --timeout 60m --snapshot --single-target --output dist/ipsw
.PHONY: snapshot
snapshot: ## Run goreleaser snapshot
@echo " > Creating Snapshot ${NEXT_VERSION}"
@GOROOT=$(shell go env GOROOT) goreleaser --clean --timeout 60m --snapshot
.PHONY: release
release: ## Create a new release from the NEXT_VERSION
@echo " > Creating Release ${NEXT_VERSION}"
@hack/make/release ${NEXT_VERSION}
@GOROOT=$(shell go env GOROOT) goreleaser --clean --timeout 60m --skip=validate
@echo " > Update Portfile ${NEXT_VERSION}"
@hack/make/portfile ../ports
.PHONY: release-minor
release-minor: ## Create a new minor semver release
@echo " > Creating Release $(shell svu minor)"
@hack/make/release $(shell svu minor)
@GOROOT=$(shell go env GOROOT) goreleaser --clean --timeout 60m --skip=validate
.PHONY: destroy
destroy: ## Remove release from the CUR_VERSION
@echo " > Deleting Release ${LOCAL_VERSION}"
rm -rf dist
git tag -d ${LOCAL_VERSION}
git push origin :refs/tags/${LOCAL_VERSION}
build: ## Build ipsw
@echo " > Building ipsw"
@go mod download
@CGO_ENABLED=1 go build -ldflags "-s -w -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppVersion=$(CUR_VERSION) -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppBuildCommit=$(CUR_COMMIT)" ./cmd/ipsw
.PHONY: build-ios
build-ios: ## Build ipsw for iOS
@echo " > Building ipsw"
@go mod download
@CGO_ENABLED=1 GOOS=ios GOARCH=arm64 CC=$(shell go env GOROOT)/misc/ios/clangwrap.sh go build -ldflags "-s -w -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppVersion=$(CUR_VERSION) -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppBuildCommit==$(CUR_COMMIT)" ./cmd/ipsw
@codesign --entitlements hack/make/data/ent.plist -s - -f ipsw
.PHONY: build-linux
build-linux: ## Build ipsw (linux)
@echo " > Building ipsw (linux)"
@go mod download
@CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC='zig cc -target aarch64-linux-musl' CXX='zig c++ -target aarch64-linux-musl' go build -ldflags "-s -w -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppVersion=$(CUR_VERSION) -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppBuildCommit=$(CUR_COMMIT)" ./cmd/ipsw
@echo " > Building ipswd (linux)"
@CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w --X github.com/blacktop/ipsw/api/types.BuildVersion=$(CUR_VERSION) -X github.com/blacktop/ipsw/api/types.BuildTime=$(date -u +%Y%m%d)" ./cmd/ipswd
.PHONY: docs
docs: ## Build the cli docs
@echo " > Updating CLI Docs"
go generate ./...
hack/make/docs
.PHONY: docs-search
docs-search: ## Build/Update the docs search index
@echo " > 🕸️ Crawling Docs 🕸️"
@http -a ${CRAWLER_USER_ID}:${CRAWLER_API_KEY} POST "https://crawler.algolia.com/api/1/crawlers/${CRAWLER_ID}/reindex"
.PHONY: test-docs
test-docs: ## Start local server hosting docusaurus docs
@echo " > Testing Docs"
cd www; pnpm start
.PHONY: update_mod
update_mod: ## Update go.mod file
@echo " > Updating go.mod"
rm go.sum || true
# go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | xargs --no-run-if-empty go get
go mod download
go mod tidy
.PHONY: update_devs
update_devs: ## Parse XCode database for new devices
@echo " > Updating device_traits.json"
go run ./cmd/ipsw/main.go device-list-gen pkg/xcode/data/device_traits.json
.PHONY: update_fcs_keys
update_fcs_keys: ## Scrape the iPhoneWiki for AES keys
@echo " > Updating fcs-keys.json"
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os iOS --beta --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os macOS --beta --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os visionOS --beta --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@hack/make/json_mini
.PHONY: update_fcs_keys_rc
update_fcs_keys_rc: ## Scrape the iPhoneWiki for AES keys
@echo " > Updating fcs-keys.json"
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os iOS --rc --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os macOS --rc --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os visionOS --rc --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@hack/make/json_mini
.PHONY: update_fcs_keys_release
update_fcs_keys_release: ## Scrape the iPhoneWiki for AES keys
@echo " > Updating fcs-keys.json"
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os iOS --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os macOS --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@CGO_ENABLED=1 go run ./cmd/ipsw/main.go dl appledb --os visionOS --latest --fcs-keys-json --output pkg/aea/data/ --confirm
@hack/make/json_mini
.PHONY: update_keys
update_keys: ## Scrape the iPhoneWiki for AES keys
@echo " > Updating firmware_keys.json"
CGO_ENABLED=0 go run ./cmd/ipsw/main.go key-list-gen pkg/info/data/firmware_keys.json
.PHONY: update_frida
update_frida: ## Updates the frida-core-devkits used in the frida cmd
@echo " > Updating frida-core-devkits"
@hack/make/frida-deps
.PHONY: update_proxy
update_proxy: ## Update the proxy pkgs
@echo " > Updating proxy list"
@GOPROXY=${IPSW_GO_PROXY} go mod download all
@GOPROXY=${IPSW_GO_PROXY} go mod tidy
.PHONY: work-macho
work-macho: ## Work on go-macho package
@echo " > Working on go-macho package"
@go work init
@go work use . ../go-macho
.PHONY: docker
docker: ## Build docker image
@echo " > Building Docker Image"
docker build --build-arg VERSION=$(NEXT_VERSION) -t $(REPO)/$(NAME):$(NEXT_VERSION) .
.PHONY: docker-daemon
docker-daemon: ## Build daemon docker image
@echo " > Building Docker Image"
docker build --build-arg VERSION=$(NEXT_VERSION) -t $(REPO)/$(NAME)-daemon:$(NEXT_VERSION) -f Dockerfile.daemon .
.PHONY: docker-tag
docker-tag: docker ## Tag docker image
docker tag $(REPO)/$(NAME):$(NEXT_VERSION) docker.pkg.github.com/blacktop/ipsw/$(NAME):$(NEXT_VERSION)
.PHONY: docker-ssh
docker-ssh: ## SSH into docker image
@docker run --init -it --rm --device /dev/fuse --cap-add SYS_ADMIN --mount type=tmpfs,destination=/app -v `pwd`/test-caches/ipsws:/data --entrypoint=bash $(REPO)/$(NAME):$(NEXT_VERSION)
.PHONY: docker-push
docker-push: docker-tag ## Push docker image to github
docker push docker.pkg.github.com/blacktop/ipsw/$(NAME):$(NEXT_VERSION)
.PHONY: docker-test
docker-test: ## Run docker test
@echo " > Testing Docker Image"
docker run --init -it --rm --device /dev/fuse --cap-add=SYS_ADMIN -v `pwd`:/data $(REPO)/$(NAME):$(NEXT_VERSION) -V extract --dyld /data/iPhone12_1_13.2.3_17B111_Restore.ipsw
clean: ## Clean up artifacts
@echo " > Cleaning"
rm *.tar || true
rm *.ipsw || true
rm kernelcache.release.* || true
rm -rf dist
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help