Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
137 lines (112 loc) · 4.99 KB
/
Copy pathmakefile
File metadata and controls
137 lines (112 loc) · 4.99 KB
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
# idownload-cli — client for idownloadd, built for jailbroken iOS.
#
# Every step is a script under scripts/ so the GitHub Actions workflow and a
# local checkout run the same code. This makefile only wires them together and
# owns the one thing that differs between the two packages: the layout.
SHELL := /bin/bash
ROOT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
CONFIG_DIR := $(ROOT_DIR)/configuration
include $(CONFIG_DIR)/build.env
VERSION_FILE := $(CONFIG_DIR)/version.txt
PACKAGE_VERSION := $(strip $(shell cat "$(VERSION_FILE)" 2>/dev/null))
PACKAGE_ID ?= wiki.qaq.idownload-cli
BUILD_DIR := $(ROOT_DIR)/build
SCRATCH_DIR := $(BUILD_DIR)/ios-$(ARCH)
PAYLOAD_PATH_FILE := $(BUILD_DIR)/payload-path.txt
PKG_DIR := $(BUILD_DIR)/Packages
IOS_BUILDER := $(ROOT_DIR)/scripts/build-ios.sh
DEB_PACKAGER := $(ROOT_DIR)/scripts/package-deb.sh
VERSION_APPLIER := $(ROOT_DIR)/scripts/apply-version.sh
DEVICE_INSTALLER := $(ROOT_DIR)/scripts/install-device.sh
# idownload-cli ships for roothide only: an unprefixed tree that dpkg drops
# into the jbroot the bootstrap picked this boot. The architecture field names
# that layout, not the CPU; the binary is plain arm64.
PACKAGE_PREFIX :=
PACKAGE_ARCHITECTURE := iphoneos-arm64e
DEB_OUTPUT ?= $(PKG_DIR)/$(PACKAGE_ID)_$(PACKAGE_VERSION)_$(PACKAGE_ARCHITECTURE).deb
ifeq ($(PACKAGE_VERSION),)
$(error $(VERSION_FILE) is missing or empty; run make set-version VERSION=x.y.z)
endif
.PHONY: all help print-version print-deb-path set-version check format test build \
package deb debs checksums install clean
.NOTPARALLEL:
all: debs
help:
@echo "idownload-cli $(PACKAGE_VERSION) — idownloadd client for jailbroken iOS"
@echo "target: $(ARCH)-apple-ios$(MIN_IOS)"
@echo
@echo " check Validate the scripts, the config and packaging inputs"
@echo " format Format Swift sources (swiftformat, .swiftformat)"
@echo " test Run the host tests (swift test, against a fake server)"
@echo " build Cross-compile idownload-cli for iOS"
@echo " deb Package for roothide (unprefixed, iphoneos-arm64e)"
@echo " debs The package plus SHA256SUMS — what CI releases"
@echo " install Install onto a device over SSH and smoke-test it"
@echo " clean Remove build/"
@echo
@echo " make set-version VERSION=1.2.3 Set the package version"
print-version:
@echo "$(PACKAGE_VERSION)"
print-deb-path:
@echo "$(DEB_OUTPUT)"
set-version:
@test -n "$(VERSION)" || { echo "usage: make set-version VERSION=1.2.3" >&2; exit 64; }
@"$(VERSION_APPLIER)" "$(VERSION)"
check:
@echo "==> shell syntax"
@for script in "$(ROOT_DIR)"/scripts/*.sh; do bash -n "$$script" || exit 1; done
@if command -v shellcheck >/dev/null; then \
shellcheck --severity=warning "$(ROOT_DIR)"/scripts/*.sh; \
else \
echo " (shellcheck not installed; syntax check only)"; \
fi
@echo "==> config"
@[[ "$(PACKAGE_VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$$ ]] || \
{ echo "error: version '$(PACKAGE_VERSION)' must look like 1.2.3 or 1.2.3-2" >&2; exit 65; }
@[[ "$(MIN_IOS)" =~ ^[0-9]+\.[0-9]+$$ ]] || \
{ echo "error: MIN_IOS '$(MIN_IOS)' must look like 15.0" >&2; exit 65; }
@grep -qF 'let packageVersion = "$(PACKAGE_VERSION)"' "$(ROOT_DIR)/Sources/idownload-cli/Version.swift" || \
{ echo "error: Version.swift disagrees with version.txt; run make set-version VERSION=$(PACKAGE_VERSION)" >&2; exit 65; }
@grep -qF '.iOS(.v$(firstword $(subst ., ,$(MIN_IOS))))' "$(ROOT_DIR)/Package.swift" || \
{ echo "error: Package.swift's iOS platform does not match MIN_IOS $(MIN_IOS)" >&2; exit 65; }
@echo "==> swift formatting"
@installed="$$(swiftformat --version 2>/dev/null || true)"; \
if [[ "$$installed" == "$(SWIFTFORMAT_VERSION)" ]]; then \
swiftformat --lint "$(ROOT_DIR)" || exit 1; \
else \
echo " (swiftformat $(SWIFTFORMAT_VERSION) not installed, found '$$installed'; skipped)"; \
fi
@echo "==> packaging inputs"
@for input in packaging/DEBIAN/control packaging/idownload-cli.entitlements \
packaging/release-notes.md; do \
test -f "$(ROOT_DIR)/$$input" || { echo "error: missing $$input" >&2; exit 66; }; \
done
@plutil -lint "$(ROOT_DIR)/packaging/idownload-cli.entitlements"
@"$(ROOT_DIR)/scripts/release-notes.sh" "v$(PACKAGE_VERSION)" >/dev/null
@echo "ok"
format:
swiftformat "$(ROOT_DIR)"
test:
swift test --package-path "$(ROOT_DIR)" --scratch-path "$(BUILD_DIR)/host"
build:
@mkdir -p "$(BUILD_DIR)"
@"$(IOS_BUILDER)" "$(SCRATCH_DIR)" >"$(PAYLOAD_PATH_FILE)"
package:
@mkdir -p "$(PKG_DIR)"
@PACKAGE_ID="$(PACKAGE_ID)" "$(DEB_PACKAGER)" \
"$$(cat "$(PAYLOAD_PATH_FILE)")" \
"$(DEB_OUTPUT)" \
"$(PACKAGE_VERSION)" \
"$(PACKAGE_ARCHITECTURE)" \
"$(PACKAGE_PREFIX)"
deb: build package
debs: deb
@$(MAKE) --no-print-directory checksums
checksums:
@cd "$(PKG_DIR)" && shasum -a 256 \
"$(PACKAGE_ID)_$(PACKAGE_VERSION)_iphoneos-arm64e.deb" \
| tee SHA256SUMS
install: debs
@"$(DEVICE_INSTALLER)" "$(PKG_DIR)"
clean:
rm -rf "$(BUILD_DIR)"