dsh-ipa-build 1.3.5 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +3 -3
- package/README.md +4 -2
- package/SKILL.md +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/bootstrap.ps1 +3 -0
- package/scripts/bootstrap.sh +1 -1
- package/scripts/ipa +57 -22
- package/scripts/ipa.ps1 +16 -5
package/NOTICE
CHANGED
|
@@ -5,13 +5,13 @@ dsh-ipa-build
|
|
|
5
5
|
|
|
6
6
|
vendor/ 下的第三方组件各自按自己的许可证分发,和上面的 MIT 无关:
|
|
7
7
|
|
|
8
|
-
- vendor/ldid-master/ —— ldid v2.1.5-procursus8(ProcursusTeam/ldid,commit 18255c5),AGPL-3.0
|
|
8
|
+
- vendor/ldid-master/ —— ldid v2.1.5-procursus8(ProcursusTeam/ldid,commit 18255c5),GNU Affero General Public License v3.0(AGPL-3.0,见该目录下的 COPYING)。
|
|
9
9
|
只在 Linux / macOS 上编译成 ~/.ipa-toolchain/bin/ldid 用于本地签名。
|
|
10
10
|
你的分发行为若触发 AGPL 义务(例如对外提供修改后的 ldid 或其衍生作品),
|
|
11
11
|
需自行履行 AGPL 的源码提供义务。
|
|
12
|
-
- vendor/libplist-2.6.0.tar.bz2 —— libplist,LGPL-2.1
|
|
12
|
+
- vendor/libplist-2.6.0.tar.bz2 —— libplist,GNU Lesser General Public License v2.1(LGPL-2.1,https://github.com/libimobiledevice/libplist)。ldid 编译时静态/动态链接它,动态链接时保留替换库的权利即可。
|
|
13
13
|
- vendor/zsign/zsign.exe —— zsign v1.1.3 Windows 版,来自 https://github.com/zhlynn/zsign 。
|
|
14
|
-
该仓库声明的许可证是 GPL-3.0
|
|
14
|
+
该仓库声明的许可证是 GNU General Public License v3.0(GPL-3.0,见上游 LICENSE),二进制未做改动;分发前请按该仓库最新声明核对。
|
|
15
15
|
- vendor/iPhoneOS16.5.sdk.tar.xz —— Apple 的 iPhoneOS SDK,版权归 Apple,仅随本插件用于本地交叉编译,不单独再分发 SDK。
|
|
16
16
|
- iPhoneOS SDK 中的系统库头文件与 .tbd stub 版权归 Apple Inc.
|
|
17
17
|
|
package/README.md
CHANGED
|
@@ -59,7 +59,9 @@ IPA_CERT_PASSWORD=证书密码 scripts/ipa resign old.ipa -o new.ipa --p12 dev.p
|
|
|
59
59
|
|
|
60
60
|
## 平台差异
|
|
61
61
|
|
|
62
|
-
`pack` / `resign` / `info` 不依赖编译器,三平台行为一样。`build` 要 clang + ld64.lld:Linux/macOS 跑完 bootstrap 就有;Windows 上 bootstrap 会装 LLVM,实在装不上而机器里有 WSL 时,`build` 会把活转给 WSL 里的 bash
|
|
62
|
+
`pack` / `resign` / `info` 不依赖编译器,三平台行为一样。`build` 要 clang + ld64.lld:Linux/macOS 跑完 bootstrap 就有;Windows 上 bootstrap 会装 LLVM,实在装不上而机器里有 WSL 时,`build` 会把活转给 WSL 里的 bash 版本,命令不用改;密码按推荐方式放在 `IPA_CERT_PASSWORD` 里也会显式带进 WSL(wsl.exe 本身不传 Windows 环境变量)。
|
|
63
|
+
|
|
64
|
+
已知差异:打 `.app` 成 `.ipa` 时,Linux/macOS 用 `zip -y` 保留符号链接,Windows 用 .NET 的 zip 实现会把 `.framework` 里的链接展开成文件副本(打包时会给出提示)。两种包都能装,但同一个 `.app` 两端打出来的体积和文件列表不一样;要完全一致就在 WSL 里跑 `pack`。
|
|
63
65
|
|
|
64
66
|
## 自检
|
|
65
67
|
|
|
@@ -68,7 +70,7 @@ scripts/ipa build scripts/examples/HelloApp --name HelloApp --bundle-id com.exam
|
|
|
68
70
|
scripts/ipa info dist/HelloApp.ipa
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
`info`
|
|
73
|
+
`info` 的签名行有内容就说明编译、打包、签名这条链路通了。签名判定按真实布局读:Mach-O 头和 load command 跟 slice 字节序走,签名 SuperBlob 固定大端。没有编译器的机器用 `pack` 打这个例子也能验证打包和签名。
|
|
72
74
|
|
|
73
75
|
## 包里的东西
|
|
74
76
|
|
package/SKILL.md
CHANGED
package/package.json
CHANGED
package/plugin.json
CHANGED
package/scripts/bootstrap.ps1
CHANGED
|
@@ -8,6 +8,9 @@ param(
|
|
|
8
8
|
'https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz'
|
|
9
9
|
),
|
|
10
10
|
# 上面那份 18.1.8 的 sha256,实测校验过(936MB,下完 tar -tJf 能完整列出)
|
|
11
|
+
# 注意:这个值写死就等于“只认这一个包”,如果上游换了 18.1.8 的构建产物,安装会被一直拒绝。
|
|
12
|
+
# 换机或换网络重下时若报对不上,先核对 size 981666720 与 tar 列表,再确认是不是上游换了包,别直接改这个数。
|
|
13
|
+
# 待办:在一台干净 Windows 机上完整跑一次 bootstrap.ps1 复核这个锚点。
|
|
11
14
|
# 换 URL 的话这个哈希也要跟着换,不然会被判成"文件不对"
|
|
12
15
|
[string]$LlvmSha = '22c5907db053026cc2a8ff96d21c0f642a90d24d66c23c6d28ee7b1d572b82e8'
|
|
13
16
|
)
|
package/scripts/bootstrap.sh
CHANGED
|
@@ -81,7 +81,7 @@ fi
|
|
|
81
81
|
|
|
82
82
|
# ldid 是 ProcursusTeam/ldid v2.1.5-procursus8(commit 18255c5)的源码快照,
|
|
83
83
|
# 想复现就 checkout 那个 commit;这里先校验快照没被改过
|
|
84
|
-
LDID_CPP_SHA="
|
|
84
|
+
LDID_CPP_SHA="78a5f4d08f8affa6bbbf7b26947ba26023bca91347ee78c4f70d46cf7b67563d"
|
|
85
85
|
|
|
86
86
|
if [ ! -x "$tc/bin/ldid" ]; then
|
|
87
87
|
echo "编 ldid"
|
package/scripts/ipa
CHANGED
|
@@ -79,14 +79,23 @@ CPU = {16777228: 'arm64', 16777223: 'x86_64', 12: 'armv7', 7: 'i386', 16777222:
|
|
|
79
79
|
|
|
80
80
|
path = sys.argv[1]
|
|
81
81
|
try:
|
|
82
|
-
|
|
82
|
+
fh = open(path, 'rb')
|
|
83
83
|
except Exception as e:
|
|
84
84
|
print('读不了|%s' % e)
|
|
85
85
|
sys.exit()
|
|
86
|
+
# 几百 MB 的二进制整读会把内存翻倍,这里只按偏移 seek 读
|
|
87
|
+
fh.seek(0, 2)
|
|
88
|
+
size = fh.tell()
|
|
86
89
|
|
|
87
90
|
def rd(off, n, endian):
|
|
91
|
+
if off is None or off < 0 or off + n > size:
|
|
92
|
+
return None
|
|
93
|
+
fh.seek(off)
|
|
94
|
+
raw = fh.read(n)
|
|
95
|
+
if len(raw) != n:
|
|
96
|
+
return None
|
|
88
97
|
fmt = ('>' if endian == 'be' else '<') + ('I' if n == 4 else 'Q')
|
|
89
|
-
return struct.unpack(fmt,
|
|
98
|
+
return struct.unpack(fmt, raw)[0]
|
|
90
99
|
|
|
91
100
|
def sig_state(base, _fat_endian=None):
|
|
92
101
|
# slice 自己的字节序看它自己的 magic,不能沿用 fat 头的字节序
|
|
@@ -110,20 +119,22 @@ def sig_state(base, _fat_endian=None):
|
|
|
110
119
|
return None
|
|
111
120
|
pos, end = base + hsz, base + hsz + sizeofcmds
|
|
112
121
|
sigoff = None
|
|
113
|
-
while pos + 8 <= end and pos + 8 <=
|
|
114
|
-
cmd,
|
|
115
|
-
if
|
|
122
|
+
while pos + 8 <= end and pos + 8 <= size:
|
|
123
|
+
cmd, cmdsz = rd(pos, 4, endian), rd(pos + 4, 4, endian)
|
|
124
|
+
if cmdsz is None or cmdsz < 8:
|
|
116
125
|
break
|
|
117
|
-
if cmd == 0x1d and pos + 16 <=
|
|
126
|
+
if cmd == 0x1d and pos + 16 <= size:
|
|
118
127
|
# dataoff 相对 slice 起点,fat 里要加上 base
|
|
119
128
|
sigoff = base + rd(pos + 8, 4, endian)
|
|
120
|
-
pos +=
|
|
121
|
-
if sigoff is None or sigoff + 12 >
|
|
129
|
+
pos += cmdsz
|
|
130
|
+
if sigoff is None or sigoff + 12 > size:
|
|
122
131
|
return None
|
|
123
|
-
|
|
132
|
+
# CodeSignature 的 SuperBlob 在文件里固定大端(FA DE 0C C0),
|
|
133
|
+
# 跟 slice 自己是小端还是大端无关,这里不能跟着 slice 走
|
|
134
|
+
if rd(sigoff, 4, 'be') != 0xfade0cc0:
|
|
124
135
|
return None
|
|
125
|
-
count = rd(sigoff + 4, 4,
|
|
126
|
-
types = [rd(sigoff + 8 + i * 8, 4,
|
|
136
|
+
count = rd(sigoff + 4, 4, 'be')
|
|
137
|
+
types = [rd(sigoff + 8 + i * 8, 4, 'be') for i in range(min(count, 20))]
|
|
127
138
|
if 0x10000 in types:
|
|
128
139
|
return 'cms'
|
|
129
140
|
if 0 in types:
|
|
@@ -150,15 +161,15 @@ elif magic in (0xcefaedfe, 0xcffaedfe):
|
|
|
150
161
|
sig = sig_state(0, 'be')
|
|
151
162
|
elif magic in FAT:
|
|
152
163
|
endian, entSize = FAT[magic]
|
|
153
|
-
nfat = rd(4, 4, endian)
|
|
164
|
+
nfat = rd(4, 4, endian) or 0
|
|
154
165
|
if nfat <= 20:
|
|
155
166
|
for i in range(nfat):
|
|
156
167
|
e = 8 + i * entSize
|
|
157
|
-
if e + entSize >
|
|
168
|
+
if e + entSize > size:
|
|
158
169
|
break
|
|
159
170
|
archs.append(CPU.get(rd(e, 4, endian), '?'))
|
|
160
171
|
off = rd(e + 8, 8 if entSize == 32 else 4, endian)
|
|
161
|
-
if off <
|
|
172
|
+
if off is not None and off < size:
|
|
162
173
|
st = sig_state(off)
|
|
163
174
|
# 多个切片取最强的那个:任一有 CMS 就是真证书签名
|
|
164
175
|
if st == 'cms' or (st and sig is None):
|
|
@@ -170,6 +181,7 @@ else:
|
|
|
170
181
|
|
|
171
182
|
label = {'cms': '真证书签名(有 CMS)', 'adhoc': 'ad-hoc 伪签名(只有 CodeDirectory)', None: '没签'}[sig]
|
|
172
183
|
print('|'.join(['+'.join(archs) or '?', label]))
|
|
184
|
+
fh.close()
|
|
173
185
|
PY
|
|
174
186
|
}
|
|
175
187
|
|
|
@@ -184,7 +196,12 @@ import os, struct, sys
|
|
|
184
196
|
app = sys.argv[1]
|
|
185
197
|
# 32/64 位 Mach-O、标准 fat(小端读出 0xBEBAFECA)和字节交换变体
|
|
186
198
|
MAG = (0xfeedface, 0xfeedfacf, 0xcefaedfe, 0xcffaedfe, 0xbebafeca, 0xbfbafeca, 0xcafebabe, 0xcafebabf)
|
|
187
|
-
|
|
199
|
+
base = os.path.basename(app.rstrip('/'))
|
|
200
|
+
prefer = [base[:-4]] if base.endswith('.app') else []
|
|
201
|
+
names = sorted(os.listdir(app))
|
|
202
|
+
# 顶层常有 helper 之类的其他 Mach-O,app 同名的那份才是主程序,先试它
|
|
203
|
+
cand = [n for n in prefer if n in names] + [n for n in names if n not in prefer]
|
|
204
|
+
for name in cand:
|
|
188
205
|
p = os.path.join(app, name)
|
|
189
206
|
if not os.path.isfile(p):
|
|
190
207
|
continue
|
|
@@ -345,7 +362,8 @@ PY
|
|
|
345
362
|
zip_payload "$tmpipa" "$work"
|
|
346
363
|
if [ -n "$p12" ]; then sign_with_cert "$tmpipa" "$out"; rm -f "$tmpipa"
|
|
347
364
|
else mv -f "$tmpipa" "$out"; fi
|
|
348
|
-
|
|
365
|
+
# 只删这次构建的目录,同 cwd 下别的 app 的中间产物不能连坐
|
|
366
|
+
rm -rf "$work"; rmdir "$PWD/.build" 2>/dev/null || true
|
|
349
367
|
echo "产物 $out"
|
|
350
368
|
}
|
|
351
369
|
|
|
@@ -433,10 +451,16 @@ sign_nested() {
|
|
|
433
451
|
while IFS= read -r x; do
|
|
434
452
|
local xe; xe="$(plist_get "$x" CFBundleExecutable)"
|
|
435
453
|
[ -n "$xe" ] || xe="$(basename "$x" .appex)"
|
|
436
|
-
|
|
454
|
+
# 扩展用自己的 entitlements(app groups 之类跟主 app 不一样),
|
|
455
|
+
# 没有就裸签,别把主 app 的高权限项摊到扩展上
|
|
456
|
+
local xent=""
|
|
457
|
+
for cand in "$x/Entitlements.plist" "$(dirname "$x")/$(basename "$x" .appex).entitlements"; do
|
|
458
|
+
[ -f "$cand" ] && { xent="$cand"; break; }
|
|
459
|
+
done
|
|
460
|
+
if [ -n "$xent" ]; then "$ldid" -S"$xent" "$x/$xe" || die "签 $x 失败"
|
|
437
461
|
else "$ldid" -S "$x/$xe" || die "签 $x 失败"; fi
|
|
438
462
|
find "$x" -name '*.dylib' -type f | while read -r d; do "$ldid" -S "$d" || true; done
|
|
439
|
-
done < <(find "$app
|
|
463
|
+
done < <(find "$app" -name '*.appex' -type d -not -path '*/Frameworks/*' 2>/dev/null)
|
|
440
464
|
fi
|
|
441
465
|
if [ -d "$app/Frameworks" ]; then
|
|
442
466
|
while IFS= read -r fwdir; do
|
|
@@ -450,13 +474,24 @@ sign_nested() {
|
|
|
450
474
|
|
|
451
475
|
# 换主 id 时扩展的 id 要跟着换,真签要求 appex id 以主 app id 开头
|
|
452
476
|
retag_appex() {
|
|
453
|
-
local app="$1" bid="$2" x eid
|
|
477
|
+
local app="$1" bid="$2" x eid pre
|
|
478
|
+
# 用扩展自己的 bundle 名,不取旧 id 的最后一段:两个扩展末段同名会撞 id。
|
|
479
|
+
# Watch 里的扩展要挂在 watchkitapp 下面。
|
|
480
|
+
while IFS= read -r x; do
|
|
481
|
+
eid="$(plist_get "$x" CFBundleIdentifier)"
|
|
482
|
+
[ -n "$eid" ] || continue
|
|
483
|
+
case "$x" in
|
|
484
|
+
*/Watch/*) pre="$bid.watchkitapp" ;;
|
|
485
|
+
*) pre="$bid" ;;
|
|
486
|
+
esac
|
|
487
|
+
plist_set "$x" "CFBundleIdentifier=$pre.$(basename "$x" .appex)"
|
|
488
|
+
done < <(find "$app" -name '*.appex' -type d 2>/dev/null)
|
|
489
|
+
# Watch/<x>.app 自己也是一个要真签的包,id 得跟着主 app 走
|
|
454
490
|
while IFS= read -r x; do
|
|
455
491
|
eid="$(plist_get "$x" CFBundleIdentifier)"
|
|
456
492
|
[ -n "$eid" ] || continue
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
done < <(find "$app/PlugIns" -maxdepth 2 -name '*.appex' -type d 2>/dev/null)
|
|
493
|
+
plist_set "$x" "CFBundleIdentifier=$bid.watchkitapp"
|
|
494
|
+
done < <(find "$app" -path '*/Watch/*.app' -type d 2>/dev/null)
|
|
460
495
|
}
|
|
461
496
|
|
|
462
497
|
cmd_resign() {
|
package/scripts/ipa.ps1
CHANGED
|
@@ -60,8 +60,14 @@ function U32-At($b, $o, $be) {
|
|
|
60
60
|
return [uint32](((($v -band 0xFF) -shl 24) -bor (($v -band 0xFF00) -shl 8) -bor (($v -band 0xFF0000) -shr 8) -bor (($v -band 0xFF000000) -shr 24)))
|
|
61
61
|
}
|
|
62
62
|
function U64-At($b, $o, $be) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
# 大端时前 4 字节是高 32 位;小端时前 4 字节才是低 32 位
|
|
64
|
+
if ($be) {
|
|
65
|
+
$hi = U32-At $b $o $true
|
|
66
|
+
$lo = U32-At $b ($o + 4) $true
|
|
67
|
+
} else {
|
|
68
|
+
$lo = U32-At $b $o $false
|
|
69
|
+
$hi = U32-At $b ($o + 4) $false
|
|
70
|
+
}
|
|
65
71
|
return ([uint64]$hi -shl 32) -bor [uint64]$lo
|
|
66
72
|
}
|
|
67
73
|
|
|
@@ -97,13 +103,14 @@ function Get-SigState($fs, $base) {
|
|
|
97
103
|
if ($sigoff -lt 0) { return '没签' }
|
|
98
104
|
$sb = Read-At $fs $sigoff 12
|
|
99
105
|
if ($sb -eq $null) { return '没签' }
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
# SuperBlob 固定大端(FA DE 0C C0),不跟 slice 的字节序走
|
|
107
|
+
if ((U32-At $sb 0 $true) -ne 4208856256) { return '没签' }
|
|
108
|
+
$cnt = U32-At $sb 4 $true
|
|
102
109
|
if ($cnt -gt 20) { $cnt = 20 }
|
|
103
110
|
$idx = Read-At $fs ($sigoff + 8) ($cnt * 8)
|
|
104
111
|
if ($idx -eq $null) { return '没签' }
|
|
105
112
|
for ($i = 0; $i -lt $cnt; $i++) {
|
|
106
|
-
if ((U32-At $idx ($i * 8) $
|
|
113
|
+
if ((U32-At $idx ($i * 8) $true) -eq 65536) { return '真证书签名(有 CMS)' }
|
|
107
114
|
}
|
|
108
115
|
return 'ad-hoc 伪签名(只有 CodeDirectory)'
|
|
109
116
|
}
|
|
@@ -534,6 +541,10 @@ function Cmd-Build($argv) {
|
|
|
534
541
|
$expectPath = ($pathOpts -contains $a)
|
|
535
542
|
}
|
|
536
543
|
$cmd = $parts -join ' '
|
|
544
|
+
# wsl.exe 默认不把 Windows 的环境变量带进 bash,密码按推荐方式放 env 的话
|
|
545
|
+
# 转发时会变成空串,所以这里显式前置进去
|
|
546
|
+
$wpass = Get-Pass $opt
|
|
547
|
+
if ($wpass) { $cmd = 'IPA_CERT_PASSWORD=' + (Q $wpass) + ' ' + $cmd }
|
|
537
548
|
& wsl.exe bash -lc $cmd
|
|
538
549
|
exit $LASTEXITCODE
|
|
539
550
|
}
|