-
Notifications
You must be signed in to change notification settings - Fork 66
1301 lines (1180 loc) · 64.7 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
#=============================================================================#
#MIT License
#Copyright (c) 2023 沉默の金
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#=============================================================================#
name: Build OpenWrt-K
on:
schedule:
- cron: '0 4 * * *'
# push:
# branches:
# - main
# paths:
# - '.github/**'
# - 'files/**'
# - '!README.md'
# pull_request:
# branches:
# - main
# paths:
# - 'config/**'
# - '.github/**'
# - 'files/**'
# - '!README.md'
workflow_dispatch:
permissions:
contents: write
discussions: write
jobs:
prepare:
outputs:
target: ${{ steps.target.outputs.target }}
subtarget: ${{ steps.target.outputs.subtarget }}
starttime: ${{ steps.time.outputs.starttime }}
runs-on: ubuntu-22.04
steps:
- name: 记录开始时间
id: time
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
echo starttime=$(date +"%y.%m.%d-%H") >> "$GITHUB_OUTPUT"
- name: 准备环境
run: |
sudo -E apt update
sudo apt install -y curl git rsync unzip wget sed tar || sudo apt install -y curl git rsync unzip wget sed tar
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 建立工作文件夹
run: |
cd $GITHUB_WORKSPACE
mkdir -p download
cd download
export DOWNLOAD_ROOT_PATH="$(pwd)"
echo "DOWNLOAD_ROOT_PATH=$DOWNLOAD_ROOT_PATH" >> $GITHUB_ENV
mkdir -p lede Lienol immortalwrt wongsyrone passwall turboacc other
cd $GITHUB_WORKSPACE
mkdir -p cmzj_package
cd cmzj_package
export CMZJ_PACKAGE_ROOT_PATH="$(pwd)"
echo "CMZJ_PACKAGE_ROOT_PATH=$CMZJ_PACKAGE_ROOT_PATH" >> $GITHUB_ENV
mkdir -p turboacc r8125
cd $GITHUB_WORKSPACE
mkdir -p cmzj_patch
cd cmzj_patch
export CMZJ_PATCH_ROOT_PATH="$(pwd)"
echo "CMZJ_PATCH_ROOT_PATH=$CMZJ_PATCH_ROOT_PATH" >> $GITHUB_ENV
mkdir -p $CMZJ_PATCH_ROOT_PATH/firewall4/patches/ $CMZJ_PATCH_ROOT_PATH/libnftnl/patches/ $CMZJ_PATCH_ROOT_PATH/nftables/patches/ $CMZJ_PATCH_ROOT_PATH/hack-5.10 $CMZJ_PATCH_ROOT_PATH/hack-5.15 $CMZJ_PATCH_ROOT_PATH/hack-6.1 $CMZJ_PATCH_ROOT_PATH/dnsmasq $CMZJ_PATCH_ROOT_PATH/libubox $CMZJ_PATCH_ROOT_PATH/netdata
- name: 克隆补丁所需源代码
working-directory: ${{ env.DOWNLOAD_ROOT_PATH }}
run: |
cd lede
git clone https://github.com/coolsnowwolf/lede
cd $DOWNLOAD_ROOT_PATH
cd immortalwrt
git clone https://github.com/immortalwrt/packages
cd $DOWNLOAD_ROOT_PATH
cd turboacc
git clone https://github.com/chenmozhijin/turboacc -b package
cd $DOWNLOAD_ROOT_PATH
git clone https://git.openwrt.org/openwrt/openwrt.git
- name: 导入拓展软件包
run: |
TMPDIR=$(mktemp -d) || exit 1
EXT_PKGS_PREP_PATH=$TMPDIR/extpackages_prepare
EXT_PKGS_DL_PATH=$DOWNLOAD_ROOT_PATH/extpackages/dl
EXT_PKGS_PATH=$DOWNLOAD_ROOT_PATH/extpackages/extpackages
EXT_PKGS_CONFIG=$GITHUB_WORKSPACE/config/OpenWrt-K/extpackages.config
mkdir -p $EXT_PKGS_PREP_PATH $EXT_PKGS_PATH $EXT_PKGS_DL_PATH
NUMBER_OF_PKGS=$(grep -c "^EXT_PACKAGES_NAME\[" $EXT_PKGS_CONFIG)
n=1
while [ "$n" -le $NUMBER_OF_PKGS ]; do
EXT_PKG_REPOSITORIE=$(grep "^EXT_PACKAGES_REPOSITORIE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_BRANCHE=$(grep "^EXT_PACKAGES_BRANCHE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
echo "REPOSITORIE=$EXT_PKG_REPOSITORIE BRANCHE=$EXT_PKG_BRANCHE" >> $EXT_PKGS_PREP_PATH/extpackagesbr.config
n=$(( n+1 ))
done
sort $EXT_PKGS_PREP_PATH/extpackagesbr.config|uniq > $EXT_PKGS_PREP_PATH/clone.config
sed -i -e "s/BRANCHE=$//g" $EXT_PKGS_PREP_PATH/clone.config
sed -i -e "s/BRANCHE=/--branch /g" $EXT_PKGS_PREP_PATH/clone.config
NUMBER_OF_CLONES=$(grep -c "REPOSITORIE=" $EXT_PKGS_PREP_PATH/clone.config)
sed -i "s/^REPOSITORIE=//g" $EXT_PKGS_PREP_PATH/clone.config
echo "开始克隆拓展软件包仓库"
n=1
echo "debug1"
cat $EXT_PKGS_PREP_PATH/clone.config
while [ "$n" -le $NUMBER_OF_CLONES ]; do
echo "debug2"
echo "EXT_PKGS_PREP_PATH=$EXT_PKGS_PREP_PATH"
echo "EXT_PKGS_DL_PATH=$EXT_PKGS_DL_PATH"
echo "EXT_PKGS_PATH=$EXT_PKGS_PATH"
echo "EXT_PKGS_CONFIG=$EXT_PKGS_CONFIG"
echo "NUMBER_OF_CLONES=$NUMBER_OF_CLONES"
echo "n=$n"
mkdir -p $EXT_PKGS_DL_PATH/TMP
echo "debug3"
ls -al $EXT_PKGS_DL_PATH/TMP
COLNE_ARGUMENT=$(sed -n "${n}p" $EXT_PKGS_PREP_PATH/clone.config)
echo "debug4"
echo "COLNE_ARGUMENT=$COLNE_ARGUMENT"
git clone --depth=1 --single-branch $COLNE_ARGUMENT $EXT_PKGS_DL_PATH/TMP
echo "debug5"
ls -al $EXT_PKGS_DL_PATH/TMP
cd $EXT_PKGS_DL_PATH/TMP
if [ "$(echo "$COLNE_ARGUMENT" | grep -c " --branch ")" -ne '0' ];then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
else
BRANCH="default_branch"
fi
echo "debug6"
echo "BRANCH=$BRANCH"
REPO_PATH="$BRANCH""/""$(echo "$COLNE_ARGUMENT" | sed -e "s/ --branch.*//g" -e "s@.*://@@g" -e "s/^[a-zA-Z.]\{1,111\}\///" -e "s/\/$//g")"
fiecho "debug7"
echo "REPO_PATH=$REPO_PATH"
mkdir -p $EXT_PKGS_DL_PATH/$REPO_PATH
cp -RT $EXT_PKGS_DL_PATH/TMP/ $EXT_PKGS_DL_PATH/$REPO_PATH
rm -rf $EXT_PKGS_DL_PATH/TMP/
echo "debug8"
ls -al $EXT_PKGS_DL_PATH/TMP
ls -al $EXT_PKGS_DL_PATH/$REPO_PATH
n=$(( n+1 ))
done
echo "开始整理拓展软件包"
n=1
while [ "$n" -le $NUMBER_OF_PKGS ]; do
NUMBER_OF_PKGS=$(grep -c "^EXT_PACKAGES_NAME\[" $EXT_PKGS_CONFIG)
EXT_PKG_NAME=$(grep "^EXT_PACKAGES_NAME\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_PATH=$(grep "^EXT_PACKAGES_PATH\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_REPOSITORIE=$(grep "^EXT_PACKAGES_REPOSITORIE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_BRANCHE=$(grep "^EXT_PACKAGES_BRANCHE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_REPO_PATH=$(echo "$EXT_PKG_REPOSITORIE" | sed -e "s/$ //g" -e "s/ .*//g" -e "s@.*://@@g" -e "s/^[a-zA-Z.]\{1,111\}\///" -e "s/\/$//g")
if [ -z "$EXT_PKG_BRANCHE" ];then
EXT_PKG_BRANCHE="default_branch"
fi
mkdir -p $EXT_PKGS_PATH/$EXT_PKG_NAME
cp -RT $EXT_PKGS_DL_PATH/$EXT_PKG_BRANCHE/$EXT_PKG_REPO_PATH/$EXT_PKG_PATH $EXT_PKGS_PATH/$EXT_PKG_NAME
n=$(( n+1 ))
done
cp -RT $EXT_PKGS_PATH $CMZJ_PACKAGE_ROOT_PATH
[[ -d $TMPDIR ]] && rm -rf "$TMPDIR"
cd $CMZJ_PACKAGE_ROOT_PATH
ls -la $(find $CMZJ_PACKAGE_ROOT_PATH -type d)
- name: 修改Makefile文件
working-directory: ${{ env.CMZJ_PACKAGE_ROOT_PATH }}
run: sed -i 's/include ..\/..\/luci.mk/include $(TOPDIR)\/feeds\/luci\/luci.mk/' $(find ./ -type f -name "Makefile")
- name: 创建符号链接以修复中文支持
working-directory: ${{ env.CMZJ_PACKAGE_ROOT_PATH }}
run: |
TMPDIR=$(mktemp -d) || exit 1
find . -name 'po' -type d > $TMPDIR/podir.list
total_rows=$(sed -n '$=' $TMPDIR/podir.list) #行数-文件夹个数
n=1
while [ "$n" -le $total_rows ]; do
DIR=$(sed -n "${n}p" $TMPDIR/podir.list)
if [ -h $DIR/zh_Hans ]; then
echo "$DIR/zh_Hans 符号链接以存在无需修复"
elif [ -d $DIR/zh_Hans ]; then
echo "$DIR/zh_Hans 目录已存在无需修复"
elif [ -e $DIR/zh_Hans ]; then
echo "$DIR/zh_Hans 存在非符号链接文件删除后重新创建"
rm -rf $DIR/zh_Hans||exit 1
ln -s zh-cn $DIR/zh_Hans||exit 1
elif [ ! -d $DIR/zh-cn ]; then
echo "$DIR/zh-cn 原汉化文件夹不存在,这可能是该luci插件原生为中文或不支持中文"
else
echo "$DIR/zh_Hans 符号链接不存在创建符号链接"
ln -s zh-cn $DIR/zh_Hans||exit 1
fi
n=$(( n+1 ))
done
[[ -d $TMPDIR ]] && rm -rf "$TMPDIR"
- name: 复制到cmzj_patch
run: |
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.10/952-net-conntrack-events-support-multiple-registrant.patch $CMZJ_PATCH_ROOT_PATH/hack-5.10/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.10/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $CMZJ_PATCH_ROOT_PATH/hack-5.10/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.10/982-add-bcm-fullconenat-support.patch $CMZJ_PATCH_ROOT_PATH/hack-5.10/
cp $DOWNLOAD_ROOT_PATH/turboacc/turboacc/hack-5.15/952-add-net-conntrack-events-support-multiple-registrant.patch $CMZJ_PATCH_ROOT_PATH/hack-5.15/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.15/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $CMZJ_PATCH_ROOT_PATH/hack-5.15/
cp $DOWNLOAD_ROOT_PATH/turboacc/turboacc/hack-6.1/952-add-net-conntrack-events-support-multiple-registrant.patch $CMZJ_PATCH_ROOT_PATH/hack-6.1/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-6.1/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $CMZJ_PATCH_ROOT_PATH/hack-6.1/
cp -RT $DOWNLOAD_ROOT_PATH/turboacc/turboacc/firewall4-04a06bd70b9808b14444cae81a2faba4708ee231/firewall4 $CMZJ_PATCH_ROOT_PATH/firewall4
cp -RT $DOWNLOAD_ROOT_PATH/turboacc/turboacc/libnftnl-1.2.5/libnftnl $CMZJ_PATCH_ROOT_PATH/libnftnl
cp -RT $DOWNLOAD_ROOT_PATH/turboacc/turboacc/nftables-1.0.7/nftables $CMZJ_PATCH_ROOT_PATH/nftables
#cp -RT $DOWNLOAD_ROOT_PATH/openwrt/package/network/services/dnsmasq $CMZJ_PATCH_ROOT_PATH/dnsmasq
#cp -RT $DOWNLOAD_ROOT_PATH/openwrt/package/libs/libubox $CMZJ_PATCH_ROOT_PATH/libubox
cp -RT $DOWNLOAD_ROOT_PATH/immortalwrt/packages/admin/netdata $CMZJ_PATCH_ROOT_PATH/netdata
- name: 压缩
run: |
cd $CMZJ_PACKAGE_ROOT_PATH
tar cvpzf $GITHUB_WORKSPACE/cmzj_package.tgz *
cd $CMZJ_PATCH_ROOT_PATH
tar cvpzf $GITHUB_WORKSPACE/cmzj_patch.tgz *
- name: 上传 cmzj_package
uses: actions/upload-artifact@v3
with:
name: cmzj_package
path: cmzj_package.tgz
- name: 上传 cmzj_patch
uses: actions/upload-artifact@v3
with:
name: cmzj_patch
path: cmzj_patch.tgz
- name: 读取架构信息
id: target
working-directory: ${{ env.DOWNLOAD_ROOT_PATH }}/openwrt
run: |
cat $GITHUB_WORKSPACE/config/target.config >> $DOWNLOAD_ROOT_PATH/openwrt/.config
make defconfig
echo target=$(sed -n '/CONFIG_TARGET_BOARD/p' .config | sed -e 's/CONFIG_TARGET_BOARD\=\"//' -e 's/\"//') >> "$GITHUB_OUTPUT"
echo subtarget=$(sed -n '/CONFIG_TARGET_SUBTARGET/p' .config | sed -e 's/CONFIG_TARGET_SUBTARGET\=\"//' -e 's/\"//') >> "$GITHUB_OUTPUT"
build1:
runs-on: ubuntu-22.04
needs: prepare
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 建立工作文件夹
run: |
cd $GITHUB_WORKSPACE
sudo mkdir -p workspace
sudo chown $USER:$GROUPS workspace
cd workspace
export WORKSPACE_ROOT_PATH="$(pwd)"
echo "WORKSPACE_ROOT_PATH=$WORKSPACE_ROOT_PATH" >> $GITHUB_ENV
cd $WORKSPACE_ROOT_PATH
mkdir -p cmzj_package
cd cmzj_package
export CMZJ_PACKAGE_ROOT_PATH="$(pwd)"
echo "CMZJ_PACKAGE_ROOT_PATH=$CMZJ_PACKAGE_ROOT_PATH" >> $GITHUB_ENV
cd $WORKSPACE_ROOT_PATH
mkdir -p cmzj_patch
cd cmzj_patch
export CMZJ_PATCH_ROOT_PATH="$(pwd)"
echo "CMZJ_PATCH_ROOT_PATH=$CMZJ_PATCH_ROOT_PATH" >> $GITHUB_ENV
cd $WORKSPACE_ROOT_PATH
mkdir -p log
cd log
export LOG_PATH="$(pwd)"
echo "LOG_PATH=$LOG_PATH" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE && cat $GITHUB_ENV >> build1_ENV
- name: 下载cmzj_package
uses: actions/download-artifact@v3
with:
name: cmzj_package
- name: 下载cmzj_patch
uses: actions/download-artifact@v3
with:
name: cmzj_patch
- name: 解压
run: |
tar xvpfz $GITHUB_WORKSPACE/cmzj_package.tgz -C $CMZJ_PACKAGE_ROOT_PATH
tar xvpfz $GITHUB_WORKSPACE/cmzj_patch.tgz -C $CMZJ_PATCH_ROOT_PATH
echo "cmzj_package" >> $LOG_PATH/cmzj_package.log
ls $CMZJ_PACKAGE_ROOT_PATH >> $LOG_PATH/cmzj_package.log
echo "cmzj_patch" >> $LOG_PATH/cmzj_patch.log
ls $CMZJ_PATCH_ROOT_PATH >> $LOG_PATH/cmzj_patch.log
echo "cmzj_package-permissions" >> $LOG_PATH/cmzj_package.log
ls -l $CMZJ_PACKAGE_ROOT_PATH/** >> $LOG_PATH/cmzj_package.log
echo "cmzj_patch-permissions" >> $LOG_PATH/cmzj_patch.log
ls -l $CMZJ_PATCH_ROOT_PATH/** >> $LOG_PATH/cmzj_patch.log
- name: 克隆源代码
working-directory: ${{ env.WORKSPACE_ROOT_PATH }}
run: |
git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
export OPENWRT_ROOT_PATH="$(pwd)"
echo "OPENWRT_ROOT_PATH=$OPENWRT_ROOT_PATH" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE && cat $GITHUB_ENV >> build1_ENV
- name: 切换标签/分支
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: git checkout $(sed -n '/openwrt_tag\/branche/p' $GITHUB_WORKSPACE/OpenWrt-K.Config | sed -e 's/.*=//')
- name: 复制cmzj_package 打补丁
working-directory: ${{ env.WORKSPACE_ROOT_PATH }}
run: |
cp -r $CMZJ_PACKAGE_ROOT_PATH $OPENWRT_ROOT_PATH/package/cmzj_package
rm -rf $OPENWRT_ROOT_PATH/package/libs/libnftnl
rm -rf $OPENWRT_ROOT_PATH/package/network/config/firewall4
rm -rf $OPENWRT_ROOT_PATH/package/network/utils/nftables
#rm -rf $OPENWRT_ROOT_PATH/package/network/services/dnsmasq
#rm -rf $OPENWRT_ROOT_PATH/package/libs/libubox
mkdir -p $OPENWRT_ROOT_PATH/package/network/config/firewall4
mkdir -p $OPENWRT_ROOT_PATH/package/libs/libnftnl
mkdir -p $OPENWRT_ROOT_PATH/package/network/utils/nftables
#mkdir -p $OPENWRT_ROOT_PATH/package/libs/libubox
#mkdir -p $OPENWRT_ROOT_PATH/package/network/services/dnsmasq
cp -RT $CMZJ_PATCH_ROOT_PATH/firewall4 $OPENWRT_ROOT_PATH/package/network/config/firewall4
cp -RT $CMZJ_PATCH_ROOT_PATH/libnftnl $OPENWRT_ROOT_PATH/package/libs/libnftnl
cp -RT $CMZJ_PATCH_ROOT_PATH/nftables $OPENWRT_ROOT_PATH/package/network/utils/nftables
#cp -RT $CMZJ_PATCH_ROOT_PATH/libubox $OPENWRT_ROOT_PATH/package/libs/libubox
#cp -RT $CMZJ_PATCH_ROOT_PATH/dnsmasq $OPENWRT_ROOT_PATH/package/network/services/dnsmasq
echo "cmzj_patch" >> $LOG_PATH/cmzj_patch.log
ls $CMZJ_PATCH_ROOT_PATH >> $LOG_PATH/cmzj_patch.log
echo "cmzj_package" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/cmzj_package >> $LOG_PATH/cmzj_patch.log
echo "libnftnl-file" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/libs/libnftnl >> $LOG_PATH/cmzj_patch.log
echo "firewall4-file" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/config/firewall4 >> $LOG_PATH/cmzj_patch.log
echo "nftables-file" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/utils/nftables >> $LOG_PATH/cmzj_patch.log
echo "firewall4-patches" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/config/firewall4/patches/ >> $LOG_PATH/cmzj_patch.log
echo "libnftnl-patches" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/libs/libnftnl/patches/ >> $LOG_PATH/cmzj_patch.log
echo "nftables-patches" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/utils/nftables/patches/ >> $LOG_PATH/cmzj_patch.log
- name: 修复问题
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
sed -i 's/^ DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt$/ DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt +kmod-udptunnel4 +kmod-udptunnel6/' package/kernel/linux/modules/netsupport.mk #https://github.com/openwrt/openwrt/commit/ecc53240945c95bc77663b79ccae6e2bd046c9c8
sed -i 's/^ dnsmasq \\$/ dnsmasq-full \\/g' ./include/target.mk
sed -i 's/256/1024/' ./target/linux/${{ needs.prepare.outputs.target }}/image/Makefile
sed -i 's/^ b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)"/ $(TOPDIR)\/tools\/b43-tools\/files\/b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)"/' ./package/kernel/mac80211/broadcom.mk
- name: 更新 feeds
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: 更新smartdns、netdata
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
WORKINGDIR="`pwd`/feeds/packages/net/smartdns"
mkdir $WORKINGDIR -p
rm $WORKINGDIR/* -fr
wget https://github.com/pymumu/openwrt-smartdns/archive/master.zip -O $WORKINGDIR/master.zip
unzip $WORKINGDIR/master.zip -d $WORKINGDIR
mv $WORKINGDIR/openwrt-smartdns-master/* $WORKINGDIR/
rmdir $WORKINGDIR/openwrt-smartdns-master
rm $WORKINGDIR/master.zip
LUCIBRANCH="master" #更换此变量
WORKINGDIR="`pwd`/feeds/luci/applications/luci-app-smartdns"
mkdir $WORKINGDIR -p
rm $WORKINGDIR/* -fr
wget https://github.com/pymumu/luci-app-smartdns/archive/${LUCIBRANCH}.zip -O $WORKINGDIR/${LUCIBRANCH}.zip
unzip $WORKINGDIR/${LUCIBRANCH}.zip -d $WORKINGDIR
mv $WORKINGDIR/luci-app-smartdns-${LUCIBRANCH}/* $WORKINGDIR/
rmdir $WORKINGDIR/luci-app-smartdns-${LUCIBRANCH}
rm $WORKINGDIR/${LUCIBRANCH}.zip
WORKINGDIR="`pwd`/feeds/packages/admin/netdata"
mkdir $WORKINGDIR -p
rm $WORKINGDIR/* -fr
cp -RT $CMZJ_PATCH_ROOT_PATH/netdata $WORKINGDIR
- name: 安装 feeds
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: ./scripts/feeds install -a
- name: 复制自定义文件并添加编译信息
run: |
cp -r files $OPENWRT_ROOT_PATH/files
chmod 755 $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin
chmod 755 $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin-passwall
#替换编译者
if [ "$(curl -s https://api.github.com/users/$(echo ${{ github.repository }} | sed "s/\/.*//g") 2>/dev/null|grep -c "^ \"name\": null,$")" -ne '0' ];then
compiler=$(echo ${{ github.repository }} | sed "s/\/.*//g")
else
compiler=$(curl -s https://api.github.com/users/$(echo ${{ github.repository }} | sed "s/\/.*//g") 2>/dev/null |grep '"name":\ "'|sed 's/ "name":\ "//'|sed 's/",//' 2>/dev/null)
fi
echo 'Compiled by' $compiler
sed -i "s/Compiled by 沉默の金/Compiled by $compiler/g" $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin
cat $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin | grep 'Compiled by'
#添加编译信息
export OPENWRT_TAG_BRANCHE="$(sed -n '/openwrt_tag\/branche/p' $GITHUB_WORKSPACE/OpenWrt-K.Config | sed -e 's/.*=//')"
echo "COMPILE_START_TIME=\"${{ needs.prepare.outputs.starttime }}\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "COMPILER=\"$compiler\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "RELEASE_NAME=\"OpenWrt-K_V${{ needs.prepare.outputs.starttime }} (${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})-[$OPENWRT_TAG_BRANCHE]\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "RELEASE_TAG_NAME=\"v${{ needs.prepare.outputs.starttime }}(${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})-($OPENWRT_TAG_BRANCHE)\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "REPOSITORY_URL=\"https://github.com/${{ github.repository }}\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "$OPENWRT_ROOT_PATH/files/etc/openwrt-k_info"
cat $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
- name: 加载自定义配置并生成配置文件
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
cat $GITHUB_WORKSPACE/config/target.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/luci.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/utilities.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/network.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/other.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/kmod.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/image.config >> $OPENWRT_ROOT_PATH/.config
make defconfig
./scripts/diffconfig.sh
./scripts/diffconfig.sh >> $LOG_PATH/build1-diffconfig.log
- name: 打内核补丁
working-directory: ${{ env.WORKSPACE_ROOT_PATH }}
run: |
kernel_version="$(sed -n '/CONFIG_LINUX_/p' $OPENWRT_ROOT_PATH/.config | sed -e 's/CONFIG_LINUX_//' -e 's/=y//' -e 's/_/./g')"
echo kernel_version=$kernel_version
cp $CMZJ_PATCH_ROOT_PATH/hack-$kernel_version/952-add-net-conntrack-events-support-multiple-registrant.patch $OPENWRT_ROOT_PATH/target/linux/generic/hack-$kernel_version
#cp $CMZJ_PATCH_ROOT_PATH/hack-$kernel_version/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $OPENWRT_ROOT_PATH/target/linux/generic/hack-$kernel_version
echo "hack-$kernel_version" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/target/linux/generic/hack-$kernel_version >> $LOG_PATH/cmzj_patch.log
- name: 加载附加内核配置
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
kernel_version="$(sed -n '/CONFIG_LINUX_/p' $OPENWRT_ROOT_PATH/.config | sed -e 's/CONFIG_LINUX_//' -e 's/=y//' -e 's/_/./g')"
cat $GITHUB_WORKSPACE/config/linux/config-$kernel_version >> $OPENWRT_ROOT_PATH/target/linux/generic/config-$kernel_version || echo "未加载附加内核配置"
- name: 下载AdGuardHome核心与DNS名单
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
if [ "$(grep -c "^CONFIG_PACKAGE_luci-app-adguardhome=y$" .config)" -ne '0' ];then
Archt="$(sed -n '/CONFIG_ARCH=/p' .config | sed -e 's/CONFIG_ARCH\=\"//' -e 's/\"//')"
case $Archt in
"i386")
Arch="386"
;;
"i686")
Arch="386"
;;
"x86_64")
Arch="amd64"
;;
"mipsel")
Arch="mipsle"
;;
"mips64el")
Arch="mips64le"
Arch="mipsle"
echo -e "mips64el use $Arch may have bug"
;;
"mips")
Arch="mips"
;;
"mips64")
Arch="mips64"
Arch="mips"
echo -e "mips64 use $Arch may have bug"
;;
"arm")
if [ "$(grep -c "CONFIG_arm_" .config)" -ne '0' ];then
armv="$(sed -n '/CONFIG_arm_/p' .config | sed -e 's/CONFIG_arm_//' -e 's/=y//')"
else
armv=v5
fi
Arch="arm$armv"
;;
"aarch64")
Arch="arm64"
;;
"powerpc")
Arch="ppc"
Arch=1
echo -e "error not support $Archt"
;;
"powerpc64")
Arch="ppc64"
Arch=1
echo -e "error not support $Archt"
;;
*)
echo -e "error not support $Archt if you can use offical release please issue a bug"
Arch=1
;;
esac
if [ "$Arch" != 1 ];then
echo AdGuardHome架构为$Arch,开始下载AdGuardHome
mkdir -p ./files/usr/bin/AdGuardHome/tmp
rm -rf ./files/usr/bin/AdGuardHome/tmp/*
latest_ver="$(curl -s https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
wget https://github.com/AdguardTeam/AdGuardHome/releases/download/${latest_ver}/AdGuardHome_linux_${Arch}.tar.gz -O ./files/usr/bin/AdGuardHome/tmp/AdGuardHome.tar.gz
tar -zxf "./files/usr/bin/AdGuardHome/tmp/AdGuardHome.tar.gz" -C "./files/usr/bin/AdGuardHome/tmp/"
mv -f ./files/usr/bin/AdGuardHome/tmp/AdGuardHome/AdGuardHome ./files/usr/bin/AdGuardHome
rm -rf ./files/usr/bin/AdGuardHome/tmp
chmod 755 $OPENWRT_ROOT_PATH/files/usr/bin/AdGuardHome/AdGuardHome
echo "下载AdGuardHome DNS黑白名单"
mkdir -p ./files/usr/bin/AdGuardHome/data/filters
cd $OPENWRT_ROOT_PATH/files/usr/bin/AdGuardHome/data/filters
curl -o 1628750870.txt https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt -s -L --retry 3
curl -o 1628750871.txt https://anti-ad.net/easylist.txt -s -L --retry 3
curl -o 1677875715.txt https://easylist-downloads.adblockplus.org/easylist.txt -s -L --retry 3
curl -o 1677875716.txt https://easylist-downloads.adblockplus.org/easylistchina.txt -s -L --retry 3
curl -o 1677875717.txt https://cdn.jsdelivr.net/gh/cjx82630/cjxlist@master/cjx-annoyance.txt -s -L --retry 3
curl -o 1677875718.txt https://cdn.jsdelivr.net/gh/zsakvo/AdGuard-Custom-Rule@master/rule/zhihu-strict.txt -s -L --retry 3
curl -o 1677875720.txt https://gist.githubusercontent.com/Ewpratten/a25ae63a7200c02c850fede2f32453cf/raw/b9318009399b99e822515d388b8458557d828c37/hosts-yt-ads -s -L --retry 3
curl -o 1677875721.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/lazy.txt -s -L --retry 3
curl -o 1677875722.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/v -s -L --retry 3
curl -o 1677875724.txt https://raw.githubusercontent.com/banbendalao/ADgk/master/ADgk.txt -s -L --retry 3
curl -o 1677875725.txt https://www.i-dont-care-about-cookies.eu/abp/ -s -L --retry 3
curl -o 1677875726.txt https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts -s -L --retry 3
curl -o 1677875727.txt https://raw.githubusercontent.com/Goooler/1024_hosts/master/hosts -s -L --retry 3
curl -o 1677875728.txt https://winhelp2002.mvps.org/hosts.txt -s -L --retry 3
curl -o 1677875733.txt https://cdn.jsdelivr.net/gh/hl2gu -s -L --retry 3
curl -o 1677875734.txt https://cdn.jsdelivr.net/gh/hg1978/AdGuard-Home-Whitelist@master/whitelist.txt -s -L --retry 3
curl -o 1677875735.txt https://cdn.jsdelivr.net/gh/mmotti/adguard-home-filters@master/whitelist.txt -s -L --retry 3
curl -o 1677875737.txt https://cdn.jsdelivr.net/gh/liwenjie119/adg-rules@master/white.txt -s -L --retry 3
curl -o 1677875739.txt https://cdn.jsdelivr.net/gh/JamesDamp/AdGuard-Home---Personal-Whitelist@master/AdGuardHome-Whitelist.txt -s -L --retry 3
curl -o 1677875740.txt https://cdn.jsdelivr.net/gh/scarletbane/AdGuard-Home-Whitelist@main/whitelist.txt -s -L --retry 3
ls
echo "制作AdGuardHome上游 DNS 服务器规则"
cd $WORKSPACE_ROOT_PATH
mkdir -p tmp
cd $WORKSPACE_ROOT_PATH/tmp
ls
rm -rf *
curl -s -L --retry 3 https://raw.githubusercontent.com/YW5vbnltb3Vz/domain-list-community/release/gfwlist.txt -o base64_YW5vbnltb3Vz.txt
curl -s -L --retry 3 https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt -o Loyalsoldier.txt
curl -s -L --retry 3 https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt -o base64_gfwlist.txt
curl -s -L --retry 3 https://raw.githubusercontent.com/Loukky/gfwlist-by-loukky/master/gfwlist.txt -o base64_Loukky.txt
base64 -d base64_YW5vbnltb3Vz.txt > YW5vbnltb3Vz.txt
base64 -d base64_gfwlist.txt > gfwlist.txt
base64 -d base64_Loukky.txt > Loukky.txt
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' YW5vbnltb3Vz.txt>> gfwlist_chen
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' Loyalsoldier.txt>> gfwlist_chen
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' gfwlist.txt>> gfwlist_chen
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' Loukky.txt>> gfwlist_chen
sort gfwlist_chen | uniq > gfwlist
sed -n '/^ - DOMAIN,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/DirectRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN,/[\//g" -e 's/$/\/]127.0.0.1:6053/g' >> ./AdGuardHomednslist
sed -n '/^ - DOMAIN-SUFFIX,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/DirectRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN-SUFFIX,/[\//g" -e 's/$/\/]127.0.0.1:6053/g' >> ./AdGuardHomednslist
sed -n '/^ - DOMAIN,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/ProxyRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN,/[\//g" -e 's/$/\/]127.0.0.1:5335/g' >> ./AdGuardHomednslist
sed -n '/^ - DOMAIN-SUFFIX,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/ProxyRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN-SUFFIX,/[\//g" -e 's/$/\/]127.0.0.1:5335/g' >> ./AdGuardHomednslist
sed -e 's/^/[\//g' -e 's/$/\/]127.0.0.1:5335/g' gfwlist >AdGuardHomednslist
sed -i "s/ //g" ./AdGuardHomednslist
cat ./AdGuardHomednslist >> $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist"(by cmzj)".yaml
echo "AdGuardHome-dnslist(by cmzj).yaml" >> $LOG_PATH/AdGuardHome.log
cat $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist"(by cmzj)".yaml >> $LOG_PATH/AdGuardHome.log
rm -rf $WORKSPACE_ROOT_PATH/tmp/*
echo "files"
ls -la $(find $OPENWRT_ROOT_PATH/files/ -type d)
else
echo "AdGuardHome核心不支持此架构,退出执行。"
rm -rf $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist\(by\ cmzj\).yaml $OPENWRT_ROOT_PATH/files/etc/AdGuardHome.yaml $OPENWRT_ROOT_PATH/files/AdGuardHome
fi
else
echo "未检测到luci-app-adguardhome配置为编译进固件,退出执行。"
rm -rf $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist\(by\ cmzj\).yaml $OPENWRT_ROOT_PATH/files/etc/AdGuardHome.yaml $OPENWRT_ROOT_PATH/files/AdGuardHome
fi
- name: 下载openclash内核
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
if [ "$(grep -c "^CONFIG_PACKAGE_luci-app-openclash=y$" .config)" -ne '0' ];then
ARCHT="$(sed -n '/CONFIG_ARCH=/p' .config | sed -e 's/CONFIG_ARCH\=\"//' -e 's/\"//')"
case "${ARCHT}" in
aarch64)
CORE_ARCH="linux-arm64"
;;
arm)
if [ "$(grep -c "CONFIG_arm_" .config)" -ne '0' ];then
armv="$(sed -n '/CONFIG_arm_/p' .config | sed -e 's/CONFIG_arm_//' -e 's/=y//')"
else
armv=v5
fi
CORE_ARCH="linux-arm$armv"
;;
i386)
CORE_ARCH="linux-386"
;;
mips64)
CORE_ARCH="linux-mips64"
;;
mips)
CORE_ARCH="linux-mips-softfloat"
;;
mipsel)
CORE_ARCH="linux-mipsle-softfloat"
;;
x86_64)
CORE_ARCH="linux-amd64"
;;
*)
CORE_ARCH="1"
;;
esac
echo $CORE_ARCH
if [ "$CORE_ARCH" != 1 ];then
OpenClashTMPDIR=$WORKSPACE_ROOT_PATH/tmp/openclash
dev_core_path="$OPENWRT_ROOT_PATH/files/etc/openclash/core/clash"
tun_core_path="$OPENWRT_ROOT_PATH/files/etc/openclash/core/clash_tun"
meta_core_path="$OPENWRT_ROOT_PATH/files/etc/openclash/core/clash_meta"
CPU_MODEL=$CORE_ARCH
RELEASE_BRANCH=master
mkdir -p $OpenClashTMPDIR $OPENWRT_ROOT_PATH/files/etc/openclash/core/
rm -rf $OpenClashTMPDIR/*
CORE_LV=$(curl -s -L --retry 3 https://raw.githubusercontent.com/vernesong/OpenClash/core/master/core_version|sed -n 2p)
curl -s -L --retry 3 -o $OpenClashTMPDIR/clash_tun.gz https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/premium/clash-"$CPU_MODEL"-"$CORE_LV".gz
curl -s -L --retry 3 -o $OpenClashTMPDIR/clash_meta.tar.gz https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz
curl -s -L --retry 3 -o $OpenClashTMPDIR/clash.tar.gz https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/dev/clash-"$CPU_MODEL".tar.gz
#tun
gzip -d $OpenClashTMPDIR/clash_tun.gz
rm -rf $OpenClashTMPDIR/clash_tun.gz
rm -rf "$tun_core_path"
chmod 4755 $OpenClashTMPDIR/clash_tun
mv $OpenClashTMPDIR/clash_tun "$tun_core_path"
#mate
rm -rf "$meta_core_path"
tar zxvf $OpenClashTMPDIR/clash_meta.tar.gz -C $OpenClashTMPDIR
mv $OpenClashTMPDIR/clash $OpenClashTMPDIR/clash_meta
rm -rf $OpenClashTMPDIR/clash_meta.tar.gz
chmod 4755 $OpenClashTMPDIR/clash_meta
mv $OpenClashTMPDIR/clash_meta "$meta_core_path"
#dev
rm -rf "$dev_core_path"
tar zxvf $OpenClashTMPDIR/clash.tar.gz -C $OpenClashTMPDIR
rm -rf $OpenClashTMPDIR/clash.tar.gz
chmod 4755 $OpenClashTMPDIR/clash
mv $OpenClashTMPDIR/clash "$dev_core_path"
echo "files"
ls -la $(find $OPENWRT_ROOT_PATH/files/ -type d)
else
echo openclash内核不支持此架构,退出执行。
rm -rf $OPENWRT_ROOT_PATH/files/etc/openclash
fi
else
echo "未检测到luci-app-openclash配置为编译进固件,退出执行。"
rm -rf $OPENWRT_ROOT_PATH/files/etc/openclash
fi
- name: 更新BT Tracker
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
export bt_tracker="$(curl -s -L --retry 3 https://github.com/XIU2/TrackersListCollection/raw/master/all_aria2.txt || curl -s -L --retry 3 https://cf.trackerslist.com/all_aria2.txt)"
sed -i "s#^uci set aria2.main.bt_tracker=.*#uci set aria2.main.bt_tracker=\'$bt_tracker\'#g" $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin
- name: 设置时区与主机名
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: sed -i -e "s/set system.@system\[-1].hostname='OpenWrt'/set system.@system\[-1].hostname='OpenWrt-k'/g" -e "s/set system.@system\[-1].timezone='UTC'/set system.@system\[-1].timezone='CST-8'/g" -e "/set system.@system\[-1].timezone='CST-8'/i\ set system.@system\[-1].zonename='Asia/Shanghai'" $OPENWRT_ROOT_PATH/package/base-files/files/bin/config_generate
- name: 检查剩余空间
run: |
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 下载 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make download -j16
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
make download -j16 || make download -j1 V=s
- name: 构建工具
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make tools/install -j $(($(nproc)+1)) || make tools/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 构建工具链
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make toolchain/install -j $(($(nproc)+1)) || make toolchain/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 删除 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: rm -rf dl
- name: 准备上传
run: |
cd $GITHUB_WORKSPACE
sudo tar cvpzf /build1_WORKSPACE.tgz *
cp $OPENWRT_ROOT_PATH/.config $OPENWRT_ROOT_PATH/build1.config
cd $OPENWRT_ROOT_PATH/files
tar cvpzf $GITHUB_WORKSPACE/openwrt_files.tgz *
- name: 上传 build1_WORKSPACE
uses: actions/upload-artifact@v3
with:
name: build1_WORKSPACE
path: /build1_WORKSPACE.tgz
- name: 上传 .config
uses: actions/upload-artifact@v3
with:
name: build1_openwrt_config
path: ${{ env.OPENWRT_ROOT_PATH }}/build1.config
- name: 上传 files
uses: actions/upload-artifact@v3
with:
name: build1_openwrt_files
path: openwrt_files.tgz
- name: 收集日志
if: failure()
run: |
mkdir -p openwrt-logs
cp -r $OPENWRT_ROOT_PATH/logs $LOG_PATH/openwrt-logs || echo "没有openwrt/logs"
cp $OPENWRT_ROOT_PATH/.config $LOG_PATH/openwrt.config || echo "没有openwrt/.config"
ls -la $(find $OPENWRT_ROOT_PATH/files/ -type d) >> $LOG_PATH/files.list
- name: 上传日志
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}-logs-
path: "${{ env.LOG_PATH }}"
build-package:
runs-on: ubuntu-latest
needs: [prepare,build1]
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 清理空间
run: |
bash $GITHUB_WORKSPACE/scripts/clear_space.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 下载build1_WORKSPACE
uses: actions/download-artifact@v3
with:
name: build1_WORKSPACE
- name: 解压
run: |
sudo mv $GITHUB_WORKSPACE/build1_WORKSPACE.tgz /build1_WORKSPACE.tgz
tar xvpfz /build1_WORKSPACE.tgz -C $GITHUB_WORKSPACE
sudo rm -rf /build1_WORKSPACE.tgz
cat build1_ENV
cat build1_ENV >> $GITHUB_ENV
- name: 环境变量
run: env
- name: 下载 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make download -j16
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
make download -j16 || make download -j1 V=s
- name: 构建内核
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make target/compile -j $(($(nproc)+1)) || make target/compile -j$(nproc) V=s || make target/compile -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 编译并生成安装包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/compile -j $(($(nproc)+1)) || make package/compile -j1 V=s
make package/install -j $(($(nproc)+1)) || make package/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 准备 artifact
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
mkdir -p ./artifact/package
echo "artifact-/bin" >> $LOG_PATH/cmzj_package.log
ls -l ./bin/** >> $LOG_PATH/cmzj_package.log
cp -rf $(find ./bin/targets/ -type f -name "*.ipk") ./artifact/package/
rm -rf $(find ./bin/targets/ -type d -name "packages")
cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ./artifact/package/
rm -rf $(find ./artifact/package/ -type f -name "kmod-*")
- name: 上传 package
uses: actions/upload-artifact@v3
with:
name: OpenWrt-package
path: ${{ env.OPENWRT_ROOT_PATH }}/artifact/package/
- name: 收集日志
if: success() || failure()
run: |
mkdir -p openwrt-logs
cp -r $OPENWRT_ROOT_PATH/logs $LOG_PATH/openwrt-logs || echo "没有openwrt/logs"
cp $OPENWRT_ROOT_PATH/.config $LOG_PATH/openwrt.config || echo "没有openwrt/.config"
- name: 上传日志
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: build-package-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}-logs
path: "${{ env.LOG_PATH }}"
build-Image_Builder:
runs-on: ubuntu-latest
needs: [prepare,build1]
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 清理空间
run: |
bash $GITHUB_WORKSPACE/scripts/clear_space.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 下载build1_WORKSPACE
uses: actions/download-artifact@v3
with:
name: build1_WORKSPACE
- name: 解压
run: |
sudo mv $GITHUB_WORKSPACE/build1_WORKSPACE.tgz /build1_WORKSPACE.tgz
tar xvpfz /build1_WORKSPACE.tgz -C $GITHUB_WORKSPACE
sudo rm -rf /build1_WORKSPACE.tgz
cat build1_ENV
cat build1_ENV >> $GITHUB_ENV
- name: 环境变量
run: env
- name: 加载自定义配置并生成配置文件
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
sed -n '/^# CONFIG_PACKAGE_kmod/p' .config | sed '/# CONFIG_PACKAGE_kmod is not set/d'|sed 's/# //g'|sed 's/ is not set/=m/g' |sed 's/kmod-shortcut-fe-cm=m/kmod-shortcut-fe-cm=n/g'|sed 's/kmod-shortcut-fe=m/kmod-shortcut-fe=n/g' |sed 's/kmod-fast-classifier=m/kmod-fast-classifier=n/g' >> .config
make defconfig
sed -n '/^# CONFIG_PACKAGE_kmod/p' .config | sed '/# CONFIG_PACKAGE_kmod is not set/d'|sed 's/# //g'|sed 's/ is not set/=m/g' |sed 's/kmod-shortcut-fe-cm=m/kmod-shortcut-fe-cm=n/g'|sed 's/kmod-shortcut-fe=m/kmod-shortcut-fe=n/g' |sed 's/kmod-fast-classifier=m/kmod-fast-classifier=n/g' >> .config
make defconfig
sed -n '/^# CONFIG_PACKAGE_kmod/p' .config | sed '/# CONFIG_PACKAGE_kmod is not set/d'|sed 's/# //g'|sed 's/ is not set/=m/g' |sed 's/kmod-shortcut-fe-cm=m/kmod-shortcut-fe-cm=n/g'|sed 's/kmod-shortcut-fe=m/kmod-shortcut-fe=n/g' |sed 's/kmod-fast-classifier=m/kmod-fast-classifier=n/g' >> .config
make defconfig
sed -i -n '/CONFIG_PACKAGE_kmod/p' .config
echo CONFIG_IB=y >> .config
echo CONFIG_IB_STANDALONE=y >> .config
cat $GITHUB_WORKSPACE/config/target.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/image.config >> $OPENWRT_ROOT_PATH/.config
make defconfig
sed -i -e "/^CONFIG_[a-zA-Z0-9]\{1,99\}_IMAGES=y$/s/=y/=cmzjnot/g" -e "/^CONFIG_GRUB_IMAGES=cmzjnot$/s/=cmzjnot/=y/g" -e "/^CONFIG_[a-zA-Z0-9]\{1,99\}_IMAGES=cmzjnot$/s/=cmzjnot/=n/g" .config
sed -i -e "/^CONFIG_TARGET_ROOTFS_TARGZ=y$/s/=y/=n/g" .config
sed -i -e "/^CONFIG_TARGET_ROOTFS_CPIOGZ=y$/s/=y/=n/g" .config
make defconfig
./scripts/diffconfig.sh
- name: 下载 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make download -j16
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
make download -j16 || make download -j1 V=s
- name: 构建内核
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make target/compile -j $(($(nproc)+1)) || make target/compile -j$(nproc) V=s || make target/compile -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 清理包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/cleanup -j $(($(nproc)+1)) || make package/cleanup -j$(nproc) V=s || make package/cleanup -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 编译并生成安装包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/compile -j $(($(nproc)+1)) || make package/compile -j1 V=s
make package/install -j $(($(nproc)+1)) || make package/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 制作Image Builder包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make target/install -j $(($(nproc)+1)) || make target/install -j$(nproc) V=s || make target/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 制作包索引、镜像概述信息并计算校验和
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/index -j $(($(nproc)+1)) || make package/index -j$(nproc) V=s || make package/index -j1 V=s
make json_overview_image_info