This repository has been archived by the owner on Mar 13, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 33
666 lines (610 loc) · 29.8 KB
/
build.yml
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
name: Build palera1n
on:
push:
paths:
- 'src/**'
- 'docs/**'
- 'patches/**'
- 'include/**'
- 'Makefile'
- 'CMakeLists.txt'
- '.github/workflows/build.yml'
pull_request:
workflow_dispatch:
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies (packages)
run: |
sudo apt-get -y update
sudo apt-get -y install mandoc make
- name: Build Documentation
run: |
make -j$(nproc) docs
mkdir ready
cp docs/*.html docs/mandoc.css docs/palera1n.1 ready
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
build-darwin:
strategy:
matrix:
include:
- arch: x86_64
gnu_triple: x86_64-apple-darwin
os: macosx
minos: 10.8
- arch: arm64
gnu_triple: aarch64-apple-darwin
os: macosx
minos: 11.0
- arch: arm64
gnu_triple: aarch64-apple-darwin
os: iphoneos
minos: 7.0
runs-on: macos-12
env:
MBEDTLS_VERSION: 3.3.0
READLINE_VERSION: 8.2
SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23
POPT_VERSION: 1.19
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies (packages)
run: |
sudo /usr/local/bin/pip3 install jsonschema jinja2
brew install make autoconf automake pkg-config gnu-sed gettext
sudo rm -rf /usr/local/Frameworks/Python*
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64
sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid
- name: Download dependencies (embedded binaries)
run: |
echo "SDK=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)" >> $GITHUB_ENV
- name: Download dependencies (source code)
run: |
curl -LOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
git clone --depth=1 https://github.com/libimobiledevice/libplist
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
- name: Select correct Xcode
run: |
sudo xcode-select -s /Applications/Xcode_14.2.app
- name: Setup environment
run: |
mkdir sysroot
echo "DESTDIR=$(pwd)/sysroot" >> $GITHUB_ENV
echo "PREFIX=/usr/local" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(pwd)/sysroot/usr/local/lib/pkgconfig" >> $GITHUB_ENV
echo "CONFIGURE_ARGS=--prefix=/usr/local --disable-shared --enable-static --build=x86_64-apple-darwin --host=${{ matrix.gnu_triple }}" >> $GITHUB_ENV
echo "CC=$(xcrun --find cc)" >> $GITHUB_ENV
echo "CXX=$(xcrun --find c++)" >> $GITHUB_ENV
echo "CPP=$(xcrun --find cc) -E" >> $GITHUB_ENV
echo "CFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
echo "CPPFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
echo "CXXFLAGS=-stdlib=libc++ -g -Os -isysroot ${{ env.SDK }} -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
echo "LDFLAGS=-g -Wl,-dead_strip -arch ${{ matrix.arch }} -isysroot ${{ env.SDK }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV
mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
- name: Prepare iPhoneOS environment
if: matrix.os == 'iphoneos'
run: |
echo "FAKE_PLATFORM=2" >> $GITHUB_ENV
echo "FAKE_SDK=7.0" >> $GITHUB_ENV
echo "FAKE_MINOS=7.0" >> $GITHUB_ENV
- name: Prepare headers
if: matrix.os != 'macosx'
run: |
mkdir -p sysroot/{{,System}/Library/Frameworks,/usr/{local/include/{bsm,objc,os/internal,sys,firehose,CoreFoundation,FSEvents,IOKit/kext,libkern,kern,arm,{mach/,}machine,CommonCrypto,Security,CoreSymbolication,Kernel/{kern,IOKit,libkern},rpc,rpcsvc,xpc/private,ktrace,mach-o,dispatch},lib/pkgconfig,/local/lib}}
MACOSX_SYSROOT=$(xcrun -sdk macosx --show-sdk-path)
TARGET_SYSROOT=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)
cp -af ${MACOSX_SYSROOT}/usr/include/{arpa,bsm,hfs,net,xpc,netinet,servers,timeconv.h,launch.h} sysroot/usr/local/include
cp -af ${MACOSX_SYSROOT}/usr/include/objc/objc-runtime.h sysroot/usr/local/include/objc
cp -af ${MACOSX_SYSROOT}/usr/include/libkern/{OSDebug.h,OSKextLib.h,OSReturn.h,OSThermalNotification.h,OSTypes.h,machine} sysroot/usr/local/include/libkern
cp -af ${MACOSX_SYSROOT}/usr/include/kern sysroot/usr/local/include
cp -af ${MACOSX_SYSROOT}/usr/include/sys/{tty*,ptrace,kern*,random,reboot,user,vnode,disk,vmmeter,conf}.h sysroot/usr/local/include/sys
cp -af ${MACOSX_SYSROOT}/System/Library/Frameworks/Kernel.framework/Versions/Current/Headers/sys/disklabel.h sysroot/usr/local/include/sys
cp -af ${MACOSX_SYSROOT}/System/Library/Frameworks/IOKit.framework/Headers/{AppleConvergedIPCKeys.h,IOBSD.h,IOCFBundle.h,IOCFPlugIn.h,IOCFURLAccess.h,IOKitServer.h,IORPC.h,IOSharedLock.h,IOUserServer.h,audio,avc,firewire,graphics,hid,hidsystem,i2c,iokitmig.h,kext,ndrvsupport,network,ps,pwr_mgt,sbp2,scsi,serial,storage,stream,usb,video} sysroot/usr/local/include/IOKit
cp -af ${MACOSX_SYSROOT}/System/Library/Frameworks/Security.framework/Headers/{mds_schema,oidsalg,SecKeychainSearch,certextensions,Authorization,eisl,SecDigestTransform,SecKeychainItem,oidscrl,cssmcspi,CSCommon,cssmaci,SecCode,CMSDecoder,oidscert,SecRequirement,AuthSession,SecReadTransform,oids,cssmconfig,cssmkrapi,SecPolicySearch,SecAccess,cssmtpi,SecACL,SecEncryptTransform,cssmapi,cssmcli,mds,x509defs,oidsbase,SecSignVerifyTransform,cssmspi,cssmkrspi,SecTask,cssmdli,SecAsn1Coder,cssm,SecTrustedApplication,SecCodeHost,SecCustomTransform,oidsattr,SecIdentitySearch,cssmtype,SecAsn1Types,emmtype,SecTransform,SecTrustSettings,SecStaticCode,emmspi,SecTransformReadTransform,SecKeychain,SecDecodeTransform,CodeSigning,AuthorizationPlugin,cssmerr,AuthorizationTags,CMSEncoder,SecEncodeTransform,SecureDownload,SecAsn1Templates,AuthorizationDB,SecCertificateOIDs,cssmapple}.h sysroot/usr/local/include/Security
cp -af ${MACOSX_SYSROOT}/usr/include/{ar,bootstrap,launch,libc,libcharset,localcharset,nlist,NSSystemDirectories,tzfile,vproc}.h sysroot/usr/local/include
cp -af ${MACOSX_SYSROOT}/usr/include/mach/{*.defs,{mach_vm,shared_region}.h} sysroot/usr/local/include/mach
cp -af ${MACOSX_SYSROOT}/usr/include/mach/machine/*.defs sysroot/usr/local/include/mach/machine
cp -af ${MACOSX_SYSROOT}/usr/include/rpc/pmap_clnt.h sysroot/usr/local/include/rpc
cp -af ${MACOSX_SYSROOT}/usr/include/rpcsvc/yp{_prot,clnt}.h sysroot/usr/local/include/rpcsvc
cp -af ${TARGET_SYSROOT}/usr/include/mach/machine/thread_state.h sysroot/usr/local/include/mach/machine
cp -af ${TARGET_SYSROOT}/usr/include/mach/arm sysroot/usr/local/include/mach
cp -af ${MACOSX_SYSROOT}/System/Library/Frameworks/IOKit.framework/Headers/* sysroot/usr/local/include/IOKit
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/stdlib.h > sysroot/usr/local/include/stdlib.h
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/time.h > sysroot/usr/local/include/time.h
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/unistd.h > sysroot/usr/local/include/unistd.h
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/mach/task.h > sysroot/usr/local/include/mach/task.h
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/mach/mach_host.h > sysroot/usr/local/include/mach/mach_host.h
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/ucontext.h > sysroot/usr/local/include/ucontext.h
gsed -E s/'__IOS_PROHIBITED|__TVOS_PROHIBITED|__WATCHOS_PROHIBITED'//g < ${TARGET_SYSROOT}/usr/include/signal.h > sysroot/usr/local/include/signal.h
gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h
- name: Build Mbed TLS
run: |
cd mbedtls-${{ env.MBEDTLS_VERSION }}
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
mkdir build
cd build
SDKROOT="${{ env.SDK }}" cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_C_COMPILER="${{ env.CC }}" \
-DCMAKE_C_FLAGS='${{ env.CFLAGS }}' \
-DCMAKE_FIND_ROOT_PATH="${{ env.DESTDIR }}" \
-DCMAKE_INSTALL_PREFIX="${{ env.PREFIX }}" \
-DMBEDTLS_PYTHON_EXECUTABLE="/usr/local/bin/python3" \
-DENABLE_TESTING=OFF \
-DENABLE_PROGRAMS=OFF \
-DMBEDTLS_FATAL_WARNINGS=OFF \
-DCMAKE_INSTALL_SYSCONFDIR="/etc"
gmake -j$(sysctl -n hw.ncpu) \
SDKROOT="${{ env.SDK }}"
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build readline
run: |
cd readline-${{ env.READLINE_VERSION }}
CC=clang CXX=clang++ ./configure ${{ env.CONFIGURE_ARGS }} ac_cv_type_sig_atomic_t=no
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build S-Lang
run: |
cd slang-${{ env.SLANG_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-x \
--without-pcre \
--without-onig \
--without-z \
--without-png \
--without-iconv
gmake -j$(sysctl -n hw.ncpu) static
gmake -j$(sysctl -n hw.ncpu) install-static DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build popt
run: |
cd popt-popt-${{ env.POPT_VERSION }}-release
autoreconf -fiv
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-libiconv-prefix \
--without-libintl-prefix \
--disable-nls \
--disable-werror
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build newt
run: |
cd newt-${{ env.NEWT_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-readline=gnu \
--without-python \
--without-tcl \
--disable-nls
gmake -j$(sysctl -n hw.ncpu) libnewt.a
mkdir -p ${{ env.DESTDIR }}/usr/local/{lib/pkgconfig,include}
install -m644 libnewt.pc ${{ env.DESTDIR }}/usr/local/lib/pkgconfig
install -m644 libnewt.a ${{ env.DESTDIR }}/usr/local/lib
install -m644 newt.h ${{ env.DESTDIR }}/usr/local/include
cd ..
- name: Build libplist
run: |
cd libplist
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }} --without-cython
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libimobiledevice-glue
run: |
cd libimobiledevice-glue
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }}
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libirecovery
run: |
sudo cp -a sysroot/usr/local/* /usr/local
cd libirecovery
autoreconf -fiv
if [ "${{ matrix.os }}" != "macosx" ]; then
gsed -i '/case kIOUSBTransactionTimeout/d' src/libirecovery.c
fi
./configure ${{ env.CONFIGURE_ARGS }}
echo -e 'all:\ninstall:' > tools/Makefile
make -j$(sysctl -n hw.ncpu) LIBS="-lncurses"
make -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
install -m644 src/.libs/libirecovery-1.0.a ${{ env.DESTDIR }}${{ env.PREFIX }}/lib
cd ..
- name: Build libusbmuxd
run: |
cd libusbmuxd
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }}
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libimobiledevice
run: |
cd libimobiledevice
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }} --with-mbedtls --enable-debug
echo -e 'all:\ninstall:' > tools/Makefile
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build palera1n
run: |
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.dylib' -delete
find dep_root -name '*.la' -delete
gmake -j$(sysctl -n hw.ncpu)
mkdir -p ready
mv src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
dsymutil palera1n-${{ matrix.os }}-${{ matrix.arch }}
strip palera1n-${{ matrix.os }}-${{ matrix.arch }}
if [ "${{ matrix.os }}" == "macosx" ]; then
ldid -S palera1n-${{ matrix.os }}-${{ matrix.arch }}
else
ldid -Ssrc/usb.xml palera1n-${{ matrix.os }}-${{ matrix.arch }}
fi
mkdir -p ready
tar -zcf ready/dep_root-${{ matrix.os }}-${{ matrix.arch }}.tgz dep_root
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} build
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}
path: palera1n-${{ matrix.os }}-${{ matrix.arch }}
retention-days: 1
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} debug symbols
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
path: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
retention-days: 1
darwin-dist:
if: ${{ github.event_name != 'pull_request' }}
runs-on: macos-latest
needs: build-darwin
steps:
- name: Download all Darwin artifacts
uses: actions/download-artifact@v3
- name: Prepare artifact
run: |
find .
lipo -create -arch arm64 ./palera1n-macosx-arm64/palera1n-macosx-arm64 -arch x86_64 ./palera1n-macosx-x86_64/palera1n-macosx-x86_64 -output palera1n-macos
mkdir -p palera1n-macos.dSYM/Contents/Resources/DWARF
cp ./palera1n-macosx-x86_64.dSYM/Contents/Info.plist palera1n-macos.dSYM/Contents
lipo -create -arch arm64 palera1n-macosx-arm64.dSYM/Contents/Resources/DWARF/palera1n-macosx-arm64 -arch x86_64 palera1n-macosx-x86_64.dSYM/Contents/Resources/DWARF/palera1n-macosx-x86_64 -output palera1n-macos.dSYM/Contents/Resources/DWARF/palera1n-macos
mkdir ready
cp palera1n-macos ready/palera1n-macos-universal
cp ./palera1n-macosx-x86_64/palera1n-macosx-x86_64 ready/palera1n-macos-x86_64
cp ./palera1n-macosx-arm64/palera1n-macosx-arm64 ready/palera1n-macos-arm64
cp ./palera1n-iphoneos-arm64/palera1n-iphoneos-arm64 ready/palera1n-ios
zip -r9 ready/palera1n-ios.dSYM.zip palera1n-iphoneos-arm64.dSYM
zip -r9 ready/palera1n-macos.dSYM.zip palera1n-macos.dSYM
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'
build-Linux:
strategy:
matrix:
triple:
- i486-linux-musl
- x86_64-linux-musl
- armel-linux-musleabi
- aarch64-linux-musl
runs-on: ubuntu-latest
env:
MBEDTLS_VERSION: 3.3.0
LIBUSB_VERSION: 1.0.26
READLINE_VERSION: 8.2
SLANG_VERSION: 2.3.3
NEWT_VERSION: 0.52.23
GPM_VERSION: 1.20.7
POPT_VERSION: 1.19
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install build dependencies (packages)
run: |
sudo apt-get remove -y libssl-dev libreadline-dev
sudo apt-get install -y pkg-config autoconf automake autopoint
sudo pip3 install jsonschema jinja2
- name: Download toolchain checksum
run: |
curl -LO https://musl.cc/SHA512SUMS
echo "TOOLCHAIN_CHECKSUM="$(grep ${{ matrix.triple }}-cross.tgz SHA512SUMS | cut -d' ' -f1) >> $GITHUB_ENV
- name: Download toolchain (cached)
id: toolchain_cache
uses: actions/cache@v3
with:
path: ${{ matrix.triple }}-cross.tgz
key: ${{ matrix.triple }}-${{ env.TOOLCHAIN_CHECKSUM }}-toolchain
- name: Download toolchain
if: steps.toolchain_cache.outputs.cache-hit != 'true'
run: |
curl -LO https://musl.cc/${{ matrix.triple }}-cross.tgz
- name: Setup environment
run: |
tar -xf ${{ matrix.triple }}-cross.tgz
mkdir sysroot
echo "$(pwd)/${{ matrix.triple }}-cross/bin" >> $GITHUB_PATH
case ${{ matrix.triple }} in
i486-linux-musl)
echo "CHECKRA1N_NAME=linux-x86" >> $GITHUB_ENV
;;
x86_64-linux-musl)
echo "CHECKRA1N_NAME=linux-x86_64" >> $GITHUB_ENV
;;
armel-linux-musleabi)
echo "CHECKRA1N_NAME=linux-armel" >> $GITHUB_ENV
;;
aarch64-linux-musl)
echo "CHECKRA1N_NAME=linux-arm64" >> $GITHUB_ENV
;;
esac
echo "PKG_CONFIG_PATH=$(pwd)/sysroot/usr/local/lib/pkgconfig" >> $GITHUB_ENV
echo "CFLAGS=-g -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
echo "CXXFLAGS=-g -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
echo "LDFLAGS=-g -Wl,--gc-sections -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
echo "INSTALL=$(command -v install) --strip-program=${{ matrix.triple }}-strip" >> $GITHUB_ENV
echo "DESTDIR=$(pwd)/sysroot" >> $GITHUB_ENV
echo "PREFIX=/usr/local" >> $GITHUB_ENV
echo "CONFIGURE_ARGS=--build=x86_64-linux-gnu --host=${{ matrix.triple }} --prefix=/usr/local --disable-shared --enable-static" >> $GITHUB_ENV
echo "CROSS_COMPILE=${{ matrix.triple }}-" >> $GITHUB_ENV
mkdir -p $(pwd)/sysroot/usr/local/lib
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
- name: Download dependencies (source code)
run: |
curl -LOOOOOOO \
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
https://github.com/telmich/gpm/archive/refs/tags/${{ env.GPM_VERSION }}.tar.gz \
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
tar -xf ${{ env.GPM_VERSION }}.tar.gz
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
git clone --depth=1 https://github.com/libimobiledevice/libplist
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
- name: Build Mbed TLS
run: |
cd mbedtls-${{ env.MBEDTLS_VERSION }}
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
mkdir build
cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=$(echo ${{ matrix.triple }} | cut -d- -f1) \
-DCMAKE_C_COMPILER='${{ env.CROSS_COMPILE }}gcc' \
-DCMAKE_C_FLAGS='${{ env.CFLAGS }}' \
-DCMAKE_CXX_FLAGS='${{ env.CXXFLAGS }}' \
-DCMAKE_FIND_ROOT_PATH="${{ env.DESTDIR }}" \
-DCMAKE_INSTALL_PREFIX="${{ env.PREFIX }}" \
-DENABLE_TESTING=OFF \
-DENABLE_PROGRAMS=OFF \
-DCMAKE_INSTALL_SYSCONFDIR="/etc"
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libusb
run: |
cd libusb-${{ env.LIBUSB_VERSION }}
./configure ${{ env.CONFIGURE_ARGS }} --disable-udev
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build readline
run: |
cd readline-${{ env.READLINE_VERSION }}
./configure ${{ env.CONFIGURE_ARGS }}
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build S-Lang
run: |
cd slang-${{ env.SLANG_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-x \
--without-pcre \
--without-onig \
--without-z \
--without-png \
--without-iconv
gmake -j$(sysctl -n hw.ncpu) static
gmake -j$(sysctl -n hw.ncpu) install-static DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build GPM
run: |
cd gpm-${{ env.GPM_VERSION }}
cat ../patches/gpm/*.patch | patch -sN -d . -p1
./autogen.sh
./configure \
${{ env.CONFIGURE_ARGS }}
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build popt
run: |
cd popt-popt-${{ env.POPT_VERSION }}-release
autoreconf -fiv
./configure \
${{ env.CONFIGURE_ARGS }} \
--without-libiconv-prefix \
--without-libintl-prefix \
--disable-nls \
--disable-werror
gmake -j$(sysctl -n hw.ncpu)
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build newt
run: |
cd newt-${{ env.NEWT_VERSION }}
./configure \
${{ env.CONFIGURE_ARGS }} \
--with-readline=gnu \
--without-python \
--without-tcl \
--disable-nls \
--with-gpm-support
gmake -j$(sysctl -n hw.ncpu) libnewt.a
mkdir -p ${{ env.DESTDIR }}/usr/local/{lib/pkgconfig,include}
install -m644 libnewt.pc ${{ env.DESTDIR }}/usr/local/lib/pkgconfig
install -m644 libnewt.a ${{ env.DESTDIR }}/usr/local/lib
install -m644 newt.h ${{ env.DESTDIR }}/usr/local/include
cd ..
- name: Build libplist
run: |
cd libplist
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }} --without-cython
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libimobiledevice-glue
run: |
cd libimobiledevice-glue
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }}
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libirecovery (sorta)
run: |
sudo mv /usr/local /usr/local.bak
sudo ln -s ${{ env.DESTDIR }}${{ env.PREFIX }} /usr/local
cd libirecovery
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }}
echo -e 'all:\ninstall:' > tools/Makefile
make -ij$(nproc)
make -ij$(nproc) install DESTDIR=${{ env.DESTDIR }}
install -m644 src/.libs/libirecovery-1.0.a ${{ env.DESTDIR }}${{ env.PREFIX }}/lib
cd ..
- name: Build libusbmuxd
run: |
cd libusbmuxd
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }}
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
- name: Build libimobiledevice
run: |
cd libimobiledevice
autoreconf -fiv
./configure ${{ env.CONFIGURE_ARGS }} --with-mbedtls --enable-debug
echo -e 'all:\ninstall:' > tools/Makefile
make -j$(nproc)
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
cd ..
sudo rm /usr/local
sudo mv /usr/local.bak /usr/local
- name: Build palera1n
run: |
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
find dep_root -name '*.so' -delete
find dep_root -name '*.la' -delete
CC="${{ matrix.triple }}-gcc" make -j$(nproc)
- name: Seperate debug symbols
run: |
${{ matrix.triple }}-objcopy --only-keep-debug src/palera1n palera1n.debug
${{ matrix.triple }}-strip --strip-debug --strip-unneeded src/palera1n
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug src/palera1n
chmod -x palera1n.debug
- name: Prepare artifact
run: |
mkdir ready
mv palera1n.debug ready/palera1n-${{ env.CHECKRA1N_NAME }}.debug
mv src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
tar -zcf ready/dep_root_${{ matrix.triple }}.tgz dep_root
- name: Upload artifact
if: ${{ github.event_name != 'pull_request' }}
uses: wangyucode/[email protected]
with:
host: ${{ secrets.NICKCHAN_FTP_HOST }}
port: ${{ secrets.NICKCHAN_FTP_PORT }}
username: palera1n
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
forceUpload: true
dryRun: false
localDir: 'ready/'
remoteDir: '/palera1n/artifacts/c-rewrite'