generated from DevOpenWRT-Router/Action_OpenWRT_AutoBuild_Linksys_Devices
-
Notifications
You must be signed in to change notification settings - Fork 4
1076 lines (1066 loc) · 46.3 KB
/
build-openwrt.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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
################################################################################
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com> #
# #
# Updated: 04/04/2022 Eliminater74 #
# #
# This is free software, licensed under the MIT License. #
# See /LICENSE for more information. #
# #
# https://github.com/P3TERX/Actions-OpenWrt #
# Description: Build OpenWrt using GitHub Actions #
# #
################################################################################
# MAIN BUILD CONTROL SECTION: DO NOT RUN THIS ACTION DIRECT, USE Builds: #
################################################################################
name: Build OpenWRT firmware
'on':
repository_dispatch: null
# workflow_dispatch:
# inputs:
# config_file:
# description: >
# '[0] wrt32x: default [1] wrt32x: eliminater [2] e8450/rt3200'
# required: true
# default: '0'
# ISP:
# description: >
# '[0] default [1] masmovil'
# required: true
# default: '0'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
### --------------------------- ###
HARDWARE_ID: '${{ github.event.client_payload.message.HARDWARE_ID }}'
HARDWARE_DEVICE: '${{ github.event.client_payload.message.HARDWARE_DEVICE }}'
CLONE_URL: https://github.com/openwrt/openwrt.git
CLONE_BRANCH: master
FEEDS_CONF: feeds.conf.default
FUNCTIONS_SH: functions.sh
DEPENDENCY_sh: dependency.sh
FETCHPACKAGES_SH: fetch_packages.sh
CREATE_ACL_SH: create_acl_for_luci.sh
BEFORE_BUILD: before_build.sh
AFTER_BUILD: after_build.sh
GITHUB_RUN: github_push.sh
EXT_INIT_ENV: environment.sh
DEVICE_NAME: ''
### --------------------------- ###
### [ CACHE SETTINGS ] ###
### --------------------------- ###
USE_CACHEWRTBUILD: true
RESTORE_CCACHE_CACHE: true
RESTORE_FEEDS_CACHE: true
RESTORE_STAGING_CACHE: true
RESTORE_DL_CACHE: true
RESTORE_BUILD_CACHE: true
RESTORE_BUILD_DIR_TOOLCHAIN_CACHE: false
RESTORE_BUILD_DIR_TARGET_CACHE: false
RESTORE_BUILD_DIR_HOST_CACHE: false
RESTORE_BUILD_DIR_HOSTPKG_CACHE: false
RESTORE_PACKAGE_CACHE: false
### --------------------------- ###
CLEANUP_ENVIROMENT: true
RESET_OPENWRT_COMMIT: false
INSTALL_LLVM: false
LOAD_FUNCTIONS: true
BOOTSTRAP_START: false
PRINT_FAILLOGS: true
VIEW_BUILD_LOGS: true
SET_BUILDKEY: false
remove_languages: true
USE_KMODS_SCRIPT: true
USE_FILES: true
USE_OpenWrtScripts: true
USE_CUST_THEMES: true
USE_CUSTOM_CONFIGURATION: true
USE_OPENWRT_PATCHES: true
USE_PR_OPENWRT_PATCHES_NEW: false
USE_PR_OPENWRT_PATCHES_PACKAGES_NEW: false
USE_PR_OPENWRT_PATCHES: false
USE_PR_OPENWRT_PATCHES_PACKAGES: false
USE_DEVOPENWRT: true
USE_FETCH_PACKAGES: true
USE_CACHE: true
USE_SMART_CHMOD: true
SSH_TMATE: false
SSH_NGROK: false
EXTERNAL_BUILD_USER_DOMAIN_SETUP: true
EXTERNAL_PRE-KERNEL_CONFIGURATION: true
EXTERNAL_CCACHE_SETUP: true
EXTERNAL_CHANGE_DEFAULT_LUCI_THEME: false
PERSONAL_PACKAGES: true
UNSORTED_PACKAGES: true
LEAN_PACKAGES: true
SIRPDBOY_PACKAGES: true
HELMIAU_PACKAGES: true
TEST_PACKAGES: true
## Disabling any of these will still build said section, just wont be debugable showing. Enabling them will add, more time to final completion.
BUILD_KMODS: true
SIGN_PACKAGES: false
BUILD_PACKAGES: true
INSTALL_PACKAGES: true
INDEX_PACKAGES: true
KMODS: true
ACL_LUCI: true
GITLOGA: true
GITLOGB: true
RUN_BEFORE_BUILD: true
RUN_AFTER_BUILD: true
RUN_GITHUB_PUSH: false
DEFAULT_THEME_CHANGE: false
CHANGE_DEFAULT_BANNER: false
DELETE_DUPLICATES: false
### --------------------------- ###
UPLOAD_BUILD_LOGS: true
UPLOAD_KMODS: true
UPLOAD_PACKAGES: true
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TARGZIP_PACKAGES: true
### --------------------------- ###
### [ GITHUB PUSH ENV ] ###
SOURCE_DIRECTORY_A: '${{ github.event.client_payload.message.SOURCE_DIRECTORY_A }}'
SRC_DIRECTORY_B: '${{ github.event.client_payload.message.SOURCE_DIRECTORY_B }}'
SOURCE_DIRECTORY_B: $SRC_DIRECTORY_B/$KMOD_DIR
DESTINATION_GITHUB_USERNAME: DevOpenWRT-Router
DESTINATION_REPOSITORY_NAME: Linksys_OpenWRT_Releases
USER_EMAIL: [email protected]
USER_NAME: BuildBot2021
DESTINATION_REPOSITORY_USERNAME: DevOpenWRT-Router
TARGET_BRANCH: main
COMMIT_MESSAGE: 'Updated: $D'
TARGET_DIRECTORY_A: packages
TARGET_DIRECTORY_B: kmods/$KMOD_DIR
### --------------------------- ###
TZ: Europe/Madrid
ARQUITECTURA: '${{ github.event.client_payload.message.ARQUITECTURA }}'
config_file: '${{ github.event.client_payload.message.config_file }}'
ISP: '${{ github.event.client_payload.message.ISP }}'
### ----------------------------------------------------------------- ###
### ----------------------------------------------------------------- ###
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@main
### ----------------------------------------------------------------- ###
- name: Build Server Configuration (Information)
env:
DEBIAN_FRONTEND: noninteractive
run: |
echo -e "----------------------------[System Distribution]------------------------------------\n"
[ -f /etc/issue ] && cat /etc/issue
echo -e "----------------------------[WARNING]------------------------------------------------\n"
echo "Warning⚠"
echo "If the performance of the allocated server is insufficient, be sure to cancel it in time and run it again!"
echo "It is known that the compilation is successful CPU model: 8370C, 8171M, E5-2673"
echo "Known underperformance CPU model: 8272CL"
echo -e "----------------------------[CPU info]-----------------------------------------------\n"
echo "CPU physical count: $(cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l)"
echo -e "CPU core and version information: $(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) \n"
echo -e "-----------------------------[Memory information]-------------------------------------"
echo "Details of installed memory:"
sudo lshw -short -C memory | grep GiB
echo -e "\n"
echo -e "-----------------------------[Memory Free]--------------------------------------------"
free -h
echo -e "------------------------------[HDD information]----------------------------------------"
echo -e "Number of hard disks: $(ls /dev/sd* | grep -v [1-9] | wc -l) \n"
echo "HDD details:"
df -Th
echo -e "-----------------------------[System Resource Limits]---------------------------------\n"
ulimit -a
### ----------------------------------------------------------------- ###
- name: HARDWARE_DEVICE
run: |
echo "Device: $HARDWARE_DEVICE"
### ----------------------------------------------------------------- ###
- name: Cleanup Environment
if: env.CLEANUP_ENVIROMENT == 'true' && !cancelled()
uses: rokibhasansagar/slimhub_actions@main
### ----------------------------------------------------------------- ###
- name: Initializing environment
if: (!cancelled())
run: |
chmod +x scripts/$DEPENDENCY_sh
source scripts/$DEPENDENCY_sh
### ----------------------------------------------------------------- ###
- name: Install LLVM
if: env.INSTALL_LLVM == 'true' && !cancelled()
run: |
sudo -E bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
### ----------------------------------------------------------------- ###
- name: Get current date
id: date
run: |
echo "::set-output name=date::$(date +'%s')"
# echo "{date}={$(date +'%s')}" >> $GITHUB_OUTPUT
### ----------------------------------------------------------------- ###
- name: Clone OpenWRT source code
working-directory: /workdir
run: |
df -hT $PWD
URL=$CLONE_URL
BRANCH=$CLONE_BRANCH
git clone "$URL" -b "$BRANCH" openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
### ----------------------------------------------------------------- ###
- name: Set build key
working-directory: '/workdir/openwrt'
if: env.SET_BUILDKEY == 'true' && !cancelled()
run: |
echo -e "${{ secrets.SNAPSHOT_SECKEY }}" > "key-build"
echo -e "${{ secrets.SNAPSHOT_PUBKEY }}" > "key-build.pub"
### ----------------------------------------------------------------- ###
- name: Check Main space usage
if: (!cancelled())
run: |
cd $GITHUB_WORKSPACE
echo "=============================================="
echo "Main Space usage:"
echo "=============================================="
df -hT
echo "=============================================="
du -h --max-depth=2 ./
echo "=============================================="
### ----------------------------------------------------------------- ###
- name: Load Functions into Settings
if: env.LOAD_FUNCTIONS == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
### ----------------------------------------------------------------- ###
- name: Run BootStrap (Error Handler)
if: env.BOOTSTRAP_START == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH BOOTSTRAP_START
### ----------------------------------------------------------------- ###
- name: Start SSH via tmate
uses: P3TERX/ssh2actions@main
if: env.SSH_TMATE == 'true' && !cancelled()
# Send connection info to Telegram (optional)
# You can find related documents here: https://core.telegram.org/bots
env:
TELEGRAM_BOT_TOKEN: '${{ secrets.TELEGRAM_BOT_TOKEN }}'
TELEGRAM_CHAT_ID: '${{ secrets.TELEGRAM_CHAT_ID }}'
### ----------------------------------------------------------------- ###
- name: Start SSH via ngrok
uses: P3TERX/ssh2actions@main
if: env.SSH_NGROK == 'true' && !cancelled()
with:
mode: ngrok
env:
# After sign up on the https://ngrok.com
# You can find this token here: https://dashboard.ngrok.com/auth/your-authtoken
NGROK_TOKEN: '${{ secrets.NGROK_TOKEN }}'
# ngrok server region [us, eu, au, ap, sa, jp, in] (optional, default: us)
# You can find this server region here: https://ngrok.com/docs#global-locations
NGROK_REGION: us
# This password you will use when authorizing via SSH
SSH_PASSWORD: '${{ secrets.SSH_PASSWORD }}'
# Send connection info to Telegram (optional)
# You can find related documents here: https://core.telegram.org/bots
TELEGRAM_BOT_TOKEN: '${{ secrets.TELEGRAM_BOT_TOKEN }}'
TELEGRAM_CHAT_ID: '${{ secrets.TELEGRAM_CHAT_ID }}'
### ----------------------------------------------------------------- ###
- name: Before Build
if: env.RUN_BEFORE_BUILD == 'true' && !cancelled()
run: |
chmod +x scripts/$BEFORE_BUILD
/bin/bash ${GITHUB_WORKSPACE}/scripts/before_build.sh
### ----------------------------------------------------------------- ###
- name: Change Default Banner
if: env.CHANGE_DEFAULT_BANNER == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
CHANGE_DEFAULT_BANNER
### ----------------------------------------------------------------- ###
- name: Reset Commit History To
if: env.RESET_OPENWRT_COMMIT == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
RESET_COMMIT "771ea6f2e3868b208b5261ae676160d5ef6544e8"
### ----------------------------------------------------------------- ###
- name: Current Commit Before Feeds/Patches
if: env.GITLOGA == 'true' && !cancelled()
run: |
cd openwrt
git log --pretty=oneline -n 1
### ----------------------------------------------------------------- ###
- name: run (feeds.conf.default) feeds
run: |
[ -e configs/$FEEDS_CONF ] && mv configs/$FEEDS_CONF openwrt/feeds.conf.default
### ----------------------------------------------------------------- ###
- name: Set LUCI Source
id: setLuci
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
SET_LUCI_SOURCE
### ----------------------------------------------------------------- ###
- name: Load fetch_packages.sh
if: env.USE_FETCH_PACKAGES == 'true' && !cancelled()
run: |
chmod +x scripts/$FETCHPACKAGES_SH
cd openwrt
$GITHUB_WORKSPACE/scripts/$FETCHPACKAGES_SH
### ----------------------------------------------------------------- ###
- name: Delete Duplicate Packages (RMLINT)
id: PackagesRMLINT
continue-on-error: true
if: env.DELETE_DUPLICATES == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
DELETE_DUPLICATES
### ----------------------------------------------------------------- ###
- name: Look inside package Directory
if: (!cancelled())
run: |
cd $GITHUB_WORKSPACE/openwrt
echo "=============================================="
echo "Main Space usage:"
echo "=============================================="
df -hT
echo "=============================================="
du -h --max-depth=3 ./package
echo "=============================================="
### ----------------------------------------------------------------- ###
- name: Update feeds Package
run: |
file=./scripts/data/feeds_update.txt
while read -r line; do
cd openwrt && ./scripts/feeds update $line
done < "$file"
### ----------------------------------------------------------------- ###
- name: Install feeds Package
run: |
file=./scripts/data/feeds_install.txt
while read -r line; do
cd openwrt && ./scripts/feeds install $line
done < "$file"
### ----------------------------------------------------------------- ###
- name: Uninstall feeds Package
run: |
file=./scripts/data/feeds_uninstall.txt
while read -r line; do
cd openwrt && ./scripts/feeds uninstall $line
done < "$file"
### ----------------------------------------------------------------- ###
- name: Developer (English language Only)
id: po-english
continue-on-error: true
if: env.remove_languages == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
REMOVE_LANGUAGES
### ----------------------------------------------------------------- ###
- name: Run Custom OpenWRT Patches
id: COP
continue-on-error: true
if: env.USE_OPENWRT_PATCHES == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
if [[ $HARDWARE_DEVICE == "e8450" ]]; then
echo "Nothing to do here for e8450/rt3200 (without custom patches)."
else
APPLY_PATCHES
fi
### ----------------------------------------------------------------- ###
- name: Pull Request OpenWRT Patches (OpenWRT)
id: PROP
continue-on-error: true
if: env.USE_PR_OPENWRT_PATCHES == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
APPLY_PR_PATCHES
### ----------------------------------------------------------------- ###
- name: Pull Request OpenWRT Packages Patches (Packages)
id: PROPP
continue-on-error: true
if: env.USE_PR_OPENWRT_PATCHES_PACKAGES == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
APPLY_PR_PATCHES_PACKAGES
### ----------------------------------------------------------------- ###
- name: Current Commit After Feeds/Patches
if: env.GITLOGB == 'true' && !cancelled()
run: |
echo "openwrt:"
cd openwrt
git log --pretty=oneline -n 1
echo "openwrt/feeds/packages"
cd "$GITHUB_WORKSPACE"/openwrt/feeds/packages
git log --pretty=oneline -n 1
cd "$GITHUB_WORKSPACE"/openwrt
### ----------------------------------------------------------------- ###
- name: Preparing (FILES)
if: env.USE_FILES == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
FILES_CHMOD
if [[ $ISP == "none" ]]; then
rm -f files/etc/config/network
echo "ISP_NONE choosed so network config file deleted"
fi
### ----------------------------------------------------------------- ###
# - name: Preparing (OpenWrtScripts)
# if: env.USE_OpenWrtScripts == 'true' && !cancelled()
# run: |
# chmod +x scripts/$FUNCTIONS_SH
# source scripts/$FUNCTIONS_SH
# cd openwrt
# FILES_OpenWrtScripts
### ----------------------------------------------------------------- ###
- name: Copy (.config)
run: |
[ -e configs/$config_file ] && mv configs/$config_file openwrt/.config
### ----------------------------------------------------------------- ###
- name: Smart Chmod
working-directory: '/workdir/openwrt'
if: env.USE_SMART_CHMOD == 'true' && !cancelled()
run: |
chmod +x "$GITHUB_WORKSPACE"/scripts/$FUNCTIONS_SH
source "$GITHUB_WORKSPACE"/scripts/$FUNCTIONS_SH
SMART_CHMOD
### ----------------------------------------------------------------- ###
- name: Cache Key Get/Check
working-directory: '/workdir/openwrt'
run: |
export cache_toolchain=$(git log --pretty=tformat:"%h" -n1 tools toolchain)
export cache_feeds=$(git log --pretty=tformat:"%h" -n1 feeds)
export cache_package=$(git log --pretty=tformat:"%h" -n1 package)
export cache_target=$(git log --pretty=tformat:"%h" -n1 target)
export cache_staging_dir=$(git log --pretty=tformat:"%h" -n1 staging_dir)
echo "cache_toolchain=$cache_toolchain" >>"$GITHUB_ENV"
echo "cache_feeds=$cache_feeds" >>"$GITHUB_ENV"
echo "cache_package=$cache_package" >>"$GITHUB_ENV"
echo "cache_target=$cache_target" >>"$GITHUB_ENV"
echo "cache_staging_dir=$cache_staging_dir" >>"$GITHUB_ENV"
### ----------------------------------------------------------------- ###
- name: Cache Acceleration (Secondary compilation of the same model with the same source code is valid within 7 days, and only one source code cache is retained each time)
uses: DevOpenWRT-Router/Cache-OpenWRT-Builds@main
if: env.USE_CACHEWRTBUILD == 'true' && !cancelled()
with:
ccache: 'true'
toolchain: 'true'
skip: 'false'
clean: '${{ contains(github.event.action, ''nocache'') }}'
prefix: '${{ github.workspace }}/openwrt'
### ----------------------------------------------------------------- ###
- name: 'Restore feeds from cache'
id: feeds-cache
uses: actions/cache@v3
if: env.RESTORE_FEEDS_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'feeds-cache'
with:
path: |
${{ github.workspace }}/openwrt/feeds/packages
${{ github.workspace }}/openwrt/feeds/luci
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore build Directory from cache'
id: build-cache
uses: actions/cache@v3
if: env.RESTORE_BUILD_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'build-cache'
with:
path: ${{ github.workspace }}/openwrt/build_dir
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore staging Directory from cache'
id: staging-cache
uses: actions/cache@v3
if: env.RESTORE_STAGING_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'staging-cache'
with:
path: ${{ github.workspace }}/openwrt/staging_dir
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore package Directory from cache'
id: package-cache
uses: actions/cache@v3
if: env.RESTORE_PACKAGE_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'package-cache'
with:
path: ${{ github.workspace }}/openwrt/package
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore downloads Directory from cache'
id: dl-cache
uses: actions/cache@v3
if: env.RESTORE_DL_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'dl-cache'
with:
path: ${{ github.workspace }}/openwrt/dl
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore build_dir/toolchain Directory from cache'
id: build_dir_toolchain-cache
uses: actions/cache@v3
if: env.RESTORE_BUILD_DIR_TOOLCHAIN_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'build_dir_toolchain-cache'
with:
path: ${{ github.workspace }}/openwrt/build_dir/toolchain-*
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore build_dir/target Directory from cache'
id: build_dir_target-cache
uses: actions/cache@v3
if: env.RESTORE_BUILD_DIR_TARGET_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'build_dir_target-cache'
with:
path: ${{ github.workspace }}/openwrt/build_dir/target-*
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore build_dir/host Directory from cache'
id: build_dir_host-cache
uses: actions/cache@v3
if: env.RESTORE_BUILD_DIR_HOST_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'build_dir_host-cache'
with:
path: ${{ github.workspace }}/openwrt/build_dir/host
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore build_dir/hostpkg Directory from cache'
id: build_dir_hostpkg-cache
uses: actions/cache@v3
if: env.RESTORE_BUILD_DIR_HOSTPKG_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'build_dir_hostpkg-cache'
with:
path: ${{ github.workspace }}/openwrt/build_dir/hostpkg
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: 'Restore .ccache from cache'
id: ccache-cache
uses: actions/cache@v3
if: env.RESTORE_CCACHE_CACHE == 'true' && !cancelled()
env:
CACHE_NAME: 'ccache-cache'
with:
path: ${{ github.workspace }}/openwrt/.ccache
key: ${{ env.CACHE_NAME }}-${{ runner.os }}-${{ steps.date.outputs.date }}
### ----------------------------------------------------------------- ###
- name: Setup cache for OpenWRT (ccache)
id: ccache
continue-on-error: true
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
CCACHE_SETUP
ccache -s
### ----------------------------------------------------------------- ###
- name: Change Build user/Domain
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
BUILD_USER_DOMAIN
### ----------------------------------------------------------------- ###
- name: Pre Defconfig Addons
run: |
chmod +x scripts/$FUNCTIONS_SH
# NO LO VEO NECESARIO, LA FUNCION AÑADE VALORES A .CONFIG QUE POR DEFECTO YA CONSIDERO
# source scripts/$FUNCTIONS_SH
# cd openwrt
# if [[ $HARDWARE_DEVICE == "e8450" ]]; then
# PRE_DEFCONFIG_ADDONS_NONCORTEX
# else
# PRE_DEFCONFIG_ADDONS
# fi
### ----------------------------------------------------------------- ###
- name: CCACHE - Setup .config to use cache
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
if [[ $HARDWARE_DEVICE == "e8450" ]]; then
echo "Nothing to do here for e8450/rt3200 (without ccache)."
else
CCACHE_SETUP
fi
### ----------------------------------------------------------------- ###
- name: Change Default theme Settings
if: env.DEFAULT_THEME_CHANGE == 'true' && !cancelled()
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
DEFAULT_THEME_CHANGE
### ----------------------------------------------------------------- ###
- name: Add ACL
if: env.ACL_LUCI == 'true' && !cancelled()
run: |
chmod +x scripts/$CREATE_ACL_SH
cd openwrt
$GITHUB_WORKSPACE/scripts/$CREATE_ACL_SH -a
### ----------------------------------------------------------------- ###
# EL ARCHIVO CONFIG UTILIZADO ES COMPLETO, NO VEO SENTIDO PARA DEFCONFIG
# OJO, POSIBLEMENTE UTIL CON COMPILACIONES SOBRE UN .CONFIG "VIEJO"
# - name: Populating .config
# id: config
# run: |
# cd openwrt
# make defconfig
### ----------------------------------------------------------------- ###
- name: Setup For Compiling
id: setup
run: |
echo -e "$(nproc) Threads to compile with."
echo -e "Creating (logs) Directory:"
cd openwrt
mkdir -p logs
### ----------------------------------------------------------------- ###
- name: Make Download
id: makedownload
run: |
cd openwrt
#make download -j50
make -j50 download
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
### ----------------------------------------------------------------- ###
- name: Building and installing GNU tar
id: GNUTAR
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make tools/tar/compile -j${make_process} V=s
### ----------------------------------------------------------------- ###
- name: Building and installing tools
id: maketools
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make tools/install -j${make_process} V=s
### ----------------------------------------------------------------- ###
- name: Building and installing toolchain
id: maketoolchain
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make toolchain/install -j${make_process} V=s
### ----------------------------------------------------------------- ###
- name: Building kmods
id: makekmods
if: env.BUILD_KMODS == 'true' && !cancelled()
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make target/compile -j${make_process} V=s
### ----------------------------------------------------------------- ###
- name: Building packages
id: makepackages
if: env.BUILD_PACKAGES == 'true' && !cancelled()
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make package/compile -j${make_process} || make package/compile -j${make_process} V=s 2>&1 | tee logs/build.log | grep -i -E "^make.*(error|[12345]...Entering directory)"
### ----------------------------------------------------------------- ###
- name: Installing packages
id: installpackages
if: env.INSTALL_PACKAGES == 'true' && !cancelled()
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make package/install -j${make_process} || make package/install -j${make_process} V=s 2>&1 | tee logs/build.log | grep -i -E "^make.*(error|[12345]...Entering directory)"
### ----------------------------------------------------------------- ###
- name: Indexing packages
id: indexingpackages
if: env.INDEX_PACKAGES == 'true' && !cancelled()
run: |
df -h
cd openwrt
let make_process=$(nproc)+2
make package/index -j${make_process} CONFIG_SIGNED_PACKAGES= || make package/index -j${make_process} CONFIG_SIGNED_PACKAGES= V=s 2>&1 | tee logs/build.log | grep -i -E "^make.*(error|[12345]...Entering directory)"
### ----------------------------------------------------------------- ###
- name: Build Firmware (OpenWRT)
id: compile
continue-on-error: true
run: |
cd openwrt
echo -e "$(nproc) thread compile"
let Make_Process=$(nproc)+2
make -j${Make_Process} target/install || make -j${Make_Process} target/install V=s
echo $?
echo "::set-output name=status::success"
# echo "{status}={success}" >> $GITHUB_OUTPUT
### --------------------------- ###
- name: If Error (Build Firmware)
uses: actions/upload-artifact@main
if: steps.compile.outcome == 'failure'
&& env.UPLOAD_BUILD_LOGS == 'true'
with:
name: 'OpenWrt_logs${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'
path: openwrt/logs/
### ----------------------------------------------------------------- ###
- name: Generate Buildinfo (OpenWRT)
id: buildinfo
continue-on-error: true
run: |
cd openwrt
echo -e "$(nproc) thread compile"
let Make_Process=$(nproc)+2
make buildinfo V=s
echo $?
echo "::set-output name=status::success"
# echo "{status}={success}" >> $GITHUB_OUTPUT
### --------------------------- ###
- name: If Error (Generate Buildinfo)
uses: actions/upload-artifact@main
if: steps.buildinfo.outcome == 'failure'
&& env.UPLOAD_BUILD_LOGS == 'true'
with:
name: 'OpenWrt_logs${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'
path: openwrt/logs/
### ----------------------------------------------------------------- ###
- name: Generate JSON Overview (OpenWRT)
id: overview
continue-on-error: true
run: |
cd openwrt
echo -e "$(nproc) thread compile"
let Make_Process=$(nproc)+2
make json_overview_image_info V=s
echo $?
echo "::set-output name=status::success"
# echo "{status}={success}" >> $GITHUB_OUTPUT
### --------------------------- ###
- name: If Error (Generate JSON Overview)
uses: actions/upload-artifact@main
if: steps.overview.outcome == 'failure'
&& env.UPLOAD_BUILD_LOGS == 'true'
with:
name: 'OpenWrt_logs${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'
path: openwrt/logs/
### ----------------------------------------------------------------- ###
- name: Generate HASH (OpenWRT)
id: hash
continue-on-error: true
run: |
cd openwrt
echo -e "$(nproc) thread compile"
let Make_Process=$(nproc)+2
make checksum V=s
echo $?
echo "::set-output name=status::success"
# echo "{status}={success}" >> $GITHUB_OUTPUT
### --------------------------- ###
- name: If Error (Generate HASH)
uses: actions/upload-artifact@main
if: steps.hash.outcome == 'failure'
&& env.UPLOAD_BUILD_LOGS == 'true'
with:
name: 'OpenWrt_logs${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'
path: openwrt/logs/
### ----------------------------------------------------------------- ###
- name: OpenWRT Variable Setups
id: VBS
working-directory: '/workdir/openwrt'
continue-on-error: true
if: (!cancelled())
run: |
export TOPDIR="$PWD"
export STAGING_DIR_HOST="$(make --no-print-directory -C target/linux val.STAGING_DIR_HOST)"
export MKHASH="$STAGING_DIR_HOST/bin/mkhash"
export PATH="$STAGING_DIR_HOST/bin":"$PATH"
export BUILD_LOG_DIR="$(make --no-print-directory -C target/linux val.BUILD_LOG_DIR)"
export BIN_DIR="$(make --no-print-directory -C target/linux val.BIN_DIR)"
export PKG_DIR="$(make --no-print-directory -C target/linux val.PACKAGE_DIR)"
export KEY_BUILD="$(make --no-print-directory -C target/linux val.BUILD_KEY)"
export KMOD_DIR="$(make --no-print-directory -C target/linux val.LINUX_VERSION val.LINUX_RELEASE val.LINUX_VERMAGIC | tr '\n' '-' | head -c -1)"
export PKG_ARCH="$(make --no-print-directory -C target/linux val.ARCH_PACKAGES)"
echo -e "PKG_ARCH=$PKG_ARCH" | tee -a "$GITHUB_ENV"
UL_TARGET="$(awk -F '/' '{print $(NF-1)}' <<< "$BIN_DIR")"
UL_SUBTARGET="$(awk -F '/' '{print $NF}' <<< "$BIN_DIR")"
echo "STAGING_DIR_HOST=$STAGING_DIR_HOST" >>"$GITHUB_ENV"
echo "MKHASH=$MKHASH" >>"$GITHUB_ENV"
echo "PATH=$PATH" >>"$GITHUB_ENV"
echo "BUILD_LOG_DIR=$BUILD_LOG_DIR" >>"$GITHUB_ENV"
echo "ARCH_PACKAGES=$ARCH_PACKAGES" >>"$GITHUB_ENV"
echo "BIN_DIR=$BIN_DIR" >>"$GITHUB_ENV"
echo "PKG_DIR=$PKG_DIR" >>"$GITHUB_ENV"
echo "KEY_BUILD=$KEY_BUILD" >>"$GITHUB_ENV"
echo "KMOD_DIR=$KMOD_DIR" >>"$GITHUB_ENV"
echo "PKG_ARCH=$PKG_ARCH" >>"$GITHUB_ENV"
### --------------------------- ###
- name: If Error (OpenWRT Variable Setups)
if: steps.VBS.outcome == 'failure'
run: |
echo "Proccess Failed at level 1"
### ----------------------------------------------------------------- ###
- name: Sign Packages (KEY_BUILD)
id: SPKB
working-directory: '/workdir/openwrt'
continue-on-error: true
if: env.SIGN_PACKAGES == 'true' && !cancelled()
run: |
export TOPDIR="$PWD"
pushd "/workdir/openwrt/bin/packages/$PKG_ARCH/routing" || exit
"$STAGING_DIR_HOST"/bin/usign -S -m "Packages" -s "$KEY_BUILD"
popd
pushd "/workdir/openwrt/bin/packages/$PKG_ARCH/packages" || exit
"$STAGING_DIR_HOST"/bin/usign -S -m "Packages" -s "$KEY_BUILD"
popd
pushd "/workdir/openwrt/bin/packages/$PKG_ARCH/base" || exit
"$STAGING_DIR_HOST"/bin/usign -S -m "Packages" -s "$KEY_BUILD"
popd
pushd "/workdir/openwrt/bin/packages/$PKG_ARCH/telephony" || exit
"$STAGING_DIR_HOST"/bin/usign -S -m "Packages" -s "$KEY_BUILD"
popd
pushd "/workdir/openwrt/bin/packages/$PKG_ARCH/luci" || exit
"$STAGING_DIR_HOST"/bin/usign -S -m "Packages" -s "$KEY_BUILD"
popd
### --------------------------- ###
- name: If Error (KEY_BUILD)
if: env.SIGN_PACKAGES == 'true' && steps.SPKB.outcome == 'failure'
run: |
echo "Proccess Failed at level 1"
### ----------------------------------------------------------------- ###
- name: List SHA256SUMS of dl Directory
id: sha256
working-directory: '/workdir/openwrt/dl'
run: |
find . -type f -exec sha256sum {} \; >> sha256sum.txt
cat "sha256sum.txt"
### ----------------------------------------------------------------- ###
- name: Generate kmods feed
id: GKMOD
working-directory: '/workdir/openwrt'
continue-on-error: true
if: env.USE_KMODS_SCRIPT == 'true' && !cancelled()
run: |
chmod +x ${GITHUB_WORKSPACE}/scripts/create_kmods
${GITHUB_WORKSPACE}/scripts/create_kmods
### --------------------------- ###
- name: If Error (kmods feed)
if: steps.GKMOD.outcome == 'failure'
run: |
echo "Proccess Failed at level 1"
### ----------------------------------------------------------------- ###
- name: Generate kmods Archives
id: PKMOD
working-directory: '/workdir/openwrt'
continue-on-error: true
if: env.USE_KMODS_SCRIPT == 'true' && !cancelled()
run: |
cd $BIN_DIR/kmods/$KMOD_DIR
tar -cvzf kmods_"$KMOD_DIR".tar.gz ./*
mv kmods_"$KMOD_DIR".tar.gz $BIN_DIR
cd "$GITHUB_WORKSPACE"/openwrt
### --------------------------- ###
- name: If Error (kmods feed)
if: steps.PKMOD.outcome == 'failure'
run: |
echo "Proccess Failed at level 1"
### ----------------------------------------------------------------- ###
- name: Create (KMOD) File for release
working-directory: '/workdir/openwrt'
continue-on-error: true
run: |
echo "$KMOD_DIR" >> "$GITHUB_WORKSPACE"/openwrt/kmod
### ----------------------------------------------------------------- ###
- name: Get Device ID Name (HARDWARE ID)
id: GET_DEVICEID
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
cd openwrt
get_deviceID
### ----------------------------------------------------------------- ###
- name: After Build
if: env.RUN_AFTER_BUILD == 'true' && !cancelled()
run: |
chmod +x scripts/$AFTER_BUILD
/bin/bash ${GITHUB_WORKSPACE}/scripts/after_build.sh
### ----------------------------------------------------------------- ###
- name: Check space usage
id: space
continue-on-error: true
if: (!cancelled())
run: |
cd openwrt
echo "=============================================="
echo "Space usage:"
echo "=============================================="
df -hT
echo "=============================================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./staging_dir
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
du -h --max-depth=1 ./package
du -h --max-depth=1 .ccache
du -h --max-depth=10 ./bin
echo "=============================================="
### ----------------------------------------------------------------- ###
- name: Copy (.config) for releases
run: |
chmod +x scripts/$FUNCTIONS_SH
source scripts/$FUNCTIONS_SH
COPY_DEFCONFIG
### ----------------------------------------------------------------- ###
- name: Prepare Packages/Kmods for Distribution
id: distribution
continue-on-error: true
if: env.RUN_GITHUB_PUSH == 'true' && (!cancelled())
env:
API_TOKEN_GITHUB: '${{ secrets.API_TOKEN_GITHUB }}'
run: |
chmod +x scripts/$GITHUB_PUSH
/bin/bash ${GITHUB_WORKSPACE}/scripts/github_push.sh
### --------------------------- ###
- name: If Error (Prepare Packages/Kmods for Distribution)
if: steps.distribution.outcome == 'failure'
run: |
echo "[+] Prepare Packages/Kmods for Distribution Failed"
### ----------------------------------------------------------------- ###
- name: Print faillogs (Errors Logs) [Logs Main, Package, Target, Toolchain, Tools]
working-directory: /workdir/openwrt
if: env.PRINT_FAILLOGS == 'true' && (!cancelled())
run: |
[ ! -e "./logs/error.txt" ] || cat "./logs/error.txt"
[ ! -e "./logs/package/error.txt" ] || cat "./logs/package/error.txt"
[ ! -e "./logs/target/error.txt" ] || cat "./logs/target/error.txt"
[ ! -e "./logs/toolchain/error.txt" ] || cat "./logs/toolchain/error.txt"
[ ! -e "./logs/tools/error.txt" ] || cat "./logs/tools/error.txt"
### ----------------------------------------------------------------- ###
- name: View Build Logs (Build Logs) [Build.log Viewable]
working-directory: /workdir/openwrt
if: env.VIEW_BUILD_LOGS == 'true' && (!cancelled())
run: |
[ ! -e "./logs/build.log" ] || cat "./logs/build.log"
### ----------------------------------------------------------------- ###
- name: Upload kmods
uses: actions/upload-artifact@main
if: >-
steps.compile.outputs.status == 'success' && steps.compile.outcome == 'success' && env.UPLOAD_KMODS == 'true'
with:
name: 'OpenWrt_kmods${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'
path: '${{ env.SOURCE_DIRECTORY_B }}'
### ----------------------------------------------------------------- ###
- name: Upload Packages
uses: actions/upload-artifact@main
if: >-
steps.compile.outputs.status == 'success' && steps.compile.outcome == 'success' && env.UPLOAD_PACKAGES == 'true'
with:
name: 'OpenWrt_bin_packages${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'
path: openwrt/bin/packages/
### ----------------------------------------------------------------- ###
- name: Upload bin directory
uses: actions/upload-artifact@main
if: >-
steps.compile.outputs.status == 'success' && steps.compile.outcome == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: 'OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}'