-
Notifications
You must be signed in to change notification settings - Fork 1
/
qbittorrent-nox-static.sh
2008 lines (1993 loc) · 95.5 KB
/
qbittorrent-nox-static.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# Copyright 2020 by userdocs and contributors
#
# SPDX-License-Identifier: Apache-2.0
#
# @author - userdocs
#
# @contributors IceCodeNew Stanislas boredazfcuk AdvenT. guillaumedsde
#
# @credits - https://gist.github.com/notsure2 https://github.com/c0re100/qBittorrent-Enhanced-Edition
#
# shellcheck disable=SC2034,SC1091 # Why are these checks excluded?
#
# https://github.com/koalaman/shellcheck/wiki/SC2034 There are quite a few variables defined by combining other variables that mean nothing on their own. This behavior is intentional and the warning can be skipped.
#
# https://github.com/koalaman/shellcheck/wiki/SC1091 I am sourcing /etc/os-release for some variables. It's not available to shellcheck to source and it's a safe file so we can skip this
#
# Script Formatting - https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format
#
#######################################################################################################################################################
# Set some script features - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
#######################################################################################################################################################
set -a
#######################################################################################################################################################
# Unset some variables to set defaults.
#######################################################################################################################################################
unset qbt_skip_delete qbt_skip_icu qbt_git_proxy qbt_curl_proxy qbt_install_dir qbt_build_dir qbt_working_dir qbt_modules_test qbt_python_version
#######################################################################################################################################################
# Color me up Scotty - define some color values to use as variables in the scripts.
#######################################################################################################################################################
cr="\e[31m" && clr="\e[91m" # [c]olor[r]ed && [c]olor[l]ight[r]ed
cg="\e[32m" && clg="\e[92m" # [c]olor[g]reen && [c]olor[l]ight[g]reen
cy="\e[33m" && cly="\e[93m" # [c]olor[y]ellow && [c]olor[l]ight[y]ellow
cb="\e[34m" && clb="\e[94m" # [c]olor[b]lue && [c]olor[l]ight[b]lue
cm="\e[35m" && clm="\e[95m" # [c]olor[m]agenta && [c]olor[l]ight[m]agenta
cc="\e[36m" && clc="\e[96m" # [c]olor[c]yan && [c]olor[l]ight[c]yan
#
tb="\e[1m" && td="\e[2m" && tu="\e[4m" && tn="\n" # [t]ext[b]old && [t]ext[d]im && [t]ext[u]nderlined && [t]ext[n]ewline
#
utick="\e[32m\U2714\e[0m" && uplus="\e[36m\U002b\e[0m" && ucross="\e[31m\U00D7\e[0m" # [u]nicode][tick] [u]nicode][plus] [u]nicode][cross]
#
urc="\e[31m\U25cf\e[0m" && ulrc="\e[91m\U25cf\e[0m" # [u]nicode[r]ed[c]ircle && [u]nicode[l]ight[r]ed[c]ircle
ugc="\e[32m\U25cf\e[0m" && ulgc="\e[92m\U25cf\e[0m" # [u]nicode[g]reen[c]ircle && [u]nicode[l]ight[g]reen[c]ircle
uyc="\e[33m\U25cf\e[0m" && ulyc="\e[93m\U25cf\e[0m" # [u]nicode[y]ellow[c]ircle && [u]nicode[l]ight[y]ellow[c]ircle
ubc="\e[34m\U25cf\e[0m" && ulbc="\e[94m\U25cf\e[0m" # [u]nicode[b]lue[c]ircle && [u]nicode[l]ight[b]lue[c]ircle
umc="\e[35m\U25cf\e[0m" && ulmc="\e[95m\U25cf\e[0m" # [u]nicode[m]agenta[c]ircle && [u]nicode[l]ight[m]agenta[c]ircle
ucc="\e[36m\U25cf\e[0m" && ulcc="\e[96m\U25cf\e[0m" # [u]nicode[c]yan[c]ircle && [u]nicode[l]ight[c]yan[c]ircle
ugrc="\e[37m\U25cf\e[0m" && ulgrcc="\e[97m\U25cf\e[0m" # [u]nicode[gr]ey[c]ircle && [u]nicode[l]ight[gr]ey[c]ircle
#
cdef="\e[39m" # [c]olor[def]ault
cend="\e[0m" # [c]olor[end]
#######################################################################################################################################################
# Check we are on a supported OS and release.
#######################################################################################################################################################
what_id="$(source /etc/os-release && printf "%s" "${ID}")" # Get the main platform name, for example: debian, ubuntu or alpine
what_version_codename="$(source /etc/os-release && printf "%s" "${VERSION_CODENAME}")" # Get the codename for this this OS. Note, Alpine does not have a unique codename.
what_version_id="$(source /etc/os-release && printf "%s" "${VERSION_ID%_*}")" # Get the version number for this codename, for example: 10, 20.04, 3.12.4
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then # If alpine, set the codename to alpine. We check for min v3.10 later with codenames.
what_version_codename="alpine"
fi
#
## Check against allowed codenames or if the codename is alpine version greater thab 3.10
if [[ ! "${what_version_codename}" =~ ^(alpine|buster|bullseye|bionic|focal|hirsute)$ ]] || [[ "${what_version_codename}" =~ ^(alpine)$ && "${what_version_id//\./}" -lt "3100" ]]; then
echo
echo -e " ${cly}This is not a supported OS. There is no reason to continue.${cend}"
echo
echo -e " id: ${td}${cly}${what_id}${cend} codename: ${td}${cly}${what_version_codename}${cend} version: ${td}${clr}${what_version_id}${cend}"
echo
echo -e " ${td}These are the supported platforms${cend}"
echo
echo -e " ${clm}Debian${cend} - ${clb}buster${cend}"
echo
echo -e " ${clm}Ubuntu${cend} - ${clb}bionic${cend} - ${clb}focal${cend}"
echo
echo -e " ${clm}Alpine${cend} - ${clb}3.10.0${cend} or greater"
echo
exit 1
fi
#######################################################################################################################################################
# This function sets some default values we use but whose values can be overridden by certain flags
#######################################################################################################################################################
set_default_values() {
DEBIAN_FRONTEND="noninteractive" && TZ="Europe/London" # For docker deploys to not get prompted to set the timezone.
#
qbt_build_tool="${qbt_build_tool:-}"
qbt_cross_name="${qbt_cross_name:-}"
#
qbt_patches_url="${qbt_patches_url:-}" # Provide a git username and repo in this format - username/repo" - In this repo the structure needs to be like this /patches/libtorrent/1.2.11/patch and/or /patches/qbittorrent/4.3.1/patch and your patch file will be automatically fetched and loadded for those matching tags.
#
libtorrent_version="${libtorrent_version:-1.2}" # Set this here so it is easy to see and change
#
qbt_qt_version=${qbt_qt_version:-5.15} # Set this here so it is easy to see and change. PATCH versions are detected automatically - 5.15.2 will be used over 5.15.0
#
qbt_python_version="3" # We are only using python3 but it's easier to just change this if we need to.
#
standard="17" && cpp_standard="c${standard}" && cxx_standard="c++${standard}" # ${standard} - Set the CXX standard. You need to set c++14 for older version of some apps, like qt 5.12
#
CDN_URL="http://dl-cdn.alpinelinux.org/alpine/edge/main" # for alpine
#
qbt_modules=("all" "install" "libexecinfo" "bison" "gawk" "glibc" "zlib" "iconv" "icu" "openssl" "boost" "libtorrent" "qtbase" "qttools" "qbittorrent") # Define our list of available modules in an array.
#
delete=() # Create this array empty. Modules listed in or added to this array will be removed from the default list of modules, changing the behaviour of all or install
#
delete_pkgs=() # Create this array empty. Packages listed in or added to this array will be removed from the default list of packages, changing the list of installed dependencies
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then # if Alpine then delete modules we don't use and set the required packages array
delete+=("bison" "gawk" "glibc")
qbt_required_pkgs=("bash" "bash-completion" "build-base" "curl" "pkgconf" "autoconf" "automake" "libtool" "git" "perl" "python${qbt_python_version}" "python${qbt_python_version}-dev" "py${qbt_python_version}-numpy" "py${qbt_python_version}-numpy-dev" "linux-headers" "ttf-freefont" "graphviz" "cmake" "re2c")
fi
#
if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then # if debian based then set the required packages array
delete+=("libexecinfo")
qbt_required_pkgs=("build-essential" "curl" "pkg-config" "automake" "libtool" "git" "perl" "python${qbt_python_version}" "python${qbt_python_version}-dev" "python${qbt_python_version}-numpy" "unzip" "graphviz")
fi
#
if [[ "${1}" != 'install' ]]; then # remove this module by default unless provided as a first argument to the script.
delete+=("install")
fi
#
if [[ "${*}" =~ ([[:space:]]|^)"icu"([[:space:]]|$) ]]; then # Don't remove the icu module if it was provided as a positional parameter.
qbt_skip_icu='no'
elif [[ "${qbt_skip_icu}" != 'no' ]]; then # else skip icu by default unless the -i flag is provided.
delete+=("icu")
fi
#
if [[ "${qbt_build_tool}" != 'cmake' ]]; then
delete_pkgs=("unzip" "ttf-freefont" "graphviz" "cmake" "re2c")
else
[[ "${qbt_skip_icu}" != 'no' ]] && delete+=("icu")
fi
#
if [[ ${qbt_cross_name} =~ ^(armhf|armv7|aarch64)$ ]]; then
alpine_arch="${qbt_cross_name}"
else
alpine_arch="$(uname -m)"
fi
#
qbt_working_dir="$(printf "%s" "$(pwd <(dirname "${0}"))")" # Get the full path to the scripts location to use with setting some path related variables.
qbt_working_dir_short="${qbt_working_dir/$HOME/\~}" # Used with echos. Use the qbt_working_dir variable but the $HOME path is replaced with a literal ~
#
qbt_install_dir="${qbt_working_dir}/qbt-build" # install relative to the script location.
qbt_install_dir_short="${qbt_install_dir/$HOME/\~}" # Used with echos. Use the qbt_install_dir variable but the $HOME path is replaced with a literal ~
#
qbt_local_paths="$PATH" # get the local users $PATH before we isolate the script by setting HOME to the install dir in the set_build_directory function.
}
#######################################################################################################################################################
# This function will check for a list of defined dependencies from the qbt_required_pkgs array. Apps like python3-dev are dynamically set
#######################################################################################################################################################
check_dependencies() {
echo -e "${tn} ${ulbc} ${tb}Checking if required core dependencies are installed${cend}${tn}"
#
## remove packages in the delete_pkgs from the qbt_required_pkgs array
for target in "${delete_pkgs[@]}"; do
for i in "${!qbt_required_pkgs[@]}"; do
if [[ "${qbt_required_pkgs[i]}" = "${target}" ]]; then
unset 'qbt_required_pkgs[i]'
fi
done
done
#
for pkg in "${qbt_required_pkgs[@]}"; do
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then
pkgman() { apk info -e "${pkg}"; }
fi
#
if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
pkgman() { dpkg -s "${pkg}"; }
fi
#
if pkgman > /dev/null 2>&1; then
echo -e " Dependency ${utick} ${pkg}"
else
if [[ -n "${pkg}" ]]; then
deps_installed='no'
echo -e " Dependency ${ucross} ${pkg}"
qbt_checked_required_pkgs+=("$pkg")
fi
fi
done
#
if [[ "${deps_installed}" = 'no' ]]; then # Check if user is able to install the dependencies, if yes then do so, if no then exit.
if [[ "$(id -un)" = 'root' ]]; then
echo -e "${tn} ${uplus} ${cg}Updating${cend}${tn}"
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then
apk update --repository="${CDN_URL}"
apk upgrade --repository="${CDN_URL}"
apk fix
fi
#
if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
apt-get update -y
apt-get upgrade -y
apt-get autoremove -y
fi
#
[[ -f /var/run/reboot-required ]] && {
echo -e "${tn}${cr} This machine requires a reboot to continue installation. Please reboot now.${cend}${tn}"
exit
}
#SS
echo -e "${tn} ${uplus} ${cg}Installing required dependencies${cend}${tn}"
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then
if ! apk add "${qbt_checked_required_pkgs[@]}" --repository="${CDN_URL}"; then
echo
exit 1
fi
fi
#
if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
if ! apt-get install -y "${qbt_checked_required_pkgs[@]}"; then
echo
exit 1
fi
fi
#
echo -e "${tn} ${utick} ${cg}Dependencies installed!${cend}"
#
deps_installed='yes'
else
echo -e "${tn}${tb} Please request or install the missing core dependencies before using this script${cend}"
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then
echo -e "${tn} ${clr}apk add${cend} ${qbt_checked_required_pkgs[*]}${tn}"
fi
#
if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
echo -e "${tn} ${clr}apt-get install -y${cend} ${qbt_checked_required_pkgs[*]}${tn}"
fi
#
exit
fi
fi
#
## All checks passed echo
if [[ "${deps_installed}" != 'no' ]]; then
echo -e "${tn} ${ugc} ${tb}All checks passed and core dependencies are installed, continuing to build${cend}"
fi
}
#######################################################################################################################################################
# 1: curl and git http/https proxy detection use -p username:pass@URL:PORT or -p URL:PORT
#######################################################################################################################################################
while (("${#}")); do
case "${1}" in
-b | --build-directory)
qbt_build_dir="${2}"
shift 2
;;
-c | --cmake)
qbt_build_tool="cmake"
shift
;;
-i | --icu)
qbt_skip_icu='no'
[[ "${qbt_skip_icu}" = 'no' ]] && delete=("${delete[@]/icu/}")
shift
;;
-p | --proxy)
qbt_git_proxy="${2}"
qbt_curl_proxy="${2}"
shift 2
;;
-ma | --multi-arch)
if [[ -n "${2}" && "${2}" =~ ^(armhf|armv7|aarch64)$ ]]; then
qbt_cross_name="${2}"
shift 2
else
echo
echo -e " ${ulrc} You must provide a valid arch option when using${cend} ${clb}-ma${cend}"
echo
echo -e " ${ulyc} armhf${cend}"
echo -e " ${ulyc} armv7${cend}"
echo -e " ${ulyc} aarch64${cend}"
echo
echo -e " ${ulgc} example usage:${clb} -ma aarch64${cend}"
echo
exit 1
fi
shift
;;
-o | --optimize)
optimize="-march=native"
shift
;;
-h-o | --help-optimize)
echo
echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
echo
echo -e " ${cly}Warning, using this flag will mean your static build is limited to a matching CPU${cend}"
echo
echo -e " Example: ${clb}-o${cend}"
echo
echo -e " Additonal flags used: ${clc}-march=native${cend}"
echo
exit
;;
-h-p | --help-proxy)
echo
echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
echo
echo -e " Specify a proxy URL and PORT to use with curl and git"
echo
echo -e " ${td}Example:${cend} ${td}${clb}-p${cend} ${td}${clc}username:password@https://123.456.789.321:8443${cend}"
echo
echo -e " ${td}${clb}-p${cend} ${td}${clc}https://proxy.com:12345${cend}"
echo
echo -e " ${cy}You can use this flag with this help command to see the value if called before the help option:${cend}"
echo
echo -e " ${td}${clb}-p${cend} ${td}${clc}https://proxy.com:12345${cend} ${td}${clb}-h-p${cend}"
echo
[[ -n "${qbt_curl_proxy}" ]] && echo -e " proxy command: ${clc}${qbt_curl_proxy}${tn}${cend}"
exit
;;
--) # end argument parsing
shift
break
;;
*) # preserve positional arguments
params1+=("${1}")
shift
;;
esac
done
#
eval set -- "${params1[@]}" # Set positional arguments in their proper place.
#######################################################################################################################################################
# 2: curl test download functions - default is no proxy - curl is a test function and curl_curl is the command function
#######################################################################################################################################################
curl_curl() {
if [[ -z "${qbt_curl_proxy}" ]]; then
"$(type -P curl)" -sNL4fq --connect-timeout 5 --retry 5 --retry-delay 5 --retry-max-time 25 "${@}"
else
"$(type -P curl)" -sNL4fq --connect-timeout 5 --retry 5 --retry-delay 5 --retry-max-time 25 --proxy-insecure -x "${qbt_curl_proxy}" "${@}"
fi
}
#
curl() {
if ! curl_curl "${@}"; then
echo 'error_url'
fi
}
#######################################################################################################################################################
# 3: git test download functions - default is no proxy - git is a test function and git_git is the command function
#######################################################################################################################################################
git_git() {
if [[ -z "${qbt_git_proxy}" ]]; then
"$(type -P git)" "${@}"
else
"$(type -P git)" -c http.sslVerify=false -c http.https://git.luolix.top.proxy="${qbt_git_proxy}" "${@}"
fi
}
#
git() {
if [[ "${2}" = '-t' ]]; then
url_test="${1}"
tag_flag="${2}"
tag_test="${3}"
else
url_test="${11}" # 11th place in our download folder function
fi
#
if ! curl -I "${url_test%\.git}" &> /dev/null; then
echo
echo -e " ${cy}There is an issue with your proxy settings or network connection${cend}"
echo
exit
fi
#
status="$(
git_git ls-remote --exit-code "${url_test}" "${tag_flag}" "${tag_test}" &> /dev/null
echo "${?}"
)"
#
if [[ "${tag_flag}" = '-t' && "${status}" = '0' ]]; then
echo "${tag_test}"
elif [[ "${tag_flag}" = '-t' && "${status}" -ge '1' ]]; then
echo 'error_tag'
else
if ! git_git "${@}"; then
echo
echo -e " ${cy}There is an issue with your proxy settings or network connection${cend}"
echo
exit
fi
fi
}
#
test_git_ouput() {
if [[ "${1}" = 'error_tag' ]]; then
echo -e "${tn} ${cy}Sorry, the provided ${3} tag ${cr}$2${cend}${cy} is not valid${cend}"
fi
}
#######################################################################################################################################################
# This function sets the build and installation directory. If the argument -b is used to set a build directory that directory is set and used.
# If nothing is specified or the switch is not used it defaults to the hard-coded path relative to the scripts location - qbittorrent-build
#######################################################################################################################################################
set_build_directory() {
if [[ -n "${qbt_build_dir}" ]]; then
if [[ "${qbt_build_dir}" =~ ^/ ]]; then
qbt_install_dir="${qbt_build_dir}"
qbt_install_dir_short="${qbt_install_dir/$HOME/\~}"
else
qbt_install_dir="${qbt_working_dir}/${qbt_build_dir}"
qbt_install_dir_short="${qbt_working_dir_short}/${qbt_build_dir}"
fi
fi
#
## Set lib and include directory paths based on install path.
include_dir="${qbt_install_dir}/include"
lib_dir="${qbt_install_dir}/lib"
#
## Define some build specific variables
LOCAL_USER_HOME="${HOME}" # Get the local user's home dir path before we contain HOME to the build dir.
HOME="${qbt_install_dir}"
PATH="${qbt_install_dir}/bin${PATH:+:${qbt_local_paths}}"
LD_LIBRARY_PATH="-L${lib_dir}"
PKG_CONFIG_PATH="${lib_dir}/pkgconfig"
}
#######################################################################################################################################################
# This function sets some compiler flags globally - b2 settings are set in the ~/user-config.jam set in the installation_modules function
#######################################################################################################################################################
custom_flags_set() {
CXXFLAGS="${optimize/*/$optimize }-std=${cxx_standard} -static -w ${qbt_strip_flags} -I${include_dir}"
CPPFLAGS="${optimize/*/$optimize }-static -w ${qbt_strip_flags} -I${include_dir}"
LDFLAGS="${optimize/*/$optimize }-static -Wl,--no-as-needed -L${lib_dir} -lpthread -pthread"
}
#
custom_flags_reset() {
CXXFLAGS="${optimize/*/$optimize }-std=${cxx_standard}"
CPPFLAGS="${optimize/*/$optimize }"
LDFLAGS=""
}
#######################################################################################################################################################
# This function is where we set your URL that we use with other functions.
#######################################################################################################################################################
set_module_urls() {
if [[ "${what_id}" =~ ^(alpine)$ ]]; then
libexecinfo_dev_url="${CDN_URL}/${alpine_arch}/$(apk info libexecinfo-dev | awk '{print $1}' | head -n 1).apk"
libexecinfo_static_url="${CDN_URL}/${alpine_arch}/$(apk info libexecinfo-static | awk '{print $1}' | head -n 1).apk"
fi
#
cmake_github_tag="$(git_git ls-remote -q -t --refs https://github.com/Kitware/CMake.git | awk '/v/{sub("refs/tags/", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
cmake_version="${cmake_github_tag#v}"
ninja_github_tag="$(git_git ls-remote -q -t --refs https://github.com/ninja-build/ninja.git | awk '/v/{sub("refs/tags/", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
ninja_version="${ninja_github_tag#v}"
#
if [[ ! "${what_id}" =~ ^(alpine)$ ]]; then
#bison_version="$(git_git ls-remote -q -t --refs https://git.savannah.gnu.org/git/bison.git | awk '/\/v/{sub("refs/tags/v", "");sub("(.*)((-|_)[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
#bison_url="http://ftpmirror.gnu.org/gnu/bison/bison-${bison_version}.tar.gz"
bison_url="http://ftpmirror.gnu.org/gnu/bison/$(grep -Eo 'bison-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl http://ftpmirror.gnu.org/gnu/bison/) | sort -V | tail -1)"
fi
#
if [[ ! "${what_id}" =~ ^(alpine)$ ]]; then
#gawk_version="$(git_git ls-remote -q -t --refs https://git.savannah.gnu.org/git/gawk.git | awk '/\/tags\/gawk/{sub("refs/tags/gawk-", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
#gawk_url="http://ftpmirror.gnu.org/gnu/gawk/gawk-${gawk_version}.tar.gz"
gawk_url="http://ftpmirror.gnu.org/gnu/gawk/$(grep -Eo 'gawk-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl http://ftpmirror.gnu.org/gnu/gawk/) | sort -V | tail -1)"
fi
#
if [[ ! "${what_id}" =~ ^(alpine)$ ]]; then
if [[ "${what_version_codename}" =~ ^(hirsute)$ ]]; then
#glibc_version="$(git_git ls-remote -q -t --refs https://sourceware.org/git/glibc.git | awk '/\/tags\/glibc-[0-9]\.[0-9]{2}$/{sub("refs/tags/glibc-", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
#glibc_url="http://ftpmirror.gnu.org/gnu/libc/glibc-${glibc_version}.tar.gz"
#glibc_url="http://ftpmirror.gnu.org/gnu/glibc/$(grep -Eo 'glibc-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl http://ftpmirror.gnu.org/gnu/glibc/) | sort -V | tail -1)"
glibc_url="http://ftpmirror.gnu.org/gnu/libc/glibc-2.33.tar.gz" # pin to the same version for this OS otherwise we get build errors
else
glibc_url="http://ftpmirror.gnu.org/gnu/libc/glibc-2.31.tar.gz" # pin to the same version for this OS otherwise we get build errors
fi
fi
#
zlib_github_tag="$(git_git ls-remote -q -t --refs https://github.com/madler/zlib.git | awk '{sub("refs/tags/", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
zlib_url="https://github.com/madler/zlib/archive/${zlib_github_tag}.tar.gz"
#
#iconv_github_tag="$(git_git ls-remote -q -t --refs https://git.savannah.gnu.org/git/libiconv.git | awk '/v/{sub("refs/tags/v", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
#iconv_url="http://ftpmirror.gnu.org/gnu/libiconv/libiconv-${iconv_github_tag}.tar.gz"
iconv_url="http://ftpmirror.gnu.org/gnu/libiconv/$(grep -Eo 'libiconv-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl http://ftpmirror.gnu.org/gnu/libiconv/) | sort -V | tail -1)"
#
icu_github_tag="$(git_git ls-remote -q -t --refs https://github.com/unicode-org/icu.git | awk '/\/release-/{sub("refs/tags/release-", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
icu_url="https://github.com/unicode-org/icu/releases/download/release-${icu_github_tag}/icu4c-${icu_github_tag/-/_}-src.tgz"
#
openssl_github_tag="$(git_git ls-remote -q -t --refs https://github.com/openssl/openssl.git | awk '/OpenSSL_1/{sub("refs/tags/", "");sub("(.*)(v6|rc|alpha|beta|-)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n1)"
openssl_url="https://github.com/openssl/openssl/archive/${openssl_github_tag}.tar.gz"
#
boost_version="$(git_git ls-remote -q -t --refs https://github.com/boostorg/boost.git | awk '{sub("refs/tags/boost-", "");sub("(.*)(rc|alpha|beta)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n1)"
boost_github_tag="boost-${boost_version}"
boost_url="https://boostorg.jfrog.io/artifactory/main/release/${boost_version}/source/boost_${boost_version//./_}.tar.gz"
boost_url_status="$(curl_curl -so /dev/null --head --write-out '%{http_code}' "https://boostorg.jfrog.io/artifactory/main/release/${boost_version}/source/boost_${boost_version//./_}.tar.gz")"
boost_github_url="https://github.com/boostorg/boost.git"
#
qt_github_tag_list="$(git_git ls-remote -q -t --refs https://github.com/qt/qtbase.git | awk '{sub("refs/tags/", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV)"
#
qtbase_github_tag="$(grep -Eom1 "v${qbt_qt_version}.([0-9]{1,2})" <<< "${qt_github_tag_list}")"
qtbase_github_url="https://github.com/qt/qtbase.git"
#
qttools_github_tag="$(grep -Eom1 "v${qbt_qt_version}.([0-9]{1,2})" <<< "${qt_github_tag_list}")"
qttools_github_url="https://github.com/qt/qttools.git"
#
libtorrent_github_url="https://github.com/arvidn/libtorrent.git"
libtorrent_github_tags_list="$(git_git ls-remote -q -t --refs https://github.com/arvidn/libtorrent.git | awk '/\/v/{sub("refs/tags/", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV)"
libtorrent_github_tag_default="$(grep -Eom1 "v${libtorrent_version}.([0-9]{1,2})" <<< "${libtorrent_github_tags_list}")"
libtorrent_github_tag="${libtorrent_github_tag:-$libtorrent_github_tag_default}"
#
qbittorrent_github_url="https://github.com/qbittorrent/qBittorrent.git"
qbittorrent_github_tag_default="$(git_git ls-remote -q -t --refs https://github.com/qbittorrent/qBittorrent.git | awk '{sub("refs/tags/", "");sub("(.*)(-[^0-9].*|rc|alpha|beta)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n1)"
qbittorrent_github_tag="${qbitorrent_github_tag:-$qbittorrent_github_tag_default}"
#
url_test="$(curl -so /dev/null "https://www.google.com")"
}
#######################################################################################################################################################
# This function verifies the module names from the array qbt_modules in the default values function.
#######################################################################################################################################################
installation_modules() {
params_count="${#}"
params_test=1
#
## remove modules from the delete array from the qbt_modules array
for target in "${delete[@]}"; do
for i in "${!qbt_modules[@]}"; do
if [[ "${qbt_modules[i]}" = "${target}" ]]; then
unset 'qbt_modules[i]'
fi
done
done
#
while [[ "${params_test}" -le "${params_count}" && "${params_count}" -gt '1' ]]; do
if [[ "${qbt_modules[*]}" =~ ${*:$params_test:1} ]]; then
:
else
qbt_modules_test="fail"
fi
params_test="$((params_test + 1))"
done
#
if [[ "${params_count}" -le '1' ]]; then
if [[ "${qbt_modules[*]}" =~ ${*:$params_test:1} && -n "${*:$params_test:1}" ]]; then
:
else
qbt_modules_test="fail"
fi
fi
#
## Activate all validated modules for installation and define some core variables.
if [[ "${qbt_modules_test}" != 'fail' ]]; then
if [[ "${*}" =~ ([[:space:]]|^)"all"([[:space:]]|$) ]]; then
for module in "${qbt_modules[@]}"; do
eval "skip_${module}=no"
done
else
for module in "${@}"; do
eval "skip_${module}=no"
done
fi
#
## Create the directories we need.
mkdir -p "${qbt_install_dir}/logs"
mkdir -p "${PKG_CONFIG_PATH}"
mkdir -p "${qbt_install_dir}/completed"
#
## Set some python variables we need.
python_major="$(python"${qbt_python_version}" -c "import sys; print(sys.version_info[0])")"
python_minor="$(python"${qbt_python_version}" -c "import sys; print(sys.version_info[1])")"
python_micro="$(python"${qbt_python_version}" -c "import sys; print(sys.version_info[2])")"
#
python_short_version="${python_major}.${python_minor}"
python_link_version="${python_major}${python_minor}"
#
echo -e "using gcc : : : <cflags>${optimize/*/$optimize }-std=${cxx_standard} <cxxflags>${optimize/*/$optimize }-std=${cxx_standard} ;${tn}using python : ${python_short_version} : /usr/bin/python${python_short_version} : /usr/include/python${python_short_version} : /usr/lib/python${python_short_version} ;" > "$HOME/user-config.jam"
#
## Echo the build directory.
echo -e "${tn} ${uyc} ${tb}Install Prefix${cend} : ${clc}${qbt_install_dir_short}${cend}"
#
## Some basic help
echo -e "${tn} ${uyc} ${tb}Script help${cend} : ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-h${cend}"
else
echo -e "${tn} ${urc} ${tb}One or more of the provided modules are not supported${cend}"
echo -e "${tn} ${uyc} ${tb}Below is a list of supported modules${cend}"
echo -e "${tn} ${umc} ${clm}${qbt_modules[*]}${tn}${cend}"
exit
fi
}
#######################################################################################################################################################
# This function will test to see if a Jamfile patch file exists via the variable patches_github_url for the tag used.
#######################################################################################################################################################
apply_patches() {
patch_app_name="${1}"
# Libtorrent has two tag formats libtorrent-1_2_11 and the newer v1.2.11. Moving forward v1.2.11 is the standard format. Make sure we always get the same outcome for either
[[ "${libtorrent_github_tag}" =~ ^RC_ ]] && libtorrent_patch_tag="${libtorrent_github_tag}"
[[ "${libtorrent_github_tag}" =~ ^libtorrent- ]] && libtorrent_patch_tag="${libtorrent_github_tag#libtorrent-}" && libtorrent_patch_tag="${libtorrent_patch_tag//_/\.}"
[[ "${libtorrent_github_tag}" =~ ^v[0-9] ]] && libtorrent_patch_tag="${libtorrent_github_tag#v}"
# Start to define the default master branch we will use by transforming the libtorrent_patch_tag variable to underscores. The result is dynamic and can be: RC_1_0, RC_1_1, RC_1_2, RC_2_0 and so on.
default_jamfile="${libtorrent_patch_tag//./\_}"
# Remove everything after second underscore. Occasionally the tag will be short, like v2.0 so we need to make sure not remove the underscore if there is only one present.
if [[ $(grep -o '_' <<< "$default_jamfile" | wc -l) -le 1 ]]; then
default_jamfile="RC_${default_jamfile}"
elif [[ $(grep -o '_' <<< "$default_jamfile" | wc -l) -ge 2 ]]; then
default_jamfile="RC_${default_jamfile%_*}"
fi
#
qbittorrent_patch_tag="${qbittorrent_github_tag#release-}" # qbittorrent has a consistent tag format of release-4.3.1.
#
if [[ "${patch_app_name}" == 'bootstrap-help' ]]; then # All the core variables we need for the help command are set so we can exit this function now.
return
fi
#
if [[ "${patch_app_name}" == 'bootstrap' ]]; then
mkdir -p "${qbt_install_dir}/patches/libtorrent/${libtorrent_patch_tag}"
mkdir -p "${qbt_install_dir}/patches/qbittorrent/${qbittorrent_patch_tag}"
echo
echo -e " ${cly}Using the defaults, these directories have been created:${cend}"
echo
echo -e " ${clc}$qbt_install_dir_short/patches/libtorrent/${libtorrent_patch_tag}${cend}"
echo
echo -e " ${clc}$qbt_install_dir_short/patches/qbittorrent/${qbittorrent_patch_tag}${cend}"
echo
echo -e " If a patch file, named ${cg}patch${cend} is found in these directories it will be applied to the relevant module with a matching tag."
else
patch_tag="${patch_app_name}_patch_tag"
patch_dir="${qbt_install_dir}/patches/${patch_app_name}/${!patch_tag}"
patch_file="${patch_dir}/patch"
patch_file_url="https://raw.githubusercontent.com/${qbt_patches_url}/master/patches/${patch_app_name}/${!patch_tag}/patch"
patch_jamfile="${qbt_install_dir}/libtorrent/Jamfile"
patch_jamfile_url="https://raw.githubusercontent.com/${qbt_patches_url}/master/patches/${patch_app_name}/${!patch_tag}/Jamfile"
#
[[ ! -d "${patch_dir}" ]] && mkdir -p "${patch_dir}"
#
if [[ -f "${patch_file}" ]]; then
echo
echo -e " ${utick} ${cr}Using ${!patch_tag} existing patch file${cend}"
[[ "${patch_app_name}" == 'qbittorrent' ]] && echo # purely comsetic
else
if curl_curl "${patch_file_url}" -o "${patch_file}"; then
echo
echo -e " ${utick} ${cr}Using ${!patch_tag} downloaded patch file${cend}"
[[ "${patch_app_name}" == 'qbittorrent' ]] && echo # purely comsetic
fi
fi
#
if [[ "${patch_app_name}" == 'libtorrent' ]]; then
if [[ -f "${patch_dir}/Jamfile" ]]; then
cp -f "${patch_dir}/Jamfile" "${patch_jamfile}"
echo
echo -e " ${utick} ${cr}Using existing custom Jamfile file${cend}"
echo
elif curl_curl "${patch_jamfile_url}" -o "${patch_jamfile}"; then
echo
echo -e " ${utick} ${cr}Using downloaded custom Jamfile file${cend}"
echo
else
curl_curl "https://raw.githubusercontent.com/arvidn/libtorrent/${default_jamfile}/Jamfile" -o "${patch_jamfile}"
echo
echo -e " ${utick} ${cr}Using libtorrent branch master Jamfile file${cend}"
echo
fi
fi
#
[[ -f "${patch_file}" ]] && patch -p1 < "${patch_file}"
fi
}
#######################################################################################################################################################
# This function is to test a directory exists before attemtping to cd and fail with and exit code if it doesn't.
#######################################################################################################################################################
_cd() {
if ! cd "${1}" > /dev/null 2>&1; then
echo -e "This directory does not exist. There is a problem"
echo
echo -e "${clr}${1}${cend}"
echo
exit 1
fi
}
#######################################################################################################################################################
# This function is for downloading source code archives
#######################################################################################################################################################
download_file() {
if [[ -n "${1}" ]]; then
url_filename="${2}"
[[ -n "${3}" ]] && subdir="/${3}" || subdir=""
echo -e "${tn} ${uplus}${cg} Installing $1${cend}${tn}"
file_name="${qbt_install_dir}/${1}.tar.gz"
[[ -f "${file_name}" ]] && rm -rf {"${qbt_install_dir:?}/$(tar tf "${file_name}" | grep -Eom1 "(.*)[^/]")","${file_name}"}
curl "${url_filename}" -o "${file_name}"
_cmd tar xf "${file_name}" -C "${qbt_install_dir}"
app_dir="${qbt_install_dir}/$(tar tf "${file_name}" | head -1 | cut -f1 -d"/")${subdir}"
mkdir -p "${app_dir}"
[[ "${1}" != 'boost' ]] && _cd "${app_dir}"
else
echo
echo "You must provide a filename name for the function - download_file"
echo "It creates the name from the appname_github_tag variable set in the URL section"
echo
echo "download_file filename url"
echo
exit
fi
}
#######################################################################################################################################################
# This function is for downloading git releases based on their tag.
#######################################################################################################################################################
download_folder() {
if [[ -n "${1}" ]]; then
github_tag="${1}_github_tag"
url_github="${2}"
[[ -n "${3}" ]] && subdir="/${3}" || subdir=""
echo -e "${tn} ${uplus}${cg} Installing ${1}${cend}${tn}"
folder_name="${qbt_install_dir}/${1}"
folder_inc="${qbt_install_dir}/include/${1}"
[[ -d "${folder_name}" ]] && rm -rf "${folder_name}"
[[ "${1}" == 'libtorrent' && -d "${folder_inc}" ]] && rm -rf "${folder_inc}"
git config --global advice.detachedHead false
_cmd git clone --no-tags --single-branch --branch "${!github_tag}" --shallow-submodules --recurse-submodules -j"$(nproc)" --depth 1 "${url_github}" "${folder_name}"
mkdir -p "${folder_name}${subdir}"
[[ -d "${folder_name}${subdir}" ]] && _cd "${folder_name}${subdir}"
else
echo
echo "You must provide a tag name for the function - download_folder"
echo "It creates the tag from the appname_github_tag variable set in the URL section"
echo
echo "download_folder tagname url subdir"
echo
exit
fi
}
#######################################################################################################################################################
# This function is for removing files and folders we no longer need
#######################################################################################################################################################
delete_function() {
if [[ -n "${1}" ]]; then
if [[ -z "${qbt_skip_delete}" ]]; then
[[ "$2" = 'last' ]] && echo -e "${tn} ${utick}${clr} Deleting $1 installation files and folders${cend}${tn}" || echo -e "${tn} ${utick}${clr} Deleting ${1} installation files and folders${cend}"
#
file_name="${qbt_install_dir}/${1}.tar.gz"
folder_name="${qbt_install_dir}/${1}"
[[ -f "${file_name}" ]] && rm -rf {"${qbt_install_dir:?}/$(tar tf "${file_name}" | grep -Eom1 "(.*)[^/]")","${file_name}"}
[[ -d "${folder_name}" ]] && rm -rf "${folder_name}"
[[ -d "${qbt_working_dir}" ]] && _cd "${qbt_working_dir}"
else
[[ "${2}" = 'last' ]] && echo -e "${tn} ${uyc}${clr} Skipping $1 deletion${cend}${tn}" || echo -e "${tn} ${uyc}${clr} Skipping ${1} deletion${cend}"
fi
else
echo
echo "The delete_function works in tandem with the application_name function"
echo "Set the appname using the application_name function then use this function."
echo
echo "delete_function appname"
echo
exit
fi
}
#######################################################################################################################################################
# This function sets the name of the application to be used with the functions download_file/folder and delete_function
#######################################################################################################################################################
application_name() {
last_app_name="skip_${app_name}"
app_name="${1}"
app_name_skip="skip_${app_name}"
app_url="${app_name}_url"
app_github_url="${app_name}_github_url"
}
#######################################################################################################################################################
# This function skips the deletion of the -n flag is supplied
#######################################################################################################################################################
application_skip() {
if [[ "${1}" = 'last' ]]; then
echo -e "${tn} ${uyc} Skipping ${clm}$app_name${cend} module installation${tn}"
else
echo -e "${tn} ${uyc} Skipping ${clm}$app_name${cend} module installation"
fi
}
#######################################################################################################################################################
# This function installs qt
#######################################################################################################################################################
install_qbittorrent() {
if [[ -f "${qbt_install_dir}/completed/qbittorrent-nox" ]]; then
#
if [[ "$(id -un)" = 'root' ]]; then
mkdir -p "/usr/local/bin"
cp -rf "${qbt_install_dir}/completed/qbittorrent-nox" "/usr/local/bin"
else
mkdir -p "${HOME}/bin"
cp -rf "${qbt_install_dir}/completed/qbittorrent-nox" "${LOCAL_USER_HOME}/bin"
fi
#
echo -e " ${tn}${tu}qbittorrent-nox has been installed!${cend}${tn}"
echo -e " Run it using this command:${tn}"
#
[[ "$(id -un)" = 'root' ]] && echo -e " ${cg}qbittorrent-nox${cend}${tn}" || echo -e " ${cg}~/bin/qbittorrent-nox${cend}${tn}"
#
exit
else
echo -e "${tn}qbittorrent-nox has not been built to the defined install directory:${tn}"
echo -e "${cg}${qbt_install_dir_short}/completed${cend}${tn}"
echo -e "Please build it using the script first then install${tn}"
#
exit
fi
}
#######################################################################################################################################################
# wtf is wrong now?
#######################################################################################################################################################
_cmd() {
if ! "${@}"; then
echo
exit 1
fi
}
#######################################################################################################################################################
# build command test
#######################################################################################################################################################
post_command() {
outcome="${PIPESTATUS[0]}"
[[ -n "${1}" ]] && command_type="${1}"
if [[ ${outcome} -gt '0' ]]; then
echo -e "${tn} ${urc} ${clr}Error: The ${command_type} command produced an exit code greater than 0 - Check the logs${cend}${tn}"
exit "${outcome}"
fi
}
#######################################################################################################################################################
# Multi Arch
#######################################################################################################################################################
_multi_arch() {
if [[ "${qbt_cross_name}" =~ ^(armhf|armv7|aarch64)$ ]]; then
if [[ "${what_version_codename}" =~ ^(alpine)$ ]]; then
echo -e "${tn} ${ugc}${cly} Using Multi Arch: ${qbt_cross_name}${cend}"
#
case "${qbt_cross_name}" in
armhf)
alpine_arch="armhf"
qbt_cross_host="armv6-linux-musleabihf"
qbt_cross_openssl="linux-armv4"
qbt_cross_boost="arm"
qbt_cross_qtbase="linux-arm-gnueabi-g++"
;;
armv7)
alpine_arch="armv7"
qbt_cross_host="armv7r-linux-musleabihf"
qbt_cross_openssl="linux-armv4"
qbt_cross_boost="arm"
qbt_cross_qtbase="linux-arm-gnueabi-g++"
;;
aarch64)
alpine_arch="aarch64"
qbt_cross_host="aarch64-linux-musl"
qbt_cross_openssl="linux-aarch64"
qbt_cross_boost="arm"
qbt_cross_qtbase="linux-aarch64-gnu-g++"
;;
esac
#
CHOST="${qbt_cross_host}"
CC="${qbt_cross_host}-gcc"
AR="${qbt_cross_host}-ar"
CXX="${qbt_cross_host}-g++"
#
mkdir -p "${qbt_install_dir}/logs"
#
[[ ! -f "${qbt_install_dir}/${qbt_cross_host}-cross.tgz" ]] && curl "https://musl.cc/${qbt_cross_host}-cross.tgz" > "${qbt_install_dir}/${qbt_cross_host}-cross.tgz"
tar xf "${qbt_install_dir}/${qbt_cross_host}-cross.tgz" --strip-components=1 -C "${qbt_install_dir}"
#
_fix_multiarch_static_links "${qbt_cross_host}"
#
multi_iconv=("--host=${qbt_cross_host}") # ${multi_iconv[@]}
#
multi_icu=("--host=${qbt_cross_host}" "-with-cross-build=${qbt_install_dir}/icu/cross") # ${multi_icu[@]}
#
multi_openssl=("./Configure" "${qbt_cross_openssl}") # ${multi_openssl[@]}
#
multi_qtbase=("-xplatform" "${qbt_cross_qtbase}") # ${multi_qtbase[@]}
#
if [[ "${qbt_build_tool}" = 'cmake' ]]; then
multi_libtorrent=("-D CMAKE_CXX_COMPILER=${qbt_cross_host}-g++") # ${multi_libtorrent[@]}
multi_qbittorrent=("-D CMAKE_CXX_COMPILER=${qbt_cross_host}-g++") # ${multi_qbittorrent[@]}
else
b2_toolset="gcc-arm"
echo -e "using gcc : arm : ${qbt_cross_host}-g++ : <cflags>${optimize/*/$optimize }-std=${cxx_standard} <cxxflags>${optimize/*/$optimize }-std=${cxx_standard} ;${tn}using python : ${python_short_version} : /usr/bin/python${python_short_version} : /usr/include/python${python_short_version} : /usr/lib/python${python_short_version} ;" > "$HOME/user-config.jam"
multi_libtorrent=("toolset=${b2_toolset}") # ${multi_libtorrent[@]}
#
multi_qbittorrent=("--host=${qbt_cross_host}") # ${multi_qbittorrent[@]}
fi
return
else
echo
echo -e " ${ulrc} Multiarch only works with Alpine Linux (native or docker)${cend}"
echo
exit 1
fi
else
multi_openssl=("./config") # ${multi_openssl[@]}
return
fi
return
}
#######################################################################################################################################################
# Github Actions release info
#######################################################################################################################################################
_release_info() {
_error_tag
#
echo -e "${tn} ${ugc} ${cly}Release boot-strapped${cend}"
#
release_info_dir="${qbt_install_dir}/release_info"
#
mkdir -p "${release_info_dir}"
#
openssl_pretty_version="${openssl_github_tag#OpenSSL_}" && openssl_pretty_version="${openssl_pretty_version//_/.}"
#
cat > "${release_info_dir}/tag.md" <<- TAG_INFO
${qbittorrent_github_tag#v}_${libtorrent_github_tag}
TAG_INFO
#
cat > "${release_info_dir}/title.md" <<- TITLE_INFO
qbittorrent ${qbittorrent_github_tag#release-} libtorrent ${libtorrent_github_tag#v}
TITLE_INFO
#
cat > "${release_info_dir}/release.md" <<- RELEASE_INFO
## Build info
Qbittorrent: ${qbittorrent_github_tag#release-}
Qt: ${qttools_github_tag#v}
Libtorrent: ${libtorrent_github_tag#v}
Boost: ${boost_version#v}
OpenSSL: ${openssl_pretty_version}
zlib: ${zlib_github_tag#v}
## Supported Architectures
These builds were created on Alpine linux using musl and [prebuilt toolchains](https://musl.cc/#binaries) for:
| Alpine Arch | Cross build files |
| :---------: | :---------------------------: |
| armhf | armv6-linux-musleabihf-cross |
| armv7 | armv7r-linux-musleabihf-cross |
| aarch64 | aarch64-linux-musl-cross |
| x86_64 | None - native build |
## Build matrix for libtorrent ${libtorrent_github_tag}
ℹ️ qt5 is still built with qmake. qt6 will use cmake when qbittorrent adds qt6 support.
ℹ️ [Check the build table for more info](https://github.com/userdocs/qbittorrent-nox-static#build-table---dependencies---arch---os---build-tools)
| Alpine Arch | iconv | icu | b2 + qmake | cmake | libtorrent ${libtorrent_github_tag} |
| :-----------: | :---: | :---: | :---: | :---: | :------------------------------------: |
| All supported | ✅ | ❌ | ✅ | ❌ | ✅ |
| All supported | ✅ | ✅ | ✅ | ❌ | ✅ |
| All supported | ✅ | ❌ | ❌ | ✅ | ✅ |
| All supported | ✅ | ✅ | ❌ | ✅ | ✅ |
⚠️ Binary builds are not stripped by default to preserve stacktrace / debugging features built into qBittorrent.
RELEASE_INFO
#
return
}
#######################################################################################################################################################
# cmake installation
#######################################################################################################################################################
_cmake() {
if [[ "${qbt_build_tool}" == 'cmake' ]]; then
echo -e "${tn} ${ulbc}${clr} Checking if cmake and ninja need to be installed${cend}"
mkdir -p "${qbt_install_dir}/bin"
_cd "${qbt_install_dir}"
#
if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
if [[ "$(cmake --version 2> /dev/null | awk 'NR==1{print $3}')" != "${cmake_github_tag#v}" ]]; then
curl "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-linux-x86_64.sh" -o "${qbt_install_dir}/cmake.sh"
if ! bash "${qbt_install_dir}/cmake.sh" --skip-license --exclude-subdir &> /dev/null; then
post_command "cmake installation"
fi
fi
#
if [[ "$("${qbt_install_dir}/bin/ninja" --version 2> /dev/null)" != "${ninja_github_tag#v}" ]]; then
curl "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-linux.zip" -o "${qbt_install_dir}/ninja-linux.zip"
if unzip -q -o "${qbt_install_dir}/ninja-linux.zip" -d "${qbt_install_dir}/bin" &> /dev/null; then
post_command "ninja installation"
fi
_cd "${qbt_install_dir}" && rm -f "${qbt_install_dir}/cmake.sh" "${qbt_install_dir}/ninja-linux.zip"
fi
fi
#
if [[ "${what_id}" =~ ^(alpine)$ ]]; then
if [[ "$("${qbt_install_dir}/bin/ninja" --version 2> /dev/null)" != "${ninja_github_tag#v}" ]]; then
download_folder ninja https://github.com/ninja-build/ninja.git
python3 configure.py --bootstrap --host=linux
cp -f "${qbt_install_dir}/ninja/ninja" "${qbt_install_dir}/bin/ninja"
_cd "${qbt_install_dir}" && rm -rf "${qbt_install_dir}/ninja"
fi
fi
#
echo -e "${tn} ${ugc}${clr} cmake and ninja are installed and ready to use${cend}"
fi
}
#######################################################################################################################################################
# static lib link fix: check for *.so and *.a versions of a lib in the $lib_dir and change the *.so link to point to the statric lib e.g. libdl.a
#######################################################################################################################################################
_fix_static_links() {
log_name="$1"