Compare commits
1295 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3816263878 | ||
|
|
3657c9f7dd | ||
|
|
f5c78c5a04 | ||
|
|
db9449993b | ||
|
|
6613c676cc | ||
|
|
b8ff421a8a | ||
|
|
7e6c90319d | ||
|
|
9a6f39216c | ||
|
|
55aef454e9 | ||
|
|
64581bb718 | ||
|
|
46e2cb8d43 | ||
|
|
c22fae679e | ||
|
|
6a527dba00 | ||
|
|
dafbb302bb | ||
|
|
6e03939f45 | ||
|
|
1264b4192f | ||
|
|
332186224f | ||
|
|
fed349827c | ||
|
|
fd309e7300 | ||
|
|
4a13358c8b | ||
|
|
8833eb99c1 | ||
|
|
6af042ca9f | ||
|
|
0c3405803a | ||
|
|
cbf22a7f29 | ||
|
|
37710884a8 | ||
|
|
066ac191a6 | ||
|
|
985a6344b3 | ||
|
|
8e392b04b8 | ||
|
|
6060b325be | ||
|
|
d84bdba08a | ||
|
|
c6897bd73e | ||
|
|
1058d3310b | ||
|
|
28d8e4ad0c | ||
|
|
8ebe5812ed | ||
|
|
19d09e537a | ||
|
|
ebc9e167f2 | ||
|
|
e030c8095e | ||
|
|
f926834384 | ||
|
|
6af3e51566 | ||
|
|
990b8d0df3 | ||
|
|
1ac8b892e2 | ||
|
|
c44377f2d9 | ||
|
|
16602d0e7f | ||
|
|
6f312a66c0 | ||
|
|
948d55185f | ||
|
|
41783b8531 | ||
|
|
5588beb542 | ||
|
|
547931c4e4 | ||
|
|
e64778911a | ||
|
|
2a9d13bfc8 | ||
|
|
a3600bf05f | ||
|
|
437729a5cf | ||
|
|
b2a844b676 | ||
|
|
5771a308a6 | ||
|
|
0b4215f257 | ||
|
|
cfe850382d | ||
|
|
717b0f96b8 | ||
|
|
91692d6215 | ||
|
|
6aac016c02 | ||
|
|
1829f6e622 | ||
|
|
b84f2f9edd | ||
|
|
de75aaa62b | ||
|
|
a5e358fc4a | ||
|
|
9666b769a1 | ||
|
|
730d18a8a9 | ||
|
|
d6c2111868 | ||
|
|
9dfffbb8f2 | ||
|
|
db2ba39763 | ||
|
|
ec43c09caf | ||
|
|
cc85521a93 | ||
|
|
54dbb0ea68 | ||
|
|
984186f376 | ||
|
|
1a791f2fd1 | ||
|
|
c6b4049a36 | ||
|
|
e335d34eee | ||
|
|
0ff604060d | ||
|
|
dec55705c7 | ||
|
|
4e4b4731ee | ||
|
|
31c93f0844 | ||
|
|
04da1243f5 | ||
|
|
0a49c7b2d9 | ||
|
|
da003f5fd1 | ||
|
|
027c40c8e9 | ||
|
|
bb2d3af1f3 | ||
|
|
128a9c2c8b | ||
|
|
9aa000c3a6 | ||
|
|
f92ebbee04 | ||
|
|
5ccd609dd6 | ||
|
|
7648b6b2f2 | ||
|
|
ebf0176245 | ||
|
|
4bea910d4d | ||
|
|
14be64fc1d | ||
|
|
e8d1890c81 | ||
|
|
438e19a4d6 | ||
|
|
c1e3522303 | ||
|
|
143bc80870 | ||
|
|
a04ea51ab5 | ||
|
|
bceeaa8a21 | ||
|
|
d478be8431 | ||
|
|
d424ed2850 | ||
|
|
6d5ab715e5 | ||
|
|
885bb5103b | ||
|
|
d71ea423dd | ||
|
|
d1149d8d00 | ||
|
|
a7989d3131 | ||
|
|
f2228cb34d | ||
|
|
9758a79d25 | ||
|
|
2f11a11623 | ||
|
|
7b01893dc8 | ||
|
|
9d1a287f91 | ||
|
|
c7e5c1fafb | ||
|
|
d3e8024553 | ||
|
|
32feeaea1b | ||
|
|
95de30d62d | ||
|
|
0d6523eba1 | ||
|
|
9f52a4d2be | ||
|
|
cf07b13776 | ||
|
|
afc4ba3d06 | ||
|
|
4cffe05711 | ||
|
|
7f1832b5fd | ||
|
|
8e1f6a35f6 | ||
|
|
55865d6a7b | ||
|
|
28d913c58b | ||
|
|
90315917e9 | ||
|
|
60ad6c1fc6 | ||
|
|
bcc3206bdd | ||
|
|
b309c46a4c | ||
|
|
58ef09fadd | ||
|
|
5b8bf70407 | ||
|
|
78ff7adf52 | ||
|
|
844cd55cde | ||
|
|
64b5df65b1 | ||
|
|
b98a616bcd | ||
|
|
7b18dfee7b | ||
|
|
56198df675 | ||
|
|
49e15b1584 | ||
|
|
8b4504fc07 | ||
|
|
99dd21f719 | ||
|
|
7c9e351fc5 | ||
|
|
1cac4e8878 | ||
|
|
ac50bd24cb | ||
|
|
51863e7808 | ||
|
|
f42088fa9e | ||
|
|
d22a4e50bc | ||
|
|
c872c9122d | ||
|
|
93088fe4b8 | ||
|
|
645a3d6bf1 | ||
|
|
6a89e41934 | ||
|
|
f2a50d0963 | ||
|
|
43ff5c3fd1 | ||
|
|
981a191de8 | ||
|
|
fd21308870 | ||
|
|
3f82ef355f | ||
|
|
2a3aa24995 | ||
|
|
ad1e488b70 | ||
|
|
6267972622 | ||
|
|
25965b18d7 | ||
|
|
18ba902da5 | ||
|
|
536caa73eb | ||
|
|
4237e8272a | ||
|
|
e7aae2808d | ||
|
|
475e8f3060 | ||
|
|
64924a7ffc | ||
|
|
c8818e4923 | ||
|
|
6600099283 | ||
|
|
8130f11cd1 | ||
|
|
106cb97e08 | ||
|
|
adca7b3ea2 | ||
|
|
12e69edb86 | ||
|
|
0a51b7ebd8 | ||
|
|
eb995e055d | ||
|
|
1eb0e7ee06 | ||
|
|
ed4545d9f2 | ||
|
|
5375a9da19 | ||
|
|
1f81fa4efc | ||
|
|
4b11ee3d8b | ||
|
|
83e8084d22 | ||
|
|
4d70428e35 | ||
|
|
16dff95df0 | ||
|
|
d7ca422100 | ||
|
|
f1eaffab4a | ||
|
|
a08ef58579 | ||
|
|
2f46cd63f5 | ||
|
|
4e9ea3ccc2 | ||
|
|
46083f03ec | ||
|
|
2156dbacad | ||
|
|
7d7e6e1702 | ||
|
|
6776e9a1a9 | ||
|
|
c609a10988 | ||
|
|
79cbceb683 | ||
|
|
404807e69b | ||
|
|
4ef5fc7f18 | ||
|
|
449da90daa | ||
|
|
f7f52691a7 | ||
|
|
058fc62568 | ||
|
|
224021f0f7 | ||
|
|
98b2e14747 | ||
|
|
1ea20097ad | ||
|
|
e6d512eb83 | ||
|
|
9d7543b681 | ||
|
|
3d8a98a2a9 | ||
|
|
4a5aba9140 | ||
|
|
7d230bcf57 | ||
|
|
f195709493 | ||
|
|
98516e0f4d | ||
|
|
0d232fba92 | ||
|
|
aabec77833 | ||
|
|
63b3832ce9 | ||
|
|
81b9c2911a | ||
|
|
f4718a05fd | ||
|
|
6496ff0b9e | ||
|
|
1773745b76 | ||
|
|
ef65acc5df | ||
|
|
51b6ece5b7 | ||
|
|
560a47f358 | ||
|
|
ad087be36a | ||
|
|
0a421eb1cb | ||
|
|
b4e2a56abc | ||
|
|
2692f07a2b | ||
|
|
57d81b2edd | ||
|
|
77a3b458bd | ||
|
|
e2c8525027 | ||
|
|
c33a9dafd0 | ||
|
|
9023f8d0e7 | ||
|
|
6fb8677451 | ||
|
|
6178b212a0 | ||
|
|
34fa12edde | ||
|
|
b6a910143d | ||
|
|
795ed0964f | ||
|
|
3dfe2bb3cf | ||
|
|
978d4c68c4 | ||
|
|
03af965c4e | ||
|
|
80f4690b14 | ||
|
|
62341da96d | ||
|
|
1a1a863938 | ||
|
|
329b97a245 | ||
|
|
62bbe6de24 | ||
|
|
5e4bf57d45 | ||
|
|
e98361f33b | ||
|
|
afd1b08b6d | ||
|
|
7dfe942973 | ||
|
|
7e00ec6523 | ||
|
|
555eb91d35 | ||
|
|
0d19ee249f | ||
|
|
4d813893e9 | ||
|
|
07685390b0 | ||
|
|
0a91a9bdd5 | ||
|
|
5f77b80a4b | ||
|
|
97f307c93c | ||
|
|
e2146a5709 | ||
|
|
a3cf4fcc99 | ||
|
|
41c449f4ac | ||
|
|
2e3dc93499 | ||
|
|
a31bfe0377 | ||
|
|
6315f44950 | ||
|
|
fbca61a7e2 | ||
|
|
3fe354930f | ||
|
|
68175ed8fa | ||
|
|
162deaf807 | ||
|
|
ef154fed2b | ||
|
|
066a377947 | ||
|
|
f099a86e53 | ||
|
|
67915c36c4 | ||
|
|
9c51e8c0f1 | ||
|
|
d48bbc92e0 | ||
|
|
a9cb459609 | ||
|
|
c2747c58be | ||
|
|
41a5e772f5 | ||
|
|
8e066b6d5b | ||
|
|
8531a2c80e | ||
|
|
7e00a49078 | ||
|
|
24a0aff66d | ||
|
|
1be3dc2a0b | ||
|
|
7c1b3c2a91 | ||
|
|
52004a1033 | ||
|
|
492ca4288c | ||
|
|
13d4c7a43f | ||
|
|
e86afb55a6 | ||
|
|
d6f2d65579 | ||
|
|
b286b3e1b3 | ||
|
|
38e5f7df2e | ||
|
|
71e7312002 | ||
|
|
dc20eeeb75 | ||
|
|
3c42e8be2d | ||
|
|
9bec7f30cd | ||
|
|
5aeb706796 | ||
|
|
4da60f0c7d | ||
|
|
5af9e5a2b1 | ||
|
|
a0b7aaabf4 | ||
|
|
0cde3bb45a | ||
|
|
797563c1db | ||
|
|
0ecd128f8f | ||
|
|
097097c664 | ||
|
|
5c44b140e4 | ||
|
|
fec96b812b | ||
|
|
efd2ea2712 | ||
|
|
915dbe1477 | ||
|
|
827a26951b | ||
|
|
f36fd1ccb2 | ||
|
|
ff65de3a75 | ||
|
|
b1ee34862c | ||
|
|
bef1fc9f26 | ||
|
|
616b0caa48 | ||
|
|
caa90fee32 | ||
|
|
341369f347 | ||
|
|
27f145ba2b | ||
|
|
c531b8b56e | ||
|
|
a936136d14 | ||
|
|
4d10023993 | ||
|
|
4829ada7d8 | ||
|
|
e36bdffaff | ||
|
|
ee8b031ee7 | ||
|
|
425ae19d9d | ||
|
|
82aafbca62 | ||
|
|
c9940ec71f | ||
|
|
1af6008c50 | ||
|
|
820591362b | ||
|
|
aa923b4276 | ||
|
|
e235b6dd17 | ||
|
|
d6fbaf91ce | ||
|
|
8458a193a6 | ||
|
|
d146a8a62a | ||
|
|
fd0907bf4b | ||
|
|
6c86e24b9d | ||
|
|
35ef3a4c37 | ||
|
|
2d358fbc6a | ||
|
|
16d643a8ee | ||
|
|
1f1008c440 | ||
|
|
23ba6b8419 | ||
|
|
a7001636c9 | ||
|
|
4ff53269f0 | ||
|
|
ca6498b547 | ||
|
|
68b921d9c5 | ||
|
|
e797b6f282 | ||
|
|
8ffe5bc12d | ||
|
|
777f9175e4 | ||
|
|
d3f6e16bc3 | ||
|
|
8b60633230 | ||
|
|
a417afa4b5 | ||
|
|
d97365ed4e | ||
|
|
c3e24ee3d5 | ||
|
|
2304d4b2aa | ||
|
|
52d8673b9b | ||
|
|
91a2fe3488 | ||
|
|
173e5a3ffc | ||
|
|
64e625d486 | ||
|
|
da82acc251 | ||
|
|
ee3bef5eab | ||
|
|
3200e2ab3b | ||
|
|
8df5363007 | ||
|
|
8df311e700 | ||
|
|
d7704712d7 | ||
|
|
ab5d20638d | ||
|
|
49cf464eb2 | ||
|
|
1a73a31e06 | ||
|
|
695ce1072c | ||
|
|
c36be5f59c | ||
|
|
27243a62bc | ||
|
|
43131e3653 | ||
|
|
fdfd1b20ce | ||
|
|
e500140bc6 | ||
|
|
d87b722b1c | ||
|
|
5e679b1c33 | ||
|
|
c490b73072 | ||
|
|
9542ce33bc | ||
|
|
f17a1c70b8 | ||
|
|
60ce1ba580 | ||
|
|
94279c795b | ||
|
|
a644c271fb | ||
|
|
013c95386c | ||
|
|
851bb508b1 | ||
|
|
f18c72f471 | ||
|
|
d70514e357 | ||
|
|
26e3c60ae8 | ||
|
|
53225997d2 | ||
|
|
bfb6022beb | ||
|
|
53adda7268 | ||
|
|
e95e9f7a9e | ||
|
|
61944e01de | ||
|
|
ff3e80c6ee | ||
|
|
d1fbf1e2af | ||
|
|
4d51d5dcd3 | ||
|
|
3c2a133fd7 | ||
|
|
e186b33850 | ||
|
|
fde3b37f01 | ||
|
|
6dcb85a5f4 | ||
|
|
434af1cd93 | ||
|
|
ef09616b77 | ||
|
|
9213e86643 | ||
|
|
1754a1a943 | ||
|
|
94bf2f5caf | ||
|
|
8ecc0fd705 | ||
|
|
62e94ad00c | ||
|
|
ffa8f397ff | ||
|
|
f4483a40e7 | ||
|
|
acc55c7d91 | ||
|
|
5e9b56399e | ||
|
|
6b7af05a7f | ||
|
|
86e0165733 | ||
|
|
6b883db9ac | ||
|
|
f6374fae9c | ||
|
|
31f1f30c31 | ||
|
|
2ea11f3e83 | ||
|
|
1b8323816c | ||
|
|
5d89f4f0e6 | ||
|
|
8e59c0e0ac | ||
|
|
29bdd09dab | ||
|
|
f0ae6c1dba | ||
|
|
4feb51f12f | ||
|
|
63f678d1a6 | ||
|
|
c058c91a83 | ||
|
|
d8284ef287 | ||
|
|
ba8e841dde | ||
|
|
0703551fd0 | ||
|
|
92f341179b | ||
|
|
fa4a69b4b9 | ||
|
|
b8d8ceb7b4 | ||
|
|
d1ec1f0dd8 | ||
|
|
77278e1119 | ||
|
|
f4812cd65b | ||
|
|
7011fc1f79 | ||
|
|
00f6deafb9 | ||
|
|
c7015c6504 | ||
|
|
78e863a2a1 | ||
|
|
a3a8127543 | ||
|
|
cf32d388fe | ||
|
|
62da78c363 | ||
|
|
777ca5a246 | ||
|
|
ff82bc632b | ||
|
|
38bafe6ed1 | ||
|
|
e1d25a25c4 | ||
|
|
de32ec5aa7 | ||
|
|
3520891247 | ||
|
|
4197e6769f | ||
|
|
e628908baf | ||
|
|
2300c3052c | ||
|
|
498eabf869 | ||
|
|
88dfac2d86 | ||
|
|
e31d600cb3 | ||
|
|
6348cc5187 | ||
|
|
42d6ba7716 | ||
|
|
651a4cba3c | ||
|
|
88ecbb22de | ||
|
|
dee86dbcef | ||
|
|
e2c79fe87d | ||
|
|
56636911b5 | ||
|
|
a36f2f8664 | ||
|
|
3eb948f1cf | ||
|
|
47129d36f7 | ||
|
|
cf6bf35af0 | ||
|
|
cfea697870 | ||
|
|
c399d074c8 | ||
|
|
4127c83bab | ||
|
|
bb14dd3a41 | ||
|
|
f9ad8ea242 | ||
|
|
6f913b2170 | ||
|
|
41d1775fb9 | ||
|
|
c840acc785 | ||
|
|
71f3e7b175 | ||
|
|
80c9db59b4 | ||
|
|
a813429924 | ||
|
|
c989f250b0 | ||
|
|
f62e3f3397 | ||
|
|
7669a0417b | ||
|
|
174ba78f0d | ||
|
|
e0396164ac | ||
|
|
d15d865cc5 | ||
|
|
8259a5fd9a | ||
|
|
2a27fd4fc1 | ||
|
|
f26817f433 | ||
|
|
a8c82a7476 | ||
|
|
3b7147b25a | ||
|
|
9aeb3541ed | ||
|
|
85d8ee940c | ||
|
|
b1a45fb4d7 | ||
|
|
4035984d72 | ||
|
|
d8b53cbfdb | ||
|
|
2ec3c3d8d1 | ||
|
|
ac114dd2f8 | ||
|
|
f64ccf4870 | ||
|
|
2dbee0b272 | ||
|
|
ff14468b14 | ||
|
|
e0988351eb | ||
|
|
bdba1fac31 | ||
|
|
8032921182 | ||
|
|
286843b40b | ||
|
|
2387b4e9f8 | ||
|
|
15ce694967 | ||
|
|
08da1c712b | ||
|
|
04b15fec17 | ||
|
|
902a40bed7 | ||
|
|
66e5c1f7e0 | ||
|
|
c86b75987e | ||
|
|
cefa25a883 | ||
|
|
a6b0338ee0 | ||
|
|
c3657b44ef | ||
|
|
c4d0d1eb0e | ||
|
|
4e5003f36e | ||
|
|
676089ee7a | ||
|
|
efd98676b8 | ||
|
|
094acc1e85 | ||
|
|
7369734df6 | ||
|
|
02f08acf5c | ||
|
|
5ac415801c | ||
|
|
35f85e048a | ||
|
|
887eec51f6 | ||
|
|
4ac8ae9cc0 | ||
|
|
78001c002f | ||
|
|
fcdcbf058a | ||
|
|
7bb3aab285 | ||
|
|
4686f71cde | ||
|
|
56e0907609 | ||
|
|
eb7753511e | ||
|
|
f2a383412c | ||
|
|
8f501dd50e | ||
|
|
3e3e9aede2 | ||
|
|
fbdeeb125d | ||
|
|
0b5c67811e | ||
|
|
5c85073939 | ||
|
|
eb51b1d7d3 | ||
|
|
895d0b4823 | ||
|
|
0fb89b854b | ||
|
|
0dba3904cf | ||
|
|
ec8f57dc98 | ||
|
|
43dd694054 | ||
|
|
3a1ec43d8d | ||
|
|
b914a17549 | ||
|
|
87997aeeb6 | ||
|
|
686c0c0891 | ||
|
|
5c275c1b82 | ||
|
|
d0b0cdaae7 | ||
|
|
a71a39230b | ||
|
|
f9b3362dbd | ||
|
|
681ea40cee | ||
|
|
fac71e0dcb | ||
|
|
06067d35b4 | ||
|
|
f6d78d0399 | ||
|
|
572851f576 | ||
|
|
685ae27d23 | ||
|
|
6c07328071 | ||
|
|
65ca09e332 | ||
|
|
2aef111e74 | ||
|
|
cb7310845f | ||
|
|
34c90e13f4 | ||
|
|
e3dd337b28 | ||
|
|
bd45eff13c | ||
|
|
64513e8d15 | ||
|
|
b38b75d316 | ||
|
|
8b4dff9c4a | ||
|
|
00e0f28d5c | ||
|
|
d2d7374786 | ||
|
|
15268cfd0f | ||
|
|
93a5ed2e6f | ||
|
|
a40e3b1525 | ||
|
|
4dc7908e74 | ||
|
|
fababf3aec | ||
|
|
22beaa7f4c | ||
|
|
7d7ff19d86 | ||
|
|
e1a32fe044 | ||
|
|
ea0a54398f | ||
|
|
88558af591 | ||
|
|
2c2befd950 | ||
|
|
a63af77e02 | ||
|
|
662898f628 | ||
|
|
9042fb5134 | ||
|
|
033f93b620 | ||
|
|
964fea4e11 | ||
|
|
1755ea5b2d | ||
|
|
7642898eab | ||
|
|
efb802b0c8 | ||
|
|
659fbc53ce | ||
|
|
f8473dfac7 | ||
|
|
5b681e2a68 | ||
|
|
aa2fd3381d | ||
|
|
a54f704719 | ||
|
|
747c29e85f | ||
|
|
4a5724cacc | ||
|
|
d4e77a4050 | ||
|
|
c455dda5fc | ||
|
|
109ac591c4 | ||
|
|
09010c2ba1 | ||
|
|
d656430142 | ||
|
|
7e3a3f5260 | ||
|
|
a70ae801b9 | ||
|
|
ed402a22ff | ||
|
|
0df9d54b27 | ||
|
|
a70b251fa2 | ||
|
|
d9dac7af6e | ||
|
|
87ec78340a | ||
|
|
48be5f5acb | ||
|
|
c0598b2dad | ||
|
|
543848ad2f | ||
|
|
4010970b7f | ||
|
|
6e40cfe238 | ||
|
|
6e2b33269a | ||
|
|
1c27e328c9 | ||
|
|
dce39ed6c8 | ||
|
|
291fd3cfc9 | ||
|
|
b6eaa9721c | ||
|
|
5080fc5864 | ||
|
|
e48958c275 | ||
|
|
459c1cf3cd | ||
|
|
026c4e4b5b | ||
|
|
8dbf5625ee | ||
|
|
f6731adf81 | ||
|
|
4fed086f7d | ||
|
|
cb0021ded8 | ||
|
|
b543c124be | ||
|
|
4b5aff7862 | ||
|
|
5f8da597ff | ||
|
|
e953aceb54 | ||
|
|
8b9c0b565b | ||
|
|
007465c996 | ||
|
|
9f679383c8 | ||
|
|
c53bd62534 | ||
|
|
6120d98688 | ||
|
|
805234a474 | ||
|
|
2e58b7325d | ||
|
|
9256daa5bc | ||
|
|
cf9516b2c2 | ||
|
|
f9c81e695a | ||
|
|
0119eb0db9 | ||
|
|
4119466247 | ||
|
|
54e13aa77f | ||
|
|
21527184b6 | ||
|
|
789240dd2f | ||
|
|
168cce314f | ||
|
|
429fe656b2 | ||
|
|
2ad8c63b59 | ||
|
|
90cf624f53 | ||
|
|
2e0059978c | ||
|
|
dc34c4494a | ||
|
|
efa31ca0fc | ||
|
|
765da083da | ||
|
|
7e629fe96d | ||
|
|
72c752bfdd | ||
|
|
5bd1b61755 | ||
|
|
6b1a364fe6 | ||
|
|
2da1dffca4 | ||
|
|
c60e740549 | ||
|
|
5b70f7fd8c | ||
|
|
ba6fa809d4 | ||
|
|
7841e9bf1e | ||
|
|
537ed4fd8c | ||
|
|
9cbad804c5 | ||
|
|
28a3aae6e1 | ||
|
|
75c1401776 | ||
|
|
b9e7937526 | ||
|
|
31852b4f57 | ||
|
|
a2851d5246 | ||
|
|
54a93f9e19 | ||
|
|
72030ccec6 | ||
|
|
5372ace76f | ||
|
|
e60ff265d0 | ||
|
|
944a803ba4 | ||
|
|
82efdf97d4 | ||
|
|
acc8f8bf72 | ||
|
|
cd13b48c21 | ||
|
|
899297de22 | ||
|
|
74be327274 | ||
|
|
c3d6b1c5f3 | ||
|
|
d49377f166 | ||
|
|
dd2333f0c8 | ||
|
|
5cde6622b5 | ||
|
|
ca00e0233b | ||
|
|
7d0923e9de | ||
|
|
a978659696 | ||
|
|
27696d707e | ||
|
|
99748a51da | ||
|
|
670acaf247 | ||
|
|
2c64d724ef | ||
|
|
f307795e57 | ||
|
|
211e98cce1 | ||
|
|
f312dd3b8d | ||
|
|
eb24afc650 | ||
|
|
e8a22c13f2 | ||
|
|
17bd90f09b | ||
|
|
b3915738d8 | ||
|
|
a41d76b84f | ||
|
|
5106de1185 | ||
|
|
14b4c77125 | ||
|
|
73c63d117f | ||
|
|
c1a16582ff | ||
|
|
08dd6228f3 | ||
|
|
32b7477d21 | ||
|
|
7f0888c9da | ||
|
|
cacc70029a | ||
|
|
86a1fa3b16 | ||
|
|
a7b55064b1 | ||
|
|
50d6324b40 | ||
|
|
31addff431 | ||
|
|
a86ed49615 | ||
|
|
7c7c1ddc00 | ||
|
|
d292c0c3fb | ||
|
|
0821663073 | ||
|
|
2124770aeb | ||
|
|
975b2391cb | ||
|
|
02c3a815de | ||
|
|
d798da80f7 | ||
|
|
9e66fe4e93 | ||
|
|
1c630d3c5b | ||
|
|
7543e67920 | ||
|
|
e2b6bb9233 | ||
|
|
40ef2ae201 | ||
|
|
91e0696bc5 | ||
|
|
d6a3de0558 | ||
|
|
4339e856d3 | ||
|
|
ac676e07c6 | ||
|
|
5d992335f1 | ||
|
|
aea231bbc0 | ||
|
|
5a1c1f5470 | ||
|
|
8a288b90bc | ||
|
|
187f90dca5 | ||
|
|
aa1ab323d9 | ||
|
|
ecb083208f | ||
|
|
42135de152 | ||
|
|
ebbe2521bc | ||
|
|
d4e1e7dd37 | ||
|
|
075f91cbde | ||
|
|
258b54ba32 | ||
|
|
683aadee17 | ||
|
|
c6bbf99883 | ||
|
|
5de4f64133 | ||
|
|
62fefdb09d | ||
|
|
9b3ca55818 | ||
|
|
3c84ad550d | ||
|
|
eb808c49a5 | ||
|
|
7c7408e4b8 | ||
|
|
a2321fdc06 | ||
|
|
aab3042c88 | ||
|
|
c41bcf7e38 | ||
|
|
cac040efdf | ||
|
|
74915f629d | ||
|
|
d425fff037 | ||
|
|
d25c0addcb | ||
|
|
dc9cb70217 | ||
|
|
a67fc7c859 | ||
|
|
8f99e12efb | ||
|
|
6ecf028c84 | ||
|
|
19b9e54261 | ||
|
|
662cd7c311 | ||
|
|
573c981de5 | ||
|
|
1cf40ae473 | ||
|
|
7d190fcbc1 | ||
|
|
0c7e65db05 | ||
|
|
8e0fbb2f6b | ||
|
|
7ee02b8fea | ||
|
|
089fc77486 | ||
|
|
463f9092a6 | ||
|
|
7bfe7c7d26 | ||
|
|
7e3eb3d5ed | ||
|
|
ef5933a412 | ||
|
|
e8c0085c47 | ||
|
|
61a049b776 | ||
|
|
283acfa4ba | ||
|
|
b8034c44e7 | ||
|
|
1b4d088b42 | ||
|
|
8f1498e73c | ||
|
|
56dfa4f1fd | ||
|
|
b2a5b0add3 | ||
|
|
5e0b02cf3f | ||
|
|
09fba2b888 | ||
|
|
44dcebf5ad | ||
|
|
340928f2db | ||
|
|
b560bc02aa | ||
|
|
b70e0c4d6b | ||
|
|
40f0a96755 | ||
|
|
51f8d597cf | ||
|
|
d60c961dac | ||
|
|
00b59ade2f | ||
|
|
460f71b012 | ||
|
|
4c6ca7d289 | ||
|
|
24af8eb090 | ||
|
|
d6834c3d5a | ||
|
|
9d226fbaa5 | ||
|
|
3c9e6c3aaa | ||
|
|
f60ab545da | ||
|
|
787b27c36d | ||
|
|
e25bc2684d | ||
|
|
77cf7845bd | ||
|
|
883876e050 | ||
|
|
edaca65598 | ||
|
|
9db5d0d89a | ||
|
|
ca1ad698b2 | ||
|
|
9c8ad7da66 | ||
|
|
f1d7aa3802 | ||
|
|
646f5f4c19 | ||
|
|
0dbf4444ce | ||
|
|
4c3d7b9cc1 | ||
|
|
2d75a48c19 | ||
|
|
7226eecf3d | ||
|
|
a033510c52 | ||
|
|
47bc5bc81a | ||
|
|
52212db815 | ||
|
|
e2fd640045 | ||
|
|
915adab934 | ||
|
|
b06a1125e1 | ||
|
|
f1f97a35a7 | ||
|
|
da87eac55d | ||
|
|
da3f90ab83 | ||
|
|
58bcec1eb2 | ||
|
|
7838284e8b | ||
|
|
0a51fa434d | ||
|
|
7dd4a0b028 | ||
|
|
a9812f63f1 | ||
|
|
88141b67fd | ||
|
|
1ab8b7c8e5 | ||
|
|
536c69d04f | ||
|
|
00910b025e | ||
|
|
3ebe6fe9c8 | ||
|
|
37d77a75c0 | ||
|
|
11f8e992e7 | ||
|
|
4a89c96232 | ||
|
|
d49848842c | ||
|
|
2fed679925 | ||
|
|
4297c2ed50 | ||
|
|
70e61c4008 | ||
|
|
c137cc8f54 | ||
|
|
75a6a36846 | ||
|
|
c0663d5ca0 | ||
|
|
b6fbf513a3 | ||
|
|
4c77e479ba | ||
|
|
ee9e2b46c0 | ||
|
|
ded7f55bcc | ||
|
|
19b612aa18 | ||
|
|
f4aae4bee2 | ||
|
|
b4d18a91ad | ||
|
|
7d3bbe599b | ||
|
|
628f887a3b | ||
|
|
920933fc47 | ||
|
|
82d01f7b99 | ||
|
|
d676f8974e | ||
|
|
6050b617aa | ||
|
|
db843855b7 | ||
|
|
0c60795c6f | ||
|
|
9ae9500fec | ||
|
|
9dcd539495 | ||
|
|
f57655c091 | ||
|
|
716589ff0e | ||
|
|
c15dfce337 | ||
|
|
8361699b6e | ||
|
|
c11bb287c0 | ||
|
|
a7360aac22 | ||
|
|
ab509f6207 | ||
|
|
6464831a38 | ||
|
|
1641ee3b02 | ||
|
|
c152e4d530 | ||
|
|
8ce2c7cf96 | ||
|
|
0b9e4c39bd | ||
|
|
d586de20d5 | ||
|
|
9467dd1847 | ||
|
|
edb590741d | ||
|
|
22c2bc6408 | ||
|
|
71d6c68e11 | ||
|
|
43cb5dd945 | ||
|
|
603525790e | ||
|
|
66ad62d209 | ||
|
|
5a8a75eb71 | ||
|
|
ae72e78592 | ||
|
|
3f8f8b0619 | ||
|
|
e9d41ffe6f | ||
|
|
7a5f56ffe6 | ||
|
|
d4ab7e0ec6 | ||
|
|
6ded3380e5 | ||
|
|
2746fe03c0 | ||
|
|
ddfa5639d0 | ||
|
|
be3982bbff | ||
|
|
252a64924f | ||
|
|
d18041429c | ||
|
|
13f6bc63c8 | ||
|
|
9112ff8860 | ||
|
|
2167c5a714 | ||
|
|
50e6e2da6e | ||
|
|
d642275209 | ||
|
|
f048bd1189 | ||
|
|
5543b7a089 | ||
|
|
7c8d64adbc | ||
|
|
90ecd7f5ed | ||
|
|
08fbdb685b | ||
|
|
4ecdc7f7bd | ||
|
|
a8ee7ec037 | ||
|
|
69622b8a64 | ||
|
|
0d9113ba5c | ||
|
|
7e1db55c22 | ||
|
|
201be5d61c | ||
|
|
a5dcaad8d0 | ||
|
|
8c1bb3d5a9 | ||
|
|
9eb4e8987b | ||
|
|
10052d4fc2 | ||
|
|
1125a25e6d | ||
|
|
c3d4bbf967 | ||
|
|
661c52c234 | ||
|
|
46811aa2ec | ||
|
|
10b26595ae | ||
|
|
a11fc9dcd9 | ||
|
|
c970135e27 | ||
|
|
31742ca834 | ||
|
|
27afe8a8e9 | ||
|
|
67380177cf | ||
|
|
f1e57b2470 | ||
|
|
18c23138cd | ||
|
|
ca485c59d2 | ||
|
|
e0944157d4 | ||
|
|
b3163241cf | ||
|
|
fd8160275a | ||
|
|
5209c37954 | ||
|
|
c6468ffdcb | ||
|
|
ab0b09ae68 | ||
|
|
18274d8e88 | ||
|
|
68961a7d9c | ||
|
|
5ec75b379a | ||
|
|
3e62f2aa85 | ||
|
|
cc88867aae | ||
|
|
cc713816c6 | ||
|
|
4515432804 | ||
|
|
43395aa6d9 | ||
|
|
526a7feb89 | ||
|
|
6e7b4bf985 | ||
|
|
cd7281600e | ||
|
|
7c75b37d09 | ||
|
|
f9d360d2bf | ||
|
|
3c683ca339 | ||
|
|
5419a13936 | ||
|
|
245f0ed5d5 | ||
|
|
e65a16c009 | ||
|
|
fd762f9d3c | ||
|
|
722de55ecb | ||
|
|
6a59ec51e1 | ||
|
|
7eb120befa | ||
|
|
92d5407269 | ||
|
|
743380290e | ||
|
|
b8f847a9ce | ||
|
|
f2d8997909 | ||
|
|
c3587edfae | ||
|
|
7825acfff3 | ||
|
|
c1c495cf6d | ||
|
|
505b14895e | ||
|
|
7379a7c0f3 | ||
|
|
f1a0a1d22f | ||
|
|
1182e79b46 | ||
|
|
1c239f00b0 | ||
|
|
d7cc74c494 | ||
|
|
5d7a13a56b | ||
|
|
7fb00280a8 | ||
|
|
bba1df37f8 | ||
|
|
9e6ff663f9 | ||
|
|
d4ecd8dc1e | ||
|
|
5f8c0a6ff3 | ||
|
|
452dbf81e8 | ||
|
|
375de1118b | ||
|
|
a21aaa8739 | ||
|
|
037da48755 | ||
|
|
cc0367a3a2 | ||
|
|
7d771ead43 | ||
|
|
bbb66dd9d4 | ||
|
|
ba98d46e97 | ||
|
|
06ec69b82e | ||
|
|
943d4edaf0 | ||
|
|
1b1f13aa71 | ||
|
|
f5208fd3e1 | ||
|
|
0373e8149e | ||
|
|
5a225c4e12 | ||
|
|
e1210e82ce | ||
|
|
1f61623eeb | ||
|
|
5b23eb08e6 | ||
|
|
3e2e7f92fd | ||
|
|
7412da9a9b | ||
|
|
084d99c77d | ||
|
|
d0027da4cc | ||
|
|
a4c3da0b1f | ||
|
|
3514664ae0 | ||
|
|
13e3c8ada1 | ||
|
|
36b4d1e6de | ||
|
|
152ea4314f | ||
|
|
76093338f4 | ||
|
|
b82956b4dc | ||
|
|
09f1d56ab1 | ||
|
|
db4def0d47 | ||
|
|
dc41cbb0c1 | ||
|
|
079a962ab7 | ||
|
|
dd4a9efd52 | ||
|
|
303f9cad14 | ||
|
|
b089172ebc | ||
|
|
a21af7a385 | ||
|
|
8131588426 | ||
|
|
969779f44a | ||
|
|
2c2c6dd950 | ||
|
|
2616d060c7 | ||
|
|
c8ee0e9c84 | ||
|
|
e0a2efeb71 | ||
|
|
b13939f074 | ||
|
|
5f2160b3d1 | ||
|
|
3c81b6bf39 | ||
|
|
342a4e906d | ||
|
|
34cda38165 | ||
|
|
f8fbc5c90a | ||
|
|
1edb4c2764 | ||
|
|
fe019cc003 | ||
|
|
a22578604a | ||
|
|
c6a0801b14 | ||
|
|
15c0ae6204 | ||
|
|
5405ce9566 | ||
|
|
322a3c93d8 | ||
|
|
754058837e | ||
|
|
10ec1fce88 | ||
|
|
2d0e198aa4 | ||
|
|
6a81785a4d | ||
|
|
f82c173e92 | ||
|
|
5c1524f086 | ||
|
|
e13656eb9b | ||
|
|
9db18d2b04 | ||
|
|
3f0e7fa78d | ||
|
|
9f3046b423 | ||
|
|
73b23fc18e | ||
|
|
2ec4957d3c | ||
|
|
fad3441389 | ||
|
|
9a7aab63b8 | ||
|
|
c5bfe31ca1 | ||
|
|
349d9aac4f | ||
|
|
9fe5782be4 | ||
|
|
3656b99141 | ||
|
|
75f8aa1d6f | ||
|
|
7ab062bd90 | ||
|
|
b4a566e76f | ||
|
|
0e351ac607 | ||
|
|
2d202abc39 | ||
|
|
6d65385086 | ||
|
|
648ffeee29 | ||
|
|
6938c44b03 | ||
|
|
3756fee7dc | ||
|
|
1cc6f5ddbe | ||
|
|
09c1f6ce23 | ||
|
|
423b041a91 | ||
|
|
d9e6840399 | ||
|
|
be4f11b1d8 | ||
|
|
dc21a18d36 | ||
|
|
baa0cfdcfd | ||
|
|
2a83a2b6b0 | ||
|
|
3146c7f58d | ||
|
|
53820935dd | ||
|
|
dcb8c2ef79 | ||
|
|
c3101acebc | ||
|
|
09a51a07bf | ||
|
|
0c10b1b1d1 | ||
|
|
60e611edd4 | ||
|
|
f705b3fa48 | ||
|
|
7baffd80af | ||
|
|
f042dc8d25 | ||
|
|
87aba9676e | ||
|
|
9fd619e7ca | ||
|
|
c2273b8c42 | ||
|
|
9af1dc8ee4 | ||
|
|
413d3078cb | ||
|
|
ec475841fc | ||
|
|
1d3e9dd209 | ||
|
|
e29eedea2c | ||
|
|
35c1a5be18 | ||
|
|
2a52c898d6 | ||
|
|
ffaee0b0c3 | ||
|
|
aed52560a7 | ||
|
|
d030f9adb5 | ||
|
|
b77c7f5390 | ||
|
|
5b39a386d0 | ||
|
|
411732edf6 | ||
|
|
1abd7a28b0 | ||
|
|
a49e59ef49 | ||
|
|
10eb726a1d | ||
|
|
63c036ccd4 | ||
|
|
9332b5a4e3 | ||
|
|
e8c38b6bf8 | ||
|
|
30537d3d69 | ||
|
|
30490d75e1 | ||
|
|
5af2aa0aa3 | ||
|
|
4fcaf5bc11 | ||
|
|
9d92da62ff | ||
|
|
af5ff9afec | ||
|
|
394bcda1b3 | ||
|
|
4c993bac04 | ||
|
|
001b477936 | ||
|
|
e66cff3686 | ||
|
|
97ae3af72c | ||
|
|
9054584280 | ||
|
|
ca1dd97a52 | ||
|
|
2e33ef697e | ||
|
|
4b70835daf | ||
|
|
bb954dc142 | ||
|
|
7901491c39 | ||
|
|
48cefa1b1d | ||
|
|
3ff2376351 | ||
|
|
f431352952 | ||
|
|
0baf265c0a | ||
|
|
5f4d5dc583 | ||
|
|
10cbae4404 | ||
|
|
e30d9026bc | ||
|
|
b14b0578f1 | ||
|
|
e0fccebf53 | ||
|
|
135444cd47 | ||
|
|
fc6131283c | ||
|
|
2d0fb8ce56 | ||
|
|
5fdea2a3c6 | ||
|
|
b33446c63b | ||
|
|
f6d03a68bb | ||
|
|
8f7b04442b | ||
|
|
255dc20d1f | ||
|
|
f63d34156a | ||
|
|
64e54e85ff | ||
|
|
b7410d96ad | ||
|
|
8ab5f5fb40 | ||
|
|
2e3c41d584 | ||
|
|
a82e413add | ||
|
|
78477c26a8 | ||
|
|
8682e99b5b | ||
|
|
70a39a3e56 | ||
|
|
253018a4ca | ||
|
|
bf666fadfd | ||
|
|
16e7007197 | ||
|
|
f869b6e292 | ||
|
|
959b8ffa0f | ||
|
|
7008794b74 | ||
|
|
3c07b29359 | ||
|
|
ca9f827d0f | ||
|
|
f211b72691 | ||
|
|
6b96e4f063 | ||
|
|
5c61ec6590 | ||
|
|
34cb47fbfa | ||
|
|
bbc773ee36 | ||
|
|
9c1ac559f9 | ||
|
|
f867f8724b | ||
|
|
34ec28100a | ||
|
|
8fb009fb0a | ||
|
|
a6e9d4c4d3 | ||
|
|
bf92473c2b | ||
|
|
f62962b3cc | ||
|
|
ff8f6127fc | ||
|
|
8e5224ec3d | ||
|
|
eac38ffc4a | ||
|
|
6831cfaede | ||
|
|
31b4658477 | ||
|
|
194f721b8f | ||
|
|
47058e2fb0 | ||
|
|
d7a2c7d2c3 | ||
|
|
8175d3ee42 | ||
|
|
b45b767468 | ||
|
|
79a0b619f0 | ||
|
|
4074338410 | ||
|
|
5659a0b3c8 | ||
|
|
8cd4fa0d1a | ||
|
|
9eeeca23d7 | ||
|
|
5c2299fb1e | ||
|
|
9d27c29d96 | ||
|
|
efe64f6eda | ||
|
|
a67b810871 | ||
|
|
daa6df971f | ||
|
|
4c9af41941 | ||
|
|
6849f678fe | ||
|
|
2b9c6e54b6 | ||
|
|
1799555f9c | ||
|
|
7c92413ddb | ||
|
|
0e155a6420 | ||
|
|
df8e7c2fd7 | ||
|
|
eb0183c9e4 | ||
|
|
383c610dde | ||
|
|
ed901cdab6 | ||
|
|
a290f22fe1 | ||
|
|
a59265a6f0 | ||
|
|
6579e52f0b | ||
|
|
909391cb37 | ||
|
|
f5f08f237f | ||
|
|
d7c9f453b9 | ||
|
|
6097792432 | ||
|
|
9e01bb709d | ||
|
|
9f926af5cf | ||
|
|
ee1f578b7a | ||
|
|
43f80335da | ||
|
|
a542e77769 | ||
|
|
9fde99519b | ||
|
|
3c0aca3b86 | ||
|
|
23db00016c | ||
|
|
90b92c70d8 | ||
|
|
ade48440c8 | ||
|
|
0a69ff40c0 | ||
|
|
bc17cf3620 | ||
|
|
10d376885c | ||
|
|
94b3c15781 | ||
|
|
835e2cd056 | ||
|
|
dc1d7d7976 | ||
|
|
07a435fbc6 | ||
|
|
3387e3d90b | ||
|
|
96fde8a2f7 | ||
|
|
81b4bbb4b5 | ||
|
|
ac4d6f46fe | ||
|
|
26eece53eb | ||
|
|
a27f92a10d | ||
|
|
5e9078d361 | ||
|
|
394905e2a0 | ||
|
|
6bd06aafd0 | ||
|
|
3ab72acc86 | ||
|
|
229bb0a434 | ||
|
|
4e09218b02 | ||
|
|
96c44191b3 | ||
|
|
51d08a5746 | ||
|
|
4e349aa583 | ||
|
|
9009bd6d9b | ||
|
|
7460f00251 | ||
|
|
1df0ae5b45 | ||
|
|
af578e6ded | ||
|
|
6696eefe7d | ||
|
|
eba633b6e4 | ||
|
|
15d9ba817e | ||
|
|
7d92781a31 | ||
|
|
2a0d056d87 | ||
|
|
f5c9fa8c3d | ||
|
|
2753a4c3d7 | ||
|
|
0f97a00f68 | ||
|
|
033dc9e678 | ||
|
|
c0a2f7c232 | ||
|
|
3932f03237 | ||
|
|
07c722bd36 | ||
|
|
e167331c01 | ||
|
|
362695afee | ||
|
|
26274ed907 | ||
|
|
e18f8bf4fc | ||
|
|
56559b57b2 | ||
|
|
9e515872c2 | ||
|
|
be8c119f46 | ||
|
|
b6cf0dedee | ||
|
|
ad9599a612 | ||
|
|
9d16a50c55 | ||
|
|
4bdce5ca83 | ||
|
|
644ef05af3 | ||
|
|
d4c782a177 | ||
|
|
dde25a1ca5 | ||
|
|
9d7a121947 | ||
|
|
019b0b060b | ||
|
|
a92b30c57b | ||
|
|
e77e42fb6c | ||
|
|
8305341d62 | ||
|
|
bbfb6d5401 | ||
|
|
66b2d36c39 | ||
|
|
cb2fc02ad7 | ||
|
|
5902d103f6 | ||
|
|
b11944f9bd | ||
|
|
62781f54c3 | ||
|
|
415d5d2092 | ||
|
|
0a65baecb0 | ||
|
|
7d87ef0757 | ||
|
|
d28f7fef10 | ||
|
|
1c37cfa311 | ||
|
|
d3c8f7fdfe | ||
|
|
ea61e2af34 | ||
|
|
0cc5beb59d | ||
|
|
12bfd5c137 | ||
|
|
ed5e66b04a | ||
|
|
bf3ded202f | ||
|
|
37886aba47 | ||
|
|
0edab81981 | ||
|
|
ed5b0981bd | ||
|
|
d12e626f69 | ||
|
|
645f073b9f | ||
|
|
5bfdcdc564 | ||
|
|
ccaf8d2b33 | ||
|
|
c96323c6bd | ||
|
|
8c4a7969fd | ||
|
|
49c5c0163d | ||
|
|
8fc2fb050b | ||
|
|
fa96a44bab | ||
|
|
03e4556718 | ||
|
|
0cbc76c56e | ||
|
|
20bbd87956 | ||
|
|
2bb2fd9089 | ||
|
|
92755d5ab6 | ||
|
|
a5ce0698f2 | ||
|
|
398350f505 | ||
|
|
4a8a3dcb9a | ||
|
|
79e7296b63 | ||
|
|
89646983ab | ||
|
|
a60446eab2 | ||
|
|
e02d70351c | ||
|
|
7a2d8fc9f8 | ||
|
|
cb0f229873 | ||
|
|
b1aae3139f | ||
|
|
3d58b6dcac | ||
|
|
2219cd3a7d | ||
|
|
182bed75d6 | ||
|
|
f1557f6e01 | ||
|
|
fceb0363de | ||
|
|
bf1fb434ae | ||
|
|
6c53a19e2e | ||
|
|
7416a9d74d | ||
|
|
4ebe58c1f1 | ||
|
|
0282062868 | ||
|
|
94735c823b | ||
|
|
2d352c3981 | ||
|
|
d310dce76e | ||
|
|
a8e8b2481c |
|
|
@ -1,4 +1,17 @@
|
|||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# Config Type : EditorConfig
|
||||
# Config Authors: 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nil Null <nil@null.org>
|
||||
# Created On : <2023-09-06>
|
||||
# Last Modified : <2025-08-27>
|
||||
#
|
||||
# 请参考 ./doc/03-为什么拒绝使用代码格式化工具.md
|
||||
#
|
||||
# http://editorconfig.org
|
||||
# --------------------------------------------------------------
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
|
|
@ -6,14 +19,34 @@ indent_style = space
|
|||
indent_size = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
||||
|
||||
# VS Code 对该配置(为 false)的实现有问题,这是确定的,
|
||||
# 然而 CLion 似乎对该配置(为 false)的实现是正确的,这导致不同贡献者反而产生了冲突
|
||||
# 所以我们现在改成 true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{c,C,cpp,cxx,cc,h,hpp}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.pl]
|
||||
indent_size = 4
|
||||
|
||||
[*.{raku,rakumod,rakutest}]
|
||||
indent_size = 2
|
||||
|
||||
[*.ps1]
|
||||
indent_size = 4
|
||||
|
||||
[*.{sh,bash}]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile,makefile,*.{mk,make,makefile}]
|
||||
indent_style = tab
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = true
|
||||
# 使用 VS Code 生成文件的默认格式
|
||||
[*.json]
|
||||
indent_size = 4
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
custom: [
|
||||
'https://afdian.com/a/ccmywish',
|
||||
'https://github.com/ccmywish/support-my-oss-work'
|
||||
]
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
name: 🐞 Bug 报告
|
||||
description: 有 Bug 了吗?
|
||||
title: "详细报告BUG是chsrc用户的一大美德"
|
||||
# labels: [ ]
|
||||
type: Bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢花时间填写此 Bug 报告!
|
||||
|
||||
1. 你可能是通过包管理器安装的 `chsrc`,其版本往往稍旧,你可先尝试使用REAME中提供的安装命令来获取最新版本
|
||||
|
||||
2. 有时 Bug 是在最新版本中引入的,此时你可在安装命令时指定 `-v` 参数临时使用旧版本解决燃眉之急,详情查看README
|
||||
|
||||
- type: textarea
|
||||
id: what-did-you-do
|
||||
attributes:
|
||||
label: 你操作了什么?
|
||||
# description: 告诉我们,在问题出现之前你使用 chsrc 做了什么?
|
||||
placeholder: 我运行了 chsrc set <target>...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: 发生了什么?
|
||||
# description: 告诉我们,发生了什么你认为不该出现的事?屏幕截图或视频记录都很有帮助
|
||||
placeholder: 换源没有成功...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: what-should-happen
|
||||
attributes:
|
||||
label: 本应该怎么样?
|
||||
# description: 告诉我们,正常的或你期望看到的 运行结果和状态
|
||||
placeholder: 我希望 chsrc 成功帮我换源...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: chsrc 版本
|
||||
# description: 你正在使用 chsrc 哪个版本?
|
||||
placeholder: 请使用 chsrc -h 或 chsrc -v 查看,并*复制发布日期*
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: os
|
||||
attributes:
|
||||
label: 你使用的是哪个操作系统?
|
||||
multiple: true
|
||||
options:
|
||||
- Windows
|
||||
- Linux
|
||||
- macOS
|
||||
- FreeBSD
|
||||
- NetBSD
|
||||
- OpenBSD
|
||||
- 其他
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: os-version
|
||||
attributes:
|
||||
label: OS 版本 / OS 发行版
|
||||
# description: ""
|
||||
placeholder: "请告诉我们具体的OS版本或发行版,如 Windows 11, Ubuntu Linux 24.04... 等等"
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Log 输出
|
||||
description: 请复制粘贴任何相关的 Log 输出。此内容将自动格式化为代码块,因此不需要反引号
|
||||
render: shell
|
||||
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: 防止重复问题
|
||||
description: 请确认在打开这个新的 issue 之前已经搜索过类似的issue。你可以评论或订阅已经存在的相关 issue
|
||||
options:
|
||||
- label: 我已在项目中搜索过类似的 issue
|
||||
required: true
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
name: 🫡 我想要对 target 换源!
|
||||
description: 想要对尚未支持的 target 进行换源?
|
||||
title: "提前找好方案怎么换源是chsrc用户的一大美德"
|
||||
# labels: [ ]
|
||||
type: Request
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
请先回答这些问题
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 描述新的换源目标
|
||||
placeholder: 它是编程语言、操作系统还是一个普通软件?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reference-solution
|
||||
attributes:
|
||||
label: 请尽可能提供可参考的换源方法
|
||||
placeholder: 往往提供该源的镜像站会附带换源方法,可以提供给我们参考
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: mirrors
|
||||
attributes:
|
||||
label: 请尽可能提供已有镜像站
|
||||
placeholder: 当你提出该请求的时候,你可能已有心仪的镜像站,请告诉我们以避免重复查找劳动
|
||||
validations:
|
||||
required: true
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
name: 🎉 我找到了新的镜像站或源!
|
||||
description: 为大家分享新的镜像站或可用源!
|
||||
title: "分享是chsrc用户的一大美德"
|
||||
# labels: [ ]
|
||||
type: Contribute
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢你的分享!这将使你与更广大的用户得到更多可选的服务!同时也让镜像站开发维护人员更加有使命感!
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 描述该镜像站或该源
|
||||
description: |
|
||||
1. 请告诉我们该镜像站的主体URL
|
||||
2. 你是否已经测试过该镜像站的可用性?
|
||||
3. 它大概提供哪些源?
|
||||
4. 你想要我们为你添加该镜像站的具体哪个源?
|
||||
validations:
|
||||
required: true
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
name: ⛓️💥 镜像源已失效
|
||||
description: 该镜像站已关停/该源已不再被支持
|
||||
title: "报告镜像源情况是chsrc用户的一大美德"
|
||||
# labels: [ ]
|
||||
type: Deprecate
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢你的一手消息!让用户不再疑惑是哪里出了错!
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 什么被弃用了?
|
||||
description: |
|
||||
1. 请告诉我们是镜像站还是某个源失效
|
||||
2. 如果可能,你可以开启该issue后参与维护!在代码中删除掉该源并不复杂!
|
||||
validations:
|
||||
required: true
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: ❤️ 赞赏支持 chsrc
|
||||
url: https://afdian.com/a/ccmywish
|
||||
# about 不支持 Markdown 语法
|
||||
about: 你是否因为 chsrc 而受到启发、节省了时间精力 or whatever?
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
## 新功能描述
|
||||
|
||||
请描述该新功能,为什么要增加这个功能,以及具体的用例
|
||||
|
||||
---
|
||||
|
||||
## 方案
|
||||
|
||||
请介绍你新增加该功能的方案
|
||||
|
||||
---
|
||||
|
||||
## 实现
|
||||
|
||||
请介绍你的实现(若实现相当直接则不需要描述)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
## 描述
|
||||
|
||||
注意: 小改动请使用该PR模板。而中等、大型规模的变化,或者引起巨大联动变化的改动,需要使用 `Refactor` PR模板。
|
||||
|
||||
请介绍你进行了什么清理,如某部分代码,如某部分文档
|
||||
|
||||
---
|
||||
|
||||
## 方案
|
||||
|
||||
请介绍你进行清理的方案(如果你认为有必要的话)
|
||||
|
||||
---
|
||||
|
||||
## 实现
|
||||
|
||||
请介绍你的实现(若实现相当直接则不需要描述)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
## 改进描述
|
||||
|
||||
请描述要改进的具体内容,为什么要增强/改善它,以及具体的用例
|
||||
|
||||
---
|
||||
|
||||
## 方案
|
||||
|
||||
请介绍你的改进方案
|
||||
|
||||
---
|
||||
|
||||
## 实现
|
||||
|
||||
请介绍你的实现(若实现相当直接则不需要描述)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
## Bug 背景
|
||||
|
||||
请介绍 Bug 的背景以及相关 issue
|
||||
|
||||
---
|
||||
|
||||
## Bug 原因
|
||||
|
||||
请描述导致 Bug 的具体原因
|
||||
|
||||
---
|
||||
|
||||
## 方案
|
||||
|
||||
请介绍你的修复方案
|
||||
|
||||
---
|
||||
|
||||
## 实现
|
||||
|
||||
请介绍你的实现(若实现相当直接则不需要描述)
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
## 问题描述
|
||||
|
||||
(此内容必填)
|
||||
|
||||
1. 简要说明此 PR 修复的具体问题或改进的功能背景
|
||||
2. 列出与此 PR 相关的 issue 或任务,若没有填 `N/A`
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 方案
|
||||
|
||||
(此内容必填)
|
||||
|
||||
详细描述针对该问题或功能改进的解决方案
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 实现
|
||||
|
||||
(此内容可选填)
|
||||
|
||||
在按照上述方案实现时,若遇到需记录和提醒他人的细节时,务必在此描述
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 测试
|
||||
|
||||
(此内容可选填)
|
||||
|
||||
描述如何验证本 PR,列出具体的测试步骤
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 备注
|
||||
|
||||
(此内容可选填)
|
||||
|
||||
列出需要特别注意或额外注意的事项
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
## 背景
|
||||
|
||||
注意: 中等、大型规模的变化,或者引起巨大联动变化的改动,才需要使用该模板。中小改动请使用 `Clean` PR模板。
|
||||
|
||||
请介绍该重构的背景,可以带来哪些优势?
|
||||
|
||||
---
|
||||
|
||||
## 方案
|
||||
|
||||
请介绍你进行重构的方案
|
||||
|
||||
---
|
||||
|
||||
## 实现
|
||||
|
||||
请介绍你的实现(若实现相当直接则不需要描述)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
## 可用性确认
|
||||
|
||||
1. 请你本人确认这些源真的可用或已经失效,不要等待其它用户帮你测试
|
||||
|
||||
2. 请确保修改后代码依然可以编译及运行
|
||||
|
||||
3. 请在你修改的各个文件的标头部分增加你自己的贡献信息,名字栏需要为中文拼音、或者英文名、或者账号名
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : (Overview .github) READIT.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2025-06-20>
|
||||
! Last Modified : <2025-06-20>
|
||||
!
|
||||
! 此文件不能叫做 README.md,否则 GitHub 主页会显示此文件
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
[`pull_request_template.md`](./pull_request_template.md) 是 [`PULL_REQUEST_TEMPLATE/Implement.md`](./PULL_REQUEST_TEMPLATE/Implement.md) 的最简化版
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# chsrc Project Rules for AI Assistants
|
||||
|
||||
## 项目概述
|
||||
|
||||
这是 chsrc 项目,一个用 C 语言编写的跨平台命令行换源工具,帮助用户在不同的镜像之间切换,适用于编程语言、操作系统、其他软件。它的最强大之处在于它是一个框架,能够帮助用户轻松地为不同的目标换源。
|
||||
|
||||
|
||||
## 架构
|
||||
|
||||
- **Framework**: 在目录 `src/framework/` 中,包含了核心实现,支持 recipe
|
||||
|
||||
- `struct.h` 里定义了各种数据结构和宏,这是整个 chsrc 的核心,也是 chef DSL 的核心
|
||||
- `chef.c` 里实现了 chef DSL,你可以使用它来确定正确的使用方法
|
||||
|
||||
- **Recipes**: 在目录 `src/recipe/` 中,包含了针对不同目标的具体实现
|
||||
|
||||
- `lang/` - 编程语言 (Ruby, JavaScript 等等)
|
||||
- `os/` - 操作系统 (Ubuntu, Arch Linux 等等)
|
||||
- `ware/` - 软件工具和应用 (Docker, Homebrew 等等)
|
||||
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
### C Coding Style:
|
||||
|
||||
请阅读 `doc/03-为什么拒绝使用代码格式化工具.md`
|
||||
|
||||
### Important Project Concepts:
|
||||
|
||||
请阅读 `doc/10-如何编写recipe.md`
|
||||
|
||||
## Important: 一定要保持注释,因为它记录了重要的维护信息
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
## 问题描述
|
||||
|
||||
1. 简要说明此 PR 修复的具体问题或改进的功能背景
|
||||
2. 列出与此 PR 相关的 issue 或任务,若没有填 `N/A`
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 方案与实现
|
||||
|
||||
详细描述针对该问题或功能改进的解决方案
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : PR-notify.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2025-06-19>
|
||||
# Last Modified : <2025-08-07>
|
||||
#
|
||||
# Notify PR
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 告知PR者
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened,
|
||||
ready_for_review, # draft PR 转为正式 PR
|
||||
review_requested,
|
||||
reopened]
|
||||
|
||||
jobs:
|
||||
enforce-dev-branch:
|
||||
name: 强制使用dev分支
|
||||
runs-on: ubuntu-latest
|
||||
# github.event.pull_request_target 内容为空,转而用 pull_request
|
||||
if: github.event.pull_request.base.ref != 'dev'
|
||||
steps:
|
||||
- name: 评论
|
||||
uses: thollander/actions-comment-pull-request@v3
|
||||
with:
|
||||
message: |
|
||||
Hi @${{github.event.pull_request.user.login}},
|
||||
|
||||
❤️ 感谢你的贡献!你的 PR 当前基于 `${{github.base_ref}}` 分支,请修改使用 `dev` 分支
|
||||
comment-tag: "❤️ 感谢你的贡献!"
|
||||
- run: |
|
||||
echo "::error::❌ PR 必须以 dev 分支为目标!当前是 ${GITHUB_BASE_REF}"
|
||||
exit 1
|
||||
|
||||
welcome:
|
||||
name: 欢迎PR者
|
||||
runs-on: ubuntu-latest
|
||||
# 仅在 opened 时欢迎,其他情况都不再重复欢迎了
|
||||
if: github.event.pull_request.base.ref == 'dev' && github.event.action == 'opened'
|
||||
steps:
|
||||
- name: 查看 GitHub Actions 环境
|
||||
run: |
|
||||
echo "Event 类型: ${{ github.event.action }}"
|
||||
echo "Event 名: ${{ github.event_name }}"
|
||||
|
||||
# 2025-10-06 移除点赞的步骤
|
||||
# 因原 peter-evans/create-or-update-comment@v5 已不再支持空body,而如果使用 Github Token 之类又过于大材小用因此移除
|
||||
|
||||
- name: 添加评论欢迎 PRer
|
||||
uses: peter-evans/create-or-update-comment@v5
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body: |
|
||||
Hi @${{github.event.pull_request.user.login}}
|
||||
|
||||
❤️ 感谢你的贡献!我们将在最少半小时,最多5天内阅读此 PR 并回复你
|
||||
edit-mode: replace
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : PR-test.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Mikachu2333 <mikachu2333@zohomail.com>
|
||||
# |
|
||||
# Created On : <2025-06-19>
|
||||
# Last Modified : <2025-08-17>
|
||||
#
|
||||
# Test PR
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 测试PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
# 仅在开 pr、草稿转正式、手动要求 review、reopen的时候运行测试
|
||||
types: [
|
||||
opened,
|
||||
# 因 synchronize 将导致 pr 的构建过于频繁而禁用
|
||||
# synchronize, # 在 pr 者 push commit 时每次构建
|
||||
ready_for_review, # draft PR 转为正式 PR
|
||||
review_requested,
|
||||
reopened,
|
||||
]
|
||||
paths:
|
||||
- "src/**"
|
||||
- "lib/**"
|
||||
|
||||
jobs:
|
||||
test-on-ubuntu:
|
||||
name: 在Ubuntu上测试
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.base.ref == 'dev'
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 测试构建情况
|
||||
run: |
|
||||
make
|
||||
|
||||
- name: 测试test情况
|
||||
run: |
|
||||
make test
|
||||
|
||||
test-on-windows:
|
||||
name: 在Windows上测试
|
||||
runs-on: windows-latest
|
||||
if: github.event.pull_request.base.ref == 'dev'
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 创建测试文件
|
||||
shell: powershell
|
||||
run: |
|
||||
New-Item -Path "$env:USERPROFILE\Documents\Powershell\Microsoft.PowerShell_profile.ps1" -ItemType File -Force
|
||||
New-Item -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" -ItemType File -Force
|
||||
|
||||
- name: 安装依赖
|
||||
run: |
|
||||
choco install just
|
||||
|
||||
- name: 测试构建情况
|
||||
run: |
|
||||
just
|
||||
|
||||
- name: 测试test情况
|
||||
run: |
|
||||
just test
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : build-on-Linux-AArch64.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2023-09-14>
|
||||
# Last Modified : <2025-09-12>
|
||||
#
|
||||
# Build chsrc on Linux (AArch64) and upload it to GitHub: the 'pre' release
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建于 Linux AArch64
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 构建
|
||||
uses: uraimo/run-on-arch-action@v3
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu_latest
|
||||
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/artifacts:/artifacts"
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install build-essential -y -q
|
||||
apt-get install git -y -q
|
||||
pwd ; ls -al
|
||||
git clone https://github.com/RubyMetric/chsrc -b gh-build -q
|
||||
cd chsrc
|
||||
|
||||
make build-in-ci-release-mode
|
||||
mv chsrc-ci-release chsrc-aarch64-linux
|
||||
|
||||
cp ./chsrc-aarch64-linux /artifacts
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
./artifacts/chsrc-aarch64-linux
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : build-on-Linux-ARMv7.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2023-09-14>
|
||||
# Last Modified : <2025-09-12>
|
||||
#
|
||||
# Build chsrc on Linux (ARMv7) and upload it to GitHub: the 'pre' release
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建于 Linux ARMv7
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 构建
|
||||
uses: uraimo/run-on-arch-action@v3
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu_latest
|
||||
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/artifacts:/artifacts"
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install build-essential -y -q
|
||||
apt-get install git -y -q
|
||||
pwd ; ls -al
|
||||
git clone https://github.com/RubyMetric/chsrc -b gh-build -q
|
||||
cd chsrc
|
||||
|
||||
make build-in-ci-release-mode
|
||||
mv chsrc-ci-release chsrc-armv7-linux
|
||||
|
||||
cp ./chsrc-armv7-linux /artifacts
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
./artifacts/chsrc-armv7-linux
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : build-on-Linux-riscv64.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2023-09-14>
|
||||
# Last Modified : <2025-09-12>
|
||||
#
|
||||
# Build chsrc on Linux (riscv64) and upload it to GitHub: the 'pre' release
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建于 Linux riscv64
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 构建
|
||||
uses: uraimo/run-on-arch-action@v3
|
||||
with:
|
||||
arch: riscv64
|
||||
distro: ubuntu_latest
|
||||
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/artifacts:/artifacts"
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install build-essential -y -q
|
||||
apt-get install git -y -q
|
||||
pwd ; ls -al
|
||||
git clone https://github.com/RubyMetric/chsrc -b gh-build -q
|
||||
cd chsrc
|
||||
|
||||
make build-in-ci-release-mode
|
||||
mv chsrc-ci-release chsrc-riscv64-linux
|
||||
|
||||
cp ./chsrc-riscv64-linux /artifacts
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
./artifacts/chsrc-riscv64-linux
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : build-on-Linux-x64.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2023-09-14>
|
||||
# Last Modified : <2025-09-12>
|
||||
#
|
||||
# Build chsrc on Linux (x64) and upload it to GitHub: the 'pre' release
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建于 Linux x64
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 构建
|
||||
run: |
|
||||
make build-in-ci-release-mode
|
||||
mv chsrc-ci-release chsrc-x64-linux
|
||||
|
||||
- name: List files
|
||||
run: ls *-linux
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-x64-linux
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : build-on-Windows.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2023-09-14>
|
||||
# Last Modified : <2025-09-12>
|
||||
#
|
||||
# Build chsrc on Windows and upload it to GitHub: the 'pre' release
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建于 Windows
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
||||
steps:
|
||||
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 安装 GCC
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: UCRT64
|
||||
update: true
|
||||
install: |
|
||||
mingw-w64-ucrt-x86_64-gcc
|
||||
mingw-w64-ucrt-x86_64-make
|
||||
mingw-w64-i686-gcc
|
||||
mingw-w64-i686-make
|
||||
|
||||
- name: 为 x64 构建
|
||||
run: |
|
||||
mingw32-make.exe build-in-ci-release-mode
|
||||
mv chsrc-ci-release.exe chsrc-x64-windows.exe
|
||||
|
||||
- name: 为 x32 构建
|
||||
env:
|
||||
MSYSTEM: MINGW32
|
||||
run: |
|
||||
mingw32-make.exe build-in-ci-release-mode
|
||||
mv chsrc-ci-release.exe chsrc-x86-windows.exe
|
||||
|
||||
- name: 为 Android 构建
|
||||
run: |
|
||||
compiler=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android21-clang
|
||||
|
||||
# 检查编译器版本
|
||||
$compiler --version
|
||||
echo
|
||||
|
||||
mingw32-make.exe build-in-ci-release-mode CC=$compiler CROSS_BUILD_WINDOWS_FOR_ANDROID=1
|
||||
echo
|
||||
|
||||
# 让我们看看里面有啥
|
||||
ls
|
||||
echo
|
||||
|
||||
mv chsrc-ci-release chsrc-arm64-android
|
||||
|
||||
- name: List files
|
||||
run: ls *.exe
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-x64-windows.exe
|
||||
chsrc-x86-windows.exe
|
||||
chsrc-arm64-android
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : build-on-macOS.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2023-09-15>
|
||||
# Last Modified : <2025-12-18>
|
||||
#
|
||||
# Build chsrc on macOS and upload it to GitHub: the 'pre' release
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建于 macOS
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
|
||||
jobs:
|
||||
on-arm64:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 检查编译器版本
|
||||
run: |
|
||||
clang --version
|
||||
echo
|
||||
gcc --version
|
||||
echo
|
||||
gcc-14 --version
|
||||
|
||||
- name: 为 arm64 (AArch64) 构建
|
||||
run: |
|
||||
make build-in-ci-release-mode
|
||||
mv chsrc-ci-release chsrc-aarch64-macos
|
||||
|
||||
- name: List files
|
||||
run: ls *-macos
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-aarch64-macos
|
||||
|
||||
|
||||
on-x64:
|
||||
# macos-13 是 x64,macos-14 是 AArch64(ARMv8-A)
|
||||
# 但是 macos-13 已经于 2025-12-04 下线
|
||||
runs-on: macos-15-intel
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: 检查编译器版本
|
||||
run: |
|
||||
clang --version
|
||||
echo
|
||||
gcc --version
|
||||
echo
|
||||
gcc-14 --version
|
||||
|
||||
- name: 为 x64 构建
|
||||
run: |
|
||||
make build-in-ci-release-mode
|
||||
mv chsrc-ci-release chsrc-x64-macos
|
||||
|
||||
- name: List files
|
||||
run: ls *-macos
|
||||
|
||||
- name: 上传至 'pre' release
|
||||
uses: softprops/action-gh-release@v2
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-x64-macos
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
name: Linux AArch64 Build
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-pipeline" ]
|
||||
pull_request:
|
||||
branches: [ "gh-pipeline" ]
|
||||
|
||||
jobs:
|
||||
aarch64-linux-build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build aarch64
|
||||
uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu_latest
|
||||
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/artifacts:/artifacts"
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install build-essential -y -q
|
||||
apt-get install git -y -q
|
||||
pwd ; ls -al
|
||||
git clone https://github.com/RubyMetric/chsrc -b gh-pipeline -q
|
||||
cd chsrc
|
||||
make CI CI_Build_Name=chsrc-aarch64-linux
|
||||
cp ./chsrc-aarch64-linux /artifacts
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
./artifacts/chsrc-aarch64-linux
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
name: Linux ARMv7 Build
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-pipeline" ]
|
||||
pull_request:
|
||||
branches: [ "gh-pipeline" ]
|
||||
|
||||
jobs:
|
||||
armv7-linu-build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build ARMv7
|
||||
uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: armv7
|
||||
distro: ubuntu_latest
|
||||
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/artifacts:/artifacts"
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install build-essential -y -q
|
||||
apt-get install git -y -q
|
||||
pwd ; ls -al
|
||||
git clone https://github.com/RubyMetric/chsrc -b gh-pipeline -q
|
||||
cd chsrc
|
||||
make CI CI_Build_Name=chsrc-armv7-linux
|
||||
cp ./chsrc-armv7-linux /artifacts
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
./artifacts/chsrc-armv7-linux
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
name: Linux riscv64 Build
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-pipeline" ]
|
||||
pull_request:
|
||||
branches: [ "gh-pipeline" ]
|
||||
|
||||
jobs:
|
||||
riscv64-linux-build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build riscv64
|
||||
uses: uraimo/run-on-arch-action@v2
|
||||
with:
|
||||
arch: riscv64
|
||||
distro: ubuntu_latest
|
||||
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}/artifacts:/artifacts"
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install build-essential -y -q
|
||||
apt-get install git -y -q
|
||||
pwd ; ls -al
|
||||
git clone https://github.com/RubyMetric/chsrc -b gh-pipeline -q
|
||||
cd chsrc
|
||||
make CI CI_Build_Name=chsrc-riscv64-linux
|
||||
cp ./chsrc-riscv64-linux /artifacts
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
./artifacts/chsrc-riscv64-linux
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
name: Linux x64 Build
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-pipeline" ]
|
||||
pull_request:
|
||||
branches: [ "gh-pipeline" ]
|
||||
|
||||
jobs:
|
||||
x64-linux-build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Compile chsrc x64
|
||||
run: |
|
||||
make CI CI_Build_Name=chsrc-x64-linux
|
||||
|
||||
- name: List files
|
||||
run: ls *-linux
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-x64-linux
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
name: macOS Build
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-pipeline" ]
|
||||
pull_request:
|
||||
branches: [ "gh-pipeline" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload-on-M1:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Compile chsrc for AArch64
|
||||
run: |
|
||||
make CI CI_Build_Name=chsrc-aarch64-macos
|
||||
|
||||
- name: List files
|
||||
run: ls *-macos
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-aarch64-macos
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
||||
|
||||
build-and-upload-on-x64:
|
||||
runs-on: macos-13 # macos-14 is AArch64(ARMv8-A)
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Compile chsrc for x64
|
||||
run: |
|
||||
make CI CI_Build_Name=chsrc-x64-macos
|
||||
|
||||
- name: List files
|
||||
run: ls *-macos
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-x64-macos
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : pkg-deb.yml
|
||||
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
# Contributors : 曾奥然 <ccmywish@qq.com>
|
||||
# |
|
||||
# Created On : <2025-06-10>
|
||||
# Last Modified : <2025-10-29>
|
||||
#
|
||||
# Build and publish deb packages
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: 构建发布deb包
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ released ]
|
||||
push:
|
||||
branches: [ "gh-build" ]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version to build'
|
||||
required: true
|
||||
default: '0.3.0' # 短暂时间内不可达到的最新版本号
|
||||
|
||||
jobs:
|
||||
Build-deb:
|
||||
name: 构建deb包
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: gh-build
|
||||
|
||||
- name: 获取版本号
|
||||
id: get_version
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "release" ]; then
|
||||
version="${{ github.event.release.tag_name }}"
|
||||
# 删除前缀 'v' if present
|
||||
version=${version#v}
|
||||
|
||||
elif [ "${{ github.event_name }}" = "push" ];then
|
||||
# 从源代码中提取版本号
|
||||
version=$(sed -E -n 's/^#define Chsrc_Version +"([0-9]+\.[0-9]+\.[0-9]+).*"/\1/p' ./src/framework/version.h)
|
||||
|
||||
else
|
||||
version="${{ github.event.inputs.version }}"
|
||||
fi
|
||||
|
||||
echo "version=$version" >> $GITHUB_OUTPUT
|
||||
echo "Version: $version"
|
||||
|
||||
- name: 验证版本号
|
||||
run: |
|
||||
version="${{ steps.get_version.outputs.version }}"
|
||||
|
||||
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Invalid version format: $version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 更新 debian/changelog
|
||||
run: |
|
||||
version="${{ steps.get_version.outputs.version }}"
|
||||
|
||||
cd ./pkg/deb
|
||||
|
||||
(cat << EOF; cat ./debian/changelog) > new_changelog
|
||||
chsrc ($version-1) unstable; urgency=medium
|
||||
|
||||
* Release version $version
|
||||
|
||||
-- 曾奥然 <ccmywish@qq.com> $(date -R)
|
||||
|
||||
EOF
|
||||
|
||||
mv -f new_changelog ./debian/changelog
|
||||
|
||||
- name: 安装构建依赖
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y debhelper devscripts build-essential fakeroot
|
||||
|
||||
- name: 构建
|
||||
run: |
|
||||
make build-deb
|
||||
|
||||
- name: 移动构建产物到./dist和./dist-for-pre
|
||||
run: |
|
||||
version="${{ steps.get_version.outputs.version }}"
|
||||
|
||||
# 创建两个目录来存放构建产物(产物内容一样,只是文件名不一样)
|
||||
mkdir dist dist-for-pre
|
||||
find ./pkg -name "chsrc_${version}*.deb" -exec mv {} dist/ \;
|
||||
cp -r dist/* dist-for-pre/
|
||||
|
||||
# 上传至 'pre' release 的文件名需要设置为 'latest', 从而稳定下载URL
|
||||
cd ./dist-for-pre
|
||||
for old_name in ./chsrc_${version}*.deb; do
|
||||
new_name="${old_name/${version}-1/latest-1}"
|
||||
mv "$old_name" "$new_name"
|
||||
done
|
||||
|
||||
- name: 验证生成的deb包
|
||||
run: |
|
||||
version="${{ steps.get_version.outputs.version }}"
|
||||
ls -la dist/
|
||||
dpkg-deb --info dist/chsrc_${version}-1_amd64.deb
|
||||
dpkg-deb --contents dist/chsrc_${version}-1_amd64.deb
|
||||
|
||||
- name: 测试deb包能否正常安装
|
||||
run: |
|
||||
version="${{ steps.get_version.outputs.version }}"
|
||||
|
||||
sudo dpkg -i dist/chsrc_${version}-1_amd64.deb || true
|
||||
sudo apt-get install -f -y || true
|
||||
|
||||
bash pkg/deb/deb-installation-test.sh
|
||||
|
||||
- name: 上传deb包到artifacts
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: chsrc-deb-files
|
||||
path: dist/chsrc_*.deb
|
||||
retention-days: 30
|
||||
|
||||
- name: 上传附件到GitHub Releases(the newly created release)
|
||||
if: github.event_name == 'release'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
# 用 * 省略版本号,以及指代各种架构
|
||||
files: dist/chsrc_*.deb
|
||||
|
||||
- name: 上传附件到GitHub Releases(the 'pre' release)
|
||||
if: github.event_name == 'push'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: pre
|
||||
# 用 * 指代各种架构
|
||||
files: dist-for-pre/chsrc_latest-1_*.deb
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Create-APT-repository:
|
||||
name: 创建APT仓库
|
||||
needs: Build-deb
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'release'
|
||||
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
pattern: chsrc-deb-files
|
||||
merge-multiple: true
|
||||
path: ./debs
|
||||
|
||||
- name: Install repository tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dpkg-dev
|
||||
|
||||
- name: Create Packages file
|
||||
run: |
|
||||
cd debs
|
||||
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
|
||||
dpkg-scanpackages . /dev/null > Packages
|
||||
|
||||
- name: Upload repository metadata
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: debian-repository-metadata
|
||||
path: debs/Packages*
|
||||
retention-days: 30
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : pub-AUR-chsrc-and-chsrc-bin.yml
|
||||
# File Authors : Terrasse <terrasse@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2024-08-29>
|
||||
# Last Modified : <2025-03-18>
|
||||
#
|
||||
# Publish the 2 packages to AUR when a new release is created:
|
||||
# 1. chsrc
|
||||
# 2. chsrc-bin
|
||||
#
|
||||
# Note: only normal version tags like 'v1.2.3' will be published
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: Publish 'chsrc' and 'chsrc-bin' to AUR
|
||||
on:
|
||||
release:
|
||||
types: [ released ]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Get the release tag
|
||||
id: get_tag
|
||||
run: |
|
||||
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
- name: Validate version tag
|
||||
run: |
|
||||
if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Abnormal version tag: $tag"
|
||||
echo "valid=0" >> $GITHUB_ENV
|
||||
else
|
||||
version=$(echo $tag | sed 's/^v//')
|
||||
echo "version=$version" >> $GITHUB_ENV
|
||||
echo "valid=1" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Fetch PKGBUILD
|
||||
run: |
|
||||
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc-bin -O ./PKGBUILD_bin
|
||||
- name: Update PKGBUILD
|
||||
run: |
|
||||
sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD_bin
|
||||
- name: Publish chsrc-bin to AUR
|
||||
if: env.valid == '1'
|
||||
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
|
||||
with:
|
||||
pkgname: chsrc-bin
|
||||
pkgbuild: ./PKGBUILD_bin
|
||||
updpkgsums: true
|
||||
test: true # Check that PKGBUILD could be built, and update pkgver
|
||||
commit_username: ${{ secrets.AUR_USERNAME }}
|
||||
commit_email: ${{ secrets.AUR_EMAIL }}
|
||||
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
commit_message: "github-action-auto-publish v${{ env.version }}"
|
||||
- name: Fetch PKGBUILD
|
||||
run: |
|
||||
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc -O ./PKGBUILD
|
||||
- name: Update PKGBUILD
|
||||
run: |
|
||||
sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD
|
||||
- name: Publish chsrc to AUR
|
||||
if: env.valid == '1'
|
||||
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
|
||||
with:
|
||||
pkgname: chsrc
|
||||
pkgbuild: ./PKGBUILD
|
||||
updpkgsums: true
|
||||
test: true # Check that PKGBUILD could be built, and update pkgver
|
||||
commit_username: ${{ secrets.AUR_USERNAME }}
|
||||
commit_email: ${{ secrets.AUR_EMAIL }}
|
||||
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
commit_message: "github-action-auto-publish v${{ env.version }}"
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : pub-AUR-chsrc-git.yml
|
||||
# File Authors : Terrasse <terrasse@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2024-08-29>
|
||||
# Last Modified : <2025-06-19>
|
||||
#
|
||||
# Publish package 'chsrc-git' to AUR when branch 'main' is updated.
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: Publish 'chsrc-git' to AUR
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "main" ] # chsrc-git syncs with main
|
||||
paths:
|
||||
- "src/**"
|
||||
- "lib/**"
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Fetch PKGBUILD
|
||||
run: |
|
||||
wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD\?h\=chsrc-git -O ./PKGBUILD
|
||||
- name: Publish to AUR
|
||||
uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
|
||||
with:
|
||||
pkgname: chsrc-git
|
||||
pkgbuild: ./PKGBUILD
|
||||
test: true # Check that PKGBUILD could be built, and update pkgver
|
||||
commit_username: ${{ secrets.AUR_USERNAME }}
|
||||
commit_email: ${{ secrets.AUR_EMAIL }}
|
||||
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
commit_message: "github-action-auto-publish\n${{ github.sha }}"
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Workflow File : pub-WinGet.yml
|
||||
# File Authors : YU-7 <2747046473@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2024-12-25>
|
||||
# Last Modified : <2024-12-25>
|
||||
#
|
||||
# This workflow publish to winget
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
name: Publish to WinGet
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: vedantmgoyal9/winget-releaser@main
|
||||
with:
|
||||
identifier: RubyMetric.chsrc
|
||||
installers-regex: '\.exe$' # Only .exe files
|
||||
token: ${{ secrets.WINGET_TOKEN }}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
name: Windows Build
|
||||
on:
|
||||
push:
|
||||
branches: [ "gh-pipeline" ]
|
||||
pull_request:
|
||||
branches: [ "gh-pipeline" ]
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install x64 gcc
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: UCRT64
|
||||
update: true
|
||||
install: |
|
||||
mingw-w64-ucrt-x86_64-gcc
|
||||
mingw-w64-ucrt-x86_64-make
|
||||
mingw-w64-i686-gcc
|
||||
mingw-w64-i686-make
|
||||
|
||||
- name: Compile chsrc x64
|
||||
run: |
|
||||
mingw32-make.exe CI CI_Build_Name=chsrc-x64-windows
|
||||
|
||||
- name: Compile chsrc x86
|
||||
env:
|
||||
MSYSTEM: MINGW32
|
||||
run: |
|
||||
mingw32-make.exe CI CI_Build_Name=chsrc-x86-windows
|
||||
|
||||
- name: List files
|
||||
run: ls *.exe
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
tag_name: pre
|
||||
files: |
|
||||
chsrc-x64-windows.exe
|
||||
chsrc-x86-windows.exe
|
||||
token: ${{ secrets.CHSRC_UPLOAD }}
|
||||
|
|
@ -1,16 +1,87 @@
|
|||
.vscode
|
||||
##############################
|
||||
# VS Code
|
||||
##############################
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
!.vscode/settings.json
|
||||
!.vscode/c_cpp_properties.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/README.md
|
||||
|
||||
*.exe
|
||||
*.out
|
||||
|
||||
|
||||
##############################
|
||||
# Binaries
|
||||
##############################
|
||||
*.o
|
||||
*.obj
|
||||
*.a
|
||||
*.lib
|
||||
*.so
|
||||
*.dll
|
||||
*.out
|
||||
*.exe
|
||||
*.res
|
||||
|
||||
# target exe name
|
||||
|
||||
##############################
|
||||
# Built executables
|
||||
##############################
|
||||
chsrc
|
||||
chsrc-debug
|
||||
chsrc-release
|
||||
chsrc-ci-release
|
||||
|
||||
|
||||
|
||||
##############################
|
||||
# Test files
|
||||
##############################
|
||||
xy
|
||||
fw
|
||||
README.md.bak*
|
||||
*.tmp
|
||||
chsrc_tmp_test.txt
|
||||
chsrc_tmp_test.txt.bak
|
||||
|
||||
# Generated when testing (when there's a bug)
|
||||
nul
|
||||
|
||||
# 'chsrc set -local' generated
|
||||
.bundle
|
||||
.npmrc
|
||||
|
||||
# Generated when testing
|
||||
nul
|
||||
|
||||
|
||||
##############################
|
||||
# Texinfo
|
||||
##############################
|
||||
chsrc.aux
|
||||
chsrc.log
|
||||
chsrc.toc
|
||||
*.info
|
||||
*.pdf
|
||||
|
||||
|
||||
|
||||
##############################
|
||||
# deb package
|
||||
##############################
|
||||
# deb package 未归档的目录
|
||||
pkg/deb/debian/chsrc/
|
||||
|
||||
# 下面这个目录包含创建出 $HOME 的虚拟环境
|
||||
pkg/deb/debian/.debhelper/
|
||||
|
||||
pkg/deb/debian/debhelper-build-stamp
|
||||
pkg/deb/debian/files
|
||||
pkg/deb/debian/chsrc.debhelper.log
|
||||
pkg/deb/debian/chsrc.substvars
|
||||
|
||||
# 以下为 deb package 构建的直接产物
|
||||
chsrc_*.deb
|
||||
chsrc-dbgsym_*.ddeb
|
||||
chsrc_*.build
|
||||
chsrc_*.buildinfo
|
||||
chsrc_*.changes
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : (for VS Code users) README.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2025-06-18>
|
||||
! Last Modified : <2025-06-20>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# Dev in VS Code
|
||||
|
||||
首先需要安装好 [just](https://github.com/casey/just),而不再硬性需要 `make`
|
||||
|
||||
1. `Ctrl-Shift-B` 直接构建
|
||||
2. `F5` 直接开始 Debug
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"intelliSenseMode": "windows-gcc-x64"
|
||||
},
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"cStandard": "c17"
|
||||
},
|
||||
{
|
||||
"name": "Mac",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"cStandard": "c17"
|
||||
}
|
||||
],
|
||||
"enableConfigurationSquiggles": true,
|
||||
"version": 4
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"ms-vscode.cpptools",
|
||||
"ms-vscode.cpptools-extension-pack",
|
||||
"editorconfig.editorconfig",
|
||||
"redhat.vscode-yaml",
|
||||
"nefrob.vscode-just-syntax"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"esbenp.prettier-vscode"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug chsrc",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/chsrc-debug",
|
||||
"args": [
|
||||
"get",
|
||||
"nodejs"
|
||||
],
|
||||
"preLaunchTask": "构建 debug 版 chsrc",
|
||||
"stopAtEntry": true,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
// 如果你认为使用弹出窗口难以调试,可尝试设置为false
|
||||
"externalConsole": true,
|
||||
// lldb 等请自行设置,不作额外说明
|
||||
"MIMode": "gdb",
|
||||
// "miDebuggerPath": "/path/to/gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"postDebugTask": "停止 debug 程序"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Debug framework",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/fw",
|
||||
"args": [],
|
||||
"preLaunchTask": "测试 framework",
|
||||
"stopAtEntry": true,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
// "miDebuggerPath": "/path/to/gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"editor.fontLigatures": false,
|
||||
|
||||
"C_Cpp.autoAddFileAssociations": false,
|
||||
"C_Cpp.intelliSenseEngine": "Tag Parser",
|
||||
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false,
|
||||
|
||||
"editor.formatOnSave": false,
|
||||
|
||||
"C_Cpp.clang_format_fallbackStyle": "GNU",
|
||||
"C_Cpp.formatting": "disabled",
|
||||
|
||||
"[c]": {
|
||||
"editor.defaultFormatter": null,
|
||||
},
|
||||
"[h]": {
|
||||
"editor.defaultFormatter": null
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.defaultFormatter": "vscode.json-language-features"
|
||||
},
|
||||
"[yaml]": {
|
||||
"editor.defaultFormatter": "redhat.vscode-yaml"
|
||||
},
|
||||
|
||||
"vscode-just.formatOnSave": false,
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "构建 chsrc",
|
||||
"command": "just",
|
||||
"args": [
|
||||
"build"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"dependsOn": "停止程序",
|
||||
"detail": "先停止原有程序,然后使用 just build 编译"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "构建 debug 版 chsrc",
|
||||
"command": "just",
|
||||
"args": [
|
||||
"build-in-debug-mode"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "测试 chsrc",
|
||||
"command": "just",
|
||||
"args": [
|
||||
"test"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "使用 just test 测试"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "测试 framework",
|
||||
"command": "just",
|
||||
"args": [
|
||||
"test-fw"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": false
|
||||
},
|
||||
"detail": "使用 just test-fw 测试 framework"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "测试 xy.h",
|
||||
"command": "just",
|
||||
"args": [
|
||||
"test-xy"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": false
|
||||
},
|
||||
"detail": "使用 just test-xy 测试 xy.h"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "停止 debug 程序",
|
||||
"windows": {
|
||||
"command": "powershell",
|
||||
"args": [
|
||||
"-c",
|
||||
"Get-Process -Name \"chsrc-debug\" -ErrorAction SilentlyContinue | Stop-Process -Force;",
|
||||
"Get-Process -Name \"gdb\" -ErrorAction SilentlyContinue | Stop-Process -Force;",
|
||||
"Get-Process -Name \"WindowsDebugLauncher\" -ErrorAction SilentlyContinue | Stop-Process -Force;"
|
||||
]
|
||||
},
|
||||
"linux": {
|
||||
"command": "bash",
|
||||
"args": [
|
||||
"-c",
|
||||
"if pgrep -f chsrc-debug > /dev/null; then pkill -f chsrc-debug; fi"
|
||||
]
|
||||
},
|
||||
"osx": {
|
||||
"command": "bash",
|
||||
"args": [
|
||||
"-c",
|
||||
"if pgrep -f chsrc-debug > /dev/null; then pkill -f chsrc-debug; fi"
|
||||
]
|
||||
},
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": false
|
||||
},
|
||||
"detail": "停止 debug 版本的 chsrc"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "停止程序",
|
||||
"windows": {
|
||||
"command": "powershell",
|
||||
"args": [
|
||||
"-c",
|
||||
"Get-Process -Name \"chsrc\" -ErrorAction SilentlyContinue | Stop-Process -Force;"
|
||||
]
|
||||
},
|
||||
"linux": {
|
||||
"command": "bash",
|
||||
"args": [
|
||||
"-c",
|
||||
"if pgrep -f chsrc > /dev/null; then pkill -f chsrc; fi"
|
||||
]
|
||||
},
|
||||
"osx": {
|
||||
"command": "bash",
|
||||
"args": [
|
||||
"-c",
|
||||
"if pgrep -f chsrc > /dev/null; then pkill -f chsrc; fi"
|
||||
]
|
||||
},
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": false
|
||||
},
|
||||
"detail": "跨平台停止 chsrc"
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
169
LICENSE-GPL.txt
|
|
@ -1,169 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (c) 2023-present 曾奥然 (Aoran Zeng), 郭恒 (Heng Guo)
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023-present 曾奥然 (Aoran Zeng), 郭恒 (Heng Guo)
|
||||
Copyright (c) 2023-2025 曾奥然 (Aoran Zeng), 郭恒 (Heng Guo)
|
||||
|
||||
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:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,45 +1,231 @@
|
|||
# ------------------------------------------------------------
|
||||
#!/usr/bin/make -f
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# -------------------------------------------------------------
|
||||
# File : Makefile
|
||||
# Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
# Created on : <2023-08-28>
|
||||
# Last modified : <2024-06-05>
|
||||
# ---------------------------------------------------------------
|
||||
# --------------------------------------------------------------
|
||||
# Build File : Makefile
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Yangmoooo <yangmoooo@outlook.com>
|
||||
# | sanchuanhehe <wyihe5520@gmail.com>
|
||||
# |
|
||||
# Created On : <2023-08-28>
|
||||
# Last Modified : <2025-10-15>
|
||||
#
|
||||
# 请阅读 ./doc/01-开发与构建.md 来使用
|
||||
# --------------------------------------------------------------
|
||||
|
||||
CFLAGS = -Iinclude # -Wall
|
||||
#=========== OS Check ================
|
||||
On-Linux = 0
|
||||
On-Windows = 0
|
||||
On-macOS = 0
|
||||
|
||||
# 只有Windows会定义该变量
|
||||
ifeq ($(OS), Windows_NT)
|
||||
CLANG_FLAGS = -Target x86_64-pc-windows-gnu
|
||||
ifeq ($(shell uname), Linux)
|
||||
On-Linux = 1
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname), Darwin)
|
||||
On-macOS = 1
|
||||
endif
|
||||
|
||||
# 只有 MSYS2 会定义 $(OS) 变量
|
||||
ifeq ($(OS), Windows_NT)
|
||||
On-Windows = 1
|
||||
endif
|
||||
# 注意, 原生 Windows 会定义 $(ComSpec) 变量,且区分大小写
|
||||
# 但是 MSYS2 并不会定义
|
||||
#=====================================
|
||||
|
||||
|
||||
|
||||
#======== Default Tooling ============
|
||||
ifeq ($(On-Windows), 1)
|
||||
# MSYS2 环境
|
||||
CC = cc
|
||||
else ifeq ($(On-macOS), 1)
|
||||
CC = clang
|
||||
else
|
||||
CC = cc
|
||||
endif
|
||||
|
||||
ifeq ($(On-macOS), 1)
|
||||
DEBUGGER = lldb
|
||||
else
|
||||
DEBUGGER = gdb
|
||||
endif
|
||||
#=====================================
|
||||
|
||||
|
||||
|
||||
#======== Compilation Config ==========
|
||||
CFLAGS += -Iinclude -Ilib
|
||||
|
||||
ifeq ($(On-Windows), 1)
|
||||
CLANG_FLAGS = -target x86_64-pc-windows-gnu
|
||||
endif
|
||||
|
||||
ifeq ($(CC), clang)
|
||||
CFLAGS += $(CLANG_FLAGS)
|
||||
endif
|
||||
ifeq ($(shell uname), Linux)
|
||||
CFLAGS += -static
|
||||
|
||||
override WARN += -Wall -Wextra -Wno-unused-variable -Wno-unused-function -Wno-missing-braces -Wno-misleading-indentation \
|
||||
-Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare
|
||||
_C_Warning_Flags := $(WARN)
|
||||
|
||||
DevMode-Target-Name = chsrc
|
||||
DebugMode-Target-Name = chsrc-debug
|
||||
ReleaseMode-Target-Name = chsrc-release
|
||||
CIReleaseMode-Target-Name = chsrc-ci-release
|
||||
|
||||
CFLAGS_debug = -g -DXY_DEBUG
|
||||
CFLAGS_static = -static
|
||||
CFLAGS_optimization = -O2
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += $(CFLAGS_debug)
|
||||
endif
|
||||
|
||||
Target = chsrc
|
||||
STATIC = 0
|
||||
|
||||
CI_Build_Name = chsrc
|
||||
#=======================
|
||||
ifeq ($(STATIC), 1)
|
||||
CFLAGS += $(CFLAGS_static)
|
||||
endif
|
||||
#=====================================
|
||||
|
||||
all:
|
||||
@$(CC) src/chsrc.c $(CFLAGS) -o $(Target)
|
||||
@echo; echo Compile done using \'$(CC)\' $(CFLAGS)
|
||||
|
||||
CI: all
|
||||
@mv $(Target) $(CI_Build_Name)
|
||||
|
||||
test: $(Target)
|
||||
@perl ./test/cli.pl
|
||||
#====== CI release mode 的配置 =======
|
||||
ifeq ($(MAKECMDGOALS), build-in-ci-release-mode)
|
||||
|
||||
CFLAGS += $(CFLAGS_optimization)
|
||||
|
||||
# 仅在 Linux 上使用静态链接
|
||||
ifeq ($(On-Linux), 1)
|
||||
CFLAGS += $(CFLAGS_static)
|
||||
endif
|
||||
|
||||
# GitHub Actions 上的 macOS 中的 LLVM 太老了
|
||||
# 而且 gcc 被重命名为了 clang
|
||||
# 需要直接指定版本
|
||||
ifeq ($(On-macOS), 1)
|
||||
CC = gcc-14
|
||||
endif
|
||||
|
||||
endif
|
||||
#=====================================
|
||||
|
||||
|
||||
|
||||
#============ Aliases ================
|
||||
all: build
|
||||
|
||||
b: build-in-dev-mode
|
||||
build: build-in-dev-mode
|
||||
bd: build-in-debug-mode
|
||||
br: build-in-release-mode
|
||||
bcir: build-in-ci-release-mode
|
||||
d: debug
|
||||
t: test
|
||||
check: test
|
||||
c: clean
|
||||
#=====================================
|
||||
|
||||
|
||||
|
||||
build-in-dev-mode:
|
||||
@echo Starting: Build in DEV mode: \'$(CC)\' $(CFLAGS) -o $(DevMode-Target-Name)
|
||||
@$(CC) src/chsrc-main.c $(CFLAGS) $(_C_Warning_Flags) -o $(DevMode-Target-Name)
|
||||
@echo Finished: Build in DEV mode
|
||||
|
||||
build-in-debug-mode: CFLAGS += $(CFLAGS_debug)
|
||||
build-in-debug-mode:
|
||||
@echo Starting: Build in DEBUG mode: \'$(CC)\' $(CFLAGS) -o $(DebugMode-Target-Name)
|
||||
@$(CC) src/chsrc-main.c $(CFLAGS) $(_C_Warning_Flags) -o $(DebugMode-Target-Name)
|
||||
@echo Finished: Build in DEBUG mode
|
||||
|
||||
build-in-release-mode: CFLAGS += $(CFLAGS_optimization)
|
||||
build-in-release-mode:
|
||||
@echo Starting: Build in RELEASE mode: \'$(CC)\' $(CFLAGS) -o $(ReleaseMode-Target-Name)
|
||||
@$(CC) src/chsrc-main.c $(CFLAGS) $(_C_Warning_Flags) -o $(ReleaseMode-Target-Name)
|
||||
@echo Finished: Build in RELEASE mode
|
||||
|
||||
# CI release mode 的配置在该文件上方
|
||||
build-in-ci-release-mode:
|
||||
@echo Starting: Build in CI-RELEASE mode: \'$(CC)\' $(CFLAGS) -o $(CIReleaseMode-Target-Name)
|
||||
@$(CC) src/chsrc-main.c $(CFLAGS) $(_C_Warning_Flags) -o $(CIReleaseMode-Target-Name)
|
||||
@echo Finished: Build in CI-RELEASE mode
|
||||
|
||||
# 永远重新编译
|
||||
debug: build-in-debug-mode
|
||||
@$(DEBUGGER) $(DebugMode-Target-Name)
|
||||
|
||||
test: test-make-env test-xy test-fw
|
||||
|
||||
test-make-env:
|
||||
@echo "On-Linux: $(On-Linux)"
|
||||
@echo "On-Windows: $(On-Windows)"
|
||||
@echo "On-macOS: $(On-macOS)"
|
||||
@echo "CC: $(CC)"
|
||||
@echo "CFLAGS: $(CFLAGS)"
|
||||
@echo "USER: $$(whoami)"
|
||||
@echo "PWD: $(shell pwd)"
|
||||
@echo "UID: $$(id -u)"
|
||||
@echo "GID: $$(id -g)"
|
||||
# 检查HOME环境变量
|
||||
@if [ -z "$(HOME)" ]; then \
|
||||
echo "HOME environment variable is not set!"; \
|
||||
else \
|
||||
echo "HOME: $(HOME)"; \
|
||||
fi
|
||||
|
||||
# 这两个测试文件都用 DEBUG mode
|
||||
test-xy: CFLAGS += $(CFLAGS_debug)
|
||||
test-xy:
|
||||
@$(CC) test/xy.c $(CFLAGS) -o xy
|
||||
@./xy
|
||||
|
||||
test-fw: CFLAGS += $(CFLAGS_debug)
|
||||
test-fw:
|
||||
@$(CC) test/fw.c $(CFLAGS) -o fw
|
||||
@./fw
|
||||
|
||||
check: test
|
||||
|
||||
# AUR package 安装时将执行此 target
|
||||
fastcheck: $(DevMode-Target-Name)
|
||||
@perl ./test/cli.pl fastcheck
|
||||
|
||||
test-cli: $(DevMode-Target-Name)
|
||||
@perl ./test/cli.pl
|
||||
|
||||
clean:
|
||||
-@rm *.exe 2>/dev/null
|
||||
-@rm *.res 2>/dev/null
|
||||
-@rm xy 2>/dev/null
|
||||
-@rm chsrc 2>/dev/null
|
||||
-@rm fw 2>/dev/null
|
||||
-@rm README.md.bak* 2>/dev/null
|
||||
|
||||
-@rm chsrc 2>/dev/null
|
||||
-@rm chsrc-debug 2>/dev/null
|
||||
-@rm chsrc-release 2>/dev/null
|
||||
-@rm chsrc-ci-release 2>/dev/null
|
||||
|
||||
# -include pkg/deb/Makefile # 不这么做,因为 pkg/deb/Makefile 需要在 pkg/deb 目录下执行
|
||||
# 保持动词在前的任务名风格
|
||||
build-deb:
|
||||
@$(MAKE) -C pkg/deb deb-build
|
||||
|
||||
clean-deb:
|
||||
@$(MAKE) -C pkg/deb deb-clean
|
||||
|
||||
install: $(ReleaseMode-Target-Name)
|
||||
install -D -m 755 $(ReleaseMode-Target-Name) $(DESTDIR)/usr/bin/chsrc
|
||||
install -D -m 644 doc/chsrc.1 $(DESTDIR)/usr/share/man/man1/chsrc.1
|
||||
|
||||
# 这样还是太麻烦,不用,我们还是靠 just 来调用吧
|
||||
#
|
||||
# 通过 make rawstr4c ARGS="[--debug] Markdown.md" 来调用
|
||||
#rawstr4c:
|
||||
# @bash ./tool/rawstr4c/run/run.sh $(ARGS)
|
||||
|
||||
.PHONY: all b build bd br bcir d t check c \
|
||||
build-in-dev-mode build-in-debug-mode build-in-release-mode build-in-ci-release-mode \
|
||||
debug test test-make-env test-xy test-fw fastcheck test-cli clean install build-deb clean-deb rawstr4c
|
||||
|
|
|
|||
531
README.md
|
|
@ -1,51 +1,186 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : README.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
! | BingChunMoLi <bingchunmoli@bingchunmoli.com>
|
||||
! |
|
||||
! Created On : <2023-12-28>
|
||||
! Last Modified : <2025-08-22>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
<div align="center">
|
||||
<img alt="chsrc logo" src="image/chsrc.png"/>
|
||||
<img alt="chsrc logo" src="doc/image/chsrc.png"/>
|
||||
</div>
|
||||
|
||||
全平台命令行换源工具,**目标支持 Linux (包括麒麟、openEuler、deepin 等), Windows, macOS, BSD 等尽可能多的操作系统,龙芯、飞腾、RISC-V 等尽可能多的 CPU**。
|
||||
全平台通用换源工具与框架 `chsrc`,**目标支持 Linux, Windows (native, MSYS2, Cygwin), macOS, BSD, Android 等尽可能多的操作系统环境,龙芯、飞腾、RISC-V 等尽可能多的 CPU**。
|
||||
|
||||
我们使用 **C99** 来完成上述目标。我们并不使用 Python 或 JS 等解释语言,因为一个简单的换源工具,不应该强行塞给用户一个庞大的解释器和数十、数百 MB 其他文件。
|
||||
我们使用 **C11** 来完成上述目标。我们并不使用 Python 或 JavaScript 等解释语言,因为一个简单的换源工具,不应该强行塞给用户一个庞大的解释器和数十、数百 MB 其他文件。
|
||||
|
||||
本软件为**自由软件**,SDPX 软件许可证为 `GPL-3.0-or-later and MIT`
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
<table align="center">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://trendshift.io/repositories/10744" target="_blank"><img src="https://trendshift.io/api/badge/repositories/10744" alt="RubyMetric%2Fchsrc | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://hellogithub.com/repository/7666ba91e01e4a59be5809b02d9e8ff6" target="_blank"><img src="https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=7666ba91e01e4a59be5809b02d9e8ff6&claim_uid=H6YVMUy7ulev8R4&theme=dark" alt="Featured|HelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## ❤️ 致所有的朋友们
|
||||
|
||||
2025年8月11日,我因通宵重构本项目代码而被送去抢救([#252](https://github.com/RubyMetric/chsrc/issues/252),[突发!换源工具 chsrc 作者在重构过程中被送去 120 抢救](https://v2ex.com/t/1151802))。大家给予的关心和帮助让我非常非常感动!在此,我衷心感谢每一位朋友!**无论是开源还是闭源,无论是否为职业程序员,我们其实都是一群使用软件、热心互助、充满友爱的人,这是一个温暖的大家庭**。
|
||||
|
||||
我为 `chsrc` 采用 GPL 协议,怀着殷切的期望:**希望能够营造像 Richard Stallman 在创建 GNU 项目之前,在 MIT 那样的氛围——写自己用得上的软件,与大家一起开发、维护,简单纯粹,无关商业利益。就像小区、校园自发组建的足球篮球队,从一次偶然的加入,逐渐成长为互相支持的伙伴**。
|
||||
|
||||
这次经历让我更加深刻地体会到:开源,是一种把大家联系在一起的方式,**它让友情、互助和协作成为可能,也让我们在共同的目标中建立起长期的纽带**。
|
||||
|
||||
最后,希望大家能够**时刻关注**自己的身体,**你可以随时 `chsrc` `chown` `chgrp` `chmod` 无限次,但是无法 `chbody`**!
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 🤝 协作与贡献
|
||||
|
||||
> [!TIP]
|
||||
> **`chsrc` 不仅是一个命令行工具,同时也是一个体现了 Ruby on Rails 思想的 MVC 换源框架,它甚至使你能够在不了解C语言的情况下编写出新的换源方法 (recipe)。** 配合使用 [rawstr4c], 这将比写 shell 脚本更加轻松。 [如何编写 recipe?](./doc/10-如何编写recipe.md)
|
||||
|
||||
---
|
||||
|
||||
> [!NOTE]
|
||||
> 这也许是你可以参与的第一个现实世界中有用的C语言项目,[用 VS Code 一分钟内上手编译、运行、测试 chsrc](./doc/01-开发与构建.md)
|
||||
>
|
||||
> 欢迎对 GitHub、Gitee 协作不熟悉的人以此为契机学习参与贡献, 欢迎任何编程初学者。[从开发到提交PR,我们覆盖全流程文档](./doc/)
|
||||
---
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **`chsrc` 可换源 65+ 目标。每个人仅仅贡献和维护自己熟悉的部分,回报是得到其他所有领域专家的帮助。** [欢迎成为 recipe 维护者](https://github.com/RubyMetric/chsrc/issues/275)
|
||||
|
||||
<br>
|
||||
|
||||
可参与的任务与挑战:
|
||||
|
||||
1. [Shell auto-completion 终端命令自动补全](https://github.com/RubyMetric/chsrc/issues/204)
|
||||
|
||||
2. [搜集默认源地址,帮助使用 `reset` 功能](https://github.com/RubyMetric/chsrc/issues/111)
|
||||
|
||||
3. [搜集测速地址,进行精准测速](https://github.com/RubyMetric/chsrc/issues/205)
|
||||
|
||||
4. [chsrc-bootstrap: 为不存在预编译 `chsrc` 的平台提供支持](https://github.com/RubyMetric/chsrc/issues/230)
|
||||
|
||||
<br>
|
||||
|
||||
<details>
|
||||
<summary>已由贡献者完成的挑战</summary>
|
||||
|
||||
1. [[Challenge] 编写统一安装的 shell 和 PowerShell 脚本](https://github.com/RubyMetric/chsrc/issues/98)
|
||||
|
||||
已由 [@Efterklang] 与 [@wickdynex] 完成
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>镜像站可用性</summary>
|
||||
|
||||
1. <https://github.com/RubyMetric/chsrc/wiki>
|
||||
2. <https://github.com/RubyMetric/chsrc/discussions>
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>打包</summary>
|
||||
|
||||
想通过 `dnf`, `flatpak`, `snap` 等系统包管理工具来安装和更新`chsrc`?若可提供维护,请访问 [issue#16 on GitHub](https://github.com/RubyMetric/chsrc/issues/16)
|
||||
|
||||
- [x] `Homebrew`
|
||||
- [x] `Scoop`
|
||||
- [x] `WinGet`
|
||||
- [x] `AUR`
|
||||
- [ ] `Flatpak`
|
||||
- [ ] `snap`
|
||||
- [ ] 缺乏其他平台/包维护者
|
||||
|
||||
</details>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 📌 示例
|
||||
|
||||
桌面端:
|
||||
|
||||
<div align="center">
|
||||
<img alt="chsrc logo" src="image/example.png"/>
|
||||
<img alt="chsrc set node" src="doc/image/example-set-nodejs.png"/>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
安卓:
|
||||
|
||||
<div align="center">
|
||||
<img alt="chsrc set python and chsrc set termux" src="doc/image/chsrc-on-Android-set-python-and-termux.jpg" width="300" height="750"/>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 🚀 安装
|
||||
|
||||
<a href="https://repology.org/project/chsrc/versions">
|
||||
<img src="https://repology.org/badge/vertical-allrepos/chsrc.svg" alt="Packaging status" align="right">
|
||||
<img src="https://repology.org/badge/vertical-allrepos/chsrc.svg" alt="Packaging status" align="right">
|
||||
</a>
|
||||
|
||||
> [!NOTE]
|
||||
> 想通过 `yay`,`pacman`,`apt`,`dnf` 等系统包管理工具来安装和更新`chsrc`?若您可提供维护,请访问 [issue#16 on GitHub](https://github.com/RubyMetric/chsrc/issues/16)
|
||||
|
||||
- [x] `homebrew` 维护者
|
||||
- [x] `scoop` 维护者
|
||||
- [ ] 缺乏 `AUR` 维护者
|
||||
- [ ] 缺乏其他平台/包维护者
|
||||
|
||||
---
|
||||
|
||||
> [!TIP]
|
||||
> [!IMPORTANT]
|
||||
> 若通过下述手动方式安装,则会下载到当前目录,可直接通过 `./chsrc` 运行
|
||||
|
||||
<details>
|
||||
<summary>Windows</summary>
|
||||
|
||||
- 可通过 `scoop` 安装,感谢 [@Gn3po4g](https://github.com/Gn3po4g) 与 [@niheaven](https://github.com/niheaven)
|
||||
- 可通过 `scoop` 安装,感谢 [@Gn3po4g] 与 [@niheaven]
|
||||
|
||||
```bash
|
||||
$ scoop install chsrc
|
||||
scoop install chsrc
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 可通过 `WinGet` 安装,感谢 [@YU-7]
|
||||
|
||||
```bash
|
||||
winget install RubyMetric.chsrc
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 可通过 `PowerShell` 脚本一键下载最新版二进制文件,感谢 [@wickdynex]
|
||||
|
||||
若下方链接无法访问,可使用 `https://gitee.com/RubyMetric/chsrc/raw/main/tool/installer.ps1` 替代
|
||||
|
||||
```PowerShell
|
||||
# 使用 -Version 指定版本 (不指定时默认为 pre)
|
||||
# 1. 安装 pre 版本; 这比从包管理器安装的总是更新一些
|
||||
# 2. 安装旧版本; 有时新版本可能引入某些 Bug,临时使用旧版本解决燃眉之急
|
||||
"& { $(iwr -useb https://chsrc.run/windows) } -Version pre" | iex
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 或手动下载二进制文件,这是最新版,往往比 `scoop` 提供的更新,适用于修复 Bug、添加新功能后及时使用,以及未安装 `scoop` 时
|
||||
|
||||
```bash
|
||||
|
|
@ -55,11 +190,71 @@ curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-windo
|
|||
# x86
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x86-windows.exe -o chsrc.exe
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>Linux</summary>
|
||||
|
||||
- 可通过 `apt`/`dpkg` 安装,感谢 [@sanchuanhehe]
|
||||
|
||||
```bash
|
||||
# x64
|
||||
$ curl -LO https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc_latest-1_amd64.deb
|
||||
|
||||
# 也可以使用 Wget
|
||||
wget https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc_latest-1_amd64.deb
|
||||
|
||||
$ sudo apt install ./chsrc_latest-1_amd64.deb
|
||||
# 或
|
||||
$ sudo sudo dpkg -i chsrc_latest-1_amd64.deb
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 支持 `AUR`,可通过 `yay` 安装,感谢 [@Jerry-Terrasse]
|
||||
|
||||
```bash
|
||||
# AUR
|
||||
$ yay -S chsrc-bin # Binary from GitHub Release
|
||||
$ yay -S chsrc-git # Build from the latest main branch (stable)
|
||||
$ yay -S chsrc # Build from GitHub Release
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 可通过 `shell` 脚本一键安装最新版,感谢 [@Efterklang] 与 [@wickdynex]
|
||||
|
||||
若下方链接无法访问,可使用 `https://gitee.com/RubyMetric/chsrc/raw/main/tool/installer.sh` 替代
|
||||
|
||||
```bash
|
||||
# 非root用户默认安装至 ~/.local/bin
|
||||
$ curl https://chsrc.run/posix | bash
|
||||
|
||||
# 也可以使用 Wget
|
||||
$ wget -O - https://chsrc.run/posix | bash
|
||||
|
||||
# root用户默认安装至 /usr/local/bin
|
||||
$ curl https://chsrc.run/posix | sudo bash
|
||||
|
||||
# 使用 -d 指定目录安装
|
||||
$ curl https://chsrc.run/posix | bash -s -- -d ./
|
||||
|
||||
# 使用 -v 指定版本 (不指定时默认为 pre)
|
||||
# 1. 安装 pre 版本; 这比从包管理器安装的总是更新一些
|
||||
# 2. 安装旧版本; 有时新版本可能引入某些 Bug,临时使用旧版本解决燃眉之急
|
||||
$ curl https://chsrc.run/posix | bash -s -- -v 0.2.1
|
||||
|
||||
# 使用 -l en 输出英文
|
||||
$ curl https://chsrc.run/posix | bash -s -- -l en
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 可手动下载二进制文件安装
|
||||
|
||||
```bash
|
||||
# x64
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-linux -o chsrc; chmod +x ./chsrc
|
||||
|
|
@ -73,43 +268,116 @@ curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-riscv64-l
|
|||
# armv7
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-armv7-linux -o chsrc; chmod +x ./chsrc
|
||||
```
|
||||
|
||||
如果你所在的处理器架构没有预编译版本,可以使用 [chsrc-bootstrap]
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>macOS</summary>
|
||||
|
||||
- 可通过 `homebrew` 安装,感谢 [@Aaron-212](https://github.com/Aaron-212) 与 [@chenrui333](https://github.com/chenrui333)
|
||||
- 可通过 `homebrew` 安装,感谢 [@Aaron-212] 与 [@chenrui333]
|
||||
|
||||
```bash
|
||||
$ brew install chsrc
|
||||
brew install chsrc
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 可通过 `shell` 脚本安装最新版,感谢 [@Efterklang] 与 [@wickdynex]
|
||||
|
||||
若下方链接无法访问,可使用 `https://gitee.com/RubyMetric/chsrc/raw/main/tool/installer.sh` 替代
|
||||
|
||||
```bash
|
||||
# 非root用户默认安装至 ~/.local/bin
|
||||
$ curl https://chsrc.run/posix | bash
|
||||
|
||||
# root用户默认安装至 /usr/local/bin
|
||||
$ curl https://chsrc.run/posix | sudo bash
|
||||
|
||||
# 使用 -d 指定目录安装
|
||||
$ curl https://chsrc.run/posix | bash -s -- -d ./
|
||||
|
||||
# 使用 -v 指定版本 (不指定时默认为 pre)
|
||||
# 1. 安装 pre 版本; 这比从包管理器安装的总是更新一些
|
||||
# 2. 安装旧版本; 有时新版本可能引入某些 Bug,临时使用旧版本解决燃眉之急
|
||||
$ curl https://chsrc.run/posix | bash -s -- -v 0.2.1
|
||||
|
||||
# 使用 -l en 输出英文
|
||||
$ curl https://chsrc.run/posix | bash -s -- -l en
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- 或手动下载二进制文件,这是最新版,往往比 `homebrew` 提供的更新,适用于修复 Bug、添加新功能后及时使用
|
||||
|
||||
```bash
|
||||
# arm/aarch64
|
||||
# arm64/aarch64
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-aarch64-macos -o chsrc; chmod +x ./chsrc
|
||||
|
||||
# x64
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-macos -o chsrc; chmod +x ./chsrc
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>BSD</summary>
|
||||
|
||||
如果已安装好了编译 `chsrc` 所需要的依赖,可直接运行:
|
||||
|
||||
```bash
|
||||
git clone https://gitee.com/RubyMetric/chsrc.git; cd chsrc
|
||||
clang -Iinclude src/chsrc.c -o chsrc
|
||||
clang -Iinclude -Ilib src/chsrc-main.c -o chsrc
|
||||
```
|
||||
|
||||
**如果还不存在这些依赖,你将会被死锁住: 我还没有换源,我该如何安装这些依赖呢?**
|
||||
|
||||
这就是 [chsrc-bootstrap] 起作用的时刻,你可使用BSD系统的原生脚本语言编写 `bootstrapper`,[并向我们提交](https://github.com/RubyMetric/chsrc/issues/230)
|
||||
|
||||
注: `chsrc` 实现的 `FreeBSD recipe` 长期存在问题,因此一个新的 `bootstrapper` 是相当必要的,请帮助你自己和大家!
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>Android/Termux</summary>
|
||||
|
||||
Termux 中默认无 `Wget`,我们都用 `cURL` 来下载安装
|
||||
|
||||
```bash
|
||||
# arm64/aarch64
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-arm64-android -o chsrc; chmod +x ./chsrc
|
||||
```
|
||||
|
||||
如果你所在的处理器架构没有预编译版本,可以使用 [chsrc-bootstrap]:
|
||||
|
||||
```bash
|
||||
curl -L https://gitee.com/RubyMetric/chsrc/raw/main/bootstrap/Termux.bash | bash
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
<details>
|
||||
<summary>其他平台</summary>
|
||||
|
||||
若你所在的平台不存在预编译好的 `chsrc`,你需要手动编译。如果已安装好了编译 `chsrc` 所需要的依赖,可直接运行:
|
||||
|
||||
```bash
|
||||
git clone https://gitee.com/RubyMetric/chsrc.git; cd chsrc; make
|
||||
```
|
||||
|
||||
**如果还不存在这些依赖,你将会被死锁住: 我还没有换源,我该如何安装这些依赖呢?**
|
||||
|
||||
这就是 [chsrc-bootstrap] 起作用的时刻,你可使用该平台原生脚本语言编写 `bootstrapper`,[并向我们提交](https://github.com/RubyMetric/chsrc/issues/230)
|
||||
|
||||
</details>
|
||||
|
||||
<br>
|
||||
|
|
@ -117,47 +385,63 @@ git clone https://gitee.com/RubyMetric/chsrc.git; cd chsrc; make
|
|||
## 💡 使用
|
||||
|
||||
```bash
|
||||
使用: chsrc <command> [options] [target] [mirror]
|
||||
名称:
|
||||
chsrc - Change Source - (GPLv3+)
|
||||
|
||||
help # 打印此帮助,或 h, -h, --help
|
||||
issue # 查看相关issue
|
||||
list (或 ls, 或 l) # 列出可用镜像源,和可换源软件
|
||||
list mirror/target # 列出可用镜像源,或可换源软件
|
||||
list os/lang/ware # 列出可换源的操作系统/编程语言/软件
|
||||
list <target> # 查看该软件可以使用哪些源
|
||||
使用:
|
||||
chsrc <command> [options] [target] [mirror]
|
||||
|
||||
cesu <target> # 对该软件所有源测速
|
||||
get <target> # 查看当前软件的源使用情况
|
||||
命令:
|
||||
help, h 打印此帮助,或 -h, --help
|
||||
issue, i 查看相关issue
|
||||
|
||||
set <target> # 换源,自动测速后挑选最快源
|
||||
set <target> first # 换源,使用维护团队测速第一的源
|
||||
set <target> <mirror> # 换源,指定使用某镜像站 (通过list命令查看)
|
||||
set <target> https://abc # 换源,用户自定义源URL
|
||||
reset <target> # 重置,使用上游默认使用的源
|
||||
list, ls, l 列出可用镜像站和可换源目标
|
||||
list mirror|target 列出支持的: 镜像站/换源目标
|
||||
list os|lang|ware 列出支持的: 操作系统/编程语言/软件
|
||||
list <target> 查看该目标可用源与支持功能
|
||||
|
||||
measure, m, cesu <target> 对该目标所有源测速
|
||||
|
||||
get, g <target> 查看该目标当前源的使用情况
|
||||
|
||||
set, s <target> 换源,自动测速后挑选最快源
|
||||
set <target> first 换源,使用维护团队测速第一的源
|
||||
set <target> <mirror> 换源,指定使用某镜像站 (通过list <target>查看)
|
||||
set <target> <URL> 换源,用户自定义源URL
|
||||
reset <target> 重置,使用上游默认使用的源
|
||||
|
||||
选项:
|
||||
-ipv6 # 使用IPv6测速
|
||||
-local # 仅对某项目而非全局换源 (仅部分软件如bundler,pdm支持)
|
||||
-dry Dry Run,模拟换源过程,命令仅打印并不运行
|
||||
-local 仅对本项目而非全局换源 (通过ls <target>查看支持情况)
|
||||
-ipv6 使用IPv6测速
|
||||
-en(glish) 使用英文输出
|
||||
-no-color 无颜色输出
|
||||
```
|
||||
|
||||
当你**不想自动测速的时候**,你可以直接指定某镜像站,源URL,以及指定维护团队已测试的最快镜像站。
|
||||
<br>
|
||||
|
||||
```bash
|
||||
chsrc set ruby # 测速,寻找最快者,换源
|
||||
# 或
|
||||
chsrc ls ruby # 列出可用的镜像站
|
||||
chsrc set ruby rubychina # 使用 RubyChina 作为镜像站
|
||||
# 或您有自己的镜像地址
|
||||
chsrc set ruby https://gems.ruby-china.com/ # 使用自定义URL
|
||||
# 或
|
||||
chsrc set ruby first # 使用维护团队测试的最快镜像站
|
||||
```
|
||||
自动测速,寻找最快者,换源
|
||||
|
||||
对部分[支持局部换源](https://gitee.com/RubyMetric/chsrc/issues/I9V5I0)的,可以避免全局换源。
|
||||
$ chsrc set ruby
|
||||
|
||||
```bash
|
||||
chsrc set -local bundler
|
||||
chsrc set -local pdm
|
||||
不想自动测速的时候,可使用维护团队测试的最快镜像站
|
||||
|
||||
$ chsrc set ruby first
|
||||
|
||||
先列出可用的镜像站,然后选择其一,如使用 RubyChina 作为镜像站
|
||||
|
||||
$ chsrc ls ruby
|
||||
$ chsrc set ruby rubychina
|
||||
|
||||
若有自己的镜像,可以使用自定义URL
|
||||
|
||||
$ chsrc set ruby https://gems.ruby-china.com/
|
||||
|
||||
对支持 *项目级* 换源的目标,可以避免全局(*系统级* 或 *用户级*)换源
|
||||
|
||||
$ chsrc set -local bundler
|
||||
$ chsrc set -local pdm
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
@ -165,23 +449,41 @@ chsrc set -local pdm
|
|||
## 编程语言开发
|
||||
|
||||
```bash
|
||||
chsrc set ruby 或 set gem
|
||||
chsrc set python 或 set pip / poetry / pdm # 同时换pip、poetry 和 pdm 这3个
|
||||
chsrc set node 或 set npm / nodejs / yarn / pnpm # 同时换这3个
|
||||
chsrc set perl 或 set cpan
|
||||
chsrc set php 或 set composer
|
||||
chsrc set lua 或 set luarocks
|
||||
chsrc set ruby|rb|gem|bundler|rubygems
|
||||
|
||||
chsrc set python | py | pypi # 同时换 pip, poetry, pdm, uv 这4个包管理器,也可以4个独立换源
|
||||
chsrc set pip
|
||||
chsrc set poetry
|
||||
chsrc set pdm
|
||||
chsrc set uv
|
||||
|
||||
chsrc set rye
|
||||
|
||||
chsrc set node | nodejs # 同时换 npm, yarn 和 pnpm 这3个包管理器,也可以3个独立换源
|
||||
chsrc set npm
|
||||
chsrc set yarn
|
||||
chsrc set pnpm
|
||||
|
||||
chsrc set nvm
|
||||
chsrc set bun
|
||||
|
||||
chsrc set perl | cpan
|
||||
chsrc set php | composer
|
||||
chsrc set lua | luarocks
|
||||
|
||||
chsrc set rust | cargo | crate
|
||||
chsrc set rustup
|
||||
|
||||
chsrc set go
|
||||
chsrc set rust 或 set cargo / crate
|
||||
chsrc set java 或 set maven / mvn / gradle
|
||||
chsrc set clojure 或 set clojars
|
||||
chsrc set dart 或 set pub / flutter # 同时会为flutter换源
|
||||
chsrc set haskell 或 set hackage/cabal/stack
|
||||
chsrc set ocaml 或 set opam
|
||||
chsrc set java | maven | mvn | maven-daemon | mvnd | gradle
|
||||
chsrc set clojure | clojars
|
||||
chsrc set dart | pub
|
||||
chsrc set flutter
|
||||
chsrc set haskell | hackage | cabal | stack
|
||||
chsrc set ocaml | opam
|
||||
|
||||
# 同时会为 bioconductor 换源
|
||||
chsrc set r 或 set cran
|
||||
chsrc set r | cran
|
||||
chsrc set julia
|
||||
```
|
||||
|
||||
|
|
@ -191,32 +493,38 @@ chsrc set julia
|
|||
|
||||
```bash
|
||||
sudo chsrc set ubuntu
|
||||
sudo chsrc set mint 或 linuxmint
|
||||
sudo chsrc set zorinos
|
||||
sudo chsrc set linuxmint
|
||||
sudo chsrc set debian
|
||||
sudo chsrc set fedora
|
||||
sudo chsrc set suse 或 set opensuse
|
||||
# 同时支持 Leap 和 Tumbleweed
|
||||
sudo chsrc set opensuse
|
||||
sudo chsrc set kali
|
||||
sudo chsrc set arch
|
||||
sudo chsrc set archlinuxcn
|
||||
sudo chsrc set manjaro
|
||||
sudo chsrc set gentoo
|
||||
sudo chsrc set rocky 或 set rockylinux
|
||||
sudo chsrc set alma 或 set almalinux
|
||||
sudo chsrc set rocky | rockylinux
|
||||
sudo chsrc set alma | almalinux
|
||||
sudo chsrc set alpine
|
||||
sudo chsrc set void 或 set voidlinux
|
||||
sudo chsrc set voidlinux
|
||||
sudo chsrc set solus
|
||||
sudo chsrc set ros 或 set ros2
|
||||
sudo chsrc set ros | ros2
|
||||
sudo chsrc set trisquel
|
||||
sudo chsrc set lite 或 set linuxlite
|
||||
sudo chsrc set raspi 或 set raspberrypi
|
||||
sudo chsrc set linuxlite
|
||||
sudo chsrc set raspi | raspberrypi
|
||||
sudo chsrc set armbian
|
||||
sudo chsrc set openwrt
|
||||
|
||||
sudo chsrc set euler 或 set openeuler
|
||||
sudo chsrc set anolis 或 set openanolis
|
||||
sudo chsrc set kylin 或 set openkylin
|
||||
sudo chsrc set openeuler
|
||||
sudo chsrc set openanolis | anolis
|
||||
sudo chsrc set openkylin
|
||||
sudo chsrc set deepin
|
||||
|
||||
chsrc set msys2 或 set msys
|
||||
chsrc set msys2 | msys
|
||||
|
||||
# Android
|
||||
chsrc set termux
|
||||
|
||||
# BSD
|
||||
sudo chsrc set freebsd
|
||||
|
|
@ -230,34 +538,15 @@ sudo chsrc set netbsd
|
|||
|
||||
```bash
|
||||
chsrc set winget
|
||||
chsrc set brew 或 set homebrew
|
||||
chsrc set cocoapods 或 set cocoa / pod
|
||||
chsrc set dockerhub 或 set docker
|
||||
chsrc set flathub
|
||||
chsrc set brew | homebrew
|
||||
chsrc set cocoapods | cocoa | pod
|
||||
chsrc set dockerhub | docker
|
||||
chsrc set flathub | flatpak
|
||||
chsrc set nix
|
||||
chsrc set guix
|
||||
chsrc set emacs 或 set elpa
|
||||
chsrc set tex 或 set ctan / latex / texlive / miktex
|
||||
chsrc set conda 或 set anaconda
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## 🛠️ 开发
|
||||
|
||||
请安装好 `gcc`或`clang` 和 `make` 以及 `curl`
|
||||
|
||||
```bash
|
||||
# 使用 dev 分支开发
|
||||
git clone https://gitee.com/RubyMetric/chsrc.git -b dev
|
||||
|
||||
make # 默认使用 cc 编译
|
||||
make CC=clang # 使用 clang 编译
|
||||
make CC=gcc # 使用 gcc 编译
|
||||
|
||||
make test # 测试命令
|
||||
make test-xy # 测试 xy.h
|
||||
make clean
|
||||
chsrc set emacs | elpa
|
||||
chsrc set tex | ctan | latex | texlive | miktex
|
||||
chsrc set conda | anaconda
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
@ -271,12 +560,40 @@ make clean
|
|||
|
||||
## ❤️ 致谢
|
||||
|
||||
感谢各个镜像站提供的优质免费镜像服务,使用的镜像站见 [source.h](./include/source.h).
|
||||
感谢各个镜像站提供的优质免费镜像服务
|
||||
|
||||
另外感谢以下项目:
|
||||
1. [mirror.c](./src/framework/mirror.c) 包含了通用的镜像站信息
|
||||
2. 各个recipe内部定义的专用镜像站
|
||||
|
||||
1. [MirrorZ 教育网镜像站](https://help.mirrors.cernet.edu.cn/)
|
||||
另外特别感谢以下组织或项目:
|
||||
|
||||
1. [校园网联合镜像站(MirrorZ)](https://help.mirrors.cernet.edu.cn/)
|
||||
2. [清华大学 Tuna](https://mirrors.tuna.tsinghua.edu.cn/)
|
||||
3. [Thanks Mirror 项目](https://github.com/eryajf/Thanks-Mirror) by [@eryajf](https://github.com/eryajf)
|
||||
3. [上海交通大学软件源镜像服务](https://mirrors.sjtug.sjtu.edu.cn/)
|
||||
4. [中国科学技术大学 Linux 用户协会](https://github.com/ustclug)
|
||||
5. [Thanks Mirror 项目](https://github.com/eryajf/Thanks-Mirror) by [@eryajf](https://github.com/eryajf)
|
||||
|
||||
<br>
|
||||
|
||||
## 🚀 赞赏支持
|
||||
|
||||
你是否因为 `chsrc` 而受到启发、节省了时间精力 or whatever?
|
||||
|
||||
爱发电主页: <https://afdian.com/a/ccmywish>
|
||||
|
||||
<img src="https://raw.githubusercontent.com/ccmywish/support-my-oss-work/main/wechat-reward.png" alt="wechat-reward" style="width:300px;"/>
|
||||
|
||||
<br>
|
||||
|
||||
[rawstr4c]: https://github.com/RubyMetric/rawstr4c
|
||||
[chsrc-bootstrap]: ./bootstrap/
|
||||
|
||||
[@Aaron-212]: https://github.com/Aaron-212
|
||||
[@chenrui333]: https://github.com/chenrui333
|
||||
[@niheaven]: https://github.com/niheaven
|
||||
[@Gn3po4g]: https://github.com/Gn3po4g
|
||||
[@Jerry-Terrasse]: https://github.com/Jerry-Terrasse
|
||||
[@Efterklang]: https://github.com/Efterklang
|
||||
[@wickdynex]: https://github.com/wickdynex
|
||||
[@YU-7]: https://github.com/YU-7
|
||||
[@sanchuanhehe]: https://github.com/sanchuanhehe
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : (chsrc-bootstrap Introduction.md)
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2025-07-12>
|
||||
! Last Modified : <2025-07-22>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# Bootstrap
|
||||
|
||||
```ruby
|
||||
begin
|
||||
download_prebuilt_chsrc_binary_for_my_platform
|
||||
rescue NoReadyMadeBinary => e
|
||||
bootstrap! e.my_platform
|
||||
end
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 预编译产生的死锁问题
|
||||
|
||||
我们支持预编译的操作系统目前只有 `Windows`, `Linux`, `macOS`,支持的架构请参考[项目 README](../README.md)
|
||||
|
||||
某些操作系统如 BSD 家族,甚至是更小众的操作系统, 或者上述操作系统的某些架构,无法享受直接下载二进制立即使用的便利性,这导致用户需要自己编译 `chsrc`.
|
||||
|
||||
然而用户自己编译则面临着一个问题: **需要提前安装项目依赖**
|
||||
|
||||
1. 把代码 `git clone` 下来 或 下载 `zip` 包进行解压缩
|
||||
2. C语言编译器
|
||||
3. `GNU make` 或 `just` (这二者非强制,但是有了更好)
|
||||
|
||||
可是如果用户还没有换源,他/她又如何获得上述这些程序呢?**这是一把死锁,导致用户最终回到手动换源的原始农耕时代。**
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## `chsrc-bootstrap` to the Rescue
|
||||
|
||||
`chsrc-bootstrap` 是一组使用原生脚本语言的脚本,每个脚本称为 `bootstrapper`,用来完成两件事情:
|
||||
|
||||
1. 帮助用户进行最基本的换源,让用户能够立即开始使用该系统安装其他软件
|
||||
|
||||
2. 用户自行决定是否需要安装 `chsrc`
|
||||
|
||||
- 若不需要: 流程直接结束,用户已可以完成基本日常工作
|
||||
|
||||
- 若需要: 帮助用户安装好所需的最少依赖,并编译安装 `chsrc`
|
||||
|
||||
注意,最基本的换源,即不测速,由维护者暂时决定先切换到某一个具体的源,先让系统跑起来。
|
||||
|
||||
### 支持的语言
|
||||
|
||||
上述提到的原生脚本语言只能是这些:
|
||||
|
||||
1. Windows: `PowerShell`, `CMD`
|
||||
|
||||
2. Linux: `Bash`, `sh`
|
||||
|
||||
备选: `Perl`
|
||||
|
||||
3. macOS: `Zsh`, `Bash`, `sh`
|
||||
|
||||
备选: `Ruby`, `Perl`
|
||||
|
||||
4. BSD: `sh`
|
||||
|
||||
备选: 待议
|
||||
|
||||
5. 其他平台: 一切该平台支持的脚本语言,无需额外安装
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## `chsrc` 与 `chsrc-bootstrap`
|
||||
|
||||
`chsrc` 需要实现 `chsrc-bootstrap` 中支持的平台。这是因为,`chsrc-bootstrap` 只换到了某一个具体的源,只是临时性的,后续用户可能还想要换到其他源,此时 `chsrc` 就可以接管。
|
||||
|
||||
而事实上,`chsrc-bootstrap` 可以完成一些操作,使得系统已经满足一些前置条件,这样的话 `chsrc` 可以在这些前置条件存在时接着换源,从而大幅减轻 `recipe` 的实现难度。
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 帮助
|
||||
|
||||
1. [FreeBSD 的换源](https://github.com/RubyMetric/chsrc/issues/11) 从项目一开始就是我们的目标之一,然而由于其:
|
||||
|
||||
- 换源所需的步骤太多
|
||||
- 面临着特有的鸡蛋困境
|
||||
- BSD 工具和 GNU 工具总是有不兼容之处
|
||||
- 在C语言中实现困难重重
|
||||
|
||||
因此我们一直没有很好的办法去实现
|
||||
|
||||
2. 任何你所在的平台,都可以添加到此
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
# ---------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# ---------------------------------------------------------------
|
||||
# File Name : Termux.bash
|
||||
# File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# Created On : <2025-07-12>
|
||||
# Last Modified : <2025-07-22>
|
||||
#
|
||||
# Termux:
|
||||
#
|
||||
# Bootstrap Termux: https://github.com/RubyMetric/chsrc/issues/173
|
||||
#
|
||||
# @consult https://help.mirrors.cernet.edu.cn/termux/
|
||||
#
|
||||
# 我们默认采用校园网联合镜像站提供的源
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
bs_echo() {
|
||||
echo "[chsrc-bootstrap] $*"
|
||||
}
|
||||
|
||||
if command -v termux-change-repo &>/dev/null; then
|
||||
termux-change-repo
|
||||
else
|
||||
|
||||
# $PREFIX 的值为: /data/data/com.termux/files/usr
|
||||
# 用户主目录 ~ 为: /data/data/com.termux/files/home
|
||||
|
||||
# 必要的
|
||||
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-main stable main@' $PREFIX/etc/apt/sources.list
|
||||
apt update
|
||||
|
||||
# x11-repo
|
||||
sed -i 's@^\(deb.*x11 main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-x11 x11 main @' $PREFIX/etc/apt/sources.list.d/x11.list
|
||||
|
||||
# root-repo
|
||||
sed -i 's@^\(deb.*root main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-root root main @' $PREFIX/etc/apt/sources.list.d/root.list
|
||||
fi
|
||||
|
||||
# 立即更新测试换源状态
|
||||
apt update && apt upgrade
|
||||
|
||||
bs_echo "基础换源已完成"
|
||||
|
||||
read -p "是否需要安装 chsrc ? (y/n): " need_install_chsrc
|
||||
|
||||
if [[ $need_install_chsrc == "y" || $need_install_chsrc == "Y" ]]; then
|
||||
bs_echo "正在安装依赖项..."
|
||||
apt-get install -y gcc make git
|
||||
git clone https://gitee.com/RubyMetric/chsrc.git --depth 1
|
||||
bs_echo "依赖安装完成!"
|
||||
|
||||
bs_echo "正在开始编译和安装"
|
||||
cd chsrc
|
||||
make build-in-release-mode
|
||||
make install
|
||||
bs_echo "chsrc 安装完成!"
|
||||
fi
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : 01-开发与构建.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
! |
|
||||
! Created On : <2024-12-27>
|
||||
! Last Modified : <2025-10-11>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# 开发 chsrc
|
||||
|
||||
## 依赖与开发环境
|
||||
|
||||
请安装好:
|
||||
|
||||
1. `GCC` 或 `Clang`
|
||||
2. [just] 或 `make`
|
||||
3. `curl`
|
||||
4. [rawstr4c] (可选)
|
||||
|
||||
**我推荐你使用 VS Code 开发,你可以在一分钟内成功编译、运行和 Debug `chsrc`**
|
||||
|
||||
1. `Ctrl-Shift-B` 直接构建
|
||||
2. `F5` 直接开始 Debug
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 获取代码
|
||||
|
||||
**请务必使用 dev 分支开发**
|
||||
|
||||
```bash
|
||||
git clone https://gitee.com/RubyMetric/chsrc.git -b dev
|
||||
```
|
||||
|
||||
关于分支的说明,可参考 [./03-CONTRIBUTING.md](./03-CONTRIBUTING.md)
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 编译运行
|
||||
|
||||
共有四种构建模式:
|
||||
|
||||
1. **`DEV mode`**
|
||||
2. **`DEBUG mode`**
|
||||
3. **`RELEASE mode`**
|
||||
4. **`CI-RELEASE mode`**
|
||||
|
||||
开发时只需要前两种模式;第四种模式只在 GitHub Actions 使用。
|
||||
|
||||
**如果你使用 `just`,可以在 VS Code 中获得更好的体验,按 `Ctrl-Shift-B` 直接使用 DEV mode 构建**
|
||||
|
||||
```bash
|
||||
just (b) # 在Windows上默认使用 gcc 编译,在macOS上默认使用 clang 编译,在其他系统上默认使用 cc 编译
|
||||
just CC=clang # 使用 clang 编译
|
||||
just CC=gcc # 使用 gcc 编译
|
||||
|
||||
# 编译出 debug 版本: chsrc-debug
|
||||
just bd
|
||||
# 编译出 release 版本: chsrc-release
|
||||
just br
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
`make` 用户:
|
||||
|
||||
```bash
|
||||
make (b) # 在Windows上默认使用 cc 编译,在macOS上默认使用 clang 编译,在其他系统上默认使用 cc 编译
|
||||
make CC=clang # 使用 clang 编译
|
||||
make CC=gcc # 使用 gcc 编译
|
||||
|
||||
# 编译出 debug 版本: chsrc-debug
|
||||
make bd
|
||||
# 编译出 release 版本: chsrc-release
|
||||
make br
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## Debug
|
||||
|
||||
**如果你使用 `just`,可以在 VS Code 中获得更好的体验,按 F5 即可立即开始 Debug**
|
||||
|
||||
```bash
|
||||
# 重新编译出 ./chsrc-debug,并启动 GDB 调试 (在macOS上启动 LLDB 调试)
|
||||
$ just debug
|
||||
|
||||
# 重新编译出 ./chsrc-debug,并启动 LLDB 调试
|
||||
$ just DEBUGGER=lldb debug
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
`make` 用户:
|
||||
|
||||
```bash
|
||||
# 重新编译出 ./chsrc-debug,并启动 GDB 调试 (在macOS上启动 LLDB 调试)
|
||||
$ make debug
|
||||
|
||||
# 重新编译出 ./chsrc-debug,并启动 LLDB 调试
|
||||
$ make debug DEBUGGER=lldb
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 测试
|
||||
|
||||
`just` 用户只需要替换下述 `make` 为 `just`
|
||||
|
||||
```bash
|
||||
make test-xy # 测试 xy.h
|
||||
make test-fw # 测试 framework
|
||||
make test # 测试上述两个
|
||||
make test-cli # 测试命令
|
||||
make clean
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 提交 PR
|
||||
|
||||
关于分支的说明以及如何提交代码,请参考 [./03-CONTRIBUTING.md](./03-CONTRIBUTING.md)
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
[rawstr4c]: https://github.com/RubyMetric/rawstr4c
|
||||
[just]: https://github.com/casey/just
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : 02-提交与贡献.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2024-12-13>
|
||||
! Last Modified : <2025-08-22>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# 贡献说明
|
||||
|
||||
## 分支
|
||||
|
||||
- `gh-build`:仅仅在发布版本时由 `@ccmywish` 推送,触发编译到 GitHub Releases 中
|
||||
- `main`: stable,代码一定是可以编译运行的,我们假设 end users 在其他条件都得不到二进制时,会自己编译这个分支来运行 `chsrc`
|
||||
- `dev`:开发分支,工作分支,在此分支上解决冲突
|
||||
|
||||
<br>
|
||||
|
||||
## 提交与审阅
|
||||
|
||||
当你提交 PR 的时候,一定要将 PR 指定 chsrc 原仓库的 dev 分支。
|
||||
|
||||
### 一个简单的 Bug
|
||||
|
||||
一个简单的 Bug fix,有写权限的维护者可以直接推送到主仓库的 `dev` 分支
|
||||
|
||||
<br>
|
||||
|
||||
### 不太容易修复的 Bug 以及新功能
|
||||
|
||||
这里要分两种情况考虑。(1)recipe 相关的 (2)framework 相关的
|
||||
|
||||
(1)
|
||||
|
||||
**如果你是 recipe Chef,则你完全负责这个 recipe,如果你拥有写权限,你可以直接推送代码到 `dev` 分支**
|
||||
|
||||
---
|
||||
|
||||
(2)
|
||||
|
||||
1. 需要先搜索你修改的部分涉及到的 recipe,然后提 issue @ 所有相关的 recipe Chef 来 review
|
||||
2. 如果涉及了所有 recipe,则 @ framework Chef,而无需把所有 recipe 的 Chef 都喊过来,但是如果觉得有必要,可以 @ 任意你觉得有能力 review 和能给出建议的人来 review
|
||||
|
||||
<br>
|
||||
|
||||
### 最好总是 issue 或 PR
|
||||
|
||||
对于有写权限的维护者来说,即使是能够直接推代码,最好也都先提 issue 或 PR,因为这样能够让大家知道代码发生了哪些变动。
|
||||
|
||||
如果你觉得要和大家讨论,则 issue;如果你觉得没有讨论的必要了,则直接 PR 后自己立即合并即可。之所以多此一举,是因为这能够显式地记录代码的加入过程,其相当于一份文档方便未来的自己和他人查阅
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : 03-为什么拒绝使用代码格式化工具.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! Created On : <2025-08-10>
|
||||
! Last Modified : <2025-08-20>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# chsrc 代码风格
|
||||
|
||||
Ruby 的语法优美性在编程行业中具有标杆地位。Matz(松本行弘)提出的 **代码应该为人类而写,偶尔为机器执行** 这一理念,已经成为现代编程语言设计的重要指导原则。`chsrc` 项目的第一作者深受 **Ruby** 语言哲学的影响。
|
||||
|
||||
本项目起源于 AI 编程尚未流行的时代,所有代码全部依赖人类的耐心来维护。现在,我们的代码以及这篇文章不仅会由人类阅读,也会由 AI 阅读。我们始终坚持:**代码的可读性和维护性是项目长期发展的根本保障**。
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 为什么我们坚持不使用代码格式化工具
|
||||
|
||||
代码格式化工具(code formatter)在多人协作的代码仓库中确实有其价值,**参与的人越多,统一格式的需求越迫切**。然而,`chsrc` 项目经过深思熟虑后,拒绝使用代码格式化工具。让我来说明这一决定背后的深层原因。
|
||||
|
||||
### 被强迫使用
|
||||
|
||||
像 `Prettier` 这样的工具表面上带来了统一性,但其代价是什么?**它是极度专制的(opiniated)**,我们必须**完全交出代码审美的自主权**。今天我们大部分人使用 `Prettier`,**并非出于真心的认同,而是因为整个前端生态圈的集体胁迫——不用就意味着被边缘化**。
|
||||
|
||||
这种现象的本质令人深思:**少数 `Prettier` 维护者的个人偏好,竟然决定了全球数百万开发者的代码美学标准。这显然是一种技术独裁,坚决拒绝向格式化工具的霸权低头**。
|
||||
|
||||
<br>
|
||||
|
||||
### 一致性 ≠ 美观 ≠ 可读
|
||||
|
||||
格式化工具只保证了表面的一致性,就像一些校服,一致不一定代表美。同样,一致不一定代表代码就是最易读易懂的。
|
||||
|
||||
每一个有追求的程序员都应该保留**对代码美学的最后决定权,格式化工具的便利性不应该以牺牲美观性和可维护性为代价**。
|
||||
|
||||
<br>
|
||||
|
||||
### 满足不了我们的需求
|
||||
|
||||
C语言的格式化工具通常选择 `clang-format`,它的配置选项十分丰富,比 `Prettier` 要理性得多。然而,即便如此,**其配置的复杂性和局限性仍然无法满足 chsrc 对代码格式的严苛要求**。如果你是一位 `clang-format` 的配置专家,我们诚挚邀请您告诉我们如何优雅地处理以下代码场景,**也许这能改变我的立场**。
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
### 挑战案例
|
||||
|
||||
以下是我认为自动格式化工具很难完美处理的代码场景:
|
||||
|
||||
`=` 对齐:
|
||||
|
||||
```c
|
||||
char *name = va_arg (args, char*);
|
||||
char *email = va_arg (args, char*);
|
||||
```
|
||||
|
||||
复杂逻辑的 `=` 对齐:
|
||||
|
||||
```c
|
||||
bool matched = iterate_menu (chsrc_pl_menu, input, &target_tmp);
|
||||
if (!matched) matched = iterate_menu (chsrc_os_menu, input, &target_tmp);
|
||||
if (!matched) matched = iterate_menu (chsrc_wr_menu, input, &target_tmp);
|
||||
```
|
||||
|
||||
预处理指令的层次缩进:
|
||||
|
||||
```c
|
||||
#ifdef _WIN32
|
||||
#define XY_Build_On_Windows 1
|
||||
#define xy_on_windows true
|
||||
#ifdef XY_DEBUG
|
||||
#define xy_debug_mode 1
|
||||
#endif
|
||||
#endif
|
||||
```
|
||||
|
||||
...... 等等
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## C语言代码风格
|
||||
|
||||
- 整体上基于 `GNU style`,但我们坚持自己的美学原则,在细节上有所改进
|
||||
|
||||
- 类型名: `PascalCase_t`,即 `UpperCamelCase_t`
|
||||
|
||||
- 函数定义和调用时,**函数名和`()`之间始终保持一个空格**,如果是在宏中,可紧凑一些,无硬性规定
|
||||
|
||||
- 函数和函数定义之间**一般保持2个空行**
|
||||
|
||||
- 若函数之间有高度关联性,**可用1个空行**
|
||||
- 若一系列函数和一系列函数存在主题性区别,**可用3个空行**
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## Markdown 写作风格
|
||||
|
||||
维护者很多时候不是从渲染好的界面来看 Markdown 文件的,而是阅读 Markdown 源文件,所以 Markdown 在源文件层面也要易读。
|
||||
|
||||
我们保持每个主题之间 **1个`<br>` + 3个空行** 的简单风格。
|
||||
|
||||
拒绝使用 VS Code 的 `markdownlint` 插件,**因为它总是用它狭隘的标准给我们增加了巨多的黄色下划线**。
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 其他语言代码风格
|
||||
|
||||
我们秉承 **入乡随俗、尊重传统** 的原则,尊重每种语言社区的既定传统。比如,`YAML` 使用2个空格,`JSON`使用4个空格,`Perl` 使用 Larry Wall 钟爱的4个空格。
|
||||
|
||||
我们使用 `.editorconfig` 来确保这些格式的应用。
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : 10-如何编写recipe.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2024-08-19>
|
||||
! Last Modified : <2025-10-28>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# Write A Recipe Even If You Don't Know C
|
||||
|
||||
## 介绍
|
||||
|
||||
**`chsrc` 不仅是一个命令行工具,同时也是一个体现了 Ruby on Rails 思想的 MVC 换源框架,它甚至使你能够在不了解C语言的情况下编写出新的换源方法(recipe)。**
|
||||
|
||||
<br>
|
||||
|
||||
我鼓励你为新的软件添加换源支持,因为通过 `chsrc` 框架,这将比写 shell 脚本更加轻松,你的贡献也将非常有价值。理论上每一个 `recipe` 都需要有专人长时间维护 ([招募](https://github.com/RubyMetric/chsrc/issues/275))。
|
||||
|
||||
- 本项目采用 `GPLv3+` 协议,是真正的**自由软件**,而非仅仅是开源软件
|
||||
- 代码规范灵活遵循 `GNU` 标准(若标准干扰了可维护性,则并不采纳)
|
||||
- 高度模块化,目录结构清晰易懂
|
||||
- 极小依赖,极易构建,只需要 `GCC` 或 `Clang` 即可编译 (`make` 和 `just`可简化编译,但不是必需的)
|
||||
- 易于将 `shell` 脚本转换为等价的 `recipe`
|
||||
- 已有大量 `recipe` 可提供参考,并提供了 [recipe template] 供直接使用
|
||||
- 本仓库外的子项目 [rawstr4c] 帮助你在C语言中维护复杂的字符串
|
||||
- [chsrc-bootstrap] 帮助你在没有预编译 `chsrc` 的平台上 bootstrap 自己
|
||||
|
||||
<br>
|
||||
|
||||
成功案例:
|
||||
|
||||
- [Armbian](../src/recipe/os/APT/Armbian.c)
|
||||
- [uv](../src/recipe/lang/Python/uv.c)
|
||||
|
||||
<br>
|
||||
|
||||
## 基本概念
|
||||
|
||||
- `target`: 所要换源的目标
|
||||
- `target group`: 一个 `target` 包含了多个子 `target`,比如 `Python group` 包含了该语言的多个包管理器
|
||||
|
||||
- `category`: 是 `target category` 的简写,即 `target` 所属的类别,可以是 **编程语言**,**操作系统**,**软件** 三类之一
|
||||
|
||||
1. 在目录中,三者分别为 `lang`, `os`, `ware`
|
||||
2. 在代码中,三者前缀分别为 `pl`, `os`, `wr`
|
||||
|
||||
- `mirror`: 是 `mirror site` 的简写,指镜像站,如清华大学开源软件镜像站
|
||||
- `source`: 该 `target` 所能换的具体的源,由 `mirror` 提供服务,往往一个 `mirror` 会提供许多 `source`
|
||||
- `recipe`: 是为一个 `target` 定义的具体换源方法,请参考 `src` 目录中的 `recipe` 目录
|
||||
|
||||
- `chef DSL`:是 `chef Domain Specific Language` 的简写,这是一组以 `chef_` 开头的函数,用来定义维护者信息、可用源等元信息
|
||||
|
||||
- **换源链接**: 指镜像站所提供的某一个具体的换源使用的URL
|
||||
- **测速链接**: 用来测速的URL,与 "换源链接" 不同,可分为 **精准测速** 和 **模糊测速**
|
||||
|
||||
- **镜像源**: 为了方便,**偶尔**我们将直接称`mirror`和/或`source`为**镜像源**,这只是一种方便性的称呼,可以统称二者,也可以根据上下文指代二者之一
|
||||
|
||||
<br>
|
||||
|
||||
## 编写 `recipe` 步骤
|
||||
|
||||
1. 确定你要编写的 `target` 的标准名称,创建 `Target-Name.c` 文件
|
||||
|
||||
大小写需严格按官方,若名称包含空格,需使用 `-` 代替空格
|
||||
|
||||
2. 根据类别将上述文件放在 `recipe/` 目录的某个子目录中
|
||||
|
||||
3. 复制 [recipe template] 的内容到上述文件中,并替换 `<...>` 占位符
|
||||
|
||||
4. 参考现有 `recipe` 的写法
|
||||
|
||||
1. 看一眼就能上手的参照物是 [PHP recipe](../src/recipe/lang/PHP.c)
|
||||
2. 最好的参照物是 [Ruby recipe](../src/recipe/lang/Ruby/Ruby.c)
|
||||
3. 组换源参照物是 [Python group recipe](../src/recipe/lang/Python/Python.c)
|
||||
|
||||
5. 在 [Wiki] 中记录的镜像站中寻找可用源;可以额外补充镜像站
|
||||
|
||||
6. 使用 chef DSL 定义 `_prelude()` 函数
|
||||
|
||||
该函数将填充 target 所有的必要信息,包括维护信息、换源信息
|
||||
|
||||
7. [设置/修改 "换源链接" 和 "测速链接" (how?)](./11-如何设置换源链接与测速链接.md)
|
||||
|
||||
8. 按需实现 `_setsrc()` `_getsrc()` `_resetsrc()`, 可以使用这些函数:
|
||||
|
||||
1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏
|
||||
2. `xy.h` 中以 `xy_` 开头的所有函数或宏
|
||||
3. `chec.c` 中以 `chef_` 开头的所有函数或宏
|
||||
4. `helper.c` 中以 `hp_` 开头的所有函数或宏
|
||||
|
||||
一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀
|
||||
|
||||
9. 在 `recipe/menu.c` 中登记此 target
|
||||
|
||||
10. [编译、运行、测试 (how?)](./01-开发与构建.md),若无问题可提交 Pull Request
|
||||
|
||||
<br>
|
||||
|
||||
## 开发准则
|
||||
|
||||
1. 代码高度可移植
|
||||
|
||||
2. Convention over Configuration
|
||||
|
||||
3. [NO UFO 原则: 不要乱丢文件到$HOME等目录,尤其是使用各种隐晦的文件名](https://www.yuque.com/ccmywish/blog/no-ufo)
|
||||
|
||||
`chsrc` 主程序不提供配置文件,不提供数据文件,干净无污染。那么在实现 `recipe` 的时候,除了备份文件外,也不要污染用户环境。
|
||||
|
||||
<br>
|
||||
|
||||
[rawstr4c]: https://github.com/RubyMetric/rawstr4c
|
||||
[chsrc-bootstrap]: ../bootstrap/
|
||||
[recipe template]: ../src/recipe/recipe-template.c
|
||||
[Wiki]: https://github.com/RubyMetric/chsrc/wiki
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : 11-如何设置换源链接与测速链接.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2025-08-11>
|
||||
! Last Modified : <2025-08-11>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# 新增/修改 "换源链接"
|
||||
|
||||
在 `_prelude()` 函数中,在 `def_sources_begin()` 的位置的**第二列**,新增/修改你想要替换的链接。
|
||||
|
||||
**注: 以下代码仅起解释作用,JavaScript换源的真正实现可能不同**
|
||||
|
||||
```c
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://registry.npmjs.org/", FeedByPrelude},
|
||||
{&NpmMirror, "https://registry.npmmirror.com", FeedByPrelude},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/", FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/npm/", FeedByPrelude},
|
||||
{&某新镜像站, "某镜像站提供的换源链接", FeedByPrelude}
|
||||
def_sources_end()
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
# 设置/修改 "测速链接"
|
||||
|
||||
在 `_prelude()` 函数中,在 `def_sources_begin()` 的位置的**第三列**,设置/修改你想要替换的链接。
|
||||
|
||||
1. 在下面代码的第一行中,我们直接给了一个链接,**这就是精准测速链接**
|
||||
2. 在下面代码的第二行和第三行中,我们都设置了一个宏 `DelegateToMirror`,这意味着我们没有直接提供精准测速链接,而是让 `chsrc` 去测试其对应镜像站定义的测速链接
|
||||
|
||||
- `NpmMirror` 是专用镜像站,所以其测速链接被设置为了 `ACCURATE`,即精准测速
|
||||
- `Huawei` 是通用镜像站,所以其测速链接被设置为了 `ROUGH `,即模糊测速
|
||||
|
||||
3. 在下面代码的第四行中,我们设置了一个宏 `FeedByPrelude`,这意味着我们将在 `_prelude()` 函数的后续动态计算 URL
|
||||
|
||||
**注: 以下代码仅起解释作用,JavaScript换源的真正实现可能不同**
|
||||
|
||||
```c
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://registry.npmjs.org/", "https://registry.npmjs.org/BigFile.tar.gz"},
|
||||
{&NpmMirror, "https://registry.npmmirror.com", DelegateToMirror},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/", DelegateToMirror},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/npm/", FeedByPrelude},
|
||||
def_sources_end()
|
||||
|
||||
// 把所有上述源的 "测速链接" 设置为 "换源链接" + postfix
|
||||
chef_set_sources_speed_measure_url_with_postfix (this, "/dir/BigFile.tar.gz");
|
||||
// 基于 "换源链接" 做更自定义的操作
|
||||
chef_set_sources_speed_measure_url_with_func (this, func, data);
|
||||
|
||||
// 调整某一个镜像站(Provider)的 "测速链接"
|
||||
chef_set_provider_speed_measure_url (&Tencent, "https://mirrors.cloud.tencent.com/npm/BigFile.tar.gz")
|
||||
// 调整某一个镜像站(Provider)的 "测速精度"
|
||||
chef_set_provider_speed_measure_accuracy (&UpstreamProvider, ROUGH);;
|
||||
```
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : 50-协作者与维护者.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2024-12-06>
|
||||
! Last Modified : <2025-08-22>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# 协作者与维护者
|
||||
|
||||
想要达到最理想的维护状态,每一个 recipe 都需要有专人长时间维护。**我们的代码里使用了 recipe (某个菜的烹饪方法) 这个词,因而整个项目便和 "饮食" 有关,比如 `menu`: 汇集了所有的 target 的菜单。因此,我们的维护者和贡献者身份依然使用了这个惯例:**
|
||||
|
||||
1. **Chef**
|
||||
|
||||
品控 (主厨): 对一个 recipe 完全负责,有写权限时可以直接推代码
|
||||
|
||||
**目前项目的发展阶段还处于 *外行实现内行* 的情况,比如 Homebrew recipe,实现者根本不是 Homebrew 的真实用户,只是根据各种文档来实现,然后等待用户反馈。所以这里当前的实现者最多只能是 Cook,无法承担 Chef 的责任**
|
||||
|
||||
2. **Cook**
|
||||
|
||||
掌勺:一个 recipe 的主要作者
|
||||
|
||||
3. **Saucier**
|
||||
|
||||
调味:一个 recipe 的次要贡献者 (除主要作者外的其他人)
|
||||
|
||||
<br>
|
||||
|
||||
**Chef 采用申请制,每个 recipe 仅有1人,请提交 PULL REQUEST 在对应的 recipe 文件中添加自己,并在 [issue #275
|
||||
](https://github.com/RubyMetric/chsrc/issues/275) 留言。**
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : (Document Introduction.md)
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nul None <nul@none.org>
|
||||
! |
|
||||
! Created On : <2024-12-27>
|
||||
! Last Modified : <2025-08-22>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# 文档说明
|
||||
|
||||
E2E (End-to-End) 开发文档:
|
||||
|
||||
- 开发环境准备,如何编译和测试,请参考 [01-开发与构建.md](./01-开发与构建.md)
|
||||
- 直接推送还是提交 PR,请参考 [02-提交与贡献.md](./02-提交与贡献.md)
|
||||
- 代码风格,请参考 [03-为什么拒绝使用代码格式化工具.md](./03-为什么拒绝使用代码格式化工具.md)
|
||||
|
||||
<br>
|
||||
|
||||
具体 recipe 相关:
|
||||
|
||||
- 如何编写一个具体的 recipe,请参考 [10-如何编写recipe.md](./10-如何编写recipe.md)
|
||||
- 如何修改换源链接、模糊/精准测速链接,请参考 [11-如何设置换源链接与测速链接.md](./11-如何设置换源链接与测速链接.md)
|
||||
|
||||
<br>
|
||||
|
||||
- 关于维护者身份的说明,请参考 [50-协作者与维护者.md](./50-协作者与维护者.md)
|
||||
|
||||
<br>
|
||||
|
||||
用户手册:
|
||||
|
||||
1. [chsrc.1](./chsrc.1)
|
||||
2. [chsrc.texi](./chsrc.texi)
|
||||
|
||||
<br>
|
||||
|
||||
## 贡献指导
|
||||
|
||||
若有任何问题,可在 [GitHub discussions](https://github.com/RubyMetric/chsrc/discussions) 中询问和讨论
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
.\" --------------------------------------------------------------
|
||||
.\" SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
.\" --------------------------------------------------------------
|
||||
.\" Doc Type : Man Page
|
||||
.\" Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
.\" Contributors : Nul None <nul@none.org>
|
||||
.\" |
|
||||
.\" Created On : <2024-08-21>
|
||||
.\" Last Modified : <2025-10-29>
|
||||
.\" ----------------------------------------------------------------
|
||||
|
||||
.TH chsrc 1 "2025-10-29" "v0.2.3.1" "RubyMetric chsrc"
|
||||
|
||||
.SH NAME
|
||||
chsrc - Change Source for every software on every platform from the command line
|
||||
|
||||
.SH SYNOPSIS
|
||||
.SY chsrc
|
||||
<command> [options] [target] [mirror]
|
||||
.YS
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
.SS 基本命令
|
||||
.TP
|
||||
.B help
|
||||
打印此帮助,或 h, -h, --help
|
||||
.TP
|
||||
.B issue
|
||||
查看相关issue
|
||||
|
||||
.TP
|
||||
\fBlist\fR (或 \fBls\fR, 或 \fBl\fR)
|
||||
列出可用镜像源,和可换源目标
|
||||
.TP
|
||||
.B list mirror/target
|
||||
列出可用镜像源,或可换源目标
|
||||
.B list os/lang/ware
|
||||
列出可换源的操作系统/编程语言/软件
|
||||
|
||||
.SS 测速命令
|
||||
.TP
|
||||
.B measure/cesu \fI<target>\fI
|
||||
对该目标所有源测速
|
||||
|
||||
.SS 查看配置命令
|
||||
.TP
|
||||
.B list \fI<target>\fR
|
||||
查看该目标可用源与支持功能
|
||||
.TP
|
||||
.B get \fI<target>\fR
|
||||
查看该目标当前源的使用情况
|
||||
|
||||
.SS 换源命令
|
||||
.TP
|
||||
.B set \fI<target>\fR
|
||||
换源,自动测速后挑选最快源
|
||||
.TP
|
||||
.B set \fI<target>\fR first
|
||||
换源,使用维护团队测速第一的源
|
||||
.TP
|
||||
.B set \fI<target>\fR \fI<mirror>\fR
|
||||
换源,指定使用某镜像站 (通过list <target>查看)
|
||||
.TP
|
||||
.B set \fI<target>\fR \fI<https://url>\fR
|
||||
换源,用户自定义源URL
|
||||
.TP
|
||||
.B reset \fI<target>\fR
|
||||
重置,使用上游默认使用的源
|
||||
|
||||
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB-dry\fR
|
||||
Dry Run,模拟换源过程,命令仅打印并不运行
|
||||
.TP
|
||||
\fB-local\fR
|
||||
仅对本项目而非全局换源 (通过ls \fI<target>\fR查看支持情况)
|
||||
.TP
|
||||
\fB-ipv6\fR
|
||||
使用IPv6测速
|
||||
.TP
|
||||
\fB-en(glish)\fR
|
||||
使用英文输出
|
||||
.TP
|
||||
\fB-no-color\fR
|
||||
无颜色输出
|
||||
|
||||
|
||||
.SH "EXIT STATUS"
|
||||
.br
|
||||
.TP
|
||||
0
|
||||
正常执行,一般表示换源成功
|
||||
.TP
|
||||
1
|
||||
用户环境导致的错误,如命令缺失
|
||||
.TP
|
||||
2
|
||||
chsrc 暂未实现支持
|
||||
.TP
|
||||
3
|
||||
维护者导致的镜像站、源信息相关错误
|
||||
.TP
|
||||
4
|
||||
致命错误,由内部Bug导致
|
||||
.TP
|
||||
5
|
||||
致命未知错误,往往代表内部未知Bug
|
||||
|
||||
|
||||
|
||||
.SH EXAMPLES
|
||||
.EX
|
||||
# 测速,寻找最快者,换源
|
||||
$ chsrc set ruby
|
||||
|
||||
# 列出可用的镜像站
|
||||
# 使用 RubyChina 作为镜像站
|
||||
$ chsrc ls ruby
|
||||
$ chsrc set ruby rubychina
|
||||
|
||||
# 可以使用自定义URL
|
||||
$ chsrc set ruby https://gems.ruby-china.com/
|
||||
|
||||
# 使用维护团队测试的最快镜像站
|
||||
$ chsrc set ruby first
|
||||
.EE
|
||||
|
||||
|
||||
.SH FILES
|
||||
.B
|
||||
遵循 No UFO(Unidentified File Objects)原则:https://www.yuque.com/ccmywish/blog/no-ufo
|
||||
.PP
|
||||
因此不会有任何文件存放在你的计算机中!
|
||||
|
||||
|
||||
|
||||
.\" .SH SEE ALSO
|
||||
|
||||
.SH AUTHOR
|
||||
Written by Aoran Zeng, Heng Guo and contributors. (See chsrc.c)
|
||||
|
||||
.SH "REPORTING BUGS"
|
||||
On Gitee: https://gitee.com/RubyMetric/chsrc/issues
|
||||
.br
|
||||
On GitHub: https://github.com/RubyMetric/chsrc/issues
|
||||
|
||||
.SH COPYRIGHT
|
||||
Copyright (C) 2025 Aoran Zeng, Heng Guo.
|
||||
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
|
||||
.br
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
@c --------------------------------------------------------------
|
||||
@c SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
@c --------------------------------------------------------------
|
||||
@c Doc Type : Texinfo
|
||||
@c Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
@c Contributors : Nul None <nul@none.org>
|
||||
@c |
|
||||
@c Created On : <2024-08-22>
|
||||
@c Last Modified : <2025-10-29>
|
||||
@c --------------------------------------------------------------
|
||||
|
||||
\input texinfo
|
||||
@setfilename chsrc.info
|
||||
@settitle chsrc
|
||||
|
||||
@set Chsrc_Version v0.2.3.1
|
||||
@set Doc_Publish_Date 2025-10-29
|
||||
|
||||
@copying
|
||||
@comment 这是软件copyright,不是文档copyright,因此不放在titlepage
|
||||
Copyright @copyright{} 2025 曾奥然, 郭恒
|
||||
@end copying
|
||||
|
||||
@titlepage
|
||||
@title chsrc printed manual
|
||||
@subtitle Change Source everywhere for every software!
|
||||
@author 曾奥然
|
||||
@c @insertcopying
|
||||
For chsrc @value{Chsrc_Version}
|
||||
@page
|
||||
@end titlepage
|
||||
|
||||
|
||||
@contents
|
||||
|
||||
@node Top
|
||||
@top chsrc on-terminal manual
|
||||
|
||||
The tool and framework @command{chsrc} is a great helper to Change Source for every software on every platform from the command line. This texinfo documentation is published on @b{@value{Doc_Publish_Date}} for @command{chsrc} @b{@value{Chsrc_Version}}
|
||||
|
||||
@exdent 使用: chsrc <command> [options] [target] [mirror]
|
||||
|
||||
Exit status:
|
||||
|
||||
@display
|
||||
0 正常执行,一般表示换源成功
|
||||
1 用户环境导致的错误,如命令缺失
|
||||
2 chsrc 暂未实现支持
|
||||
3 维护者导致的镜像站、源信息相关错误
|
||||
4 致命错误,由内部Bug导致
|
||||
5 致命未知错误,往往代表内部未知Bug
|
||||
@end display
|
||||
|
||||
@noindent
|
||||
维护:
|
||||
@itemize
|
||||
@item On Gitee: https://gitee.com/RubyMetric/chsrc/issues
|
||||
@item On GitHub: https://github.com/RubyMetric/chsrc/issues
|
||||
@end itemize
|
||||
|
||||
|
||||
@menu
|
||||
* commands:: 命令
|
||||
* options:: 选项
|
||||
* examples:: 例子
|
||||
@end menu
|
||||
|
||||
@insertcopying
|
||||
|
||||
|
||||
|
||||
@node commands
|
||||
@chapter 命令
|
||||
|
||||
@section 基本命令
|
||||
@table @samp
|
||||
@item help
|
||||
打印此帮助,或 h, -h, --help
|
||||
@item issue
|
||||
查看相关issue
|
||||
|
||||
@item list (或 ls, 或 l)
|
||||
列出可用镜像源,和可换源目标
|
||||
|
||||
@item list mirror/target
|
||||
列出可用镜像源,或可换源目标
|
||||
|
||||
@item list os/lang/ware
|
||||
列出可换源的操作系统/编程语言/软件
|
||||
@end table
|
||||
|
||||
|
||||
@section 测速命令
|
||||
@table @samp
|
||||
@item measure <target>
|
||||
@itemx cesu <target>
|
||||
对该目标所有源测速
|
||||
@end table
|
||||
|
||||
@page
|
||||
@section 查看配置命令
|
||||
@table @samp
|
||||
@item list <target>
|
||||
查看该目标可用源与支持功能
|
||||
|
||||
@item get <target>
|
||||
查看该目标当前源的使用情况
|
||||
@end table
|
||||
|
||||
|
||||
@section 换源命令
|
||||
@table @samp
|
||||
@item set <target>
|
||||
换源,自动测速后挑选最快源
|
||||
|
||||
@item set <target> first
|
||||
换源,使用维护团队测速第一的源
|
||||
|
||||
@item set <target> <mirror>
|
||||
换源,指定使用某镜像站 (通过list <target>查看)
|
||||
|
||||
@item set <target> https://url
|
||||
换源,用户自定义源URL
|
||||
|
||||
@item reset <target>
|
||||
重置,使用上游默认使用的源
|
||||
@end table
|
||||
|
||||
|
||||
|
||||
@node options
|
||||
@chapter 选项
|
||||
@table @samp
|
||||
@item -dry
|
||||
Dry Run,模拟换源过程,命令仅打印并不运行
|
||||
|
||||
@item -ipv6
|
||||
使用IPv6测速
|
||||
|
||||
@item -local
|
||||
仅对本项目而非全局换源 (通过ls <target>查看支持情况)
|
||||
|
||||
@item -en(glish)
|
||||
使用英文输出
|
||||
|
||||
@item -no-color
|
||||
无颜色输出
|
||||
@end table
|
||||
|
||||
|
||||
|
||||
@node examples
|
||||
@chapter 例子
|
||||
@example
|
||||
# 测速,寻找最快者,换源
|
||||
$ chsrc set ruby
|
||||
|
||||
# 列出可用的镜像站
|
||||
# 使用 RubyChina 作为镜像站
|
||||
$ chsrc ls ruby
|
||||
$ chsrc set ruby rubychina
|
||||
|
||||
# 可以使用自定义URL
|
||||
$ chsrc set ruby https://gems.ruby-china.com/
|
||||
|
||||
# 使用维护团队测试的最快镜像站
|
||||
$ chsrc set ruby first
|
||||
@end example
|
||||
|
||||
@bye
|
||||
|
After Width: | Height: | Size: 914 KiB |
|
After Width: | Height: | Size: 734 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g>
|
||||
<path d="M13.392,207.176L130.909,79.868L369.203,79.868L486.608,207.055L486.608,210.821L255.801,459.814L244.311,459.814L13.392,210.7L13.392,207.176ZM250.056,118.434C186.007,118.434 134.008,170.433 134.008,234.482C134.008,298.53 186.007,350.53 250.056,350.53C314.104,350.53 366.104,298.53 366.104,234.482C366.104,170.433 314.104,118.434 250.056,118.434Z" style="fill:#a52019;"/>
|
||||
<path d="M189.09,222.379C183.346,222.379 178.683,217.716 178.683,211.972C178.683,209.1 179.849,206.498 181.733,204.614L204.205,182.142C204.253,182.092 204.302,182.042 204.351,181.993C208.413,177.931 215.007,177.931 219.069,181.993C223.131,186.055 223.131,192.649 219.069,196.711C219.02,196.76 218.97,196.808 218.921,196.856L214.212,201.565L312.183,201.565C317.927,201.565 322.59,206.228 322.59,211.972C322.59,217.716 317.927,222.379 312.183,222.379L189.09,222.379Z" style="fill:#a52019;"/>
|
||||
<path d="M311.547,245.378C317.29,245.378 321.954,250.042 321.954,255.785C321.954,258.657 320.788,261.259 318.904,263.143L296.431,285.616C296.383,285.665 296.335,285.715 296.286,285.764C292.224,289.826 285.629,289.826 281.568,285.764C277.506,281.703 277.506,275.108 281.568,271.046C281.617,270.997 281.666,270.949 281.716,270.901L286.424,266.193L188.453,266.193C182.71,266.193 178.046,261.529 178.046,255.785C178.046,250.042 182.71,245.378 188.453,245.378L311.547,245.378Z" style="fill:#a52019;"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 143 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 77 KiB |
828
include/chsrc.h
|
|
@ -1,828 +0,0 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright © 2023-2024 Aoran Zeng, Heng Guo
|
||||
* -------------------------------------------------------------
|
||||
* File : chsrc.h
|
||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* | Heng Guo <2085471348@qq.com>
|
||||
* Contributors : Peng Gao <gn3po4g@outlook.com>
|
||||
* |
|
||||
* Created on : <2023-08-29>
|
||||
* Last modified : <2024-08-08>
|
||||
*
|
||||
* chsrc 头文件
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#include "xy.h"
|
||||
#include "source.h"
|
||||
|
||||
#define App_Name "chsrc"
|
||||
|
||||
#define Exit_UserCause 1
|
||||
#define Exit_Unsupported 2
|
||||
#define Exit_MatinerIssue 3
|
||||
#define Exit_FatalBug 4
|
||||
#define Exit_FatalUnkownError 5
|
||||
|
||||
#define chsrc_log(str) xy_log(App_Name,str)
|
||||
#define chsrc_succ(str) xy_succ(App_Name,str)
|
||||
#define chsrc_info(str) xy_info(App_Name,str)
|
||||
#define chsrc_warn(str) xy_warn(App_Name,str)
|
||||
#define chsrc_error(str) xy_error(App_Name,str)
|
||||
|
||||
// 2系列都是带有括号的
|
||||
#define chsrc_succ2(str) xy_succ_brkt(App_Name,"成功",str)
|
||||
#define chsrc_log2(str) xy_info_brkt(App_Name,"LOG",str)
|
||||
#define chsrc_warn2(str) xy_warn_brkt(App_Name,"警告",str)
|
||||
#define chsrc_error2(str) xy_error_brkt(App_Name,"错误",str)
|
||||
|
||||
#define to_red(str) xy_str_to_red(str)
|
||||
#define to_blue(str) xy_str_to_blue(str)
|
||||
#define to_green(str) xy_str_to_green(str)
|
||||
#define to_yellow(str) xy_str_to_yellow(str)
|
||||
#define to_purple(str) xy_str_to_purple(str)
|
||||
#define to_bold(str) xy_str_to_bold(str)
|
||||
#define to_boldred(str) xy_str_to_bold(xy_str_to_red(str))
|
||||
#define to_boldblue(str) xy_str_to_bold(xy_str_to_blue(str))
|
||||
#define to_boldgreen(str) xy_str_to_bold(xy_str_to_green(str))
|
||||
#define to_boldyellow(str) xy_str_to_bold(xy_str_to_yellow(str))
|
||||
#define to_boldpurple(str) xy_str_to_bold(xy_str_to_purple(str))
|
||||
|
||||
void
|
||||
chsrc_note2 (const char* str)
|
||||
{
|
||||
char *prompt = xy_2strjoin (to_yellow (App_Name " "), to_boldyellow ("提示"));
|
||||
xy_log_brkt_to (prompt, to_yellow (str), stdout);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chsrc_log_check_result (const char *check_what, const char *check_type, bool exist)
|
||||
{
|
||||
if (!exist)
|
||||
{
|
||||
xy_log_brkt (App_Name, to_boldred ("检查"), xy_strjoin (5,
|
||||
to_red ("x "), check_type, " ", to_red (check_what), " 不存在"));
|
||||
}
|
||||
else
|
||||
{
|
||||
xy_log_brkt (App_Name, to_boldgreen ("检查"), xy_strjoin (5,
|
||||
to_green ("√ "), check_type, " ", to_green (check_what), " 存在"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chsrc_log_cmd_result (bool result, int ret_code)
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
xy_log_brkt (to_green (App_Name), to_boldgreen ("运行"), to_green ("√ 命令执行成功"));
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[8] = {0};
|
||||
sprintf (buf, "%d", ret_code);
|
||||
char *log = xy_2strjoin (to_red ("x 命令执行失败,返回码 "), to_boldred (buf));
|
||||
xy_log_brkt (to_red (App_Name), to_boldred ("运行"), log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Cli_Option_IPv6 = false;
|
||||
bool Cli_Option_Locally = false;
|
||||
bool Cli_Option_InEnglish = false;
|
||||
|
||||
|
||||
bool
|
||||
is_url (const char *str)
|
||||
{
|
||||
return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测二进制程序是否存在
|
||||
*
|
||||
* @param check_cmd 检测 `prog_name` 是否存在的一段命令,一般来说,填 `prog_name` 本身即可,
|
||||
* 但是某些情况下,需要使用其他命令绕过一些特殊情况,比如 python 这个命令在Windows上
|
||||
* 会自动打开 Microsoft Store,需避免
|
||||
*
|
||||
* @param prog_name 要检测的二进制程序名
|
||||
*/
|
||||
bool
|
||||
query_program_exist (char *check_cmd, char *prog_name)
|
||||
{
|
||||
char *which = check_cmd;
|
||||
|
||||
int ret = system(which);
|
||||
|
||||
// char buf[32] = {0}; sprintf(buf, "错误码: %d", ret);
|
||||
|
||||
if (0 != ret)
|
||||
{
|
||||
// xy_warn (xy_strjoin(4, "× 命令 ", progname, " 不存在,", buf));
|
||||
chsrc_log_check_result (prog_name, "命令", false);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log_check_result (prog_name, "命令", true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @note 此函数只能对接受 --version 选项的程序有效
|
||||
*/
|
||||
bool
|
||||
chsrc_check_program (char *prog_name)
|
||||
{
|
||||
char *quiet_cmd = xy_str_to_quietcmd (xy_2strjoin (prog_name, " --version"));
|
||||
return query_program_exist (quiet_cmd, prog_name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @note 此函数具有强制性,检测不到就直接退出
|
||||
*/
|
||||
void
|
||||
chsrc_ensure_program (char *prog_name)
|
||||
{
|
||||
char *quiet_cmd = xy_str_to_quietcmd (xy_2strjoin (prog_name, " --version"));
|
||||
bool exist = query_program_exist (quiet_cmd, prog_name);
|
||||
if (exist)
|
||||
{
|
||||
// OK, nothing should be done
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_error (xy_strjoin (3, "未找到 ", prog_name, " 命令,请检查是否存在"));
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
chsrc_check_file (char *path)
|
||||
{
|
||||
if (xy_file_exist (path))
|
||||
{
|
||||
chsrc_log_check_result (path, "文件", true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log_check_result (path, "文件", false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于 _setsrc 函数,检测用户输入的镜像站code,是否存在于该target可用源中
|
||||
*
|
||||
* @param target 目标名
|
||||
* @param input 如果用户输入 default 或者 def,则选择第一个源
|
||||
*/
|
||||
#define find_mirror(s, input) query_mirror_exist(s##_sources, s##_sources_n, (char*)#s+3, input)
|
||||
int
|
||||
query_mirror_exist (SourceInfo *sources, size_t size, char *target, char *input)
|
||||
{
|
||||
if (is_url (input))
|
||||
{
|
||||
chsrc_error ("暂不支持对该软件使用用户自定义源,请联系开发者询问原因或请求支持");
|
||||
exit (Exit_Unsupported);
|
||||
}
|
||||
|
||||
if (0==size || 1==size)
|
||||
{
|
||||
chsrc_error (xy_strjoin (3, "当前 ", target, " 无任何可用源,请联系维护者"));
|
||||
exit (Exit_MatinerIssue);
|
||||
}
|
||||
|
||||
if (2==size)
|
||||
{
|
||||
chsrc_succ (xy_strjoin (4, sources[1].mirror->name, " 是 ", target, " 目前唯一可用镜像站,感谢他们的慷慨支持"));
|
||||
}
|
||||
|
||||
if (xy_streql ("reset", input))
|
||||
{
|
||||
puts ("将重置为上游默认源");
|
||||
return 0; // 返回第1个,因为第1个是上游默认源
|
||||
}
|
||||
|
||||
if (xy_streql ("first", input))
|
||||
{
|
||||
puts ("将使用维护团队测速第一的源");
|
||||
return 1; // 返回第2个,因为第1个是上游默认源
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
SourceInfo source = sources[0];
|
||||
|
||||
bool exist = false;
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
source = sources[i];
|
||||
if (xy_streql (source.mirror->code, input))
|
||||
{
|
||||
idx = i;
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exist)
|
||||
{
|
||||
chsrc_error (xy_strjoin (3, "镜像站 ", input, " 不存在"));
|
||||
chsrc_error (xy_2strjoin ("查看可使用源,请使用 chsrc list ", target));
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 该函数来自 oh-my-mirrorz.py,由 @ccmywish 翻译为C语言,但功劳和版权属于原作者
|
||||
*/
|
||||
char *
|
||||
to_human_readable_speed (double speed)
|
||||
{
|
||||
char *scale[] = {"Byte/s", "KByte/s", "MByte/s", "GByte/s", "TByte/s"};
|
||||
int i = 0;
|
||||
while (speed > 1024.0)
|
||||
{
|
||||
i += 1;
|
||||
speed /= 1024.0;
|
||||
}
|
||||
char *buf = xy_malloc0 (64);
|
||||
sprintf (buf, "%.2f %s", speed, scale[i]);
|
||||
|
||||
char *new = NULL;
|
||||
if (i <= 1 ) new = to_red (buf);
|
||||
else
|
||||
{
|
||||
if (i == 2 && speed < 2.00) new = to_yellow (buf);
|
||||
else new = to_green (buf);
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测速代码参考自 https://github.com/mirrorz-org/oh-my-mirrorz/blob/master/oh-my-mirrorz.py
|
||||
* 功劳和版权属于原作者,由 @ccmywish 修改为C语言,并做了额外调整
|
||||
*
|
||||
* @return 返回测得的速度,若出错,返回-1
|
||||
*/
|
||||
double
|
||||
test_speed_url (const char *url)
|
||||
{
|
||||
char *time_sec = "6";
|
||||
|
||||
/* 现在我们切换至跳转后的链接来测速,不再使用下述判断
|
||||
if (xy_str_start_with(url, "https://registry.npmmirror"))
|
||||
{
|
||||
// 这里 npmmirror 跳转非常慢,需要1~3秒,所以我们给它留够至少8秒测速时间,否则非常不准
|
||||
time_sec = "10";
|
||||
}
|
||||
*/
|
||||
|
||||
char *ipv6 = ""; // 默认不启用
|
||||
|
||||
if (Cli_Option_IPv6==true)
|
||||
{
|
||||
ipv6 = "--ipv6";
|
||||
}
|
||||
|
||||
// 我们用 —L,因为Ruby China源会跳转到其他地方
|
||||
// npmmirror 也会跳转
|
||||
char *curl_cmd = xy_strjoin (7, "curl -qsL ", ipv6,
|
||||
" -o " xy_os_devnull,
|
||||
" -w \"%{http_code} %{speed_download}\" -m", time_sec,
|
||||
" -A chsrc/" Chsrc_Version " ", url);
|
||||
|
||||
// chsrc_info (xy_2strjoin ("测速命令 ", curl_cmd));
|
||||
|
||||
char *buf = xy_run (curl_cmd, 0, NULL);
|
||||
// 如果尾部有换行,删除
|
||||
buf = xy_str_strip (buf);
|
||||
|
||||
// 分隔两部分数据
|
||||
char *split = strchr (buf, ' ');
|
||||
if (split) *split = '\0';
|
||||
|
||||
// puts(buf); puts(split+1);
|
||||
int http_code = atoi (buf);
|
||||
double speed = atof (split+1);
|
||||
char *speedstr = to_human_readable_speed (speed);
|
||||
|
||||
if (200!=http_code)
|
||||
{
|
||||
char* httpcodestr = to_yellow (xy_2strjoin ("HTTP码 ", buf));
|
||||
puts (xy_strjoin (3, speedstr, " | ", httpcodestr));
|
||||
}
|
||||
else
|
||||
{
|
||||
puts (speedstr);
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
get_max_ele_idx_in_dbl_ary (double *array, int size)
|
||||
{
|
||||
double maxval = array[0];
|
||||
int maxidx = 0;
|
||||
|
||||
for (int i=1; i<size; i++)
|
||||
{
|
||||
if (array[i]>maxval)
|
||||
{
|
||||
maxval = array[i];
|
||||
maxidx = i;
|
||||
}
|
||||
}
|
||||
return maxidx;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动测速选择镜像站和源
|
||||
*/
|
||||
#define auto_select(s) auto_select_(s##_sources, s##_sources_n, (char*)#s+3)
|
||||
int
|
||||
auto_select_ (SourceInfo *sources, size_t size, const char *target)
|
||||
{
|
||||
if (0==size || 1==size)
|
||||
{
|
||||
chsrc_error (xy_strjoin (3, "当前 ", target, " 无任何可用源,请联系维护者: chsrc issue"));
|
||||
exit (Exit_MatinerIssue);
|
||||
}
|
||||
|
||||
bool onlyone = false;
|
||||
if (2==size) onlyone = true;
|
||||
|
||||
char *check_curl = xy_str_to_quietcmd ("curl --version");
|
||||
bool exist_curl = query_program_exist (check_curl, "curl");
|
||||
if (!exist_curl)
|
||||
{
|
||||
chsrc_error ("没有curl命令,无法测速");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
|
||||
double speeds[size];
|
||||
double speed = 0.0;
|
||||
for (int i=0;i<size;i++)
|
||||
{
|
||||
SourceInfo src = sources[i];
|
||||
const char* url = src.mirror->__bigfile_url;
|
||||
if (NULL==url)
|
||||
{
|
||||
if (xy_streql ("upstream", src.mirror->code))
|
||||
{
|
||||
continue; // 上游默认源不测速
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_warn (xy_strjoin (3, "开发者未提供 ", src.mirror->code, " 镜像站测速链接,跳过该站点"));
|
||||
speed = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("%s", xy_strjoin (3, "测速 ", src.mirror->site , " ... "));
|
||||
fflush (stdout);
|
||||
speed = test_speed_url (url);
|
||||
}
|
||||
speeds[i] = speed;
|
||||
}
|
||||
int fastidx = get_max_ele_idx_in_dbl_ary (speeds, size);
|
||||
|
||||
if (onlyone)
|
||||
chsrc_succ (xy_strjoin (4, sources[fastidx].mirror->name, " 是 ", target, " 目前唯一可用镜像站,感谢他们的慷慨支持"));
|
||||
else
|
||||
puts (xy_2strjoin ("最快镜像站: ", to_green (sources[fastidx].mirror->name)));
|
||||
|
||||
return fastidx;
|
||||
}
|
||||
|
||||
|
||||
#define use_specific_mirror_or_auto_select(input, s) \
|
||||
(NULL!=(input)) ? find_mirror(s, input) : auto_select(s)
|
||||
|
||||
|
||||
|
||||
bool
|
||||
source_is_upstream (SourceInfo *source)
|
||||
{
|
||||
return xy_streql (source->mirror->code, "upstream");
|
||||
}
|
||||
|
||||
bool
|
||||
source_is_userdefine (SourceInfo *source)
|
||||
{
|
||||
return xy_streql (source->mirror->code, "user");
|
||||
}
|
||||
|
||||
bool
|
||||
source_has_empty_url (SourceInfo *source)
|
||||
{
|
||||
return source->url == NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户*只可能*通过下面三种方式来换源,无论哪一种都会返回一个 SourceInfo 出来
|
||||
*
|
||||
* 1. 用户指定 MirrorCode
|
||||
* 2. 用户什么都没指定 (将测速选择最快镜像)
|
||||
* 3. 用户给了一个 URL
|
||||
*
|
||||
* @dependency 变量 option
|
||||
* @dependency 变量 source
|
||||
*/
|
||||
#define chsrc_yield_source(for_what) \
|
||||
if (is_url (option)) \
|
||||
{ \
|
||||
SourceInfo __tmp = { &UserDefine, option }; \
|
||||
source = __tmp; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
int __index = use_specific_mirror_or_auto_select (option, for_what); \
|
||||
source = for_what##_sources[__index]; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define split_between_source_changing_process puts ("--------------------------------")
|
||||
|
||||
/**
|
||||
* 用于 _setsrc 函数
|
||||
*
|
||||
* 1. 告知用户选择了什么源和镜像
|
||||
* 2. 对选择的源和镜像站进行一定的校验
|
||||
*/
|
||||
void
|
||||
chsrc_confirm_source (SourceInfo *source)
|
||||
{
|
||||
// 由于实现问题,我们把本应该独立出去的默认上游源,也放在了可以换源的数组中,而且放在第一个
|
||||
// chsrc 已经规避用户使用未实现的 `chsrc reset`
|
||||
// 但是某些用户可能摸索着强行使用 chsrc set target upstream,从而执行起该禁用的功能,
|
||||
// 之所以禁用,是因为有的 reset 我们并没有实现,我们在这里阻止这些邪恶的用户
|
||||
if (source_is_upstream (source) && source_has_empty_url (source))
|
||||
{
|
||||
chsrc_error ("暂未对该软件实现重置");
|
||||
exit (Exit_Unsupported);
|
||||
}
|
||||
else if (source_has_empty_url (source))
|
||||
{
|
||||
chsrc_error ("该源URL不存在,请向开发团队提交bug");
|
||||
exit (Exit_FatalBug);
|
||||
}
|
||||
else
|
||||
{
|
||||
puts (xy_strjoin (5, "选中镜像站: ", to_green (source->mirror->abbr), " (", to_green (source->mirror->code), ")"));
|
||||
}
|
||||
|
||||
split_between_source_changing_process;
|
||||
}
|
||||
|
||||
|
||||
#define ChsrcTypeAuto "auto"
|
||||
#define ChsrcTypeReset "reset"
|
||||
#define ChsrcTypeSemiAuto "semiauto"
|
||||
#define ChsrcTypeManual "manual"
|
||||
#define ChsrcTypeUntested "untested"
|
||||
|
||||
/**
|
||||
* @param source 可为NULL
|
||||
* @param last_word 5种选择:ChsrcTypeAuto | ChsrcTypeReset | ChsrcTypeSemiAuto | ChsrcTypeManual | ChsrcTypeUntested
|
||||
*/
|
||||
void
|
||||
chsrc_say_lastly (SourceInfo *source, const char *last_word)
|
||||
{
|
||||
split_between_source_changing_process;
|
||||
|
||||
if (xy_streql (ChsrcTypeAuto, last_word))
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
if (source_is_userdefine (source))
|
||||
{
|
||||
chsrc_log ("全自动换源完成; 邀您参与贡献,帮助其他人使用该URL换源: chsrc issue");
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log (xy_2strjoin ("全自动换源完成,感谢镜像提供方: ", to_purple (source->mirror->name)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log ("全自动换源完成");
|
||||
}
|
||||
}
|
||||
else if (xy_streql (ChsrcTypeReset, last_word))
|
||||
{
|
||||
// source_is_upstream (source)
|
||||
chsrc_log (to_purple ("已重置为上游默认源"));
|
||||
}
|
||||
else if (xy_streql (ChsrcTypeSemiAuto, last_word))
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
if (source_is_userdefine (source))
|
||||
{
|
||||
chsrc_log ("半自动换源完成,仍需按上述提示手工操作; 邀您参与贡献,帮助其他人使用该URL换源: chsrc issue");
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log (xy_2strjoin ("半自动换源完成,仍需按上述提示手工操作,感谢镜像提供方: ", to_purple (source->mirror->name)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log ("半自动换源完成,仍需按上述提示手工操作");
|
||||
}
|
||||
chsrc_warn ("若您有完全自动化的换源方案,邀您帮助: chsrc issue");
|
||||
}
|
||||
else if (xy_streql (ChsrcTypeManual, last_word))
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
if (source_is_userdefine (source))
|
||||
{
|
||||
chsrc_log ("因实现约束需按上述提示手工操作; 邀您参与贡献,帮助其他人使用该URL换源: chsrc issue");
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log (xy_2strjoin ("因实现约束需按上述提示手工操作,感谢镜像提供方: ", to_purple (source->mirror->name)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log ("因实现约束需按上述提示手工操作");
|
||||
}
|
||||
chsrc_warn ("若您有完全自动化的换源方案,邀您帮助: chsrc issue");
|
||||
}
|
||||
else if (xy_streql (ChsrcTypeUntested, last_word))
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
if (source_is_userdefine (source))
|
||||
{
|
||||
chsrc_log ("邀您参与贡献,帮助其他人使用该URL换源: chsrc issue");
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log (xy_2strjoin ("感谢镜像提供方: ", to_purple (source->mirror->name)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log ("自动换源完成");
|
||||
}
|
||||
chsrc_warn ("该换源步骤已实现但未经测试或存在任何反馈,请报告使用情况: chsrc issue");
|
||||
}
|
||||
else
|
||||
{
|
||||
puts (last_word);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
chsrc_ensure_root ()
|
||||
{
|
||||
char *euid = getenv ("$EUID");
|
||||
if (NULL==euid)
|
||||
{
|
||||
char *buf = xy_run ("id -u", 0, NULL);
|
||||
if (0!=atoi(buf)) goto not_root;
|
||||
else return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0!=atoi(euid)) goto not_root;
|
||||
else return;
|
||||
}
|
||||
not_root:
|
||||
chsrc_error ("请在命令前使用 sudo 或切换为root用户来保证必要的权限");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
|
||||
|
||||
#define RunOpt_Default 0x0000 // 默认若命令运行失败,直接退出
|
||||
#define RunOpt_Dont_Notify_On_Success 0x0010 // 运行成功不提示用户,只有运行失败时才提示用户
|
||||
#define RunOpt_No_Last_New_Line 0x0100 // 不输出最后的空行
|
||||
#define RunOpt_Dont_Abort_On_Failure 0x1000 // 命令运行失败也不退出
|
||||
|
||||
static void
|
||||
chsrc_run (const char *cmd, int run_option)
|
||||
{
|
||||
xy_log_brkt (to_blue (App_Name), to_boldblue ("运行"), to_blue (cmd));
|
||||
int status = system (cmd);
|
||||
if (0==status)
|
||||
{
|
||||
if (! (RunOpt_Dont_Notify_On_Success & run_option))
|
||||
{
|
||||
chsrc_log_cmd_result (true, status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_log_cmd_result (false, status);
|
||||
if (! (run_option & RunOpt_Dont_Abort_On_Failure))
|
||||
{
|
||||
chsrc_error ("关键错误,强制结束");
|
||||
exit (Exit_FatalUnkownError);
|
||||
}
|
||||
}
|
||||
|
||||
if (! (RunOpt_No_Last_New_Line & run_option))
|
||||
{
|
||||
puts ("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
chsrc_view_file (const char *path)
|
||||
{
|
||||
char *cmd = NULL;
|
||||
path = xy_uniform_path (path);
|
||||
if (xy_on_windows)
|
||||
{
|
||||
cmd = xy_2strjoin ("type ", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = xy_2strjoin ("cat ", path);
|
||||
}
|
||||
chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line);
|
||||
}
|
||||
|
||||
static void
|
||||
chsrc_ensure_dir (const char *dir)
|
||||
{
|
||||
dir = xy_uniform_path (dir);
|
||||
|
||||
if (xy_dir_exist (dir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 不存在就生成
|
||||
char *mkdir_cmd = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
mkdir_cmd = "md "; // 已存在时返回 errorlevel = 1
|
||||
}
|
||||
else
|
||||
{
|
||||
mkdir_cmd = "mkdir -p ";
|
||||
}
|
||||
char *cmd = xy_2strjoin (mkdir_cmd, dir);
|
||||
cmd = xy_str_to_quietcmd (cmd);
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line|RunOpt_Dont_Notify_On_Success);
|
||||
chsrc_note2 (xy_2strjoin ("目录不存在,已自动创建 ", dir));
|
||||
}
|
||||
|
||||
static void
|
||||
chsrc_append_to_file (const char *str, const char *file)
|
||||
{
|
||||
file = xy_uniform_path (file);
|
||||
char *dir = xy_parent_dir (file);
|
||||
chsrc_ensure_dir (dir);
|
||||
|
||||
char *cmd = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
cmd = xy_strjoin (4, "echo ", str, " >> ", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = xy_strjoin (4, "echo '", str, "' >> ", file);
|
||||
}
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line|RunOpt_Dont_Notify_On_Success);
|
||||
}
|
||||
|
||||
static void
|
||||
chsrc_prepend_to_file (const char *str, const char *file)
|
||||
{
|
||||
file = xy_uniform_path (file);
|
||||
char *dir = xy_parent_dir (file);
|
||||
chsrc_ensure_dir (dir);
|
||||
|
||||
char *cmd = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
xy_unimplement;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = xy_strjoin (4, "sed -i '1i ", str, "' ", file);
|
||||
}
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line|RunOpt_Dont_Notify_On_Success);
|
||||
}
|
||||
|
||||
static void
|
||||
chsrc_overwrite_file (const char *str, const char *file)
|
||||
{
|
||||
file = xy_uniform_path (file);
|
||||
char *dir = xy_parent_dir (file);
|
||||
chsrc_ensure_dir (dir);
|
||||
|
||||
char *cmd = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
cmd = xy_strjoin (4, "echo ", str, " > ", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = xy_strjoin (4, "echo '", str, "' > ", file);
|
||||
}
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
}
|
||||
|
||||
static void
|
||||
chsrc_backup (const char *path)
|
||||
{
|
||||
char *cmd = NULL;
|
||||
bool exist = xy_file_exist (path);
|
||||
|
||||
if (!exist)
|
||||
{
|
||||
chsrc_note2 (xy_2strjoin ("文件不存在,跳过备份: ", path));
|
||||
return;
|
||||
}
|
||||
|
||||
if (xy_on_bsd || xy_on_macos)
|
||||
{
|
||||
/* BSD 和 macOS 的 cp 不支持 --backup 选项 */
|
||||
cmd = xy_strjoin (5, "cp -f ", path, " ", path, ".bak");
|
||||
}
|
||||
else if (xy_on_windows)
|
||||
{
|
||||
// /Y 表示覆盖
|
||||
cmd = xy_strjoin (5, "copy /Y ", path, " ", path, ".bak" );
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = xy_strjoin (5, "cp ", path, " ", path, ".bak --backup='t'");
|
||||
}
|
||||
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line|RunOpt_Dont_Notify_On_Success);
|
||||
chsrc_note2 (xy_strjoin (3, "备份文件名为 ", path, ".bak"));
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
chsrc_get_cpuarch ()
|
||||
{
|
||||
char *ret;
|
||||
bool exist;
|
||||
|
||||
if (xy_on_windows)
|
||||
{
|
||||
xy_unimplement;
|
||||
}
|
||||
|
||||
exist = chsrc_check_program ("arch");
|
||||
if (exist)
|
||||
{
|
||||
ret = xy_run ("arch", 0, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
exist = chsrc_check_program ("uname");
|
||||
if (exist)
|
||||
{
|
||||
ret = xy_run ("uname -m", 0, NULL);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_error ("无法检测到CPU类型");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Target Info */
|
||||
typedef struct TargetInfo_t {
|
||||
void (*getfn) (char *option);
|
||||
void (*setfn) (char *option);
|
||||
void (*resetfn) (char *option);
|
||||
SourceInfo *sources;
|
||||
size_t sources_n;
|
||||
} TargetInfo;
|
||||
|
||||
// 大部分target还不支持reset,所以暂时先默认设置为NULL来过渡
|
||||
#define def_target(t) TargetInfo t##_target = {t##_getsrc, t##_setsrc, NULL, t##_sources, t##_sources_n}
|
||||
|
||||
#define def_target_full(t) TargetInfo t##_target = {t##_getsrc, t##_setsrc, t##_resetsrc, t##_sources, t##_sources_n}
|
||||
|
||||
#define def_target_noget(t) TargetInfo t##_target = {NULL, t##_setsrc, NULL, t##_sources, t##_sources_n}
|
||||
979
include/source.h
|
|
@ -1,979 +0,0 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright © 2023-2024 Aoran Zeng, Heng Guo
|
||||
* -------------------------------------------------------------
|
||||
* File : source.h
|
||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* | Heng Guo <2085471348@qq.com>
|
||||
* Contributors : Shengwei Chen <414685209@qq.com>
|
||||
* |
|
||||
* Created on : <2023-08-29>
|
||||
* Last modified : <2024-07-24>
|
||||
*
|
||||
* 镜像站与换源信息
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
typedef struct {
|
||||
const char *code; // 用于用户指定镜像站
|
||||
const char *abbr;
|
||||
const char *name;
|
||||
const char *site;
|
||||
const char *__bigfile_url; // 用于对该镜像站测速
|
||||
} MirrorSite;
|
||||
|
||||
// #define Big_File_ubuntu "/indices/md5sums.gz" 这个是错的
|
||||
#define Big_File_ctan "/systems/texlive/Images/texlive.iso" // 4.8GB
|
||||
#define Big_File_debian "/ls-lR.gz" // 13.9 MB
|
||||
#define Big_File_archlinux "/iso/latest/archlinux-x86_64.iso" // 800MB 左右
|
||||
#define Big_File_deepin "/20.9/deepin-desktop-community-20.9-amd64.iso" // 4GB左右
|
||||
|
||||
|
||||
/**
|
||||
* 教育网镜像
|
||||
*
|
||||
* 我们目前根据 https://github.com/mirrorz-org/oh-my-mirrorz 挑选速度前10位
|
||||
*/
|
||||
MirrorSite
|
||||
MirrorZ = {"mirrorz", "MirrorZ", "MirrorZ 校园网镜像站", "https://mirrors.cernet.edu.cn/", NULL},
|
||||
|
||||
Tuna = {"tuna", "TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/",
|
||||
"https://mirrors.tuna.tsinghua.edu.cn/speedtest/1000mb.bin"},
|
||||
|
||||
Sjtug_Zhiyuan = {"sjtu", "SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/",
|
||||
"https://mirrors.sjtug.sjtu.edu.cn/ctan" Big_File_ctan},
|
||||
|
||||
Zju = {"zju", "ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/",
|
||||
"https://mirrors.zju.edu.cn/debian" Big_File_debian},
|
||||
|
||||
Lzuoss = {"lzu", "LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/",
|
||||
"https://mirror.lzu.edu.cn/CTAN" Big_File_ctan},
|
||||
|
||||
Jlu = {"jlu", "JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/",
|
||||
"https://mirrors.jlu.edu.cn/_static/speedtest.bin"},
|
||||
|
||||
Bfsu = {"bfsu", "BFSU", "北京外国语大学开源软件镜像站","https://mirrors.bfsu.edu.cn/",
|
||||
"https://mirrors.bfsu.edu.cn/speedtest/1000mb.bin"},
|
||||
|
||||
Pku = {"pku", "PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/",
|
||||
"https://mirrors.pku.edu.cn/debian" Big_File_debian},
|
||||
|
||||
Bjtu = {"bjtu", "BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/",
|
||||
"https://mirror.bjtu.edu.cn/archlinux" Big_File_archlinux},
|
||||
|
||||
Sustech = {"sustech", "SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/",
|
||||
"https://mirrors.sustech.edu.cn/site/speedtest/1000mb.bin"},
|
||||
|
||||
Ustc = {"ustc", "USTC", "中国科学技术大学开源镜像站", "https://mirrors.ustc.edu.cn/",
|
||||
"https://mirrors.ustc.edu.cn/CTAN" Big_File_ctan},
|
||||
|
||||
Hust = {"hust", "HUST", "华中科技大学开源镜像站", "https://mirrors.hust.edu.cn/",
|
||||
"https://mirrors.hust.edu.cn/debian" Big_File_debian},
|
||||
|
||||
// 速度暂时处于10位以后,但是目前可用的源
|
||||
Nju = {"nju", "NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/",
|
||||
"https://mirrors.nju.edu.cn/archlinux" Big_File_archlinux};
|
||||
|
||||
|
||||
// @ccmywish: [2023-09-05] 我只使用了不到5次,重庆大学镜像站就把我的ip封杀了,对用户来说封杀策略过严,暂时不可靠,暂时不用
|
||||
//
|
||||
// Cqu = {"cqu", "CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/",
|
||||
// "https://mirrors.cqu.edu.cn/speedtest/1000mb.bin"};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商业公司提供的源
|
||||
*
|
||||
* @warning 腾讯软件源中,有很多链接都已失效,请仔细检查
|
||||
*/
|
||||
MirrorSite
|
||||
Ali = {"ali", "Ali OPSX", "阿里巴巴开源镜像站", "https://developer.aliyun.com/mirror/",
|
||||
"https://mirrors.aliyun.com/deepin-cd" Big_File_deepin},
|
||||
|
||||
Tencent = {"tencent", "Tencent", "腾讯软件源", "https://mirrors.tencent.com/",
|
||||
"https://mirrors.cloud.tencent.com/debian" Big_File_debian},
|
||||
|
||||
Huawei = {"huawei", "Huawei Cloud", "华为开源镜像站", "https://mirrors.huaweicloud.com/",
|
||||
"https://mirrors.huaweicloud.com/debian" Big_File_debian },
|
||||
|
||||
Volcengine = {"volc", "Volcengine", "火山引擎开源软件镜像站", "https://developer.volcengine.com/mirror/",
|
||||
"https://mirrors.volces.com/debian" Big_File_debian },
|
||||
|
||||
// 没有找到 DaoCloud 合适的下载链接,先随便给一个,以规避 chsrc 自动测速时所有 dockerhub 镜像站都没有测速链接带来的 bug
|
||||
DaoCloud = {"daocloud", "DaoCloud","上海道客网络科技有限公司", "https://www.daocloud.io/",
|
||||
"https://qiniu-download-public.daocloud.io/DaoCloud_Enterprise/dce5/offline-community-v0.18.0-amd64.tar"},
|
||||
|
||||
Netease = {"netease", "Netease", "网易开源镜像站", "https://mirrors.163.com/",
|
||||
"https://mirrors.163.com/deepin-cd" Big_File_deepin},
|
||||
|
||||
Sohu = {"sohu", "SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/",
|
||||
"https://mirrors.sohu.com/deepin-cd" Big_File_deepin},
|
||||
|
||||
Api7 = {"api7", "api7.ai", "深圳支流科技有限公司", "https://www.apiseven.com/", NULL},
|
||||
|
||||
Fit2Cloud = {"fit2cloud", "FIT2CLOUD", "杭州飞致云信息科技有限公司", "https://www.fit2cloud.com/", NULL};
|
||||
|
||||
// 开源社区
|
||||
MirrorSite
|
||||
RubyChina = {"rubychina", "RubyChina", "Ruby China 社区", "https://gems.ruby-china.com/",
|
||||
"https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem"}, // 9.9 MB
|
||||
|
||||
NpmMirror = {"npmmirror", "npmmirror", "npmmirror (阿里云赞助)", "https://npmmirror.com/",
|
||||
// 注意,这个是跳转后的地址,不确定未来会不会改变
|
||||
"https://cdn.npmmirror.com/packages/%40tensorflow/tfjs/4.10.0/tfjs-4.10.0.tgz"}, // 29MB
|
||||
|
||||
GoProxyCN = {"goproxy.cn", "Goproxy.cn", "Goproxy.cn (七牛云赞助)", "https://goproxy.cn/",
|
||||
"https://goproxy.cn/github.com/aws/aws-sdk-go/@v/v1.45.2.zip"}, // 30 MB
|
||||
|
||||
GoProxyIO = {"goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/",
|
||||
"https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip"}, // 30 MB
|
||||
|
||||
NugetOrg = {"nuget.org", "NuGet Org", "Nuget Organization", "https://www.nuget.org/", NULL},
|
||||
EmacsChina = {"emacschina", "EmacsChina", "Emacs China 社区", "https://elpamirror.emacs-china.org/", NULL},
|
||||
|
||||
Huecker = {"huecker", "(Russia) Huecker", "俄罗斯 Huecker.io", "https://huecker.io/",
|
||||
// 同 DaoCloud,没有合适的下载链接,先随便给一个,以避免 bug
|
||||
"https://huecker.io/en/use.html"};
|
||||
|
||||
|
||||
MirrorSite
|
||||
Upstream = {"upstream", "Upstream", "上游默认源", NULL, NULL};
|
||||
MirrorSite
|
||||
UserDefine = {"user", "用户自定义", "用户自定义", NULL, NULL};
|
||||
|
||||
|
||||
|
||||
MirrorSite*
|
||||
available_mirrors[] = {
|
||||
&MirrorZ, &Tuna, &Sjtug_Zhiyuan, &Zju, &Lzuoss, &Jlu, &Bfsu, &Pku, &Bjtu, &Sustech, &Ustc, &Hust, &Nju, // &Cqu,
|
||||
&Ali, &Tencent, &Huawei, &Volcengine, &Netease, &Sohu, &Api7, &Fit2Cloud,
|
||||
&RubyChina, &EmacsChina, &NpmMirror, &GoProxyCN, &GoProxyIO,
|
||||
// 暂不支持 &NugetOrg
|
||||
|
||||
// 不要列出 &Upstream 和 &UserDdefine
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
const MirrorSite *mirror;
|
||||
const char *url;
|
||||
} SourceInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 2024-05-25 更新
|
||||
*
|
||||
* @note
|
||||
* 下面的源,并非都实现正确,
|
||||
* BFSU 和 Tuna 以及 阿里的镜像都有问题,会循环遍历一个gem的所有版本,导致安装时间相当长
|
||||
*
|
||||
* @note 网络情况
|
||||
* 若实现正确:
|
||||
* 1. 目前北外最快最稳定
|
||||
* 2. 腾讯挺快,个别时候不稳定,但稳定时能达到4.5MB甚至以上
|
||||
* 3. tuna 有时快有时慢,不稳定,一般在3MB以下
|
||||
* 4. rubychina 有时快有时慢,快时一般在 2MB以下,慢时一般在1MB以下
|
||||
* 5. 阿里云最不稳定,经常最慢
|
||||
*/
|
||||
static SourceInfo
|
||||
pl_ruby_sources[] = {
|
||||
{&Upstream, "https://rubygems.org"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/rubygems/"},
|
||||
{&Tencent, "https://mirrors.tencent.com/rubygems/"},
|
||||
{&RubyChina, "https://gems.ruby-china.com/"}
|
||||
|
||||
// {&Bfsu, "https://mirrors.bfsu.edu.cn/rubygems/"},
|
||||
// {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rubygems/"},
|
||||
// {&Ali, "https://mirrors.aliyun.com/rubygems/"},
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* Sjtug, Tuna, Lzuoss, Jlu, Bfsu, 网易,搜狐 都没有
|
||||
*
|
||||
* @note 腾讯软件源虽然有npm的名,但名存实亡
|
||||
*/
|
||||
pl_nodejs_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&NpmMirror, "https://registry.npmmirror.com"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/npm"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-05-24 更新
|
||||
*
|
||||
* 参考: https://help.mirrors.cernet.edu.cn/CPAN/
|
||||
*/
|
||||
pl_perl_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/"},
|
||||
{&Bjtu, "https://mirror.bjtu.edu.cn/cpan/"},
|
||||
{&Hust, "https://mirrors.hust.edu.cn/CPAN/"},
|
||||
{&Ali, "https://mirrors.aliyun.com/CPAN/"},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/CPAN/"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* @note 缺少教育网或开源社区软件源
|
||||
*/
|
||||
pl_php_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/composer/"},
|
||||
{&Tencent, "https://mirrors.tencent.com/composer/"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/php/"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-27 更新
|
||||
*
|
||||
* @note 目前只有唯一一个源
|
||||
*/
|
||||
pl_lua_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Api7, "https://luarocks.cn"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* @note 缺少教育网软件源
|
||||
*/
|
||||
pl_go_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&GoProxyCN, "https://goproxy.cn"},
|
||||
{&Ali, "https://mirrors.aliyun.com/goproxy/"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/goproxy/"},
|
||||
{&GoProxyIO, "https://goproxy.io"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-05-24 更新
|
||||
*
|
||||
* @note 缺少商业公司或开源社区软件源
|
||||
*
|
||||
* @note 以下都支持稀疏索引,我们换源时都将默认添加 `sparse+`
|
||||
*/
|
||||
pl_rust_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/crates.io-index/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/crates.io-index/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/crates.io-index/"},
|
||||
{&Hust, "https://mirrors.hust.edu.cn/crates.io-index/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* @note 缺少教育网或开源社区软件源
|
||||
*/
|
||||
pl_java_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://maven.aliyun.com/repository/public/"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/maven/"},
|
||||
{&Netease, "http://mirrors.163.com/maven/repository/maven-public/"} // 网易的24小时更新一次
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*
|
||||
* @note 不太好换,且用户可能不多,我们暂时只给用户提供文档
|
||||
*/
|
||||
pl_clojure_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/help/clojars/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/help/clojars.html"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* @note 暂时未实现该换源功能,可参照
|
||||
* https://mirrors.huaweicloud.com/mirrorDetail/5ebf85de07b41baf6d0882ab?mirrorName=nuget&catalog=language
|
||||
*/
|
||||
pl_dotnet_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&NugetOrg, "https://www.nuget.org/api/v2/"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/nuget/v3"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*
|
||||
* @note 我们这里挑选的必须也支持 Flutter
|
||||
*
|
||||
* 我们将会在setsrc函数中生成
|
||||
* 1. https://mirrors.tuna.tsinghua.edu.cn/dart-pub
|
||||
* 2. https://mirrors.tuna.tsinghua.edu.cn/flutter
|
||||
*/
|
||||
pl_dart_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
// {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/"}, // 不确定SJTUG的flutter镜像给的对不对
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/"},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*/
|
||||
pl_haskell_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/hackage"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/hackage"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/hackage"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/hackage"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-15 更新
|
||||
*/
|
||||
pl_ocaml_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/git/opam-repository.git"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-04 更新
|
||||
*
|
||||
* @note 以下注释的,是不含有bioconductor的镜像站,
|
||||
* 我们在换cran的同时,也直接帮助用户换bioconductor
|
||||
*/
|
||||
pl_r_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/cran/"},
|
||||
// {&Ali, "https://mirrors.aliyun.com/CRAN/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"},
|
||||
// {&Sustech, "https://mirrors.sustech.edu.cn/CRAN"},
|
||||
// {&Bfsu, "https://mirrors.bfsu.edu.cn/CRAN/"},
|
||||
// {&Bjtu, "https://mirror.bjtu.edu.cn/cran/"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-05 更新
|
||||
*
|
||||
* @note 缺少商业公司或开源社区软件源
|
||||
*/
|
||||
pl_julia_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/julia"},
|
||||
{&Pku, "https://mirrors.pku.edu.cn/julia"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/julia"}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
static SourceInfo
|
||||
os_ubuntu_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/ubuntu"},
|
||||
{&Volcengine, "https://mirrors.volces.com/ubuntu"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/ubuntu"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/ubuntu"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/ubuntu"},
|
||||
{&Tencent, "https://mirrors.tencent.com/ubuntu"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/ubuntu"},
|
||||
{&Netease, "https://mirrors.163.com/ubuntu"},
|
||||
{&Sohu, "https://mirrors.sohu.com/ubuntu"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-29 更新
|
||||
*
|
||||
* @note: 实际上镜像站里的内容和Ubuntu的不太一样
|
||||
*/
|
||||
os_mint_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/linuxmint/"},
|
||||
{&Ali, "http://mirrors.aliyun.com/linuxmint-packages/"},
|
||||
{&Netease, "https://mirrors.163.com/linuxmint/packages/"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-06 更新
|
||||
*
|
||||
* TODO: 1. 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_deepin_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/deepin"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/deepin"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/deepin"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/deepin"},
|
||||
{&Tencent, "https://mirrors.tencent.com/deepin"},
|
||||
{&Netease, "https://mirrors.163.com/deepin"},
|
||||
{&Sohu, "https://mirrors.sohu.com/deepin"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
os_debian_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/debian"},
|
||||
{&Volcengine, "https://mirrors.volces.com/debian"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/debian"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian"},
|
||||
{&Tencent, "https://mirrors.tencent.com/debian"},
|
||||
{&Netease, "https://mirrors.163.com/debian"},
|
||||
{&Sohu, "https://mirrors.sohu.com/debian"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-02 更新
|
||||
*
|
||||
* TODO: 1. 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_fedora_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/fedora"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/fedora"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/fedora"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/fedora"},
|
||||
{&Tencent, "https://mirrors.tencent.com/fedora"},
|
||||
{&Netease, "https://mirrors.163.com/fedora"},
|
||||
{&Sohu, "https://mirrors.sohu.com/fedora"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
os_kali_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/kali"},
|
||||
{&Volcengine, "https://mirrors.volces.com/kali"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/kali"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/kali"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/kali"},
|
||||
{&Tencent, "https://mirrors.tencent.com/kali"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/kali"},
|
||||
{&Netease, "https://mirrors.163.com/kali"},
|
||||
{&Sohu, "https://mirrors.sohu.com/kali"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-07-03 更新
|
||||
* @note 不要给后面加 / ,因为ARM情况下,还要额外加一个 arm 后缀
|
||||
*/
|
||||
os_arch_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/archlinux"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/archlinux"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/archlinux"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/archlinux"},
|
||||
{&Tencent, "https://mirrors.tencent.com/archlinux"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/archlinux"}, // 不支持 archlinuxcn
|
||||
{&Netease, "https://mirrors.163.com/archlinux"}, // archlinuxcn 的URL和其他镜像站不同
|
||||
// {&Sohu, "https://mirrors.sohu.com/archlinux"} // 不支持 archlinuxcn
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-07-03 更新
|
||||
*
|
||||
* @note 根据 GitHub:@zheng7fu2 建议,拆分 archlinuxcn 出来
|
||||
*/
|
||||
os_archlinuxcn_sources[] = {
|
||||
{&Upstream, "https://repo.archlinuxcn.org/"},
|
||||
{&Ali, "https://mirrors.aliyun.com/archlinuxcn/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/archlinuxcn/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/archlinuxcn/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/"},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/archlinuxcn/"},
|
||||
{&Netease, "https://mirrors.163.com/archlinux-cn/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-05 更新
|
||||
*
|
||||
* TODO: 1. 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_gentoo_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "mirrors.aliyun.com"},
|
||||
{&Bfsu, "mirrors.bfsu.edu.cn"},
|
||||
{&Ustc, "mirrors.ustc.edu.cn"},
|
||||
{&Tuna, "mirrors.tuna.tsinghua.edu.cn"},
|
||||
{&Tencent, "mirrors.tencent.com"},
|
||||
{&Netease, "mirrors.163.com"},
|
||||
{&Sohu, "mirrors.sohu.com"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
os_opensuse_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/opensuse"},
|
||||
{&Volcengine, "https://mirrors.volces.com/opensuse"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/opensuse"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/opensuse"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/opensuse"},
|
||||
{&Tencent, "https://mirrors.tencent.com/opensuse"},
|
||||
{&Netease, "https://mirrors.163.com/opensuse"},
|
||||
{&Sohu, "https://mirrors.sohu.com/opensuse"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* TODO: 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_msys2_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/msys2"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/msys2"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/msys2"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/msys2"},
|
||||
{&Tencent, "https://mirrors.tencent.com/msys2"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/msys2"},
|
||||
{&Netease, "https://mirrors.163.com/msys2"},
|
||||
{&Sohu, "https://mirrors.sohu.com/msys2"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
os_rocky_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/rockylinux"},
|
||||
{&Volcengine, "https://mirrors.volces.com/rockylinux"},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rocky"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/rocky-linux"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/rocky"},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/rocky"},
|
||||
{&Sohu, "https://mirrors.sohu.com/Rocky"},
|
||||
{&Netease, "https://mirrors.163.com/rocky"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
os_alma_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/almalinux"},
|
||||
{&Volcengine, "https://mirrors.volces.com/almalinux"},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/almalinux"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/almalinux"},
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*/
|
||||
os_alpine_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/alpine"},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/alpine"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/alpine"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/alpine"},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/alpine"},
|
||||
{&Ali, "https://mirrors.aliyun.com/alpine"},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/alpine"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/alpine"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-24 更新
|
||||
*/
|
||||
os_void_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/voidlinux"},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/voidlinux"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/voidlinux"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-29 更新
|
||||
*/
|
||||
os_solus_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/solus/packages/shannon/eopkg-index.xml.xz"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/solus/packages/shannon/eopkg-index.xml.xz"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/solus/packages/shannon/eopkg-index.xml.xz"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-29 更新
|
||||
*/
|
||||
os_linuxlite_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/linuxliteos/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-29 更新
|
||||
*/
|
||||
os_trisquel_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/trisquel/"},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/trisquel/"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/trisquel/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/trisquel/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-29 更新
|
||||
*/
|
||||
os_raspberrypi_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&MirrorZ, "https://help.mirrors.cernet.edu.cn/raspberrypi/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/raspberrypi/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/raspberrypi/"},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/raspberrypi/"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/raspberrypi/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-20 更新
|
||||
*/
|
||||
os_armbian_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/armbian"},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/armbian"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/armbian"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/armbian"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/armbian"},
|
||||
{&Nju, "https://mirrors.nju.edu.cn/armbian"},
|
||||
{&Ali, "https://mirrors.aliyun.com/armbian"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-27 更新
|
||||
*
|
||||
* @note 该源需要 FreeBSD 中文社区积极参与维护
|
||||
*
|
||||
* @ccmywish: [2023-09-24] 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports
|
||||
* @ccmywish: [2023-09-27] 请务必保持Nju前面有至少一个镜像,原因请查看 freebsd 的换源函数
|
||||
*/
|
||||
os_freebsd_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ustc, "mirrors.ustc.edu.cn"},
|
||||
{&Nju, "mirror.nju.edu.cn"},
|
||||
{&Netease, "mirrors.163.com"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-05 更新
|
||||
*
|
||||
* TODO: 1. 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_netbsd_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/pkgsrc/packages/NetBSD/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/pkgsrc/packages/NetBSD/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/pkgsrc/packages/NetBSD/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pkgsrc/packages/NetBSD/"},
|
||||
{&Tencent, "https://mirrors.tencent.com/pkgsrc/packages/NetBSD/"},
|
||||
{&Netease, "https://mirrors.163.com/pkgsrc/packages/NetBSD/"},
|
||||
{&Sohu, "https://mirrors.sohu.com/pkgsrc/packages/NetBSD/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-02 更新
|
||||
*
|
||||
* TODO: 1. 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_openbsd_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/OpenBSD/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/OpenBSD/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/OpenBSD/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/OpenBSD/"},
|
||||
{&Tencent, "https://mirrors.tencent.com/OpenBSD/"},
|
||||
{&Netease, "https://mirrors.163.com/OpenBSD/"},
|
||||
{&Sohu, "https://mirrors.sohu.com/OpenBSD/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-06 更新
|
||||
*
|
||||
* TODO: 1. 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
os_openeuler_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/openeuler/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/openeuler/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/openeuler/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/openeuler/"},
|
||||
{&Tencent, "https://mirrors.tencent.com/openeuler/"},
|
||||
{&Netease, "https://mirrors.163.com/openeuler/"},
|
||||
{&Sohu, "https://mirrors.sohu.com/openeuler/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-12 更新
|
||||
*/
|
||||
os_anolis_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/anolis"},
|
||||
{&Hust, "https://mirrors.hust.edu.cn/anolis"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-29 更新
|
||||
*/
|
||||
os_openkylin_sources[] = {
|
||||
{&Upstream, "https://archive.openkylin.top/openkylin/"},
|
||||
{&Ali, "https://mirrors.aliyun.com/openkylin/"},
|
||||
{&Netease, "https://mirrors.163.com/openkylin/"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-04-18 更新
|
||||
*
|
||||
* TODO: 未经测试是否有效
|
||||
*/
|
||||
os_ros_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn"},
|
||||
{&Tencent, "https://mirrors.tencent.com"},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com"},
|
||||
{&Netease, "https://mirrors.163.com"},
|
||||
{&Sohu, "https://mirrors.sohu.com"}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-07 更新
|
||||
*
|
||||
* @note: 目前仅有一个源
|
||||
*/
|
||||
static SourceInfo
|
||||
wr_winget_sources[] = {
|
||||
{&Upstream, "https://cdn.winget.microsoft.com/cache"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/winget-source"},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*
|
||||
* @note 1. 这些链接将会在setsrc函数中补充完整
|
||||
* 2. 不确定 Sustech 能否工作
|
||||
*/
|
||||
wr_brew_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2024-06-08 更新
|
||||
*/
|
||||
wr_cocoapods_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/git/CocoaPods/Specs.git"}
|
||||
},
|
||||
|
||||
/**
|
||||
* 2024-07-24 更新
|
||||
*
|
||||
* @note USTC 与 SJTUG 于 2024-06-06 停止支持 DockerHub
|
||||
* @note NJU 于 2024-06-07 停止支持 DockerHub
|
||||
*
|
||||
* 参考:https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6
|
||||
*/
|
||||
wr_dockerhub_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
// {&Ustc, "https://docker.mirrors.ustc.edu.cn/"},
|
||||
|
||||
// https://github.com/DaoCloud/public-image-mirror
|
||||
{&DaoCloud, "https://docker.m.daocloud.io"},
|
||||
{&Fit2Cloud, "https://docker.1panel.live"},
|
||||
|
||||
// 暂时加入,未来若国内镜像恢复,将删除
|
||||
// https://huecker.io/en/use.html#unbanned
|
||||
{&Huecker, "https://huecker.io"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-11 更新
|
||||
*
|
||||
* @note 目前只有一个源
|
||||
*/
|
||||
wr_flathub_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/flathub"},
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-22 更新
|
||||
*
|
||||
* @note 1. 目前只有一个源
|
||||
* 2. 这些链接将会在setsrc函数中补充完整
|
||||
*/
|
||||
wr_nix_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/nix-channels/"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-11 更新
|
||||
*
|
||||
* @note 目前只有一个源
|
||||
*/
|
||||
wr_guix_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/git/guix.git"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*
|
||||
* @note Emacs用户往往只需要一次性换源,只会极少次调用 chsrc,我们只给用户提供文档
|
||||
*/
|
||||
wr_emacs_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/docs/emacs-elpa"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/help/elpa/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/help/elpa/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/help/elpa.html"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/docs/elpa/"},
|
||||
{&EmacsChina, "https://elpamirror.emacs-china.org/"}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*
|
||||
* @note 这些链接将会在setsrc函数中补充完整
|
||||
*/
|
||||
wr_anaconda_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/anaconda/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/anaconda/"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/anaconda/"},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/anaconda"}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 2023-09-10 更新
|
||||
*
|
||||
* TODO: 1. 暂未添加商业公司源
|
||||
*/
|
||||
wr_tex_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/ctan/systems/texlive/tlnet"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/CTAN/systems/texlive/tlnet"},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet"},
|
||||
{&Jlu, "https://mirrors.jlu.edu.cn/CTAN/systems/texlive/tlnet"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/CTAN/systems/texlive/tlnet"}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources)
|
||||
|
||||
def_sources_n(pl_ruby); def_sources_n(pl_nodejs);
|
||||
def_sources_n(pl_perl); def_sources_n(pl_php); def_sources_n(pl_lua);
|
||||
def_sources_n(pl_go); def_sources_n(pl_rust);
|
||||
def_sources_n(pl_java); def_sources_n(pl_clojure);
|
||||
def_sources_n(pl_dotnet); def_sources_n(pl_dart); def_sources_n(pl_haskell);
|
||||
def_sources_n(pl_ocaml);
|
||||
def_sources_n(pl_r); def_sources_n(pl_julia);
|
||||
|
||||
def_sources_n(os_ubuntu); def_sources_n(os_mint);
|
||||
def_sources_n(os_debian); def_sources_n(os_fedora);
|
||||
def_sources_n(os_kali); def_sources_n(os_opensuse);
|
||||
def_sources_n(os_arch); def_sources_n(os_archlinuxcn);
|
||||
def_sources_n(os_msys2); def_sources_n(os_gentoo);
|
||||
def_sources_n(os_alpine); def_sources_n(os_rocky); def_sources_n(os_alma);
|
||||
def_sources_n(os_void);
|
||||
def_sources_n(os_solus);
|
||||
|
||||
def_sources_n(os_trisquel); def_sources_n(os_linuxlite); def_sources_n(os_raspberrypi);
|
||||
def_sources_n(os_armbian);
|
||||
|
||||
def_sources_n(os_freebsd); def_sources_n(os_netbsd); def_sources_n(os_openbsd);
|
||||
|
||||
def_sources_n(os_ros);
|
||||
|
||||
def_sources_n(os_deepin); def_sources_n(os_openeuler); def_sources_n(os_openkylin);
|
||||
def_sources_n(os_anolis);
|
||||
|
||||
def_sources_n(wr_winget);
|
||||
def_sources_n(wr_brew); def_sources_n(wr_cocoapods);
|
||||
def_sources_n(wr_dockerhub);
|
||||
def_sources_n(wr_flathub);
|
||||
def_sources_n(wr_nix); def_sources_n(wr_guix);
|
||||
def_sources_n(wr_tex); def_sources_n(wr_emacs);
|
||||
def_sources_n(wr_anaconda);
|
||||
760
include/xy.h
|
|
@ -1,760 +0,0 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright © 2023-2024 Aoran Zeng, Heng Guo
|
||||
* -------------------------------------------------------------
|
||||
* File : xy.h
|
||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* | Heng Guo <2085471348@qq.com>
|
||||
* Contributors : Null Nil <null@nil.com>
|
||||
* |
|
||||
* Created on : <2023-08-28>
|
||||
* Last modified : <2024-08-08>
|
||||
*
|
||||
* xy: 襄阳、咸阳
|
||||
* Corss-Platform C utilities for CLI applications in Ruby flavor
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#ifndef XY_H
|
||||
#define XY_H
|
||||
|
||||
#define _XY_Version "v0.1.4.0-2024/08/08"
|
||||
#define _XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/include/xy.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// #define NDEBUG
|
||||
|
||||
#ifdef _WIN32
|
||||
#define XY_On_Windows 1
|
||||
#define xy_on_windows true
|
||||
#define xy_on_linux false
|
||||
#define xy_on_macos false
|
||||
#define xy_on_bsd false
|
||||
#define xy_os_devnull "nul"
|
||||
#include <windows.h>
|
||||
#define xy_useutf8() SetConsoleOutputCP (65001)
|
||||
|
||||
#elif defined(__linux__) || defined(__linux)
|
||||
#define XY_On_Linux 1
|
||||
#define xy_on_windows false
|
||||
#define xy_on_linux true
|
||||
#define xy_on_macos false
|
||||
#define xy_on_bsd false
|
||||
#define xy_os_devnull "/dev/null"
|
||||
#define xy_useutf8()
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#define XY_On_macOS 1
|
||||
#define xy_on_windows false
|
||||
#define xy_on_linux false
|
||||
#define xy_on_macos true
|
||||
#define xy_on_bsd false
|
||||
#define xy_os_devnull "/dev/null"
|
||||
#define xy_useutf8()
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
|
||||
#define XY_On_BSD 1
|
||||
#define xy_on_windows false
|
||||
#define xy_on_linux false
|
||||
#define xy_on_macos false
|
||||
#define xy_on_bsd true
|
||||
#define xy_os_devnull "/dev/null"
|
||||
#define xy_useutf8()
|
||||
#endif
|
||||
|
||||
void putf (double n) { printf ("%f\n", n); }
|
||||
void puti (long long n) { printf ("%lld\n", n); }
|
||||
void putb (bool n) { if (n) puts ("true"); else puts ("false"); }
|
||||
void print (const char *s) { printf ("%s", s); }
|
||||
void println (const char *s) { printf ("%s\n", s);}
|
||||
void say (const char *s) { printf ("%s\n", s);}
|
||||
|
||||
#define assert_str(a, b) assert (xy_streql ((a), (b)))
|
||||
|
||||
#define xy_unsupport assert(!"Unsuppoted")
|
||||
#define xy_unimplement assert(!"Unimplemented temporarily")
|
||||
#define xy_unreach assert(!"This code shouldn't be reached")
|
||||
|
||||
#define xy_arylen(x) (sizeof (x) / sizeof (x[0]))
|
||||
|
||||
static inline void *
|
||||
xy_malloc0 (size_t size)
|
||||
{
|
||||
void *ptr = malloc (size);
|
||||
memset (ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************
|
||||
* String
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* 将str中所有的pat字符串替换成replace,返回一个全新的字符串
|
||||
*/
|
||||
static char *
|
||||
xy_str_gsub (const char *str, const char *pat, const char *replace)
|
||||
{
|
||||
size_t replace_len = strlen (replace);
|
||||
size_t pat_len = strlen (pat);
|
||||
|
||||
int unit = replace_len - pat_len;
|
||||
if (unit <= 0)
|
||||
unit = 0;
|
||||
|
||||
size_t len = strlen (str);
|
||||
|
||||
const char *cur = str;
|
||||
int count = 0;
|
||||
|
||||
while (cur < str + len)
|
||||
{
|
||||
char *fnd = strstr (cur, pat);
|
||||
if (fnd)
|
||||
{
|
||||
count++;
|
||||
cur = fnd + pat_len;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
// puti(count); DEBUG 匹配次数
|
||||
|
||||
char *ret = malloc (unit * count + len + 1);
|
||||
char *retcur = ret;
|
||||
|
||||
cur = str;
|
||||
while (cur < str + len)
|
||||
{
|
||||
char *fnd = strstr (cur, pat);
|
||||
if (fnd)
|
||||
{
|
||||
ptrdiff_t diff = fnd - cur;
|
||||
strncpy (retcur, cur, diff);
|
||||
cur = fnd + pat_len;
|
||||
|
||||
retcur += diff;
|
||||
strcpy (retcur, replace);
|
||||
retcur += replace_len;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
strcpy (retcur, cur);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_2strjoin (const char *str1, const char *str2)
|
||||
{
|
||||
size_t len = strlen (str1);
|
||||
size_t size = len + strlen (str2) + 1;
|
||||
char *ret = malloc (size);
|
||||
strcpy (ret, str1);
|
||||
strcpy (ret + len, str2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_strjoin (unsigned int count, ...)
|
||||
{
|
||||
size_t al_fixed = 128;
|
||||
char *ret = calloc (1, al_fixed);
|
||||
// 已分配次数
|
||||
int al_times = 1;
|
||||
// 当前已分配量
|
||||
size_t al_cur = al_fixed;
|
||||
|
||||
const char *str = NULL;
|
||||
// 需要分配的量
|
||||
size_t al_need = 0;
|
||||
// 用于 strcpy() 到 ret 的哪个位置
|
||||
char *cur = ret + 0;
|
||||
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
// 是否需要重新分配
|
||||
bool need_realloc = false;
|
||||
|
||||
str = va_arg (args, const char *);
|
||||
al_need += strlen (str);
|
||||
while (al_need > al_cur)
|
||||
{
|
||||
al_times += 1;
|
||||
al_cur = al_times * al_fixed;
|
||||
need_realloc = true;
|
||||
}
|
||||
// printf("al_times %d, al_need %zd, al_cur %zd\n", al_times, al_need,
|
||||
// al_cur);
|
||||
if (need_realloc)
|
||||
{
|
||||
ptrdiff_t diff = cur - ret;
|
||||
ret = realloc (ret, al_cur);
|
||||
cur = ret + diff;
|
||||
}
|
||||
if (NULL == ret)
|
||||
{
|
||||
fprintf (stderr, "xy.h: No availble memory!");
|
||||
return NULL;
|
||||
}
|
||||
strcpy (cur, str);
|
||||
// puts(ret);
|
||||
cur += strlen (str);
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
*cur = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_strdup (const char *str)
|
||||
{
|
||||
size_t len = strlen (str);
|
||||
char *new = xy_malloc0 (len + 1);
|
||||
strcpy (new, str);
|
||||
return new;
|
||||
}
|
||||
|
||||
#define _XY_Str_Bold 1
|
||||
#define _XY_Str_Faint 2
|
||||
#define _XY_Str_Italic 3
|
||||
#define _XY_Str_Underline 4
|
||||
#define _XY_Str_Blink 5
|
||||
#define _XY_Str_Cross 9
|
||||
|
||||
#define xy_str_to_bold(str) _xy_str_to_terminal_style (_XY_Str_Bold, str)
|
||||
#define xy_str_to_faint(str) _xy_str_to_terminal_style (_XY_Str_Faint, str)
|
||||
#define xy_str_to_italic(str) _xy_str_to_terminal_style (_XY_Str_Italic, str)
|
||||
#define xy_str_to_underline(str) _xy_str_to_terminal_style (_XY_Str_Underline, str)
|
||||
#define xy_str_to_blink(str) _xy_str_to_terminal_style (_XY_Str_Blink, str)
|
||||
#define xy_str_to_cross(str) _xy_str_to_terminal_style (_XY_Str_Cross, str)
|
||||
|
||||
#define _XY_Str_Red 31
|
||||
#define _XY_Str_Green 32
|
||||
#define _XY_Str_Yellow 33
|
||||
#define _XY_Str_Blue 34
|
||||
#define _XY_Str_Magenta 35
|
||||
#define _XY_Str_Cyan 36
|
||||
|
||||
#define xy_str_to_red(str) _xy_str_to_terminal_style (_XY_Str_Red, str)
|
||||
#define xy_str_to_green(str) _xy_str_to_terminal_style (_XY_Str_Green, str)
|
||||
#define xy_str_to_yellow(str) _xy_str_to_terminal_style (_XY_Str_Yellow, str)
|
||||
#define xy_str_to_blue(str) _xy_str_to_terminal_style (_XY_Str_Blue, str)
|
||||
#define xy_str_to_magenta(str) _xy_str_to_terminal_style (_XY_Str_Magenta, str)
|
||||
#define xy_str_to_purple xy_str_to_magenta
|
||||
#define xy_str_to_cyan(str) _xy_str_to_terminal_style (_XY_Str_Cyan, str)
|
||||
|
||||
static char *
|
||||
_xy_str_to_terminal_style (int style, const char *str)
|
||||
{
|
||||
char *color_fmt_str = NULL;
|
||||
|
||||
switch (style)
|
||||
{
|
||||
case _XY_Str_Red:
|
||||
color_fmt_str = "\e[31m%s\e[0m"; break;
|
||||
case _XY_Str_Green:
|
||||
color_fmt_str = "\e[32m%s\e[0m"; break;
|
||||
case _XY_Str_Yellow:
|
||||
color_fmt_str = "\e[33m%s\e[0m"; break;
|
||||
case _XY_Str_Blue:
|
||||
color_fmt_str = "\e[34m%s\e[0m"; break;
|
||||
case _XY_Str_Magenta:
|
||||
color_fmt_str = "\e[35m%s\e[0m"; break;
|
||||
case _XY_Str_Cyan:
|
||||
color_fmt_str = "\e[36m%s\e[0m"; break;
|
||||
case _XY_Str_Bold:
|
||||
color_fmt_str = "\e[1m%s\e[0m"; break;
|
||||
case _XY_Str_Faint:
|
||||
color_fmt_str = "\e[2m%s\e[0m"; break;
|
||||
case _XY_Str_Italic:
|
||||
color_fmt_str = "\e[3m%s\e[0m"; break;
|
||||
case _XY_Str_Underline:
|
||||
color_fmt_str = "\e[4m%s\e[0m"; break;
|
||||
case _XY_Str_Blink:
|
||||
color_fmt_str = "\e[5m%s\e[0m"; break;
|
||||
case _XY_Str_Cross:
|
||||
color_fmt_str = "\e[9m%s\e[0m"; break;
|
||||
}
|
||||
|
||||
// -2 把中间%s减掉
|
||||
size_t len = strlen (color_fmt_str) - 2;
|
||||
char *buf = malloc (strlen (str) + len + 1);
|
||||
sprintf (buf, color_fmt_str, str);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static bool
|
||||
xy_streql (const char *str1, const char *str2)
|
||||
{
|
||||
if (NULL==str1 || NULL==str2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return strcmp (str1, str2) == 0 ? true : false;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_str_to_quietcmd (const char *cmd)
|
||||
{
|
||||
char *ret = NULL;
|
||||
#ifdef _WIN32
|
||||
ret = xy_2strjoin (cmd, " >nul 2>nul ");
|
||||
#else
|
||||
ret = xy_2strjoin (cmd, " 1>/dev/null 2>&1 ");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool
|
||||
xy_str_end_with (const char *str, const char *suffix)
|
||||
{
|
||||
size_t len1 = strlen (str);
|
||||
size_t len2 = strlen (suffix);
|
||||
|
||||
if (0 == len2)
|
||||
return true; // 空字符串直接返回
|
||||
if (len1 < len2)
|
||||
return false;
|
||||
|
||||
const char *cur1 = str + len1 - 1;
|
||||
const char *cur2 = suffix + len2 - 1;
|
||||
|
||||
for (int i = 0; i < len2; i++)
|
||||
{
|
||||
if (*cur1 != *cur2)
|
||||
return false;
|
||||
cur1--;
|
||||
cur2--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
xy_str_start_with (const char *str, const char *prefix)
|
||||
{
|
||||
if (NULL==str || NULL==prefix)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len1 = strlen (str);
|
||||
size_t len2 = strlen (prefix);
|
||||
|
||||
if (0 == len2)
|
||||
return true; // 空字符串直接返回
|
||||
if (len1 < len2)
|
||||
return false;
|
||||
|
||||
const char *cur1 = str;
|
||||
const char *cur2 = prefix;
|
||||
|
||||
for (int i = 0; i < len2; i++)
|
||||
{
|
||||
if (*cur1 != *cur2)
|
||||
return false;
|
||||
cur1++;
|
||||
cur2++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_str_delete_prefix (const char *str, const char *prefix)
|
||||
{
|
||||
char *new = xy_strdup (str);
|
||||
bool yes = xy_str_start_with (str, prefix);
|
||||
if (!yes)
|
||||
return new;
|
||||
|
||||
size_t len = strlen (prefix);
|
||||
char *cur = new + len;
|
||||
return cur;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_str_delete_suffix (const char *str, const char *suffix)
|
||||
{
|
||||
char *new = xy_strdup (str);
|
||||
bool yes = xy_str_end_with (str, suffix);
|
||||
if (!yes)
|
||||
return new;
|
||||
|
||||
size_t len1 = strlen (str);
|
||||
size_t len2 = strlen (suffix);
|
||||
char *cur = new + len1 - len2;
|
||||
*cur = '\0';
|
||||
return new;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_str_strip (const char *str)
|
||||
{
|
||||
char *new = xy_strdup (str);
|
||||
|
||||
while (strchr ("\n\r\v\t\f ", new[0]))
|
||||
{
|
||||
new += 1;
|
||||
}
|
||||
|
||||
size_t len = strlen (new);
|
||||
|
||||
char *last = new + len - 1;
|
||||
|
||||
while (strchr ("\n\r\v\t\f ", *last))
|
||||
{
|
||||
*last = '\0';
|
||||
last -= 1;
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Logging
|
||||
******************************************************/
|
||||
|
||||
#define _XY_Log_Plain 000000001
|
||||
#define _XY_Log_Success 000000001 << 1
|
||||
#define _XY_Log_Info 000000001 << 2
|
||||
#define _XY_Log_Warn 000000001 << 3
|
||||
#define _XY_Log_Error 000000001 << 4
|
||||
|
||||
#define xy_log(prompt, str) _xy_log (_XY_Log_Plain, prompt, str)
|
||||
#define xy_succ(prompt,str) _xy_log (_XY_Log_Success, prompt, str)
|
||||
#define xy_info(prompt,str) _xy_log (_XY_Log_Info, prompt, str)
|
||||
#define xy_warn(prompt,str) _xy_log (_XY_Log_Warn, prompt, str)
|
||||
#define xy_error(prompt,str) _xy_log (_XY_Log_Error, prompt, str)
|
||||
|
||||
static void
|
||||
_xy_log (int level, const char *prompt, const char *content)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
bool to_stderr = false;
|
||||
|
||||
/**
|
||||
* 'app: content'
|
||||
*/
|
||||
if (level & _XY_Log_Plain)
|
||||
{
|
||||
str = xy_strjoin (3, prompt, ": ", content);
|
||||
}
|
||||
else if (level & _XY_Log_Success)
|
||||
{
|
||||
str = xy_strjoin (3, prompt, ": ", xy_str_to_green (content));
|
||||
}
|
||||
else if (level & _XY_Log_Info)
|
||||
{
|
||||
str = xy_strjoin (3, prompt, ": ", xy_str_to_blue (content));
|
||||
}
|
||||
else if (level & _XY_Log_Warn)
|
||||
{
|
||||
str = xy_strjoin (3, prompt, ": ", xy_str_to_yellow (content));
|
||||
to_stderr = true;
|
||||
}
|
||||
else if (level & _XY_Log_Error)
|
||||
{
|
||||
str = xy_strjoin (3, prompt, ": ", xy_str_to_red (content));
|
||||
to_stderr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// xy_assert ("CAN'T REACH!");
|
||||
}
|
||||
|
||||
if (to_stderr)
|
||||
{
|
||||
fprintf (stderr, "%s\n", str);
|
||||
}
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
}
|
||||
free (str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* brkt 系列输出受 pip 启发,为了输出方便,使用 xy.h 的程序应该
|
||||
*
|
||||
* 1.若想完全自定义颜色和输出位置:
|
||||
*
|
||||
* 应基于下述 xy_log_brkt_to 定义自己的输出函数
|
||||
*
|
||||
* 2.若想自定义颜色,而保持输出到stdout:
|
||||
*
|
||||
* 应基于下述 xy_log_brkt 定义
|
||||
*
|
||||
* 3.若对log无细致要求,想要快速使用log功能:
|
||||
*
|
||||
* 应基于下述 xy_<level>_brkt 定义自己的 app_<level>_brkt(),或直接使用 xy_<level>_brkt
|
||||
*/
|
||||
|
||||
static void
|
||||
xy_log_brkt_to (const char *prompt, const char *content, FILE *stream)
|
||||
{
|
||||
char *str = xy_strjoin (4, "[", prompt, "] ", content);
|
||||
fprintf (stream, "%s\n", str);
|
||||
free (str);
|
||||
}
|
||||
|
||||
#define xy_log_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Plain, prompt1,prompt2,content)
|
||||
#define xy_succ_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Success,prompt1,prompt2,content)
|
||||
#define xy_info_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Info, prompt1,prompt2,content)
|
||||
#define xy_warn_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Warn, prompt1,prompt2,content)
|
||||
#define xy_error_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Error, prompt1,prompt2,content)
|
||||
|
||||
static void
|
||||
_xy_log_brkt (int level, const char *prompt1, const char *prompt2, const char *content)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
bool to_stderr = false;
|
||||
|
||||
if (level & _XY_Log_Plain)
|
||||
{
|
||||
str = xy_strjoin (6, "[", prompt1, " ", prompt2, "] ", content);
|
||||
}
|
||||
else if (level & _XY_Log_Success)
|
||||
{
|
||||
/* [app 成功] [app success] */
|
||||
str = xy_strjoin (6,
|
||||
"[", xy_str_to_green (prompt1), " ", xy_str_to_bold (xy_str_to_green (prompt2)), "] ", xy_str_to_green (content));
|
||||
}
|
||||
else if (level & _XY_Log_Info)
|
||||
{
|
||||
/* [app 信息] [app info]
|
||||
[app 提示] [app notice]
|
||||
*/
|
||||
str = xy_strjoin (6,
|
||||
"[", xy_str_to_blue (prompt1), " ", xy_str_to_bold (xy_str_to_blue (prompt2)), "] ", xy_str_to_blue (content));
|
||||
}
|
||||
else if (level & _XY_Log_Warn)
|
||||
{
|
||||
/* [app 警告] [app warn] */
|
||||
str = xy_strjoin (6,
|
||||
"[", xy_str_to_yellow (prompt1), " ", xy_str_to_bold (xy_str_to_yellow (prompt2)), "] ", xy_str_to_yellow (content));
|
||||
to_stderr = true;
|
||||
}
|
||||
else if (level & _XY_Log_Error)
|
||||
{
|
||||
/* [app 错误] [app error] */
|
||||
str = xy_strjoin (6,
|
||||
"[", xy_str_to_red (prompt1), " ", xy_str_to_bold (xy_str_to_red (prompt2)), "] ", xy_str_to_red (content));
|
||||
to_stderr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// xy_assert ("CAN'T REACH!");
|
||||
}
|
||||
|
||||
if (to_stderr)
|
||||
{
|
||||
fprintf (stderr, "%s\n", str);
|
||||
}
|
||||
else
|
||||
{
|
||||
puts (str);
|
||||
}
|
||||
free (str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************
|
||||
* System
|
||||
******************************************************/
|
||||
/**
|
||||
* 执行cmd,返回某行输出结果,并对已经遍历过的行执行iter_func
|
||||
*
|
||||
* @param cmd 要执行的命令
|
||||
* @param n 指定命令执行输出的结果行中的某一行,0 表示最后一行,n (n>0) 表示第n行
|
||||
* 该函数会返回这一行的内容
|
||||
* @param iter_func 对遍历时经过的行的内容,进行函数调用
|
||||
*
|
||||
* @note 返回的字符串最后面一般有换行符号
|
||||
*
|
||||
* 由于目标行会被返回出来,所以 iter_func() 并不执行目标行,只会执行遍历过的行
|
||||
*/
|
||||
static char *
|
||||
xy_run (const char *cmd, unsigned long n, void (*iter_func) (const char *))
|
||||
{
|
||||
const int size = 512;
|
||||
char *buf = (char *) malloc (size);
|
||||
|
||||
FILE *stream = popen (cmd, "r");
|
||||
if (stream == NULL)
|
||||
{
|
||||
fprintf (stderr, "xy: 命令执行失败\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *ret = NULL;
|
||||
unsigned long count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (NULL == fgets (buf, size, stream))
|
||||
break;
|
||||
ret = buf;
|
||||
count += 1;
|
||||
if (n == count)
|
||||
break;
|
||||
if (iter_func)
|
||||
{
|
||||
iter_func (buf);
|
||||
}
|
||||
}
|
||||
|
||||
pclose (stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define xy_os_home _xy_os_home ()
|
||||
static char *
|
||||
_xy_os_home ()
|
||||
{
|
||||
char *home = NULL;
|
||||
if (xy_on_windows)
|
||||
home = getenv ("USERPROFILE");
|
||||
else
|
||||
home = getenv ("HOME");
|
||||
return home;
|
||||
}
|
||||
|
||||
#define xy_win_powershell_profile _xy_win_powershell_profile ()
|
||||
#define xy_win_powershellv5_profile _xy_win_powershellv5_profile ()
|
||||
static char *
|
||||
_xy_win_powershell_profile ()
|
||||
{
|
||||
return xy_2strjoin (
|
||||
xy_os_home, "\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1");
|
||||
}
|
||||
|
||||
char *
|
||||
_xy_win_powershellv5_profile ()
|
||||
{
|
||||
return xy_2strjoin (
|
||||
xy_os_home,
|
||||
"\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1");
|
||||
}
|
||||
|
||||
/**
|
||||
* @note Windows上,`path` 不要夹带变量名,因为最终 access() 不会帮你转换
|
||||
*/
|
||||
static bool
|
||||
xy_file_exist (const char *path)
|
||||
{
|
||||
const char *new_path = path;
|
||||
if (xy_str_start_with (path, "~"))
|
||||
{
|
||||
new_path = xy_2strjoin (xy_os_home, path + 1);
|
||||
}
|
||||
// 0 即 F_OK
|
||||
return (0==access (new_path, 0)) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note xy_file_exist() 和 xy_dir_exist() 两个函数在所有平台默认都支持使用 '~',
|
||||
* 但实现中都没有调用 xy_uniform_path(),以防万一,调用前可能需要用户手动调用它
|
||||
*/
|
||||
static bool
|
||||
xy_dir_exist (const char *path)
|
||||
{
|
||||
const char *dir = path;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
if (xy_str_start_with (path, "~"))
|
||||
{
|
||||
dir = xy_2strjoin (xy_os_home, path + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (xy_on_windows)
|
||||
{
|
||||
#ifdef XY_On_Windows
|
||||
// 也可以用 opendir() #include <dirent.h>
|
||||
DWORD attr = GetFileAttributesA (dir);
|
||||
|
||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
// Q: 我们应该报错吗?
|
||||
return false;
|
||||
}
|
||||
else if (attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
int status = system (xy_2strjoin ("test -d ", dir));
|
||||
|
||||
if (0==status)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 该函数即使在非Windows下也可调用,作用是删除路径左右两边多出来的空白符
|
||||
*/
|
||||
static char *
|
||||
xy_uniform_path (const char *path)
|
||||
{
|
||||
char *new = xy_str_strip (path); // 防止开发者多写了空白符
|
||||
|
||||
// 这个函数仅在Windows上才进行替换
|
||||
if (xy_on_windows)
|
||||
{
|
||||
if (xy_str_start_with (new, "~/"))
|
||||
{
|
||||
// 或 %USERPROFILE%
|
||||
new = xy_strjoin (3, xy_os_home, "\\",
|
||||
xy_str_delete_prefix (new, "~/"));
|
||||
}
|
||||
new = xy_str_gsub (new, "/", "\\");
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static char *
|
||||
xy_parent_dir (const char *path)
|
||||
{
|
||||
char *dir = xy_uniform_path (path);
|
||||
char *last = NULL;
|
||||
if (xy_on_windows)
|
||||
{
|
||||
last = strrchr (dir, '\\');
|
||||
*last = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
last = strrchr (dir, '/');
|
||||
*last = '\0';
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
#!/usr/bin/env just --justfile
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# Build File : justfile
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
# |
|
||||
# Created On : <2025-06-18>
|
||||
# Last Modified : <2025-10-15>
|
||||
#
|
||||
# 该文件主要用于在原生Windows上执行项目的基本任务,而不借助于
|
||||
# GNU make 以及相应的 MSYS2、Cygwin 环境
|
||||
# --------------------------------------------------------------
|
||||
# just (build) -> chsrc.exe
|
||||
# just bd (build-in-debug-mode) -> chsrc-debug.exe
|
||||
# just br (build-in-release-mode) -> chsrc-release.exe
|
||||
# just debug
|
||||
# just test
|
||||
# just clean
|
||||
#
|
||||
# just STATIC=1 br 静态链接 (注意只能在 br 任务中使用)
|
||||
#
|
||||
# 不支持 just DEBUG=1,请直接使用 just bd (等价于 just build-in-debug-mode)
|
||||
#
|
||||
# --------------------------------------------------------------
|
||||
# 注意,由于我们要在 GitHub Actions 上编译 x32 版的 chsrc,所以需要使用 make,
|
||||
# 而不清楚 just 在 MINGW32 中的情况,所以我们在此 justfile 中并不实现关于 CI 的功能
|
||||
# --------------------------------------------------------------
|
||||
|
||||
set windows-shell := ['cmd', '/c']
|
||||
|
||||
CC := if os() == 'windows' {
|
||||
"gcc"
|
||||
} else if os() == 'macos' {
|
||||
"clang"
|
||||
} else {
|
||||
"cc"
|
||||
}
|
||||
|
||||
DEBUGGER := if os() == 'windows' {
|
||||
"gdb"
|
||||
} else if os() == 'macos' {
|
||||
"lldb"
|
||||
} else {
|
||||
"gdb"
|
||||
}
|
||||
|
||||
CFLAGS_chk_Clang := if os() == 'windows' {
|
||||
if CC == 'clang' {
|
||||
'-target x86_64-pc-windows-gnu'
|
||||
} else {''}
|
||||
} else {''}
|
||||
|
||||
|
||||
CFLAGS_base := '-Iinclude -Ilib ' + CFLAGS_chk_Clang
|
||||
|
||||
WARN := '-Wall -Wextra -Wno-unused-variable -Wno-unused-function -Wno-missing-braces -Wno-misleading-indentation' + ' ' + \
|
||||
'-Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare'
|
||||
CFLAGS_warn := WARN
|
||||
|
||||
|
||||
CFLAGS_debug := '-g -DXY_DEBUG'
|
||||
|
||||
DevMode-Target-Name := 'chsrc'
|
||||
DebugMode-Target-Name := 'chsrc-debug'
|
||||
ReleaseMode-Target-Name := 'chsrc-release'
|
||||
|
||||
STATIC := '0'
|
||||
|
||||
CFLAGS_static := "-static"
|
||||
|
||||
CFLAGS_chk_static := if STATIC == '1' {
|
||||
CFLAGS_static
|
||||
} else { "" }
|
||||
|
||||
|
||||
CFLAGS_optimization := "-O2"
|
||||
|
||||
|
||||
CFLAGS_dev_mode_prompt := CFLAGS_base
|
||||
CFLAGS_debug_mode_prompt := CFLAGS_base + ' ' + CFLAGS_debug
|
||||
CFLAGS_release_mode_prompt := CFLAGS_base + ' ' + CFLAGS_optimization + ' ' + CFLAGS_chk_static
|
||||
|
||||
CFLAGS_dev_mode := CFLAGS_dev_mode_prompt + ' ' + CFLAGS_warn
|
||||
CFLAGS_debug_mode := CFLAGS_debug_mode_prompt + ' ' + CFLAGS_warn
|
||||
CFLAGS_release_mode := CFLAGS_release_mode_prompt + ' ' + CFLAGS_warn
|
||||
|
||||
#=======================
|
||||
|
||||
BIN_xy := if os() == 'windows' {'xy.exe'} else {'./xy'}
|
||||
BIN_fw := if os() == 'windows' {'fw.exe'} else {'./fw'}
|
||||
BIN_rm := if os() == 'windows' {'del'} else {'rm'}
|
||||
#=======================
|
||||
alias b := build-in-dev-mode
|
||||
alias bd:= build-in-debug-mode
|
||||
alias br:= build-in-release-mode
|
||||
alias build:=build-in-dev-mode
|
||||
alias d := debug
|
||||
alias t := test
|
||||
alias check := test
|
||||
alias c := clean
|
||||
|
||||
default: build-in-dev-mode
|
||||
|
||||
build-in-dev-mode:
|
||||
@echo Starting: Build in DEV mode: '{{CC}}' {{CFLAGS_dev_mode_prompt}} -o {{DevMode-Target-Name}}
|
||||
@{{CC}} src/chsrc-main.c {{CFLAGS_dev_mode}} -o {{DevMode-Target-Name}}
|
||||
@echo Finished: Build in DEV mode
|
||||
|
||||
build-in-debug-mode:
|
||||
@echo Starting: Build in DEBUG mode: '{{CC}}' {{CFLAGS_debug_mode_prompt}} -o {{DebugMode-Target-Name}}
|
||||
@{{CC}} src/chsrc-main.c {{CFLAGS_debug_mode}} -o {{DebugMode-Target-Name}}
|
||||
@echo Finished: Build in DEBUG mode
|
||||
|
||||
build-in-release-mode:
|
||||
@echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}}
|
||||
@{{ if os() == 'windows' { \
|
||||
'(if exist chsrc.res del chsrc.res)' + \
|
||||
' & windres src/resource/chsrc.rc -O coff -o chsrc.res' \
|
||||
} else { '' } }}
|
||||
@{{ if os() == 'windows' { \
|
||||
CC + ' src/chsrc-main.c chsrc.res ' + CFLAGS_release_mode + ' -o ' + ReleaseMode-Target-Name \
|
||||
} else { \
|
||||
CC + ' src/chsrc-main.c ' + CFLAGS_release_mode + ' -o ' + ReleaseMode-Target-Name \
|
||||
} }}
|
||||
@echo Finished: Build in RELEASE mode
|
||||
|
||||
debug: build-in-debug-mode
|
||||
@{{DEBUGGER}} {{DebugMode-Target-Name}}
|
||||
|
||||
test: test-xy test-fw
|
||||
|
||||
# 这两个测试文件都用 DEBUG mode
|
||||
test-xy:
|
||||
@{{CC}} test/xy.c {{CFLAGS_debug_mode}} -o xy
|
||||
@{{BIN_xy}}
|
||||
|
||||
test-fw:
|
||||
@{{CC}} test/fw.c {{CFLAGS_debug_mode}} -o fw
|
||||
@{{BIN_fw}}
|
||||
|
||||
fastcheck:
|
||||
@perl ./test/cli.pl fastcheck
|
||||
|
||||
test-cli:
|
||||
@perl ./test/cli.pl
|
||||
|
||||
clean:
|
||||
-@{{BIN_rm}} *.exe
|
||||
-@{{BIN_rm}} *.res
|
||||
-@{{BIN_rm}} xy
|
||||
-@{{BIN_rm}} fw
|
||||
-@{{BIN_rm}} chsrc
|
||||
-@{{BIN_rm}} chsrc-debug
|
||||
-@{{BIN_rm}} chsrc-release
|
||||
-@{{BIN_rm}} README.md.bak*
|
||||
|
||||
# 使用: just rawstr4c [--debug] Markdown.md
|
||||
# rawstr4c *args:
|
||||
# @{{ if os() == 'windows' { 'tool\\rawstr4c\\run\\run.bat' } else { 'bash ./tool/rawstr4c/run/run.sh' } }} {{args}}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
# ---------------------------------------------------------------
|
||||
# Lefthook File : lefthook.yml
|
||||
# File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nul None <nul@none.org>
|
||||
# |
|
||||
# Created On : <2025-10-28>
|
||||
# Last Modified : <2025-10-30>
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
min_version: 2.0.1
|
||||
|
||||
pre-commit:
|
||||
only:
|
||||
- ref: dev
|
||||
parallel: false
|
||||
jobs:
|
||||
- name: 试运行 DEBUG mode
|
||||
# 触发所有 _prelude() 函数检查
|
||||
run: |
|
||||
just build-in-debug-mode
|
||||
./chsrc-debug get pip
|
||||
glob: "*.{c,h}"
|
||||
exclude: test/*
|
||||
|
||||
- name: 测试 xy.h
|
||||
run: just test-xy
|
||||
glob:
|
||||
- lib/xy.h
|
||||
- test/xy.c
|
||||
|
||||
- name: 测试 framework
|
||||
run: just test-fw
|
||||
glob:
|
||||
- "src/framework/*.{c,h}"
|
||||
- src/chsrc-main.c
|
||||
- test/fw.c
|
||||
|
||||
post-merge:
|
||||
only:
|
||||
- ref: main
|
||||
jobs:
|
||||
- name: 测试编译 DEV mode
|
||||
run: just build-in-dev-mode
|
||||
|
||||
pre-push:
|
||||
only:
|
||||
- ref: gh-build
|
||||
jobs:
|
||||
- name: 测试编译 RELEASE mode
|
||||
run: just build-in-release-mode
|
||||
|
||||
- name: 测试运行
|
||||
run: just test-cli
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : README.md
|
||||
! Doc Authors : 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nil Null <nil@null.org>
|
||||
! |
|
||||
! Created On : <2025-06-15>
|
||||
! Last Modified : <2025-06-16>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# AUR package
|
||||
|
||||
本文档说明了 `chsrc` 项目的 AUR 包的相关情况
|
||||
|
||||
<br>
|
||||
|
||||
## 相关文件
|
||||
|
||||
CI 维护者 [@Jerry-Terrasse](https://github.com/Jerry-Terrasse)
|
||||
|
||||
- [.github/workflows/pub-AUR-chsrc-git.yml](../../.github/workflows/pub-AUR-chsrc-git.yml)
|
||||
- [.github/workflows/pub-AUR-chsrc-and-chsrc-bin.yml`](../../.github/workflows/pub-AUR-chsrc-git.yml)
|
||||
|
||||
<br>
|
||||
|
||||
## 分发
|
||||
|
||||
位于 https://aur.archlinux.org/packages
|
||||
|
||||
- [chsrc-bin](https://aur.archlinux.org/packages/chsrc-bin): 从 GitHub Releases 直接下载的二进制文件
|
||||
|
||||
- [chsrc](https://aur.archlinux.org/packages/chsrc):从 GitHub Releases 的代码构建
|
||||
|
||||
- [chsrc-git](https://aur.archlinux.org/packages/chsrc-git):从最新源码构建的版本,偶尔可能不稳定
|
||||
|
|
@ -1,14 +1,56 @@
|
|||
# Packages
|
||||
|
||||
https://github.com/RubyMetric/chsrc/issues/16
|
||||
## 分发情况
|
||||
|
||||
- [x] `Homebrew`
|
||||
- [x] `scoop`
|
||||
- [ ] `AUR`
|
||||
- [x] `Scoop`
|
||||
- [x] `WinGet`
|
||||
- [x] `AUR`
|
||||
- [ ] `Flatpak`
|
||||
- [ ] `snap`
|
||||
- [ ] ...
|
||||
|
||||
<br>
|
||||
|
||||
```bash
|
||||
$ brew install chsrc
|
||||
|
||||
$ scoop install chsrc
|
||||
|
||||
$ winget install RubyMetric.chsrc
|
||||
|
||||
yay -S chsrc-bin # Binary from GitHub Release
|
||||
yay -S chsrc # Build from GitHub Release
|
||||
yay -S chsrc-git # Build from the latest main branch (stable)
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
- Homebrew
|
||||
|
||||
https://github.com/Homebrew/homebrew-core/blob/master/Formula/c/chsrc.rb
|
||||
|
||||
- Scoop
|
||||
|
||||
https://github.com/ScoopInstaller/Main/blob/master/bucket/chsrc.json
|
||||
|
||||
- WinGet
|
||||
|
||||
https://github.com/microsoft/winget-pkgs/tree/master/manifests/r/RubyMetric/chsrc
|
||||
|
||||
- AUR:
|
||||
|
||||
- https://aur.archlinux.org/packages/chsrc-bin
|
||||
|
||||
- https://aur.archlinux.org/packages/chsrc
|
||||
|
||||
- https://aur.archlinux.org/packages/chsrc-git
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## 打包情况
|
||||
|
||||
- [x] `deb`
|
||||
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,126 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : BUILD.md
|
||||
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
! Contributors : 曾奥然 <ccmywish@qq.com>
|
||||
! |
|
||||
! Created On : <2025-06-14>
|
||||
! Last Modified : <2025-06-16>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# 构建 deb package
|
||||
|
||||
## 准备
|
||||
|
||||
安装构建所需的依赖:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential debhelper devscripts fakeroot
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## 构建
|
||||
|
||||
```bash
|
||||
git clone https://github.com/RubyMetric/chsrc.git
|
||||
cd chsrc
|
||||
|
||||
# 进入 deb 目录
|
||||
cd pkg/deb
|
||||
|
||||
# 执行构建命令
|
||||
./Makefile deb-make
|
||||
```
|
||||
|
||||
### 调试构建
|
||||
|
||||
```bash
|
||||
# 启用详细输出
|
||||
DEB_BUILD_OPTIONS="nocheck" debuild -us -uc -b
|
||||
|
||||
# 检查构建日志
|
||||
less ../chsrc_*.build
|
||||
|
||||
# 检查包内容
|
||||
dpkg --contents ../chsrc_*.deb
|
||||
# 或
|
||||
dpkg-deb --contents ../chsrc_*.deb
|
||||
```
|
||||
|
||||
### 交叉编译
|
||||
|
||||
为不同架构进行构建:
|
||||
|
||||
```bash
|
||||
# For ARM64
|
||||
CC=aarch64-linux-gnu-gcc dpkg-buildpackage -us -uc -b -aarm64
|
||||
|
||||
# For ARMv7 (armhf)
|
||||
CC=arm-linux-gnueabihf-gcc dpkg-buildpackage -us -uc -b -aarmhf
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### 安装
|
||||
|
||||
```bash
|
||||
sudo dpkg -i ../chsrc_*.deb
|
||||
sudo apt-get install -f # 修复依赖问题
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### 测试安装情况
|
||||
|
||||
```bash
|
||||
# 运行测试
|
||||
bash ./deb-installation-test.sh
|
||||
|
||||
# 查看文档安装情况
|
||||
man chsrc
|
||||
|
||||
# 查看 deb 包的 copyright
|
||||
cat /usr/share/doc/chsrc/copyright
|
||||
|
||||
# 查看 deb 包 changelog
|
||||
zless /usr/share/doc/chsrc/changelog.Debian.gz
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### 清理构建产物
|
||||
|
||||
```bash
|
||||
./Makefile deb-clean
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## 卸载
|
||||
|
||||
```bash
|
||||
sudo apt-get remove chsrc
|
||||
```
|
||||
|
||||
包括删除配置在内的完全删除:
|
||||
|
||||
```bash
|
||||
sudo apt-get purge chsrc
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## 故障排查
|
||||
|
||||
常见问题:
|
||||
|
||||
1. **构建失败**: 检查 debian/control 中的依赖是否正确
|
||||
2. **交叉编译失败**: 确认目标架构的工具链已正确安装
|
||||
3. **安装测试失败**: 检查 postinst 脚本是否有错误
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : CI.md
|
||||
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
! Contributors : 曾奥然 <ccmywish@qq.com>
|
||||
! |
|
||||
! Created On : <2025-06-14>
|
||||
! Last Modified : <2025-06-16>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# deb package CI/CD
|
||||
|
||||
本文档说明了 chsrc 项目的 deb 包自动构建和发布流程。
|
||||
|
||||
## CI 文件
|
||||
|
||||
CI 维护者 [@sanchuanhehe](https://github.com/sanchuanhehe)
|
||||
|
||||
- [.github/workflows/pkg-deb.yml](../../.github/workflows/pkg-deb.yml)
|
||||
|
||||
<br>
|
||||
|
||||
## 支持的架构
|
||||
|
||||
当前支持以下架构的 deb 包构建:
|
||||
|
||||
- `amd64` (x86_64)
|
||||
|
||||
<br>
|
||||
|
||||
## CI 构建产物
|
||||
|
||||
每次 CI 构建会生成:
|
||||
|
||||
1. **deb 包文件**: `chsrc_<version>-1_<arch>.deb`
|
||||
2. **仓库元数据**: `Packages` 和 `Packages.gz` 文件用于创建 APT 仓库
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## 自动触发
|
||||
|
||||
deb 包构建 CI 会在以下情况下自动触发:
|
||||
|
||||
1. **Push 事件**:当 push 到 `gh-build` 分支时自动构建,并上传 deb 包 到 `pre` 这个特定的 release 中
|
||||
2. **Release 事件**: 当创建新的 release 时自动构建,并上传 deb 包到最新的这个 release 中
|
||||
2. **手动触发**: 可以在 GitHub Actions 页面手动触发构建
|
||||
|
||||
<br>
|
||||
|
||||
## 手动发布流程
|
||||
|
||||
1. 确保所有代码已合并到主分支
|
||||
2. 更新版本号和 changelog
|
||||
3. 创建并推送 git tag: `git tag v1.2.3 && git push origin v1.2.3`
|
||||
4. 在 GitHub 上创建 release
|
||||
5. CI 将自动构建并上传 deb 包
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/make -f
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# Build File : Makefile
|
||||
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
# Contributors : 曾奥然 <ccmywish@qq.com>
|
||||
# |
|
||||
# Created On : <2025-06-14>
|
||||
# Last Modified : <2025-06-16>
|
||||
#
|
||||
# deb package targets
|
||||
#
|
||||
# @issue https://github.com/RubyMetric/chsrc/pull/206
|
||||
# 这些本是 debhelper 兼容性版本 (debian/compat) 为 9 时所需要定义的 targets
|
||||
# 然而现在已经为版本 13 (debian/compat已移除),不再需要这些 targets,仅出于
|
||||
# 实用目的保留。由于以上原因,也不要修改这些 targets 的名称。
|
||||
# --------------------------------------------------------------
|
||||
|
||||
all: deb-build
|
||||
|
||||
deb-prepare:
|
||||
@echo "Starting: Prepare for building deb package"
|
||||
@echo "Finished: Prepare for building deb package"
|
||||
|
||||
deb-build: deb-prepare
|
||||
@echo "Starting: Build deb package"
|
||||
@debuild -us -uc -b
|
||||
@echo "Finished: Build deb package"
|
||||
|
||||
deb-clean:
|
||||
@echo "Starting: Clean deb build artifacts"
|
||||
-@rm -rf debian/chsrc/
|
||||
-@rm -f ../chsrc_*.deb ../chsrc-dbgsym_*.ddeb ../chsrc_*.changes ../chsrc_*.buildinfo ../chsrc_*.build
|
||||
@echo "Finished: Clean deb build artifacts"
|
||||
|
||||
.PHONY: deb-prepare deb-build deb-clean
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GFDL-1.3-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Doc Type : Markdown
|
||||
! Doc Name : README.md
|
||||
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
! | 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nil Null <nil@null.org>
|
||||
! |
|
||||
! Created On : <2025-06-14>
|
||||
! Last Modified : <2025-06-16>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# deb package
|
||||
|
||||
本文档说明了 `chsrc` 项目的 deb 包的相关情况
|
||||
|
||||
<br>
|
||||
|
||||
## 相关文件
|
||||
|
||||
- `.github/workflows/pkg-deb.yml` - CI 配置文件
|
||||
- `./CI.md` - CI 情况说明
|
||||
|
||||
<wbr>
|
||||
|
||||
- `./debian/` - deb 包构建配置目录
|
||||
- `./BUILD.md` - 如何手动构建
|
||||
- `./Makefile` - deb 包构建 Makefile
|
||||
- `./deb-installation-test.sh` - deb 包 **已正确安装** 测试脚本
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## 安装
|
||||
|
||||
如果你是普通用户,你应该从 [GitHub Releases](https://github.com/RubyMetric/chsrc/releases) 下载合适的 deb 包,然后运行以下命令安装:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i chsrc_*.deb
|
||||
sudo apt-get install -f # Fix any dependency issues
|
||||
```
|
||||
|
||||
如果你是高级用户,你可以自己阅读本目录下的 [./BUILD.md](./BUILD.md) 来自己构建 deb 包并按照上述同样的方式安装。
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## `debian/` 目录结构
|
||||
|
||||
```
|
||||
debian/
|
||||
├── changelog # 版本更新日志
|
||||
├── compat # debhelper 兼容性版本
|
||||
├── control # 包控制信息和依赖
|
||||
├── copyright # 版权信息
|
||||
├── postinst # 安装后脚本
|
||||
├── prerm # 卸载前脚本
|
||||
└── rules # 构建规则
|
||||
```
|
||||
|
||||
其中,最后三个是 `+x` 的可执行文件。
|
||||
|
||||
<br>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# Test File : deb-installation-test.sh
|
||||
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
# Contributors : 曾奥然 <ccmywish@qq.com>
|
||||
# |
|
||||
# Created On : <2025-06-14>
|
||||
# Last Modified : <2025-06-16>
|
||||
#
|
||||
# Test script for deb package installation
|
||||
# --------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
|
||||
echo "Testing installation of deb package 'chsrc' ..."
|
||||
|
||||
# Test 1: Check if chsrc binary exists and is executable
|
||||
if [ ! -f "/usr/bin/chsrc" ]; then
|
||||
echo "ERROR: /usr/bin/chsrc not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "/usr/bin/chsrc" ]; then
|
||||
echo "ERROR: /usr/bin/chsrc is not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ /usr/bin/chsrc binary exists and is executable"
|
||||
|
||||
# Test 2: Check if man page exists
|
||||
if [ ! -f "/usr/share/man/man1/chsrc.1" ]; then
|
||||
echo "WARNING: chsrc man page not found at /usr/share/man/man1/chsrc.1"
|
||||
else
|
||||
echo "✓ chsrc man page exists"
|
||||
fi
|
||||
|
||||
# Test 3: Test basic functionality
|
||||
echo "Testing basic chsrc functionality..."
|
||||
if /usr/bin/chsrc help >/dev/null 2>&1; then
|
||||
echo "✓ command 'chsrc help' works"
|
||||
else
|
||||
echo "ERROR: command 'chsrc help' failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if /usr/bin/chsrc list >/dev/null 2>&1; then
|
||||
echo "✓ command 'chsrc list' works"
|
||||
else
|
||||
echo "ERROR: command 'chsrc list' failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All installation tests of deb package 'chsrc' passed!"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
chsrc (0.2.3-1) unstable; urgency=medium
|
||||
|
||||
* v0.2.3 已发布
|
||||
|
||||
-- 曾奥然 <ccmywish@qq.com> Wed, 29 Oct 2025 11:29:05 +0800
|
||||
|
||||
|
||||
chsrc (0.1.9-1) unstable; urgency=medium
|
||||
|
||||
* v0.1.9 已发布
|
||||
|
||||
-- 曾奥然 <ccmywish@qq.com> Sun, 15 Jun 2025 13:32:50 +0800
|
||||
|
||||
|
||||
chsrc (0.0.1-1) unstable; urgency=medium
|
||||
|
||||
* 首个 deb 包已完成!
|
||||
|
||||
-- sanchuanhehe <wyihe5520@gmail.com> Mon, 10 Jun 2025 00:00:00 +0000
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
Source: chsrc
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: sanchuanhehe <wyihe5520@gmail.com>
|
||||
Build-Depends: debhelper-compat (= 13), build-essential, libc6-dev
|
||||
Standards-Version: 4.6.0
|
||||
Homepage: https://chsrc.run/
|
||||
Vcs-Git: https://github.com/RubyMetric/chsrc.git
|
||||
Vcs-Browser: https://github.com/RubyMetric/chsrc
|
||||
|
||||
Package: chsrc
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: Change Source - A tool for changing software sources
|
||||
chsrc is a command-line tool for changing software sources (mirrors)
|
||||
for various package managers and programming language ecosystems.
|
||||
It supports automatic detection and switching of sources for better
|
||||
download speeds in different regions.
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: chsrc
|
||||
Upstream-Contact: 曾奥然 <ccmywish@qq.com>
|
||||
Source: https://github.com/RubyMetric/chsrc
|
||||
|
||||
Files: *
|
||||
Copyright: 2023-2025 曾奥然 <ccmywish@qq.com>
|
||||
2023-2025 郭恒 <2085471348@qq.com>
|
||||
License: GPL-3+
|
||||
Comment: The authors' names are indicated in each source code file's header.
|
||||
|
||||
Files: lib/xy.h
|
||||
Copyright: 2023-2025 曾奥然 <ccmywish@qq.com>
|
||||
2023-2025 郭恒 <2085471348@qq.com>
|
||||
License: MIT
|
||||
|
||||
Files: pkg/deb/debian/*
|
||||
Copyright: 2025 sanchuanhehe <wyihe5520@gmail.com>
|
||||
License: GPL-3+
|
||||
|
||||
License: GPL-3+
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
|
||||
Comment:
|
||||
On Debian systems, the full text of the GNU General Public License
|
||||
version 3 can be found in the file '/usr/share/common-licenses/GPL-3'.
|
||||
|
||||
License: MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023-2025 曾奥然 (Aoran Zeng), 郭恒 (Heng Guo)
|
||||
|
||||
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 (including the next paragraph) 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.
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# deb File : postinst
|
||||
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
# Contributors : Nil Null <nil@null.org>
|
||||
# |
|
||||
# Created On : <2025-06-14>
|
||||
# Last Modified : <2025-06-16>
|
||||
#
|
||||
# postinst script for chsrc
|
||||
# --------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
# Update man database
|
||||
if command -v mandb >/dev/null 2>&1; then
|
||||
mandb -q /usr/share/man/man1/chsrc.1 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Make sure chsrc is executable
|
||||
chmod +x /usr/bin/chsrc
|
||||
|
||||
echo "chsrc has been successfully installed!"
|
||||
echo "Run 'chsrc help' to get started."
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# deb File : prerm
|
||||
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
# Contributors : Nil Null <nil@null.org>
|
||||
# |
|
||||
# Created On : <2025-06-14>
|
||||
# Last Modified : <2025-06-16>
|
||||
#
|
||||
# prerm script for chsrc
|
||||
# --------------------------------------------------------------
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
remove|upgrade|deconfigure)
|
||||
# Nothing special to do during removal
|
||||
;;
|
||||
|
||||
failed-upgrade)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "prerm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/make -f
|
||||
# --------------------------------------------------------------
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# --------------------------------------------------------------
|
||||
# Build File : rules
|
||||
# File Authors : sanchuanhehe <wyihe5520@gmail.com>
|
||||
# | 曾奥然 <ccmywish@qq.com>
|
||||
# Contributors : Nil Null <nil@null.org>
|
||||
# |
|
||||
# Created On : <2025-06-14>
|
||||
# Last Modified : <2025-06-20>
|
||||
#
|
||||
# 该文件是 Makefile 格式
|
||||
# --------------------------------------------------------------
|
||||
#
|
||||
# debuild 调用 dpkg-buildpackage
|
||||
#
|
||||
# dpkg-buildpackage 通过调用 fakeroot debian/rules <target> 执行本文件
|
||||
#
|
||||
# 由于下面的 %,所有任务都将被传递给 dh
|
||||
#
|
||||
# 比如:
|
||||
#
|
||||
# debian/rules <target>
|
||||
#
|
||||
# 会转换为:
|
||||
#
|
||||
# dh <target>
|
||||
#
|
||||
# 来执行
|
||||
#
|
||||
# 简单理解,将顺序调用:
|
||||
# 1. dh clean
|
||||
# 2. dh build (debian/rules override_dh_auto_build)
|
||||
# 3. dh binary (debian/rules override_dh_auto_install)
|
||||
# --------------------------------------------------------------
|
||||
|
||||
# 由于 debuild 要寻找 debian/ 目录,因此当前工作目录一定在 pkg/deb 下
|
||||
Chsrc-Root-Dir = $(CURDIR)/../../
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
# 切换到 chsrc 根目录
|
||||
@$(MAKE) -C $(Chsrc-Root-Dir) build-in-release-mode
|
||||
|
||||
override_dh_auto_install:
|
||||
@$(MAKE) -C $(Chsrc-Root-Dir) install DESTDIR=$(CURDIR)/debian/chsrc
|
||||
|
|
@ -0,0 +1,984 @@
|
|||
/** ------------------------------------------------------------
|
||||
* Copyright © 2023-2025 曾奥然, 郭恒
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
* chsrc: Change Source
|
||||
*
|
||||
* 全平台通用换源工具与框架
|
||||
*
|
||||
* Change Source everywhere for every software
|
||||
*
|
||||
* 项目创建者: 曾奥然, 郭恒
|
||||
* -------------------------------------------------------------
|
||||
*
|
||||
* 这是一个高度依靠贡献者的项目,我们直接把每一位贡献者写进了代码
|
||||
* 里,这是比 Git commit message 更加稳定的方式。但我们不满足于仅
|
||||
* 把大家写在注释里,因为C语言在编译时会无情地把这些信息抹去。
|
||||
*
|
||||
* 所以,我们让每一位贡献者直接参与运行时!
|
||||
*
|
||||
* 想象一下,每一位贡献者都化作一串比特,穿梭于全国各地的桌面PC中,
|
||||
* 流淌在数据中心的机房,分身在手机、路由器、小型嵌入式设备中...
|
||||
* 每当 chsrc 执行一次 recipe 相关的操作,这些比特便会复苏,贡献者
|
||||
* 的信息随之浮现。它提醒着使用者:在你与开源世界的每一次交互背后,
|
||||
* 都是许多人的协作,跨越省份与疆域,以代码相连。
|
||||
*
|
||||
* 我们希望营造像 Richard Stallman 在创建 GNU 项目之前,在 MIT 时
|
||||
* 那样的氛围 —— 写自己用得上的软件,与大家一起开发、维护,简单纯
|
||||
* 粹,无关商业利益。就像小区、校园自发组建的足球篮球队,从一次偶
|
||||
* 然的加入,逐渐成长为互相支持的伙伴。
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc"
|
||||
#define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc"
|
||||
|
||||
#include "framework/version.h"
|
||||
#include "framework/core.c"
|
||||
#include "framework/chef.c"
|
||||
|
||||
void
|
||||
chsrc_register_contributors ()
|
||||
{
|
||||
/* 项目创建者 */
|
||||
chef_register_contributor ("@ccmywish", "曾奥然", "ccmywish@qq.com", NULL);
|
||||
// 该 ID 为 Gitee ID
|
||||
chef_register_contributor ("@G_I_Y", "郭恒", "2085471348@qq.com", NULL);
|
||||
|
||||
/* 所有贡献者 (按参与贡献时间排序) */
|
||||
chef_register_contributor ("@Aaron-212", "Aaron Ruan", "aaron212cn@outlook.com", NULL);
|
||||
chef_register_contributor ("@chenrui333", "Rui Chen", "rui@chenrui.dev", NULL);
|
||||
chef_register_contributor ("@livelycode36", "Shengwei Chen", "414685209@qq.com", NULL);
|
||||
chef_register_contributor ("@Gn3po4g", "Peng Gao", "gn3po4g@outlook.com", NULL);
|
||||
chef_register_contributor ("@BlockLune", "BlockLune", "blocklune@gmail.com", NULL);
|
||||
chef_register_contributor ("@MrWillCom", "Mr. Will", "mr.will.com@outlook.com", NULL);
|
||||
chef_register_contributor ("@Jerry-Terrasse", "Terrasse", "terrasse@qq.com", NULL);
|
||||
chef_register_contributor ("@lontten", "Lontten", "lontten@163.com", NULL);
|
||||
chef_register_contributor ("@happy-game", "Happy Game", "happygame1024@gmail.com", NULL);
|
||||
chef_register_contributor ("@Word2VecT", "Word2VecT", "tangzinan@bupt.edu.cn", NULL);
|
||||
chef_register_contributor ("@wickdynex", "Xuan", "wick.dynex@qq.com", NULL);
|
||||
chef_register_contributor ("@Efterklang", "GnixAij", "gaojiaxing0220@gmail.com", NULL);
|
||||
chef_register_contributor ("@czyt", "czyt", "czyt.go@gmail.com", NULL);
|
||||
chef_register_contributor ("@XUANJI233", "XUANJI233", "xuanji233@outlook.com", NULL);
|
||||
chef_register_contributor ("@Yangmoooo", "Yangmoooo", "yangmoooo@outlook.com", NULL);
|
||||
chef_register_contributor ("@zouri", "Zouri", "guoshuaisun@outlook.com", NULL);
|
||||
chef_register_contributor ("@xyx1926885268", "Yongxiang", "1926885268@qq.com", NULL);
|
||||
chef_register_contributor ("@YU-7", "YU-7", "2747046473@qq.com", NULL);
|
||||
chef_register_contributor ("@juzeon", "juzeon", "skyjuzheng@gmail.com", NULL);
|
||||
chef_register_contributor ("@jialinlvcn", "Jialin Lyu", "jialinlvcn@aliyun.com", NULL);
|
||||
chef_register_contributor ("@Kattos", "ccy", "icuichengyi@gmail.com", NULL);
|
||||
chef_register_contributor ("@xrgzs", "MadDogOwner", "xiaoran@xrgzs.top", NULL);
|
||||
chef_register_contributor ("@sanchuanhehe", "sanchuanhehe", "wyihe5520@gmail.com", NULL);
|
||||
chef_register_contributor ("@Mikachu2333", "Mikachu2333", "mikachu.23333@zohomail.com", NULL);
|
||||
chef_register_contributor ("@techoc", "Rui Yang", "techoc@foxmail.com", NULL);
|
||||
chef_register_contributor ("@BingChunMoLi", "BingChunMoLi", "bingchunmoli@bingchunmoli.com", NULL);
|
||||
// 该 ID 为 Gitee ID
|
||||
chef_register_contributor ("@hezonglun", "HeZongLun", "hezonglun123456@outlook.com", NULL);
|
||||
chef_register_contributor ("@Young-Lord", "LY", "ly-niko@qq.com", NULL);
|
||||
|
||||
/**
|
||||
* AI贡献者:
|
||||
*
|
||||
* ChatGPT、GitHub Copilot、DeepSeek
|
||||
*
|
||||
* 这几位是贡献者显式说明的,也许还有隐式使用的一些AI并没有被记录下来,可以添加在这里
|
||||
*/
|
||||
}
|
||||
|
||||
#include "recipe/menu.c"
|
||||
|
||||
#include "rawstr4c.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
cli_print_available_mirrors ()
|
||||
{
|
||||
{
|
||||
char *msg = ENGLISH ? "To specify a source, use chsrc set " : "指定使用某源,请使用 chsrc set ";
|
||||
say (bdblue(xy_strcat (3, msg, "<target>", " <code>\n")));
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Available Mirror Sites: \n" : "可用镜像站: \n";
|
||||
say (bdgreen(msg));
|
||||
}
|
||||
|
||||
{
|
||||
char *msg1 = ENGLISH ? "Mirror abbr" : "镜像站简写";
|
||||
char *msg2 = ENGLISH ? "Mirror URL" : "镜像站URL";
|
||||
char *msg3 = ENGLISH ? "Mirror Name" : "镜像站";
|
||||
char *format = ENGLISH ? " %-13s%-28s%-35s%s\n" : " %-13s%-33s%-42s%s\n";
|
||||
printf (format, "code", msg1, msg2, msg3);
|
||||
say ("--------- -------------- ------------------------------------- ---------------------");
|
||||
}
|
||||
|
||||
for (int i = 0; i < xy_c_array_len (chsrc_available_mirrors); i++)
|
||||
{
|
||||
MirrorSite_t *mir = chsrc_available_mirrors[i];
|
||||
printf ("%-14s%-18s%-41s ", mir->code, mir->abbr, mir->site); say (mir->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 遍历以 / 为分隔符的别名字符串,对每个别名调用回调函数
|
||||
*
|
||||
* @param aliases 空格分隔的 alias 字符串
|
||||
* @param callback 对每个 alias 调用的回调函数
|
||||
* @param user_data 传递给回调函数的用户数据
|
||||
*
|
||||
* @return 如果回调函数返回true则停止遍历并返回true,否则返回false
|
||||
*/
|
||||
bool
|
||||
iterate_aliases (const char *aliases, bool (*callback)(const char *alias, void *user_data), void *user_data)
|
||||
{
|
||||
char *aliases_copy = xy_strdup (aliases);
|
||||
char *tok_start = aliases_copy;
|
||||
char *cursor;
|
||||
bool result = false;
|
||||
|
||||
while (*tok_start != '\0')
|
||||
{
|
||||
cursor = tok_start;
|
||||
while (*cursor != '/' && *cursor != '\0') cursor++;
|
||||
|
||||
// 结束当前token
|
||||
char space_or_eos = *cursor;
|
||||
*cursor = '\0';
|
||||
|
||||
// 调用回调函数
|
||||
if (callback(tok_start, user_data))
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
*cursor = space_or_eos;
|
||||
if (space_or_eos == '\0') { break; }
|
||||
tok_start = cursor+1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用于 cli_print_targets_for_menu 的回调函数,打印每个别名
|
||||
*/
|
||||
bool
|
||||
callback_print_alias (const char *alias, void *user_data)
|
||||
{
|
||||
printf ("%s ", alias);
|
||||
return false; // 继续遍历,不停止
|
||||
}
|
||||
|
||||
void
|
||||
callback_print_targets (void *data, void *DUMMY)
|
||||
{
|
||||
Target_t *target = (Target_t *) data;
|
||||
// 使用通用的别名遍历函数打印所有别名
|
||||
iterate_aliases (target->aliases, callback_print_alias, NULL);
|
||||
br(); // 每个target换行
|
||||
}
|
||||
|
||||
void
|
||||
cli_print_targets_for_menu (XySeq_t *menu)
|
||||
{
|
||||
xy_seq_each (menu, callback_print_targets, NULL);
|
||||
br(); // 最后额外换行
|
||||
}
|
||||
|
||||
void
|
||||
cli_print_supported_targets ()
|
||||
{
|
||||
{
|
||||
char *msg = ENGLISH ? "Support following targets (same line indicates these targets are compatible)"
|
||||
: "支持对以下目标换源 (同一行表示这几个命令兼容)" ;
|
||||
say (bdblue(msg)); br();
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Programming Languages" : "编程语言";
|
||||
say (bdgreen(msg));
|
||||
say ("-------------------------");
|
||||
cli_print_targets_for_menu (ProgStore.pl);
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Operating Systems" : "操作系统";
|
||||
say (bdgreen(msg));
|
||||
say ("-------------------------");
|
||||
cli_print_targets_for_menu (ProgStore.os);
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Softwares" : "软件";
|
||||
say (bdgreen(msg));
|
||||
say ("-------------------------");
|
||||
cli_print_targets_for_menu (ProgStore.wr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cli_print_menu (char *menu)
|
||||
{
|
||||
if (xy_streql (menu, "pl"))
|
||||
{
|
||||
char *msg =
|
||||
ENGLISH ? "Support following Programming Languages (same line indicates these targets are compatible)\n"
|
||||
: "支持对以下编程语言生态换源 (同一行表示这几个目标兼容)\n";
|
||||
say (bdgreen(msg));
|
||||
cli_print_targets_for_menu (ProgStore.pl);
|
||||
}
|
||||
else if (xy_streql (menu, "os"))
|
||||
{
|
||||
char *msg =
|
||||
ENGLISH ? "Support following Operating Systems (same line indicates these targets are compatible)\n"
|
||||
: "支持对以下操作系统换源 (同一行表示这几个目标兼容)\n";
|
||||
say (bdgreen(msg));
|
||||
cli_print_targets_for_menu (ProgStore.os);
|
||||
}
|
||||
else if (xy_streql (menu, "wr"))
|
||||
{
|
||||
char *msg =
|
||||
ENGLISH ? "Support following Softwares (same line indicates these targets are compatible)\n"
|
||||
: "支持对以下软件换源 (同一行表示这几个目标兼容)\n";
|
||||
say (bdgreen(msg));
|
||||
cli_print_targets_for_menu (ProgStore.wr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用于 chsrc list <target>
|
||||
*/
|
||||
void
|
||||
cli_print_target_available_sources (Source_t sources[], size_t size)
|
||||
{
|
||||
for (int i=0;i<size;i++)
|
||||
{
|
||||
Source_t src = sources[i];
|
||||
const MirrorSite_t *mir = src.mirror;
|
||||
if (NULL == src.url)
|
||||
{
|
||||
src.url = "Please help to add the upstream url!";
|
||||
}
|
||||
printf ("%-14s%-18s%-50s ", mir->code, mir->abbr, src.url);
|
||||
say (mir->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cli_print_target_features (Target_t *target, const char *input_target_name)
|
||||
{
|
||||
{
|
||||
char *msg = ENGLISH ? "\nAvailable Features:\n" : "\n可用功能:\n";
|
||||
say (bdgreen(msg));
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? " Get: View the current source state " : " Get: 查看当前源状态 ";
|
||||
char *get_msg = xy_strcat (3, msg, "| chsrc get ", input_target_name);
|
||||
if (target->getfn != NULL) printf (" %s%s\n", bdgreen(YesMark), purple(get_msg));
|
||||
else printf (" %s%s\n", bdred(NoMark), get_msg);br();
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? " Reset: Reset to the default source " : " Reset: 重置回默认源 ";
|
||||
char *reset_msg = xy_strcat (3, msg, "| chsrc reset ", input_target_name);
|
||||
if (target->resetfn != NULL) printf (" %s%s\n", bdgreen(YesMark), purple(reset_msg));
|
||||
else printf (" %s%s\n", bdred(NoMark), reset_msg);br();
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? " UserDefine: using user-defined source link " : " UserDefine: 用户自定义换源链接 ";
|
||||
char *user_define_msg = xy_strcat (5, msg, "| chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name);
|
||||
if (target->can_user_define) printf (" %s%s\n", bdgreen(YesMark), purple(user_define_msg));
|
||||
else printf (" %s%s\n", bdred(NoMark), user_define_msg);br();
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? " Locally: Change source only for this project " : " Locally: 仅对本项目换源 ";
|
||||
char *locally_msg = xy_strcat (3, msg, "| chsrc set -local ", input_target_name);
|
||||
|
||||
switch (target->cap_local)
|
||||
{
|
||||
case CanNot:
|
||||
printf (" %s%s\n", bdred(NoMark), locally_msg);br();
|
||||
break;
|
||||
case FullyCan:
|
||||
printf (" %s%s\n", bdgreen(YesMark), purple(locally_msg));br();
|
||||
break;
|
||||
case PartiallyCan:
|
||||
printf (" %s%s\n\n %s\n", bdgreen(HalfYesMark), purple(locally_msg),
|
||||
target->cap_local_explain ? target->cap_local_explain : "");br();
|
||||
break;
|
||||
default:
|
||||
xy_unreached();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? " English: Output in English " : " English: 英文输出 ";
|
||||
char *english_msg = xy_strcat (3, msg, "| chsrc set -en ", input_target_name);
|
||||
if (target->can_english) printf (" %s%s\n", bdgreen(YesMark), purple(english_msg));
|
||||
else printf (" %s%s\n", bdred(NoMark), english_msg);br();
|
||||
}
|
||||
|
||||
if (target->note)
|
||||
{
|
||||
char *msg = ENGLISH ? "NOTE: " : "备注: ";
|
||||
printf ("%s%s\n\n", bdyellow (msg), bdyellow (target->note));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 简略打印维护信息
|
||||
*
|
||||
* 用于 chsrc get/set/reset <target>
|
||||
*/
|
||||
void
|
||||
cli_print_target_maintain_info_briefly (Target_t *target, const char *input_target_name)
|
||||
{
|
||||
if (target->sources_last_updated)
|
||||
{
|
||||
char *msg = ENGLISH ? "Ingredient(Sources) Last Updated: " : "食源检查: ";
|
||||
printf ("%s%s ", msg, purple(target->sources_last_updated));
|
||||
}
|
||||
|
||||
if (target->last_updated)
|
||||
{
|
||||
char *msg = ENGLISH ? "Recipe Last Updated: " : "食谱更新: ";
|
||||
printf ("%s%s ", msg, purple(target->last_updated));
|
||||
}
|
||||
|
||||
char num[32]; sprintf(num, "%d", target->cooks_n + target->sauciers_n);
|
||||
char *msg = ENGLISH ? "Contributors: " : "后厨人数: ";
|
||||
printf ("%s%s ", msg, purple(num));
|
||||
|
||||
msg = ENGLISH ? xy_strcat (3, "(See chsrc ls ", input_target_name, ")")
|
||||
: xy_strcat (3, "(详查 chsrc ls ", input_target_name, ")");
|
||||
printf ("%s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 详细打印维护信息
|
||||
*
|
||||
* 用于 chsrc ls <target>
|
||||
*/
|
||||
void
|
||||
cli_print_target_maintain_info (Target_t *target, const char *input_target_name)
|
||||
{
|
||||
if (target->created_on)
|
||||
{
|
||||
char *msg = ENGLISH ? "Recipe Created On: " : "食谱创建: ";
|
||||
printf ("%s%s ", bdblue(msg), target->created_on);
|
||||
}
|
||||
|
||||
if (target->last_updated)
|
||||
{
|
||||
char *msg = ENGLISH ? "Recipe Last Updated: " : "食谱更新: ";
|
||||
printf ("%s%s ", bdblue(msg), target->last_updated);
|
||||
}
|
||||
|
||||
if (target->sources_last_updated)
|
||||
{
|
||||
char *msg = ENGLISH ? "Ingredient(Sources) Last Updated: " : "食源检查: ";
|
||||
printf ("%s%s\n", bdblue(msg), target->sources_last_updated);
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Current Chef: " : "品控: ";
|
||||
if (target->chef)
|
||||
{
|
||||
printf ("%s%s <%s>\n", bdblue(msg),
|
||||
target->chef->name ? target->chef->name : "Unknown",
|
||||
target->chef->email ? target->chef->email : "unknown@example.com");
|
||||
}
|
||||
else
|
||||
{
|
||||
char *msg1 = CHINESE ? "该 recipe 的负责人暂空缺, 欢迎担任" : "Vacant, Welcome to hold the position";
|
||||
printf ("%s%s\n", bdblue(msg), bdgreen(msg1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Cooks: " : "掌勺: ";
|
||||
if (target->cooks && target->cooks_n > 0)
|
||||
{
|
||||
printf ("%s", bdblue(msg));
|
||||
for (size_t i = 0; i < target->cooks_n; i++)
|
||||
{
|
||||
if (i > 0) printf (", ");
|
||||
printf ("%s <%s>",
|
||||
target->cooks[i]->name ? target->cooks[i]->name : "Unknown",
|
||||
target->cooks[i]->email ? target->cooks[i]->email : "unknown@example.com");
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
char *msg1 = CHINESE ? "暂空缺, 欢迎担任" : "Vacant, Welcome to hold the position";
|
||||
printf ("%s%s\n", bdblue(msg), bdgreen(msg1));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Sauciers: " : "调味: ";
|
||||
if (target->sauciers && target->sauciers_n > 0)
|
||||
{
|
||||
printf ("%s", bdblue(msg));
|
||||
for (size_t i = 0; i < target->sauciers_n; i++)
|
||||
{
|
||||
if (i > 0) printf (", ");
|
||||
printf ("%s <%s>", target->sauciers[i]->name, target->sauciers[i]->email );
|
||||
}
|
||||
br();
|
||||
}
|
||||
else
|
||||
{
|
||||
char *msg1 = CHINESE ? "暂空缺, 欢迎参与贡献" : "Vacant, Welcome to contribute!";
|
||||
printf ("%s%s\n", bdblue(msg), bdgreen(msg1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cli_print_version ()
|
||||
{
|
||||
char *version_string = "v" Chsrc_Version " (" Chsrc_Release_Date ")";
|
||||
|
||||
char *str = xy_str_gsub (CHINESE ? RAWSTR_chsrc_for_v_CHINESE : RAWSTR_chsrc_for_v_ENGLISH,
|
||||
"@ver@", version_string);
|
||||
println (str);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cli_print_help ()
|
||||
{
|
||||
char *version_string = "v" Chsrc_Version " (" Chsrc_Release_Date ")";
|
||||
|
||||
const char *raw = CHINESE ? RAWSTR_chsrc_USAGE_CHINESE : RAWSTR_chsrc_USAGE_ENGLISH;
|
||||
|
||||
char *str = xy_str_gsub (raw, "@ver@", version_string);
|
||||
println (str);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cli_print_issues ()
|
||||
{
|
||||
println (RAWSTR_chsrc_for_issue);
|
||||
|
||||
/*
|
||||
if (chsrc_check_program ("gh"))
|
||||
{
|
||||
char *cmd = xy_quiet_cmd ("gh browse --repo RubyMetric/chsrc");
|
||||
system (cmd);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 用于 callback_find_target() 的回调函数,检查别名是否匹配用户输入
|
||||
*/
|
||||
bool
|
||||
callback_match_alias (const char *alias, void *user_data)
|
||||
{
|
||||
const char *input = (const char *)user_data;
|
||||
return xy_streql_ic (input, alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 用于 iterate_menu() 的回调函数
|
||||
*/
|
||||
bool
|
||||
callback_is_one_of_target_aliases (void *data, void *input)
|
||||
{
|
||||
Target_t *target = (Target_t *) data;
|
||||
if (iterate_aliases (target->aliases, callback_match_alias, input))
|
||||
{
|
||||
target->preludefn();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户输入 `input` 是否与该 `menu` 中的某个 target 匹配
|
||||
* 若匹配将直接调用 prelude
|
||||
*
|
||||
* @param[in] menu menu
|
||||
* @param[in] input 用户输入的目标名
|
||||
* @param[out] target 返回匹配到的 Target_t 指针
|
||||
*
|
||||
* @return 匹配到则返回true,未匹配到则返回false
|
||||
*/
|
||||
bool
|
||||
iterate_menu (XySeq_t *menu, const char *input, Target_t **target)
|
||||
{
|
||||
Target_t *t = xy_seq_find (menu, callback_is_one_of_target_aliases, (void *) input);
|
||||
|
||||
if (t)
|
||||
{
|
||||
*target = t;
|
||||
t->preludefn();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*target = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
callback_perform_all_prelude_for_menu (void *data, void *DUMMY)
|
||||
{
|
||||
Target_t *target = (Target_t *) data;
|
||||
|
||||
if (!target->preludefn)
|
||||
{
|
||||
chef_debug_target (target);
|
||||
chsrc_panic ("未定义 _prelude() !");
|
||||
}
|
||||
|
||||
target->preludefn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 用于检查所有 _prelude() 是否能正常工作
|
||||
*
|
||||
* 为了防止 DEBUG 模式下运行流程和普通模式下运行流程不一样,我们只在 Get, Set, Reset
|
||||
* 之后才运行该函数
|
||||
*/
|
||||
void
|
||||
chsrc_perform_all_prelude ()
|
||||
{
|
||||
chsrc_debug ("prelude", "DEBUG模式下, 额外检查所有 _prelude() 是否能正常工作");
|
||||
xy_seq_each (ProgStore.pl, callback_perform_all_prelude_for_menu, NULL);
|
||||
xy_seq_each (ProgStore.os, callback_perform_all_prelude_for_menu, NULL);
|
||||
xy_seq_each (ProgStore.wr, callback_perform_all_prelude_for_menu, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 在必要的时期,最后告诉用户一些信息
|
||||
*/
|
||||
void
|
||||
chsrc_op_epilogue ()
|
||||
{
|
||||
br();
|
||||
chsrc_note2 (RAWSTR_chsrc_op_epilogue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
TargetOp_Get_Source = 1,
|
||||
TargetOp_Set_Source,
|
||||
TargetOp_Reset_Source,
|
||||
TargetOp_Measure_Source,
|
||||
TargetOp_List_Config
|
||||
} TargetOp;
|
||||
|
||||
/**
|
||||
* 寻找target,并根据 `code` 执行相应的操作
|
||||
*
|
||||
* @param input 用户输入的目标
|
||||
* @param code 对target要执行的操作
|
||||
* @param option 额外的指示,可为NULL
|
||||
*
|
||||
* @return 找到目标返回true,未找到返回false
|
||||
*/
|
||||
bool
|
||||
get_target (const char *input, TargetOp code, char *option)
|
||||
{
|
||||
chsrc_register_contributors ();
|
||||
|
||||
Target_t *target = NULL;
|
||||
|
||||
bool matched = iterate_menu (ProgStore.pl, input, &target);
|
||||
if (!matched) matched = iterate_menu (ProgStore.os, input, &target);
|
||||
if (!matched) matched = iterate_menu (ProgStore.wr, input, &target);
|
||||
|
||||
if (!matched) return false;
|
||||
|
||||
if (TargetOp_Set_Source==code)
|
||||
{
|
||||
if (target->setfn)
|
||||
{
|
||||
target->setfn(option);
|
||||
}
|
||||
else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 set 功能,邀您帮助: chsrc issue"));
|
||||
}
|
||||
else if (TargetOp_Reset_Source==code)
|
||||
{
|
||||
if (target->resetfn)
|
||||
{
|
||||
target->resetfn(option);
|
||||
}
|
||||
else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 reset 功能,邀您帮助: chsrc issue"));
|
||||
}
|
||||
else if (TargetOp_Get_Source==code)
|
||||
{
|
||||
if (target->getfn)
|
||||
{
|
||||
target->getfn("");
|
||||
}
|
||||
else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 get 功能,邀您帮助: chsrc issue"));
|
||||
}
|
||||
else if (TargetOp_List_Config==code)
|
||||
{
|
||||
{
|
||||
char *msg = ENGLISH ? "To specify a source, use chsrc set " : "指定使用某源,请使用 chsrc set ";
|
||||
say (bdblue(xy_strcat (3, msg, input, " <code>\n")));
|
||||
}
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Available Sources: \n" : "可用源: \n";
|
||||
say (bdgreen(msg));
|
||||
}
|
||||
|
||||
{
|
||||
char *msg1 = ENGLISH ? "Mirror abbr" : "镜像站简写";
|
||||
char *msg2 = ENGLISH ? "Source URL" : "换源链接";
|
||||
char *msg3 = ENGLISH ? "Mirror Name" : "镜像站";
|
||||
char *format = ENGLISH ? " %-13s%-33s%-38s%s\n" : " %-13s%-36s%-46s%s\n";
|
||||
printf (format, "code", msg1, msg2, msg3);
|
||||
say ("--------- -------------- ----------------------------------------------- ---------------------");
|
||||
}
|
||||
|
||||
cli_print_target_available_sources (target->sources, target->sources_n);
|
||||
cli_print_target_features (target, input);
|
||||
|
||||
{
|
||||
char *msg = ENGLISH ? "Maintainer Information:\n" : "维护信息:\n";
|
||||
say (bdgreen(msg));
|
||||
cli_print_target_maintain_info (target, input);
|
||||
}
|
||||
}
|
||||
else if (TargetOp_Measure_Source==code)
|
||||
{
|
||||
auto_select_mirror (target->sources, target->sources_n, input);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 简短显示维护信息 */
|
||||
if (TargetOp_Get_Source==code || TargetOp_Set_Source==code || TargetOp_Reset_Source==code)
|
||||
{
|
||||
cli_print_target_maintain_info_briefly (target, input);
|
||||
}
|
||||
|
||||
if (TargetOp_Set_Source==code || TargetOp_Measure_Source==code)
|
||||
{
|
||||
// 2025-09-19: 已告知该消息给用户一个多月,我们不再告知
|
||||
// chsrc_op_epilogue ();
|
||||
}
|
||||
|
||||
#ifdef XY_DEBUG
|
||||
chef_debug_target (target);
|
||||
chsrc_perform_all_prelude ();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char const *argv[])
|
||||
{
|
||||
chsrc_init_framework ();
|
||||
chsrc_init_menu ();
|
||||
|
||||
argc -= 1;
|
||||
|
||||
if (0==argc)
|
||||
{
|
||||
cli_print_help ();
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
const char *command = argv[1];
|
||||
|
||||
// chsrc set target mirror
|
||||
// 1 2 3
|
||||
int cli_arg_Target_pos = 2;
|
||||
int cli_arg_Mirror_pos = cli_arg_Target_pos + 1;
|
||||
const char *target = NULL;
|
||||
|
||||
/**
|
||||
* (1)
|
||||
* chsrc set -local -en target mirror
|
||||
* 1 2 3 4 5
|
||||
* argc = 5
|
||||
*
|
||||
* (2) 考虑到这种情况,i必须还是从1开始
|
||||
* chsrc -en -h
|
||||
* 1 2
|
||||
*
|
||||
* argc = 2
|
||||
*/
|
||||
/* 从第一个参数遍历到最后一个参数 */
|
||||
for (int i=1; i<=argc; i++)
|
||||
{
|
||||
if (xy_str_start_with (argv[i], "-"))
|
||||
{
|
||||
if (xy_streql (argv[i], "-ipv6"))
|
||||
{
|
||||
ProgMode.Ipv6Mode = true;
|
||||
}
|
||||
else if (xy_streql (argv[i], "-local"))
|
||||
{
|
||||
ProgMode.LocalMode = true;
|
||||
}
|
||||
else if (xy_streql (argv[i], "-en") || xy_streql (argv[i], "-english"))
|
||||
{
|
||||
ProgMode.EnglishMode = true;
|
||||
}
|
||||
else if (xy_streql (argv[i], "-dry"))
|
||||
{
|
||||
ProgMode.DryRunMode = true;
|
||||
}
|
||||
else if (xy_streql (argv[i], "-no-color") || xy_streql (argv[i], "-no-colour"))
|
||||
{
|
||||
ProgMode.NoColorMode = true;
|
||||
xy.enable_color = false;
|
||||
}
|
||||
else if ( xy_streql (argv[i], "-h")
|
||||
|| xy_streql (argv[i], "-help")
|
||||
|| xy_streql (argv[i], "--help"))
|
||||
{
|
||||
command = "help"; /* 交到下方处理 */
|
||||
}
|
||||
else if ( xy_streql (argv[i], "-v")
|
||||
|| xy_streql (command, "-version")
|
||||
|| xy_streql (command, "--version"))
|
||||
{
|
||||
command = "version"; /* 交到下方处理 */
|
||||
}
|
||||
else
|
||||
{
|
||||
char *msg = ENGLISH ? "Unknown option: " : "未识别的命令行选项 ";
|
||||
chsrc_error (xy_2strcat (msg, argv[i])); return Exit_Unknown;
|
||||
}
|
||||
cli_arg_Target_pos++;
|
||||
cli_arg_Mirror_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool matched = false;
|
||||
|
||||
if (in_dry_run_mode())
|
||||
{
|
||||
char *dry_msg = ENGLISH ? "Enable [Dry Run] mode. "
|
||||
"Simulate the source changing process (skipping speed measurement). "
|
||||
"Commands only print but don't run\n"
|
||||
: "开启Dry Run模式,模拟换源过程(跳过测速),命令仅打印并不运行\n";
|
||||
chsrc_log (bdyellow(dry_msg));
|
||||
}
|
||||
|
||||
/* chsrc help */
|
||||
if ( xy_streql (command, "h")
|
||||
|| xy_streql (command, "-h")
|
||||
|| xy_streql (command, "help")
|
||||
|| xy_streql (command, "-help")
|
||||
|| xy_streql (command, "--help"))
|
||||
{
|
||||
cli_print_help ();
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
/* chsrc -v */
|
||||
else if ( xy_streql (command, "-v")
|
||||
|| xy_streql (command, "-version")
|
||||
|| xy_streql (command, "--version")
|
||||
|| xy_streql (command, "ver")
|
||||
|| xy_streql (command, "version"))
|
||||
{
|
||||
cli_print_version ();
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
/* chsrc list */
|
||||
else if ( xy_streql (command, "list")
|
||||
|| xy_streql (command, "l")
|
||||
|| xy_streql (command, "ls"))
|
||||
{
|
||||
if (argc < cli_arg_Target_pos)
|
||||
{
|
||||
cli_print_available_mirrors ();
|
||||
br();
|
||||
cli_print_supported_targets ();
|
||||
}
|
||||
else
|
||||
{
|
||||
target = argv[cli_arg_Target_pos];
|
||||
if ( xy_streql (target, "mirrors")
|
||||
|| xy_streql (target, "mirror"))
|
||||
{
|
||||
cli_print_available_mirrors ();
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
else if ( xy_streql (target, "targets")
|
||||
|| xy_streql (target, "target"))
|
||||
{
|
||||
cli_print_supported_targets ();
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
else if (xy_streql (target, "os"))
|
||||
{
|
||||
cli_print_menu ("os");
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
else if ( xy_streql (target, "lang")
|
||||
|| xy_streql (target, "pl")
|
||||
|| xy_streql (target, "language"))
|
||||
{
|
||||
cli_print_menu ("pl");
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
else if ( xy_streql (target, "ware")
|
||||
|| xy_streql (target, "software"))
|
||||
{
|
||||
cli_print_menu ("wr");
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
matched = get_target (target, TargetOp_List_Config, NULL);
|
||||
if (!matched) goto not_matched;
|
||||
}
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
#define MSG_EN_USE_LIST_TARGETS "Use `chsrc list targets` to see all supported targets"
|
||||
#define MSG_CN_USE_LIST_TARGETS "使用 chsrc list targets 查看所有支持的目标"
|
||||
|
||||
/* chsrc measure */
|
||||
else if ( xy_streql (command, "measure")
|
||||
|| xy_streql (command, "mea")
|
||||
|| xy_streql (command, "m")
|
||||
|| xy_streql (command, "cesu")
|
||||
|| xy_streql (command, "ce")
|
||||
|| xy_streql (command, "c"))
|
||||
{
|
||||
if (argc < cli_arg_Target_pos)
|
||||
{
|
||||
char *msg = ENGLISH ? "Please provide the target name you want to measure. " MSG_EN_USE_LIST_TARGETS
|
||||
: "请提供想要测速源的目标名。" MSG_CN_USE_LIST_TARGETS;
|
||||
chsrc_error (msg);
|
||||
return Exit_Unknown;
|
||||
}
|
||||
ProgMode.MeasureMode = true;
|
||||
target = argv[cli_arg_Target_pos];
|
||||
matched = get_target (target, TargetOp_Measure_Source, NULL);
|
||||
if (!matched) goto not_matched;
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
|
||||
/* chsrc get */
|
||||
else if ( xy_streql (command, "get")
|
||||
|| xy_streql (command, "g"))
|
||||
{
|
||||
if (argc < cli_arg_Target_pos)
|
||||
{
|
||||
char *msg = ENGLISH ? "Please provide the target name you want to view the source. " MSG_EN_USE_LIST_TARGETS
|
||||
: "请提供想要查看源的目标名。" MSG_CN_USE_LIST_TARGETS;
|
||||
chsrc_error (msg);
|
||||
return Exit_Unknown;
|
||||
}
|
||||
target = argv[cli_arg_Target_pos];
|
||||
matched = get_target (target, TargetOp_Get_Source, NULL);
|
||||
if (!matched) goto not_matched;
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
/* chsrc set */
|
||||
else if ( xy_streql (command, "set")
|
||||
|| xy_streql (command, "s"))
|
||||
{
|
||||
if (argc < cli_arg_Target_pos)
|
||||
{
|
||||
char *msg = ENGLISH ? "Please provide the target name you want to set the source. " MSG_EN_USE_LIST_TARGETS
|
||||
: "请提供想要设置源的目标名。" MSG_CN_USE_LIST_TARGETS;
|
||||
chsrc_error (msg);
|
||||
return Exit_Unknown;
|
||||
}
|
||||
|
||||
target = argv[cli_arg_Target_pos];
|
||||
char *mirrorCode_or_url = NULL;
|
||||
if (argc >= cli_arg_Mirror_pos)
|
||||
{
|
||||
mirrorCode_or_url = xy_strdup (argv[cli_arg_Mirror_pos]);
|
||||
}
|
||||
|
||||
matched = get_target (target, TargetOp_Set_Source, mirrorCode_or_url);
|
||||
if (!matched) goto not_matched;
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
/* chsrc reset */
|
||||
else if ( xy_streql (command, "reset")
|
||||
|| xy_streql (command, "rest")
|
||||
|| xy_streql (command, "r"))
|
||||
{
|
||||
if (argc < cli_arg_Target_pos)
|
||||
{
|
||||
char *msg = ENGLISH ? "Please provide the target name you want to reset the source. " MSG_EN_USE_LIST_TARGETS
|
||||
: "请提供想要重置源的目标名。" MSG_CN_USE_LIST_TARGETS;
|
||||
chsrc_error (msg);
|
||||
return Exit_Unknown;
|
||||
}
|
||||
|
||||
ProgMode.ResetMode = true;
|
||||
target = argv[cli_arg_Target_pos];
|
||||
matched = get_target (target, TargetOp_Reset_Source, NULL);
|
||||
if (!matched) goto not_matched;
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
/* chsrc issue */
|
||||
else if ( xy_streql (command, "issue")
|
||||
|| xy_streql (command, "issues")
|
||||
|| xy_streql (command, "isue")
|
||||
|| xy_streql (command, "i"))
|
||||
{
|
||||
cli_print_issues ();
|
||||
return Exit_OK;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char *msg1 = ENGLISH ? "Unknown command `" : "不支持的命令 ";
|
||||
char *msg2 = ENGLISH ? "`. Use `chsrc help` to view usage" : ". 请使用 chsrc help 查看使用方式";
|
||||
chsrc_error (xy_strcat (3, msg1, command, msg2));
|
||||
return Exit_Unknown;
|
||||
}
|
||||
|
||||
not_matched:
|
||||
if (!matched)
|
||||
{
|
||||
char *msg = ENGLISH ? "Unknown target. " MSG_EN_USE_LIST_TARGETS
|
||||
: "暂不支持的换源目标。" MSG_CN_USE_LIST_TARGETS;
|
||||
chsrc_error (msg);
|
||||
return Exit_Unknown;
|
||||
}
|
||||
}
|
||||
2872
src/chsrc.c
|
|
@ -0,0 +1,388 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Name : chef.c
|
||||
* File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
* Contributors : BingChunMoLi <bingchunmoli@bingchunmoli.com>
|
||||
* Created On : <2025-08-09>
|
||||
* Last Modified : <2025-10-27>
|
||||
*
|
||||
* chef DSL: for chefs (recipe makers) to define a target
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void
|
||||
chef_debug_target (Target_t *target)
|
||||
{
|
||||
#ifdef XY_DEBUG
|
||||
if (!target)
|
||||
{
|
||||
chsrc_debug2 ("target", "Target is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
say ("DEBUG Target Information:");
|
||||
printf (" Aliases: %s\n", target->aliases);
|
||||
|
||||
printf (" Get Function: %p\n", target->getfn);
|
||||
printf (" Set Function: %p\n", target->setfn);
|
||||
printf (" Reset Function: %p\n", target->resetfn);
|
||||
printf (" Prelude Function: %p\n", target->preludefn);
|
||||
|
||||
printf (" Inited?: %d\n", target->inited);
|
||||
|
||||
printf (" Sources: %p\n", target->sources);
|
||||
printf (" Sources Count: %d\n", target->sources_n);
|
||||
|
||||
printf (" Chef: %p\n", target->chef);
|
||||
printf (" Cooks: %p\n", target->cooks);
|
||||
printf (" Cooks Count: %d\n", target->cooks_n);
|
||||
printf (" Sauciers: %p\n", target->sauciers);
|
||||
printf (" Sauciers Count: %d\n", target->sauciers_n);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_debug_contributor (Contributor_t *contributor)
|
||||
{
|
||||
#ifdef XY_DEBUG
|
||||
if (!contributor)
|
||||
{
|
||||
chsrc_debug2 ("contrib", "Contributor is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
say ("DEBUG Contributor Information:");
|
||||
printf (" ID: %s\n", contributor->id);
|
||||
printf (" Name: %s\n", contributor->name);
|
||||
printf (" Email: %s\n", contributor->email);
|
||||
printf (" DisplayName: %s\n", contributor->display_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 登记所有贡献者
|
||||
*
|
||||
* @param id 贡献者 ID,这个ID最好是GitHub用户名,但也可以不是,只需要在 chsrc 内部进行区分即可
|
||||
* @param display_name 如果没有提供该参数,则使用 name
|
||||
*/
|
||||
void
|
||||
chef_register_contributor (char *id, char *name, char *email, char *display_name)
|
||||
{
|
||||
if (!id || !name || !email)
|
||||
xy_unreached();
|
||||
|
||||
Contributor_t *contributor = xy_malloc0 (sizeof (Contributor_t));
|
||||
contributor->id = xy_strdup (id);
|
||||
contributor->name = xy_strdup (name);
|
||||
contributor->email = xy_strdup (email);
|
||||
|
||||
if (!display_name)
|
||||
contributor->display_name = xy_strdup (name);
|
||||
else
|
||||
contributor->display_name = xy_strdup (display_name);
|
||||
|
||||
xy_map_set (ProgStore.contributors, id, contributor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 修改 Provider 的测速地址
|
||||
*
|
||||
* @note 这个修改的是全局 Provider 里的信息。往往用来设置 UpstreamProvider
|
||||
*/
|
||||
void
|
||||
chef_set_provider_speed_measure_url (SourceProvider_t *provider, char *url)
|
||||
{
|
||||
provider->psmi.skip = NotSkip;
|
||||
provider->psmi.url = xy_strdup (url);
|
||||
chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, "(镜像站信息本身) 设置测速链接: ", url));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 修改 Provider 的测速精度
|
||||
*
|
||||
* @note 这个修改的是全局 Provider 里的信息。往往用来设置 UpstreamProvider
|
||||
*/
|
||||
void
|
||||
chef_set_provider_speed_measure_accuracy (SourceProvider_t *provider, bool accuracy)
|
||||
{
|
||||
provider->psmi.accurate = accuracy;
|
||||
chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, "(镜像站信息本身) 设置测速精度: ", accuracy ? "精准" : "粗略"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 提供一个函数,这个函数基于 "换源链接" 和用户提供的数据来构造和填充精准测速链接
|
||||
*/
|
||||
void
|
||||
chef_set_sources_speed_measure_url_with_func (
|
||||
Target_t *target,
|
||||
char *(*func)(const char *url, const char *user_data),
|
||||
char *user_data)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
Source_t *sources = target->sources;
|
||||
int n = target->sources_n;
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
Source_t *src = &sources[i];
|
||||
ProviderType_t type = src->provider->type;
|
||||
if (src->url)
|
||||
{
|
||||
/* 为空时才修改 或者里面是脏数据 */
|
||||
if (NULL==src->speed_measure_url || !hp_is_url (src->speed_measure_url))
|
||||
{
|
||||
src->speed_measure_url = func (src->url, user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 给 "换源链接" 增加一个后缀来构造和填充专用测速链接
|
||||
*/
|
||||
void
|
||||
chef_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix)
|
||||
{
|
||||
chef_set_sources_speed_measure_url_with_func (target, xy_2strcat, postfix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @note 用于: 组中的 item target 在 standalone 模式时正确填充源信息
|
||||
*/
|
||||
void
|
||||
chef_use_other_target_sources (Target_t *this, Target_t *other)
|
||||
{
|
||||
if (!other->inited)
|
||||
{
|
||||
if (other->preludefn)
|
||||
other->preludefn();
|
||||
else
|
||||
{
|
||||
chef_debug_target (other);
|
||||
chsrc_panic ("`other` 未定义 _prelude() !");
|
||||
}
|
||||
}
|
||||
|
||||
this->sources = other->sources;
|
||||
this->sources_n = other->sources_n;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_allow_english (Target_t *target)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
target->can_english = true;
|
||||
}
|
||||
|
||||
void
|
||||
chef_deny_english (Target_t *target)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
target->can_english = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_zh, const char *explain_en)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
target->cap_local = cap;
|
||||
|
||||
if (cap == FullyCan)
|
||||
{
|
||||
target->cap_local_explain = xy_strdup (CHINESE ? "完全支持项目级换源" : "Supports project-level source switching");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cap == CanNot)
|
||||
{
|
||||
target->cap_local_explain = xy_strdup (CHINESE ? "无法进行项目级换源" : "Unable to perform project-level source switching");
|
||||
return;
|
||||
}
|
||||
|
||||
target->cap_local_explain = xy_strdup (CHINESE ? explain_zh : explain_en);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_allow_user_define (Target_t *target)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
target->can_user_define = true;
|
||||
target->can_user_define_explain = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
chef_deny_user_define (Target_t *target)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
target->can_user_define = false;
|
||||
|
||||
char *reason = CHINESE ? "URL将会根据内部实现重写,因此不能自定义"
|
||||
: "The URL will be rewritten based on internal implementation, so it cannot be customized";
|
||||
target->can_user_define_explain = reason;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_set_note (Target_t *target, const char *note_zh, const char *note_en)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
const char *msg = CHINESE ? note_zh : note_en;
|
||||
|
||||
if (msg)
|
||||
target->note = xy_strdup (msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 验证该 `id` 所指的贡献者确有其人
|
||||
*/
|
||||
Contributor_t *
|
||||
chef_verify_contributor (const char *id)
|
||||
{
|
||||
xy_cant_be_null (id);
|
||||
|
||||
Contributor_t *c = xy_map_get (ProgStore.contributors, id);
|
||||
if (!c)
|
||||
{
|
||||
char error[256];
|
||||
snprintf (error, sizeof (error), "贡献者 %s 不存在, 是否写错?或请在 chsrc-main.c 中登记该贡献者", id);
|
||||
chsrc_panic (error);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设置 Chef (recipe 负责人)
|
||||
*/
|
||||
void
|
||||
chef_set_chef (Target_t *target, const char *id)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
/* Chef 可为空 */
|
||||
if (!id)
|
||||
{
|
||||
target->chef = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
Contributor_t *c = chef_verify_contributor (id);
|
||||
target->chef = c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设置 Cooks (recipe 核心作者)
|
||||
*/
|
||||
void
|
||||
chef_set_cooks (Target_t *target, size_t count, ...)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
chsrc_panic ("recipe 一定至少有1位作者(cooks)");
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
|
||||
target->cooks = xy_malloc0 (count * sizeof (Contributor_t*));
|
||||
target->cooks_n = count;
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
char *id = va_arg (args, char*);
|
||||
target->cooks[i] = chef_verify_contributor (id);
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
chef_set_sauciers (Target_t *target, uint32_t count, ...)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
target->sauciers = NULL;
|
||||
target->sauciers_n = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start (args, count);
|
||||
|
||||
target->sauciers = xy_malloc0 (count * sizeof (Contributor_t*));
|
||||
target->sauciers_n = count;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++)
|
||||
{
|
||||
char *id = va_arg (args, char*);
|
||||
target->sauciers[i] = chef_verify_contributor (id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
chef_set_created_on (Target_t *target, char *date)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
xy_cant_be_null (date);
|
||||
|
||||
target->created_on = xy_strdup (date);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_set_last_updated (Target_t *target, char *date)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
xy_cant_be_null (date);
|
||||
|
||||
target->last_updated = xy_strdup (date);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chef_set_sources_last_updated (Target_t *target, char *date)
|
||||
{
|
||||
xy_cant_be_null (target);
|
||||
xy_cant_be_null (date);
|
||||
|
||||
target->sources_last_updated = xy_strdup (date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @note 某些 target 需要修改 User-Agent
|
||||
* 由于单独测速 (chsrc measure) 的时候也需要进行此项修改,
|
||||
* 所以该函数不能仅仅放在 _setsrc() 里,而是应当放在 _prelude() 里
|
||||
*/
|
||||
void
|
||||
chef_set_user_agent (char *user_agent)
|
||||
{
|
||||
ProgStatus.user_agent = user_agent;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Name : helper.c
|
||||
* File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
* Contributors : Nul None <nul@none.org>
|
||||
* Created On : <2025-07-14>
|
||||
* Last Modified : <2025-10-28>
|
||||
*
|
||||
* For chefs (recipe makers) and sometimes framewoker
|
||||
* to do some work not releated to OS operations
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
bool
|
||||
hp_is_url (const char *str)
|
||||
{
|
||||
return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 一律返回新字符串
|
||||
*/
|
||||
char *
|
||||
hp_remove_trailing_slash (char *str)
|
||||
{
|
||||
char *newstr = xy_strdup (str);
|
||||
size_t len = strlen (newstr);
|
||||
if (len > 0 && newstr[len - 1] == '/')
|
||||
newstr[len - 1] = '\0';
|
||||
return newstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 一律返回新字符串
|
||||
*/
|
||||
char *
|
||||
hp_ensure_trailing_slash (char *str)
|
||||
{
|
||||
size_t len = strlen (str);
|
||||
if (len == 0 || str[len - 1] == '/')
|
||||
return xy_strdup (str);
|
||||
|
||||
return xy_2strcat (str, "/");
|
||||
}
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Name : mirror.c
|
||||
* File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
* | 郭恒 <2085471348@qq.com>
|
||||
* Contributors : Shengwei Chen <414685209@qq.com>
|
||||
* | Jialin Lyu <jialinlvcn@aliyun.com>
|
||||
* | Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
|
||||
* |
|
||||
* Created On : <2023-08-29>
|
||||
* Last Modified : <2025-10-07>
|
||||
*
|
||||
* 通用镜像站
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#define Big_File_ubuntu "/18.04/ubuntu-18.04.6-desktop-amd64.iso" // 2.3 GB
|
||||
#define Big_File_ctan "/systems/texlive/Images/texlive.iso" // 4.8 GB
|
||||
#define Big_File_archlinux "/iso/latest/archlinux-x86_64.iso" // 800 MB
|
||||
#define Big_File_deepin "/20.9/deepin-desktop-community-20.9-amd64.iso" // 4 GB
|
||||
|
||||
/**
|
||||
* 教育网镜像
|
||||
*
|
||||
* @sync https://github.com/RubyMetric/chsrc/wiki
|
||||
*
|
||||
* 排序部分参考 https://github.com/mirrorz-org/oh-my-mirrorz
|
||||
*/
|
||||
MirrorSite_t MirrorZ =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"mirrorz", "MirrorZ", "校园网联合镜像站(MirrorZ)", "https://mirrors.cernet.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.cernet.edu.cn/ubuntu/dists/noble/Contents-amd64.gz", ROUGH}
|
||||
},
|
||||
|
||||
Tuna =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"tuna", "TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.tuna.tsinghua.edu.cn/speedtest/1000mb.bin", ROUGH}
|
||||
},
|
||||
|
||||
/**
|
||||
* @note 2025-03-17 SJTUG 共设两台服务器。思源服务器同步新镜像,致远服务器兼容原 SJTU 镜像站。
|
||||
* @note 有些target(例如flathub)思源站的兼容性不好,可以考虑将两个服务器分开测试
|
||||
*/
|
||||
|
||||
Sjtug_Zhiyuan =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"sjtu-zy", "SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.sjtug.sjtu.edu.cn/ctan" Big_File_ctan, ROUGH}
|
||||
},
|
||||
|
||||
Sjtug_Siyuan =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"sjtu-sy", "SJTUG-siyuan", "上海交通大学思源镜像站", "https://mirror.sjtu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirror.sjtu.edu.cn/ctan" Big_File_ctan, ROUGH}
|
||||
},
|
||||
|
||||
Bfsu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"bfsu", "BFSU", "北京外国语大学开源软件镜像站", "https://mirrors.bfsu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.bfsu.edu.cn/speedtest/1000mb.bin", ROUGH}
|
||||
},
|
||||
|
||||
Ustc =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"ustc", "USTC", "中国科学技术大学开源软件镜像", "https://mirrors.ustc.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.ustc.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Zju =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"zju", "ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.zju.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Jlu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"jlu", "JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.jlu.edu.cn/_static/speedtest.bin", ROUGH}
|
||||
},
|
||||
|
||||
Lzuoss =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"lzu", "LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirror.lzu.edu.cn/CTAN" Big_File_ctan, ROUGH}
|
||||
},
|
||||
|
||||
Pku =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"pku", "PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.pku.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Bjtu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"bjtu", "BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirror.bjtu.edu.cn/archlinux" Big_File_archlinux, ROUGH}
|
||||
},
|
||||
|
||||
Sustech =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"sustech", "SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.sustech.edu.cn/site/speedtest/1000mb.bin", ROUGH}
|
||||
},
|
||||
|
||||
Nju =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"nju", "NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.nju.edu.cn/archlinux" Big_File_archlinux, ROUGH}
|
||||
},
|
||||
|
||||
Xjtu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"xjtu", "XJTU", "西安交通大学软件镜像站", "https://mirrors.xjtu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.xjtu.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Hust =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"hust", "HUST", "华中科技大学开源镜像站", "https://mirrors.hust.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.hust.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Iscas =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"iscas", "ISCAS", "中科院软件所智能软件研究中心开源镜像站", "https://mirror.iscas.ac.cn/",
|
||||
{NotSkip, NA, NA, "https://mirror.iscas.ac.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Hit =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"hit", "HIT", "哈尔滨工业大学开源软件镜像站", "https://mirrors.hit.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.hit.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Scau =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"scau", "SCAU", "华南农业大学开源软件镜像站", "https://mirrors.scau.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.scau.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
NJTech =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"njtech", "NJTech", "南京工业大学开源软件镜像站", "https://mirrors.njtech.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.njtech.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Nyist =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"nyist", "NYIST", "南阳理工学院开源软件镜像站", "https://mirror.nyist.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirror.nyist.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Sdu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"sdu", "SDU", "山东大学镜像站", "https://mirrors.sdu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.sdu.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Qlu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"qlu", "QLU", "齐鲁工业大学开源镜像站", "https://mirrors.qlu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.qlu.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Cqupt =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"cqupt", "CQUPT", "重庆邮电大学开源镜像站", "https://mirrors.cqupt.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.cqupt.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
/**
|
||||
* @note 2023-09-05 封杀策略过严,谨慎使用
|
||||
*/
|
||||
Cqu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"cqu", "CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.cqu.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Neosoft =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"neosoft", "Neosoft", "大连东软信息学院开源镜像站", "https://mirrors.neusoft.edu.cn/",
|
||||
{NotSkip, NA, NA, "https://mirrors.neusoft.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商业公司提供的源
|
||||
*/
|
||||
MirrorSite_t Ali =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"ali", "Ali OPSX Public", "阿里巴巴开源镜像站(公网)", "https://developer.aliyun.com/mirror/",
|
||||
{NotSkip, NA, NA, "https://mirrors.aliyun.com/ubuntu/ls-lR.gz", ROUGH} // 31MB左右
|
||||
},
|
||||
/*
|
||||
// https://mirrors.cloud.aliyuncs.com/
|
||||
Ali_ECS_VPC =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"ali-ECS-VPC", "Ali OPSX ECS VPC", "阿里巴巴开源镜像站(ECS VPC网络)", "https://developer.aliyun.com/mirror/",
|
||||
{NotSkip, NA, NA, "https://mirrors.cloud.aliyuncs.com/deepin-cd" Big_File_deepin, ROUGH}
|
||||
},
|
||||
|
||||
// https://mirrors.aliyuncs.com/
|
||||
Ali_ECS_classic =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"ali-ECS", "Ali OPSX ECS", "阿里巴巴开源镜像站(ECS 经典网络)", "https://developer.aliyun.com/mirror/",
|
||||
{NotSkip, NA, NA, "https://mirrors.aliyuncs.com/deepin-cd" Big_File_deepin, ROUGH}
|
||||
},
|
||||
*/
|
||||
|
||||
Tencent =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"tencent", "Tencent Public", "腾讯软件源(公网)", "https://mirrors.tencent.com/",
|
||||
{NotSkip, NA, NA, "https://mirrors.cloud.tencent.com/mariadb/mariadb-12.1.0/winx64-packages/mariadb-12.1.0-winx64-debugsymbols.zip", ROUGH} // 110MB左右
|
||||
},
|
||||
/*
|
||||
Tencent_Intra =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"tencent-intra", "Tencent Intranet", "腾讯软件源(内网)", "https://mirrors.tencent.com/",
|
||||
{NotSkip, NA, NA, "https://mirrors.cloud.tencentyun.com/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
*/
|
||||
|
||||
Huawei =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"huawei", "Huawei Cloud", "华为开源镜像站", "https://mirrors.huaweicloud.com/",
|
||||
{NotSkip, NA, NA, "https://mirrors.huaweicloud.com/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
HuaweiCDN =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"huawei-cdn", "Huawei Cloud CDN", "华为开源镜像站(CDN)", "https://repo.huaweicloud.com/",
|
||||
{NotSkip, NA, NA, "https://repo.huaweicloud.com/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
|
||||
Volcengine =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"volc", "Volcengine", "火山引擎开源软件镜像站(公网)", "https://developer.volcengine.com/mirror/",
|
||||
{NotSkip, NA, NA, "https://mirrors.volces.com/ubuntu-releases" Big_File_ubuntu, ROUGH}
|
||||
},
|
||||
/*
|
||||
Volceengine_Intra =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"volc-intra", "Volcengine Intranet", "火山引擎开源软件镜像站(内网)",
|
||||
"https://developer.volcengine.com/mirror/",
|
||||
"https://mirrors.ivolces.com/ubuntu-releases" Big_File_ubuntu, ROUGH},
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @note 2025-06-20 网易开源镜像站的速度始终过低,不建议再使用
|
||||
*/
|
||||
Netease =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"netease", "Netease", "网易开源镜像站", "https://mirrors.163.com/",
|
||||
{NotSkip, NA, NA, "https://mirrors.163.com/deepin-cd" Big_File_deepin, ROUGH}
|
||||
},
|
||||
|
||||
/**
|
||||
* @note 2025-06-20 搜狐开源镜像站的速度始终过低,不建议再使用
|
||||
*/
|
||||
Sohu =
|
||||
{
|
||||
IS_GeneralMirrorSite,
|
||||
"sohu", "SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/",
|
||||
{NotSkip, NA, NA, "https://mirrors.sohu.com/deepin-cd" Big_File_deepin, ROUGH}
|
||||
};
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Name : struct.h
|
||||
* File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
* | 郭恒 <2085471348@qq.com>
|
||||
* Contributors : Shengwei Chen <414685209@qq.com>
|
||||
* |
|
||||
* Created On : <2023-08-29>
|
||||
* Last Modified : <2025-08-22>
|
||||
*
|
||||
* chsrc struct
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
typedef struct ProviderSpeedMeasureInfo_t
|
||||
{
|
||||
bool skip; /* 是否默认跳过 */
|
||||
char *skip_reason_CN; /* 跳过的原因(中文)*/
|
||||
char *skip_reason_EN; /* 跳过的原因(英文)*/
|
||||
char *url; /* 测速链接 */
|
||||
bool accurate; /* 是否为精准测速,上游源和专用镜像站为 ACCURATE,通用镜像站为 ROUGH */
|
||||
}
|
||||
ProviderSpeedMeasureInfo_t;
|
||||
|
||||
#define SKIP true
|
||||
#define NotSkip false
|
||||
#define ToFill NULL
|
||||
#define NA NULL
|
||||
|
||||
#define ACCURATE true
|
||||
#define ROUGH false
|
||||
|
||||
typedef enum ProviderType_t
|
||||
{
|
||||
IS_GeneralMirrorSite, /* 通用镜像站 */
|
||||
IS_DedicatedMirrorSite, /* 专用镜像站 */
|
||||
IS_UpstreamProvider, /* 上游默认源 */
|
||||
IS_UserDefinedProvider, /* 用户提供 */
|
||||
}
|
||||
ProviderType_t;
|
||||
|
||||
typedef struct SourceProvider_t
|
||||
{
|
||||
const ProviderType_t type; /* 类型 */
|
||||
const char *code; /* 用于用户指定某一 Provider */
|
||||
const char *abbr; /* 需要使用 Provider 的英文名时,用这个代替,因为大部分 Provider 没有提供正式的英文名 */
|
||||
const char *name; /* Provider 中文名 */
|
||||
const char *site; /* Provider 首页 */
|
||||
ProviderSpeedMeasureInfo_t psmi;
|
||||
}
|
||||
SourceProvider_t;
|
||||
|
||||
typedef SourceProvider_t MirrorSite_t;
|
||||
|
||||
SourceProvider_t UpstreamProvider =
|
||||
{
|
||||
IS_UpstreamProvider,
|
||||
/* 引入新的上游默认源时,请使下面第一行的前三个字段保持不变,只添加第四个字段 */
|
||||
"upstream", "Upstream", "上游默认源", NULL,
|
||||
/* 引入新的上游默认源时,请完全修改下面这个结构体,可使用 def_need_measure_info 宏 */
|
||||
{SKIP, "URL未知,邀您参与贡献!", "URL unknown, welcome to contribute!", NULL, ACCURATE}
|
||||
};
|
||||
|
||||
#define def_need_measure_info {SKIP, "缺乏较大的测速对象,邀您参与贡献!", "Lack of large object URL, welcome to contribute!", NULL, ACCURATE}
|
||||
|
||||
SourceProvider_t UserDefinedProvider =
|
||||
{
|
||||
IS_UserDefinedProvider,
|
||||
"user", "用户自定义", "用户自定义", NULL,
|
||||
{SKIP, "用户自定义源不测速", "SKIP for user-defined source", NULL, ACCURATE}
|
||||
};
|
||||
|
||||
|
||||
typedef struct Source_t
|
||||
{
|
||||
union {
|
||||
SourceProvider_t *provider;
|
||||
MirrorSite_t *mirror;
|
||||
};
|
||||
/* 用于换源的 URL */
|
||||
char *url;
|
||||
|
||||
/* 对该 source 的专用测速链接,这就是精准测速 */
|
||||
char *speed_measure_url;
|
||||
}
|
||||
Source_t;
|
||||
|
||||
/* 不用给专用测速链接,因为 Upstream 的整体测速链接已是精准测速 */
|
||||
#define DelegateToUpstream NULL
|
||||
/* 不用给专用测速链接,因为该镜像站是专用镜像站,其整体测速链接已是精准测速 */
|
||||
#define DelegateToMirror NULL
|
||||
/* 看到该注释的贡献者,你可以帮忙寻找专用测速链接 */
|
||||
#define NeedContribute NULL
|
||||
/* 由 prelude() 填充 */
|
||||
#define FeedByPrelude NULL
|
||||
|
||||
|
||||
typedef enum Capability_t
|
||||
{
|
||||
CanNot,
|
||||
FullyCan,
|
||||
PartiallyCan
|
||||
}
|
||||
Capability_t;
|
||||
|
||||
|
||||
|
||||
typedef struct Contributor_t
|
||||
{
|
||||
char *id; /* 全局唯一贡献者标识符,防止反复写信息,以 @ 开头 */
|
||||
char *name; /* 贡献者姓名; 鉴于该项目完全依赖于贡献者,建议留下真实姓名或者昵称 */
|
||||
char *email;
|
||||
char *display_name; /* recipe 结束时会显示贡献者信息,如果你不愿显示真实姓名或者昵称,可以另外提供一个名字 */
|
||||
}
|
||||
Contributor_t;
|
||||
|
||||
|
||||
typedef struct Target_t
|
||||
{
|
||||
/* 以 / 为分隔符的多个目标别名 */
|
||||
char *aliases;
|
||||
|
||||
void (*getfn) (char *option);
|
||||
void (*setfn) (char *option);
|
||||
void (*resetfn) (char *option);
|
||||
|
||||
/* 初始化函数,用于填充该 struct 的各种信息 */
|
||||
void (*preludefn) (void);
|
||||
bool inited; /* 是否执行过了 preludefn() */
|
||||
|
||||
Source_t *sources;
|
||||
int sources_n;
|
||||
|
||||
|
||||
/* Features */
|
||||
bool can_english; /* 是否支持英文输出 */
|
||||
|
||||
bool can_user_define; /* 是否支持用户自定义URL来换源 */
|
||||
char *can_user_define_explain; /* 用户自定义URL的说明 */
|
||||
|
||||
Capability_t cap_local; /* 是否支持 local mode */
|
||||
char *cap_local_explain; /* local mode 的说明 */
|
||||
|
||||
char *note; /* 备注 */
|
||||
|
||||
|
||||
/* recipe 维护信息 */
|
||||
char *created_on;
|
||||
char *last_updated;
|
||||
char *sources_last_updated;
|
||||
|
||||
Contributor_t *chef; /* 该 recipe *当前*的总负责人 (可以任职也可以休职) */
|
||||
Contributor_t **cooks; /* 该 recipe 的主要作者 */
|
||||
int cooks_n;
|
||||
Contributor_t **sauciers; /* 该 recipe 的次要贡献者 (除主要作者外的其他人) */
|
||||
int sauciers_n;
|
||||
}
|
||||
Target_t;
|
||||
|
||||
|
||||
|
||||
#define def_target(t, aliases) void t##_getsrc(char *option);void t##_setsrc(char *option);void t##_resetsrc(char *option); Target_t t##_target={aliases};
|
||||
|
||||
#define chef_allow_gsr(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
|
||||
#define chef_allow_s(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
|
||||
#define chef_allow_sr(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
|
||||
#define chef_allow_gs(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
|
||||
#define chef_allow_NOOP(t)
|
||||
#define chef_prep_this(t,op) Target_t *this = &t##_target; this->inited = true; chef_allow_##op(t);
|
||||
|
||||
#define use_this(t) Target_t *this = &t##_target;
|
||||
#define chsrc_use_this_source(t) Target_t *this = &t##_target; Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
|
||||
#define def_sources_begin() Source_t sources[] = {
|
||||
#define def_sources_end() }; \
|
||||
this->sources_n = xy_c_array_len(sources); \
|
||||
char *_sources_storage = xy_malloc0 (sizeof(sources)); \
|
||||
memcpy (_sources_storage, sources, sizeof(sources)); \
|
||||
this->sources = (Source_t *)_sources_storage;
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Name : version.h
|
||||
* File Authors : 曾奥然 <ccmywish@qq.com>
|
||||
* | Mikachu2333 <mikachu.23333@zohomail.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* |
|
||||
* Created On : <2025-10-10>
|
||||
* Last Modified : <See 'Chsrc_Release_Date'>
|
||||
*
|
||||
* 发布新版本前请修改此文件
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#define Chsrc_Version "0.2.3.4"
|
||||
|
||||
// 以下四个宏仅用于 resource/chsrc.rc
|
||||
#define Chsrc_Version_Major 0
|
||||
#define Chsrc_Version_Minor 2
|
||||
#define Chsrc_Version_Patch 3
|
||||
#define Chsrc_Version_Pre 4
|
||||
|
||||
#define Chsrc_Release_Date "2025/12/18"
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GPL-3.0-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Config Type : rawstr4c (Markdown)
|
||||
! Config Authors: 曾奥然 <ccmywish@qq.com>
|
||||
! Contributors : Nil Null <nil@null.org>
|
||||
! Created On : <2025-07-22>
|
||||
! Last Modified : <2025-10-29>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# [rawstr4c] input for chsrc
|
||||
|
||||
`chsrc` 使用的 C标准 (最低要求) 是 `gnu11` (`c11` 的超集),这也就是说,我们项目是可以,而且是 **推荐** 同时混用 `R"()"` 和 `rawstr4c` 的
|
||||
|
||||
`LLVM` 对 `R"()"` 的支持是在 2024年07月 以后。但是在 GitHub Actions 中,所有出现的 `LLVM` 版本都太低了,
|
||||
这使得我们被迫把已经写过的 `R"()"` 全部再转换为 `rawstr4c`.
|
||||
|
||||
用户端的编译器一般比较新,然而可能也没有新到如此的地步,通过使用 `rawstr4c` 我们也放宽了用户对编译器的要求。
|
||||
|
||||
我们预计等2~3年后,在项目中重新开始 `R"()"` 的写法
|
||||
|
||||
<br>
|
||||
|
||||
- prefix = `RAWSTR_chsrc`
|
||||
- output = `:global-variable-only-header`
|
||||
- translate = `:oct`
|
||||
- no-postfix = `true`
|
||||
|
||||
<br>
|
||||
|
||||
## 中文帮助
|
||||
|
||||
- name = `USAGE_CHINESE`
|
||||
|
||||
```
|
||||
名称:
|
||||
chsrc - Change Source - (GPLv3+)
|
||||
|
||||
版本:
|
||||
@ver@
|
||||
|
||||
使用:
|
||||
chsrc <command> [options] [target] [mirror]
|
||||
|
||||
命令:
|
||||
help, h 打印此帮助,或 -h, --help
|
||||
issue, i 查看相关issue
|
||||
|
||||
list, ls, l 列出可用镜像站和可换源目标
|
||||
list mirror|target 列出支持的: 镜像站/换源目标
|
||||
list os|lang|ware 列出支持的: 操作系统/编程语言/软件
|
||||
list <target> 查看该目标可用源与支持功能
|
||||
|
||||
measure, m, cesu <target> 对该目标所有源测速
|
||||
|
||||
get, g <target> 查看该目标当前源的使用情况
|
||||
|
||||
set, s <target> 换源,自动测速后挑选最快源
|
||||
set <target> first 换源,使用维护团队测速第一的源
|
||||
set <target> <mirror> 换源,指定使用某镜像站 (通过list <target>查看)
|
||||
set <target> <URL> 换源,用户自定义源URL
|
||||
reset <target> 重置,使用上游默认使用的源
|
||||
|
||||
选项:
|
||||
-dry Dry Run,模拟换源过程,命令仅打印并不运行
|
||||
-local 仅对本项目而非全局换源 (通过ls <target>查看支持情况)
|
||||
-ipv6 使用IPv6测速
|
||||
-en(glish) 使用英文输出
|
||||
-no-color 无颜色输出
|
||||
|
||||
维护:
|
||||
邀请您担任 Chef, 为用户把关您熟悉的 recipe
|
||||
|
||||
源代码地址: https://github.com/RubyMetric/chsrc
|
||||
成为维护者: https://github.com/RubyMetric/chsrc/issues/275
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 英文帮助
|
||||
|
||||
- name = `USAGE_ENGLISH`
|
||||
|
||||
```
|
||||
NAME:
|
||||
chsrc - Change Source - (GPLv3+)
|
||||
|
||||
VERSION:
|
||||
@ver@
|
||||
|
||||
USAGE:
|
||||
chsrc <command> [options] [target] [mirror]
|
||||
|
||||
COMMANDS:
|
||||
help, h Print this help, or -h, --help
|
||||
issue, i See related issues
|
||||
|
||||
list, ls, l List available mirror sites and supported targets
|
||||
list mirror|target List supported: mirror sites/supported targets
|
||||
list os|lang|ware List supported: OSes/Programming Languages/Softwares
|
||||
list <target> View available sources and supporting features for <target>
|
||||
|
||||
measure, m, cesu <target> Measure velocity of all sources of <target>
|
||||
|
||||
get, g <target> View the current source state for <target>
|
||||
|
||||
set, s <target> Change source, select the fastest source by automatic speed measurement
|
||||
set <target> first Change source, select the fastest source measured by the maintainers team
|
||||
set <target> <mirror> Change source, specify a mirror site (Via `list <target>`)
|
||||
set <target> <URL> Change source, using user-defined source URL
|
||||
reset <target> Reset source to the upstream's default
|
||||
|
||||
OPTIONS:
|
||||
-dry Dry Run. Simulate the source changing process, command only prints, not run
|
||||
-local Change source only for this project rather than globally (Via `ls <target>`)
|
||||
-ipv6 Speed measurement using IPv6
|
||||
-en(glish) Output in English
|
||||
-no-color Output without color
|
||||
|
||||
MAINTAIN:
|
||||
We invite you to become a Chef to ensure the quality of recipes you are familiar with for users:
|
||||
|
||||
Source Code: @url@
|
||||
Become a Maintainer: https://github.com/RubyMetric/chsrc/issues/275
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## for `chsrc -v`
|
||||
|
||||
- name = `for__v_CHINESE`
|
||||
|
||||
```
|
||||
chsrc @ver@
|
||||
|
||||
Copyright (C) 2023-2025 曾奥然, 郭恒
|
||||
许可证 GPLv3+:GNU GPL 第 3 版或更高版本 <https://gnu.org/licenses/gpl.html>
|
||||
这是自由软件:您可以自由修改和分发它。
|
||||
在法律允许的最大范围内,本软件按'原样'提供,不作任何明示或暗示的保证。
|
||||
|
||||
由作者:曾奥然、郭恒,协作者:Mikachu2333、Happy Game 以及各位贡献者开发。(详见 chsrc-main.c, 或 `chsrc ls <target>`)
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## for `chsrc -v -en`
|
||||
|
||||
- name = `for__v_ENGLISH`
|
||||
|
||||
```
|
||||
chsrc @ver@
|
||||
|
||||
Copyright (C) 2023-2025 Aoran Zeng, Heng Guo
|
||||
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
Written by authors: Aoran Zeng, Heng Guo, collaborators: Mikachu2333, Happy Game, and contributors. (See chsrc-main.c, or `chsrc ls <target>`)
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## for `chsrc issue`
|
||||
|
||||
- name = `for_issue`
|
||||
|
||||
```
|
||||
我们同时在 GitHub 和 Gitee 接受 issue 和 Bug 报告:
|
||||
|
||||
- https://github.com/RubyMetric/chsrc/issues
|
||||
- https://gitee.com/RubyMetric/chsrc/issues
|
||||
|
||||
|
||||
欢迎参与具体任务:
|
||||
|
||||
Shell auto-completion 终端命令自动补全:
|
||||
|
||||
https://github.com/RubyMetric/chsrc/issues/204
|
||||
|
||||
搜集上游默认源地址,帮助进行 chsrc reset:
|
||||
|
||||
https://github.com/RubyMetric/chsrc/issues/111
|
||||
|
||||
搜集测速地址,进行精准测速:
|
||||
|
||||
https://github.com/RubyMetric/chsrc/issues/205
|
||||
|
||||
帮助没有预编译的平台编写 shell 脚本:
|
||||
|
||||
https://github.com/RubyMetric/chsrc/issues/230
|
||||
|
||||
|
||||
支持的通用镜像站:
|
||||
- https://github.com/RubyMetric/chsrc/wiki
|
||||
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
## 最后告诉用户一些维护信息
|
||||
|
||||
- name = `op_epilogue`
|
||||
|
||||
```
|
||||
|
||||
* 精准测速: 能真实反映你未来使用该资源时的速度,因为它直接测量你关注的那个资源。
|
||||
* 模糊测速: 仅代表该镜像站提供服务的一个可能速度。因而可能会出现测速数值较高,但实际使用体验不佳的现象。
|
||||
当你遇到模糊测速时,请尽可能向我们提交准确的测速链接: chsrc issue
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
[rawstr4c]: https://github.com/RubyMetric/rawstr4c
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
def_target(pl_clojure, "clojure/clojars/cloj/lein");
|
||||
|
||||
void
|
||||
pl_clojure_prelude ()
|
||||
{
|
||||
chef_prep_this (pl_clojure, s);
|
||||
|
||||
chef_set_created_on (this, "2023-09-10");
|
||||
chef_set_last_updated (this, "2025-08-10");
|
||||
chef_set_sources_last_updated (this, "2025-08-21");
|
||||
|
||||
chef_set_chef (this, NULL);
|
||||
chef_set_cooks (this, 1, "@ccmywish");
|
||||
chef_set_sauciers (this, 1, "@hezonglun");
|
||||
|
||||
chef_allow_local_mode (this, FullyCan, NULL, NULL);
|
||||
chef_deny_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider,"https://repo.clojars.org/", DelegateToUpstream},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/clojars/", DelegateToMirror},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/clojars/", DelegateToMirror},
|
||||
{&Nju, "https://mirror.nju.edu.cn/clojars/", DelegateToMirror},
|
||||
{&Nyist, "https://mirror.nyist.edu.cn/clojars/", DelegateToMirror},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/clojars/", DelegateToMirror},
|
||||
{&Iscas, "https://mirror.iscas.ac.cn/clojars/", DelegateToMirror}
|
||||
def_sources_end()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_clojure_setsrc (char *option)
|
||||
{
|
||||
chsrc_use_this_source (pl_clojure);
|
||||
|
||||
if (chsrc_in_local_mode())
|
||||
{
|
||||
chsrc_note2 ("请在项目根目录中的 project.clj 中手动添加 :mirrors 关键字:");
|
||||
char *config = xy_str_gsub (RAWSTR_pl_clojure_project_clj, "@url@", source.url);
|
||||
println (config);
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_note2 ("请在 ~/.lein/projfiles.clj 中手动添加 :mirrors 关键字:");
|
||||
char *config = xy_str_gsub (RAWSTR_pl_clojure_projfiles_clj, "@url@", source.url);
|
||||
println (config);
|
||||
}
|
||||
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
def_target(pl_dart_flutter, "flutter");
|
||||
|
||||
void
|
||||
pl_dart_flutter_prelude (void)
|
||||
{
|
||||
chef_prep_this (pl_dart_flutter, gsr);
|
||||
|
||||
chef_set_created_on (this, "2023-09-10");
|
||||
chef_set_last_updated (this, "2025-07-11");
|
||||
chef_set_sources_last_updated (this, "2025-04-15");
|
||||
|
||||
chef_set_chef (this, NULL);
|
||||
chef_set_cooks (this, 1, "@ccmywish");
|
||||
chef_set_sauciers (this, 2, "@czyt", "@xrgzs");
|
||||
|
||||
chef_allow_local_mode (this, CanNot, NULL, NULL);
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://storage.googleapis.com", FeedByPrelude},
|
||||
{&FlutterCN, "https://storage.flutter-io.cn", FeedByPrelude},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn", FeedByPrelude }, /* 官方文档也没有给后缀,怀疑是否存在问题 */
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/flutter", FeedByPrelude},
|
||||
{&Nju, "https://mirror.nju.edu.cn/flutter", FeedByPrelude}
|
||||
def_sources_end()
|
||||
|
||||
chef_set_sources_speed_measure_url_with_postfix (this, "/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* chsrc get flutter
|
||||
*/
|
||||
void
|
||||
pl_dart_flutter_getsrc (char *option)
|
||||
{
|
||||
chsrc_view_env ("FLUTTER_STORAGE_BASE_URL", NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @consult https://mirrors.tuna.tsinghua.edu.cn/flutter
|
||||
* @consult https://mirror.sjtu.edu.cn/docs/flutter_infra
|
||||
* @consult https://mirror.nju.edu.cn/mirrorz-help/flutter/?mirror=NJU
|
||||
*/
|
||||
void
|
||||
pl_dart_flutter_setsrc (char *option)
|
||||
{
|
||||
chsrc_use_this_source (pl_dart_flutter);
|
||||
|
||||
char *w = NULL;
|
||||
char *cmd = NULL;
|
||||
if (xy.on_windows)
|
||||
{
|
||||
cmd = xy_strcat (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\"");
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *zshrc = xy_zshrc;
|
||||
char *bashrc = xy_bashrc;
|
||||
|
||||
chsrc_backup (zshrc);
|
||||
w = xy_strcat (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n");
|
||||
chsrc_append_to_file (w, zshrc);
|
||||
|
||||
if (xy_file_exist (bashrc))
|
||||
{
|
||||
chsrc_backup (bashrc);
|
||||
chsrc_append_to_file (w, bashrc);
|
||||
}
|
||||
}
|
||||
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_dart_flutter_resetsrc (char *option)
|
||||
{
|
||||
pl_dart_flutter_setsrc (option);
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
def_target(pl_dart, "dart/pub");
|
||||
|
||||
void
|
||||
pl_dart_prelude (void)
|
||||
{
|
||||
chef_prep_this (pl_dart, gsr);
|
||||
|
||||
chef_set_created_on (this, "2023-09-10");
|
||||
chef_set_last_updated (this, "2025-07-11");
|
||||
chef_set_sources_last_updated (this, "2025-04-15");
|
||||
|
||||
chef_set_chef (this, NULL);
|
||||
chef_set_cooks (this, 1, "@ccmywish");
|
||||
chef_set_sauciers (this, 2, "@czyt", "@xrgzs");
|
||||
|
||||
chef_allow_local_mode (this, FullyCan, NULL, NULL);
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://pub.dev", FeedByPrelude},
|
||||
{&FlutterCN, "https://pub.flutter-io.cn", FeedByPrelude},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/dart-pub", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/dart-pub", FeedByPrelude},
|
||||
{&Nju, "https://mirror.nju.edu.cn/dart-pub", FeedByPrelude}
|
||||
def_sources_end()
|
||||
|
||||
chef_set_sources_speed_measure_url_with_postfix (this, "/packages/flutter_vision/versions/1.1.4.tar.gz");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_dart_getsrc (char *option)
|
||||
{
|
||||
chsrc_view_env ("PUB_HOSTED_URL", NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/dart-pub/
|
||||
* @consult https://mirror.sjtu.edu.cn/docs/dart-pub
|
||||
* @consult https://mirror.nju.edu.cn/mirrorz-help/dart-pub/?mirror=NJU
|
||||
*/
|
||||
void
|
||||
pl_dart_setsrc (char *option)
|
||||
{
|
||||
chsrc_use_this_source (pl_dart);
|
||||
|
||||
char *w = NULL;
|
||||
char *cmd = NULL;
|
||||
if (xy.on_windows)
|
||||
{
|
||||
cmd = xy_strcat (3, "setx PUB_HOSTED_URL \"", source.url, "\"");
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *zshrc = xy_zshrc;
|
||||
char *bashrc = xy_bashrc;
|
||||
|
||||
chsrc_backup (zshrc);
|
||||
w = xy_strcat (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n");
|
||||
|
||||
chsrc_append_to_file (w, zshrc);
|
||||
|
||||
if (xy_file_exist (bashrc))
|
||||
{
|
||||
chsrc_backup (bashrc);
|
||||
chsrc_append_to_file (w, bashrc);
|
||||
}
|
||||
}
|
||||
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_dart_resetsrc (char *option)
|
||||
{
|
||||
pl_dart_setsrc (option);
|
||||
}
|
||||