qbittorrent-nox-static.sh 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright 2020 by userdocs and contributors
  4. #
  5. # SPDX-License-Identifier: Apache-2.0
  6. #
  7. # @author - userdocs
  8. #
  9. # @contributors IceCodeNew Stanislas boredazfcuk AdvenT. guillaumedsde
  10. #
  11. # @credits - https://gist.github.com/notsure2 https://github.com/c0re100/qBittorrent-Enhanced-Edition
  12. #
  13. # shellcheck disable=SC2034,SC1091 # Why are these checks excluded?
  14. #
  15. # 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.
  16. #
  17. # 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
  18. #
  19. # Script Formatting - https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format
  20. #
  21. #######################################################################################################################################################
  22. # Set some script features - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
  23. #######################################################################################################################################################
  24. set -a
  25. #######################################################################################################################################################
  26. # Unset some variables to set defaults.
  27. #######################################################################################################################################################
  28. 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
  29. #######################################################################################################################################################
  30. # Color me up Scotty - define some color values to use as variables in the scripts.
  31. #######################################################################################################################################################
  32. cr="\e[31m" && clr="\e[91m" # [c]olor[r]ed && [c]olor[l]ight[r]ed
  33. cg="\e[32m" && clg="\e[92m" # [c]olor[g]reen && [c]olor[l]ight[g]reen
  34. cy="\e[33m" && cly="\e[93m" # [c]olor[y]ellow && [c]olor[l]ight[y]ellow
  35. cb="\e[34m" && clb="\e[94m" # [c]olor[b]lue && [c]olor[l]ight[b]lue
  36. cm="\e[35m" && clm="\e[95m" # [c]olor[m]agenta && [c]olor[l]ight[m]agenta
  37. cc="\e[36m" && clc="\e[96m" # [c]olor[c]yan && [c]olor[l]ight[c]yan
  38. #
  39. 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
  40. #
  41. 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]
  42. #
  43. 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
  44. 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
  45. 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
  46. 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
  47. 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
  48. 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
  49. 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
  50. #
  51. cdef="\e[39m" # [c]olor[def]ault
  52. cend="\e[0m" # [c]olor[end]
  53. #######################################################################################################################################################
  54. # Check we are on a supported OS and release.
  55. #######################################################################################################################################################
  56. what_id="$(source /etc/os-release && printf "%s" "${ID}")" # Get the main platform name, for example: debian, ubuntu or alpine
  57. 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.
  58. 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
  59. #
  60. if [[ "${what_id}" =~ ^(alpine)$ ]]; then # If alpine, set the codename to alpine. We check for min v3.10 later with codenames.
  61. what_version_codename="alpine"
  62. fi
  63. #
  64. ## Check against allowed codenames or if the codename is alpine version greater thab 3.10
  65. if [[ ! "${what_version_codename}" =~ ^(alpine|buster|bullseye|bionic|focal|hirsute)$ ]] || [[ "${what_version_codename}" =~ ^(alpine)$ && "${what_version_id//\./}" -lt "3100" ]]; then
  66. echo
  67. echo -e " ${cly}This is not a supported OS. There is no reason to continue.${cend}"
  68. echo
  69. echo -e " id: ${td}${cly}${what_id}${cend} codename: ${td}${cly}${what_version_codename}${cend} version: ${td}${clr}${what_version_id}${cend}"
  70. echo
  71. echo -e " ${td}These are the supported platforms${cend}"
  72. echo
  73. echo -e " ${clm}Debian${cend} - ${clb}buster${cend}"
  74. echo
  75. echo -e " ${clm}Ubuntu${cend} - ${clb}bionic${cend} - ${clb}focal${cend}"
  76. echo
  77. echo -e " ${clm}Alpine${cend} - ${clb}3.10.0${cend} or greater"
  78. echo
  79. exit 1
  80. fi
  81. #######################################################################################################################################################
  82. # This function sets some default values we use but whose values can be overridden by certain flags
  83. #######################################################################################################################################################
  84. set_default_values() {
  85. DEBIAN_FRONTEND="noninteractive" && TZ="Europe/London" # For docker deploys to not get prompted to set the timezone.
  86. #
  87. qbt_build_tool="${qbt_build_tool:-}"
  88. qbt_cross_name="${qbt_cross_name:-}"
  89. qbt_cross_target="${qbt_cross_target:-${what_id}}"
  90. qbt_cmake_debug="${qbt_cmake_debug:-}"
  91. #
  92. 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.
  93. #
  94. libtorrent_version="${libtorrent_version:-1.2}" # Set this here so it is easy to see and change
  95. #
  96. 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
  97. #
  98. [[ "${qbt_qt_version}" =~ ^6\. ]] && qbt_use_qt6="ON" || qbt_use_qt6="OFF" # this automatically toggles the use of QT6 with qbittorrent and cmake
  99. #
  100. qbt_python_version="3" # We are only using python3 but it's easier to just change this if we need to.
  101. #
  102. 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
  103. #
  104. CDN_URL="http://dl-cdn.alpinelinux.org/alpine/edge/main" # for alpine
  105. #
  106. 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.
  107. #
  108. 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
  109. #
  110. 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
  111. #
  112. if [[ ${qbt_cross_name} =~ ^(x86_64|armhf|armv7|aarch64)$ ]]; then
  113. _multi_arch bootstrap
  114. else
  115. cross_arch="$(uname -m)"
  116. delete_pkgs+=("crossbuild-essential-${cross_arch}")
  117. fi
  118. #
  119. if [[ "${what_id}" =~ ^(alpine)$ ]]; then # if Alpine then delete modules we don't use and set the required packages array
  120. delete+=("bison" "gawk" "glibc")
  121. 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")
  122. fi
  123. #
  124. if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then # if debian based then set the required packages array
  125. delete+=("libexecinfo")
  126. qbt_required_pkgs=("build-essential" "crossbuild-essential-${cross_arch}" "curl" "pkg-config" "automake" "libtool" "git" "openssl" "perl" "python${qbt_python_version}" "python${qbt_python_version}-dev" "python${qbt_python_version}-numpy" "unzip" "graphviz" "re2c")
  127. fi
  128. #
  129. if [[ "${1}" != 'install' ]]; then # remove this module by default unless provided as a first argument to the script.
  130. delete+=("install")
  131. fi
  132. #
  133. if [[ "${*}" =~ ([[:space:]]|^)"icu"([[:space:]]|$) ]]; then # Don't remove the icu module if it was provided as a positional parameter.
  134. qbt_skip_icu='no'
  135. elif [[ "${qbt_skip_icu}" != 'no' ]]; then # else skip icu by default unless the -i flag is provided.
  136. delete+=("icu")
  137. fi
  138. #
  139. if [[ "${qbt_build_tool}" != 'cmake' ]]; then
  140. delete_pkgs+=("unzip" "ttf-freefont" "graphviz" "cmake" "re2c")
  141. else
  142. [[ "${qbt_skip_icu}" != 'no' ]] && delete+=("icu")
  143. fi
  144. #
  145. qbt_working_dir="$(printf "%s" "$(pwd <(dirname "${0}"))")" # Get the full path to the scripts location to use with setting some path related variables.
  146. 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 ~
  147. #
  148. qbt_install_dir="${qbt_working_dir}/qbt-build" # install relative to the script location.
  149. 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 ~
  150. #
  151. 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.
  152. }
  153. #######################################################################################################################################################
  154. # This function will check for a list of defined dependencies from the qbt_required_pkgs array. Apps like python3-dev are dynamically set
  155. #######################################################################################################################################################
  156. check_dependencies() {
  157. echo -e "${tn} ${ulbc} ${tb}Checking if required core dependencies are installed${cend}${tn}"
  158. #
  159. ## remove packages in the delete_pkgs from the qbt_required_pkgs array
  160. for target in "${delete_pkgs[@]}"; do
  161. for i in "${!qbt_required_pkgs[@]}"; do
  162. if [[ "${qbt_required_pkgs[i]}" = "${target}" ]]; then
  163. unset 'qbt_required_pkgs[i]'
  164. fi
  165. done
  166. done
  167. #
  168. for pkg in "${qbt_required_pkgs[@]}"; do
  169. #
  170. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  171. pkgman() { apk info -e "${pkg}"; }
  172. fi
  173. #
  174. if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
  175. pkgman() { dpkg -s "${pkg}"; }
  176. fi
  177. #
  178. if pkgman > /dev/null 2>&1; then
  179. echo -e " Dependency ${utick} ${pkg}"
  180. else
  181. if [[ -n "${pkg}" ]]; then
  182. deps_installed='no'
  183. echo -e " Dependency ${ucross} ${pkg}"
  184. qbt_checked_required_pkgs+=("$pkg")
  185. fi
  186. fi
  187. done
  188. #
  189. if [[ "${deps_installed}" = 'no' ]]; then # Check if user is able to install the dependencies, if yes then do so, if no then exit.
  190. if [[ "$(id -un)" = 'root' ]]; then
  191. echo -e "${tn} ${uplus} ${cg}Updating${cend}${tn}"
  192. #
  193. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  194. apk update --repository="${CDN_URL}"
  195. apk upgrade --repository="${CDN_URL}"
  196. apk fix
  197. fi
  198. #
  199. if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
  200. apt-get update -y
  201. apt-get upgrade -y
  202. apt-get autoremove -y
  203. fi
  204. #
  205. [[ -f /var/run/reboot-required ]] && {
  206. echo -e "${tn}${cr} This machine requires a reboot to continue installation. Please reboot now.${cend}${tn}"
  207. exit
  208. }
  209. #SS
  210. echo -e "${tn} ${uplus} ${cg}Installing required dependencies${cend}${tn}"
  211. #
  212. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  213. if ! apk add "${qbt_checked_required_pkgs[@]}" --repository="${CDN_URL}"; then
  214. echo
  215. exit 1
  216. fi
  217. fi
  218. #
  219. if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
  220. if ! apt-get install -y "${qbt_checked_required_pkgs[@]}"; then
  221. echo
  222. exit 1
  223. fi
  224. fi
  225. #
  226. echo -e "${tn} ${utick} ${cg}Dependencies installed!${cend}"
  227. #
  228. deps_installed='yes'
  229. else
  230. echo -e "${tn}${tb} Please request or install the missing core dependencies before using this script${cend}"
  231. #
  232. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  233. echo -e "${tn} ${clr}apk add${cend} ${qbt_checked_required_pkgs[*]}${tn}"
  234. fi
  235. #
  236. if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
  237. echo -e "${tn} ${clr}apt-get install -y${cend} ${qbt_checked_required_pkgs[*]}${tn}"
  238. fi
  239. #
  240. exit
  241. fi
  242. fi
  243. #
  244. ## All checks passed echo
  245. if [[ "${deps_installed}" != 'no' ]]; then
  246. echo -e "${tn} ${ugc} ${tb}All checks passed and core dependencies are installed, continuing to build${cend}"
  247. fi
  248. }
  249. #######################################################################################################################################################
  250. # 1: curl and git http/https proxy detection use -p username:pass@URL:PORT or -p URL:PORT
  251. #######################################################################################################################################################
  252. while (("${#}")); do
  253. case "${1}" in
  254. -b | --build-directory)
  255. qbt_build_dir="${2}"
  256. shift 2
  257. ;;
  258. -bv | --boost-version)
  259. if [[ -n "${2}" ]]; then
  260. boost_version="${2}"
  261. shift 2
  262. else
  263. echo
  264. echo -e " ${ulrc} You must provide a valid arch option when using${cend} ${clb}-bv${cend}"
  265. echo
  266. exit 1
  267. fi
  268. shift
  269. ;;
  270. -c | --cmake)
  271. qbt_build_tool="cmake"
  272. shift
  273. ;;
  274. -i | --icu)
  275. qbt_skip_icu='no'
  276. [[ "${qbt_skip_icu}" = 'no' ]] && delete=("${delete[@]/icu/}")
  277. shift
  278. ;;
  279. -p | --proxy)
  280. qbt_git_proxy="${2}"
  281. qbt_curl_proxy="${2}"
  282. shift 2
  283. ;;
  284. -ma | --multi-arch)
  285. if [[ -n "${2}" && "${2}" =~ ^(x86_64|armhf|armv7|aarch64)$ ]]; then
  286. qbt_cross_name="${2}"
  287. shift 2
  288. else
  289. echo
  290. echo -e " ${ulrc} You must provide a valid arch option when using${cend} ${clb}-ma${cend}"
  291. echo
  292. echo -e " ${ulyc} armhf${cend}"
  293. echo -e " ${ulyc} armv7${cend}"
  294. echo -e " ${ulyc} aarch64${cend}"
  295. echo -e " ${ulyc} x86_64${cend}"
  296. echo
  297. echo -e " ${ulgc} example usage:${clb} -ma aarch64${cend}"
  298. echo
  299. exit 1
  300. fi
  301. shift
  302. ;;
  303. -o | --optimize)
  304. optimize="-march=native"
  305. shift
  306. ;;
  307. -h-bv | --help-boost-version)
  308. echo
  309. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  310. echo
  311. echo -e " This will let you set a specific version of boost to use with older build combos"
  312. echo
  313. echo -e " Example: ${clb}-bv 1.76.0${cend}"
  314. echo
  315. exit
  316. ;;
  317. -h-o | --help-optimize)
  318. echo
  319. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  320. echo
  321. echo -e " ${cly}Warning, using this flag will mean your static build is limited to a matching CPU${cend}"
  322. echo
  323. echo -e " Example: ${clb}-o${cend}"
  324. echo
  325. echo -e " Additonal flags used: ${clc}-march=native${cend}"
  326. echo
  327. exit
  328. ;;
  329. -h-p | --help-proxy)
  330. echo
  331. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  332. echo
  333. echo -e " Specify a proxy URL and PORT to use with curl and git"
  334. echo
  335. echo -e " ${td}Example:${cend} ${td}${clb}-p${cend} ${td}${clc}username:password@https://123.456.789.321:8443${cend}"
  336. echo
  337. echo -e " ${td}${clb}-p${cend} ${td}${clc}https://proxy.com:12345${cend}"
  338. echo
  339. echo -e " ${cy}You can use this flag with this help command to see the value if called before the help option:${cend}"
  340. echo
  341. echo -e " ${td}${clb}-p${cend} ${td}${clc}https://proxy.com:12345${cend} ${td}${clb}-h-p${cend}"
  342. echo
  343. [[ -n "${qbt_curl_proxy}" ]] && echo -e " proxy command: ${clc}${qbt_curl_proxy}${tn}${cend}"
  344. exit
  345. ;;
  346. --) # end argument parsing
  347. shift
  348. break
  349. ;;
  350. *) # preserve positional arguments
  351. params1+=("${1}")
  352. shift
  353. ;;
  354. esac
  355. done
  356. #
  357. set -- "${params1[@]}" # Set positional arguments in their proper place.
  358. #######################################################################################################################################################
  359. # 2: curl test download functions - default is no proxy - curl is a test function and curl_curl is the command function
  360. #######################################################################################################################################################
  361. curl_curl() {
  362. if [[ -z "${qbt_curl_proxy}" ]]; then
  363. "$(type -P curl)" -sNL4fq --connect-timeout 5 --retry 5 --retry-delay 5 --retry-max-time 25 "${@}"
  364. else
  365. "$(type -P curl)" -sNL4fq --connect-timeout 5 --retry 5 --retry-delay 5 --retry-max-time 25 --proxy-insecure -x "${qbt_curl_proxy}" "${@}"
  366. fi
  367. }
  368. #
  369. curl() {
  370. if ! curl_curl "${@}"; then
  371. echo 'error_url'
  372. fi
  373. }
  374. #######################################################################################################################################################
  375. # 3: git test download functions - default is no proxy - git is a test function and git_git is the command function
  376. #######################################################################################################################################################
  377. git_git() {
  378. if [[ -z "${qbt_git_proxy}" ]]; then
  379. "$(type -P git)" "${@}"
  380. else
  381. "$(type -P git)" -c http.sslVerify=false -c http.https://github.com.proxy="${qbt_git_proxy}" "${@}"
  382. fi
  383. }
  384. #
  385. git() {
  386. if [[ "${2}" = '-t' ]]; then
  387. url_test="${1}"
  388. tag_flag="${2}"
  389. tag_test="${3}"
  390. else
  391. url_test="${11}" # 11th place in our download folder function
  392. fi
  393. #
  394. if ! curl -I "${url_test%\.git}" &> /dev/null; then
  395. echo
  396. echo -e " ${cy}There is an issue with your proxy settings or network connection${cend}"
  397. echo
  398. exit
  399. fi
  400. #
  401. status="$(
  402. git_git ls-remote --exit-code "${url_test}" "${tag_flag}" "${tag_test}" &> /dev/null
  403. echo "${?}"
  404. )"
  405. #
  406. if [[ "${tag_flag}" = '-t' && "${status}" = '0' ]]; then
  407. echo "${tag_test}"
  408. elif [[ "${tag_flag}" = '-t' && "${status}" -ge '1' ]]; then
  409. echo 'error_tag'
  410. else
  411. if ! git_git "${@}"; then
  412. echo
  413. echo -e " ${cy}There is an issue with your proxy settings or network connection${cend}"
  414. echo
  415. exit
  416. fi
  417. fi
  418. }
  419. #
  420. test_git_ouput() {
  421. if [[ "${1}" = 'error_tag' ]]; then
  422. echo -e "${tn} ${cy}Sorry, the provided ${3} tag ${cr}$2${cend}${cy} is not valid${cend}"
  423. fi
  424. }
  425. #######################################################################################################################################################
  426. # 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.
  427. # If nothing is specified or the switch is not used it defaults to the hard-coded path relative to the scripts location - qbittorrent-build
  428. #######################################################################################################################################################
  429. set_build_directory() {
  430. if [[ -n "${qbt_build_dir}" ]]; then
  431. if [[ "${qbt_build_dir}" =~ ^/ ]]; then
  432. qbt_install_dir="${qbt_build_dir}"
  433. qbt_install_dir_short="${qbt_install_dir/$HOME/\~}"
  434. else
  435. qbt_install_dir="${qbt_working_dir}/${qbt_build_dir}"
  436. qbt_install_dir_short="${qbt_working_dir_short}/${qbt_build_dir}"
  437. fi
  438. fi
  439. #
  440. ## Set lib and include directory paths based on install path.
  441. include_dir="${qbt_install_dir}/include"
  442. lib_dir="${qbt_install_dir}/lib"
  443. #
  444. ## Define some build specific variables
  445. LOCAL_USER_HOME="${HOME}" # Get the local user's home dir path before we contain HOME to the build dir.
  446. HOME="${qbt_install_dir}"
  447. PATH="${qbt_install_dir}/bin${PATH:+:${qbt_local_paths}}"
  448. PKG_CONFIG_PATH="${lib_dir}/pkgconfig"
  449. }
  450. #######################################################################################################################################################
  451. # This function sets some compiler flags globally - b2 settings are set in the ~/user-config.jam set in the installation_modules function
  452. #######################################################################################################################################################
  453. custom_flags_set() {
  454. CXXFLAGS="${optimize/*/$optimize }-std=${cxx_standard} -static -w ${qbt_strip_flags} -I${include_dir}"
  455. CPPFLAGS="${optimize/*/$optimize }-static -w ${qbt_strip_flags} -I${include_dir}"
  456. LDFLAGS="${optimize/*/$optimize }-static -L${lib_dir}"
  457. }
  458. #
  459. custom_flags_reset() {
  460. CXXFLAGS="${optimize/*/$optimize } -w -std=${cxx_standard}"
  461. CPPFLAGS="${optimize/*/$optimize } -w"
  462. LDFLAGS=""
  463. }
  464. #######################################################################################################################################################
  465. # This function is where we set your URL that we use with other functions.
  466. #######################################################################################################################################################
  467. set_module_urls() {
  468. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  469. libexecinfo_dev_url="${CDN_URL}/${cross_arch}/$(apk info libexecinfo-dev | awk '{print $1}' | head -n 1).apk"
  470. libexecinfo_static_url="${CDN_URL}/${cross_arch}/$(apk info libexecinfo-static | awk '{print $1}' | head -n 1).apk"
  471. fi
  472. #
  473. cmake_github_tag="$(git_git ls-remote -q -t --refs https://github.com/userdocs/cmake-qbittorrent-nox-static.git | awk '{sub("refs/tags/", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
  474. cmake_debian_version=${cmake_github_tag%_*}
  475. ninja_debian_version=${cmake_github_tag#*_}
  476. #
  477. ninja_github_tag="master"
  478. ninja_version="$(curl https://raw.githubusercontent.com/ninja-build/ninja/master/src/version.cc | sed -rn 's|const char\* kNinjaVersion = "(.*)";|\1|p')"
  479. #
  480. if [[ ! "${what_id}" =~ ^(alpine)$ ]]; then
  481. #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)"
  482. #bison_url="https://ftp.gnu.org/gnu/bison/bison-${bison_version}.tar.gz"
  483. bison_url="https://ftp.gnu.org/gnu/bison/$(grep -Eo 'bison-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl https://ftp.gnu.org/gnu/bison/) | sort -V | tail -1)"
  484. fi
  485. #
  486. if [[ ! "${what_id}" =~ ^(alpine)$ ]]; then
  487. #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)"
  488. #gawk_url="https://ftp.gnu.org/gnu/gawk/gawk-${gawk_version}.tar.gz"
  489. gawk_url="https://ftp.gnu.org/gnu/gawk/$(grep -Eo 'gawk-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl https://ftp.gnu.org/gnu/gawk/) | sort -V | tail -1)"
  490. fi
  491. #
  492. if [[ ! "${what_id}" =~ ^(alpine)$ ]]; then
  493. if [[ "${what_version_codename}" =~ ^(hirsute)$ ]]; then
  494. #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)"
  495. #glibc_url="https://ftp.gnu.org/gnu/libc/glibc-${glibc_version}.tar.gz"
  496. #glibc_url="https://ftp.gnu.org/gnu/glibc/$(grep -Eo 'glibc-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl https://ftp.gnu.org/gnu/glibc/) | sort -V | tail -1)"
  497. glibc_url="https://ftp.gnu.org/gnu/libc/glibc-2.33.tar.gz" # pin to the same version for this OS otherwise we get build errors
  498. else
  499. glibc_url="https://ftp.gnu.org/gnu/libc/glibc-2.31.tar.gz" # pin to the same version for this OS otherwise we get build errors
  500. fi
  501. fi
  502. #
  503. zlib_github_tag="develop" # use this to fix arm cross building with cmake until a new release including these fixes is available (>2.0.5)
  504. # zlib_github_version="$(git_git ls-remote -q -t --refs https://github.com/zlib-ng/zlib-ng | awk '{sub("refs/tags/", "");sub("(.*)(-[^0-9].*)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
  505. zlib_version="$(curl https://raw.githubusercontent.com/zlib-ng/zlib-ng/${zlib_github_tag}/zlib.h.in | sed -rn 's|#define ZLIB_VERSION "(.*)"|\1|p')" # get the version from the headers
  506. zlib_github_url="https://github.com/zlib-ng/zlib-ng.git"
  507. #
  508. #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)"
  509. #zlib_url="https://github.com/madler/zlib/archive/${zlib_github_tag}.tar.gz"
  510. #
  511. iconv_url="https://ftp.gnu.org/gnu/libiconv/$(grep -Eo 'libiconv-([0-9]{1,3}[.]?)([0-9]{1,3}[.]?)([0-9]{1,3}?)\.tar.gz' <(curl https://ftp.gnu.org/gnu/libiconv/) | sort -V | tail -1)"
  512. #
  513. 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)"
  514. icu_url="https://github.com/unicode-org/icu/releases/download/release-${icu_github_tag}/icu4c-${icu_github_tag/-/_}-src.tgz"
  515. #
  516. openssl_github_tag="$(git_git ls-remote -q -t --refs https://github.com/openssl/openssl.git | awk '/openssl/{sub("refs/tags/", "");sub("(.*)(v6|rc|alpha|beta)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n1)"
  517. openssl_version="${openssl_github_tag#openssl-}"
  518. openssl_url="https://github.com/openssl/openssl/archive/${openssl_github_tag}.tar.gz"
  519. #
  520. boost_version="${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)}"
  521. boost_github_tag="boost-${boost_version}"
  522. boost_url="https://boostorg.jfrog.io/artifactory/main/release/${boost_version}/source/boost_${boost_version//./_}.tar.gz"
  523. 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")"
  524. boost_github_url="https://github.com/boostorg/boost.git"
  525. #
  526. if [[ "${qbt_qt_version}" =~ ^6\. ]]; then
  527. 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)"
  528. #
  529. qtbase_github_tag="$(grep -Eom1 "v${qbt_qt_version}.([0-9]{1,2})" <<< "${qt_github_tag_list}")"
  530. # qtbase_github_url="https://github.com/qt/qtbase.git"
  531. #
  532. qttools_github_tag="$(grep -Eom1 "v${qbt_qt_version}.([0-9]{1,2})" <<< "${qt_github_tag_list}")"
  533. #qttools_github_url="https://github.com/qt/qttools.git"
  534. #
  535. qtbase_url="https://download.qt.io/official_releases/qt/${qbt_qt_version}/${qtbase_github_tag/v/}/submodules/qtbase-everywhere-src-${qtbase_github_tag/v/}.tar.xz"
  536. qttools_url="https://download.qt.io/official_releases/qt/${qbt_qt_version}/${qttools_github_tag/v/}/submodules/qttools-everywhere-src-${qttools_github_tag/v/}.tar.xz"
  537. #
  538. qbt_qt_full_version="${qtbase_github_tag}"
  539. else
  540. qtbase_github_tag="kde/5.15"
  541. qtbase_github_url="https://invent.kde.org/qt/qt/qtbase.git"
  542. #
  543. qttools_github_tag="kde/5.15"
  544. qttools_github_url="https://invent.kde.org/qt/qt/qttools.git"
  545. #
  546. qbt_qt_full_version="$(curl "https://invent.kde.org/qt/qt/qtbase/-/raw/${qtbase_github_tag}/.qmake.conf" | sed -rn 's|MODULE_VERSION = (.*)|\1|p')" # get the version from the headers
  547. fi
  548. #
  549. libtorrent_github_url="https://github.com/arvidn/libtorrent.git"
  550. 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)"
  551. libtorrent_github_tag_default="$(grep -Eom1 "v${libtorrent_version}.([0-9]{1,2})" <<< "${libtorrent_github_tags_list}")"
  552. libtorrent_github_tag="${libtorrent_github_tag:-$libtorrent_github_tag_default}"
  553. #
  554. qbittorrent_github_url="https://github.com/qbittorrent/qBittorrent.git"
  555. 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)"
  556. qbittorrent_github_tag="${qbitorrent_github_tag:-$qbittorrent_github_tag_default}"
  557. #
  558. url_test="$(curl -so /dev/null "https://www.google.com")"
  559. }
  560. #######################################################################################################################################################
  561. # This function verifies the module names from the array qbt_modules in the default values function.
  562. #######################################################################################################################################################
  563. installation_modules() {
  564. params_count="${#}"
  565. params_test=1
  566. #
  567. ## remove modules from the delete array from the qbt_modules array
  568. for target in "${delete[@]}"; do
  569. for i in "${!qbt_modules[@]}"; do
  570. if [[ "${qbt_modules[i]}" = "${target}" ]]; then
  571. unset 'qbt_modules[i]'
  572. fi
  573. done
  574. done
  575. #
  576. while [[ "${params_test}" -le "${params_count}" && "${params_count}" -gt '1' ]]; do
  577. if [[ "${qbt_modules[*]}" =~ ${*:$params_test:1} ]]; then
  578. :
  579. else
  580. qbt_modules_test="fail"
  581. fi
  582. params_test="$((params_test + 1))"
  583. done
  584. #
  585. if [[ "${params_count}" -le '1' ]]; then
  586. if [[ "${qbt_modules[*]}" =~ ${*:$params_test:1} && -n "${*:$params_test:1}" ]]; then
  587. :
  588. else
  589. qbt_modules_test="fail"
  590. fi
  591. fi
  592. #
  593. ## Activate all validated modules for installation and define some core variables.
  594. if [[ "${qbt_modules_test}" != 'fail' ]]; then
  595. if [[ "${*}" =~ ([[:space:]]|^)"all"([[:space:]]|$) ]]; then
  596. for module in "${qbt_modules[@]}"; do
  597. eval "skip_${module}=no"
  598. done
  599. else
  600. for module in "${@}"; do
  601. eval "skip_${module}=no"
  602. done
  603. fi
  604. #
  605. ## Create the directories we need.
  606. mkdir -p "${qbt_install_dir}/logs"
  607. mkdir -p "${PKG_CONFIG_PATH}"
  608. mkdir -p "${qbt_install_dir}/completed"
  609. #
  610. ## Set some python variables we need.
  611. python_major="$(python"${qbt_python_version}" -c "import sys; print(sys.version_info[0])")"
  612. python_minor="$(python"${qbt_python_version}" -c "import sys; print(sys.version_info[1])")"
  613. python_micro="$(python"${qbt_python_version}" -c "import sys; print(sys.version_info[2])")"
  614. #
  615. python_short_version="${python_major}.${python_minor}"
  616. python_link_version="${python_major}${python_minor}"
  617. #
  618. 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"
  619. #
  620. ## Echo the build directory.
  621. echo -e "${tn} ${uyc} ${tb}Install Prefix${cend} : ${clc}${qbt_install_dir_short}${cend}"
  622. #
  623. ## Some basic help
  624. echo -e "${tn} ${uyc} ${tb}Script help${cend} : ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-h${cend}"
  625. else
  626. echo -e "${tn} ${urc} ${tb}One or more of the provided modules are not supported${cend}"
  627. echo -e "${tn} ${uyc} ${tb}Below is a list of supported modules${cend}"
  628. echo -e "${tn} ${umc} ${clm}${qbt_modules[*]}${tn}${cend}"
  629. exit
  630. fi
  631. }
  632. #######################################################################################################################################################
  633. # This function will test to see if a Jamfile patch file exists via the variable patches_github_url for the tag used.
  634. #######################################################################################################################################################
  635. apply_patches() {
  636. patch_app_name="${1}"
  637. # 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
  638. [[ "${libtorrent_github_tag}" =~ ^RC_ ]] && libtorrent_patch_tag="${libtorrent_github_tag}"
  639. [[ "${libtorrent_github_tag}" =~ ^libtorrent- ]] && libtorrent_patch_tag="${libtorrent_github_tag#libtorrent-}" && libtorrent_patch_tag="${libtorrent_patch_tag//_/\.}"
  640. [[ "${libtorrent_github_tag}" =~ ^v[0-9] ]] && libtorrent_patch_tag="${libtorrent_github_tag#v}"
  641. # 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.
  642. default_jamfile="${libtorrent_patch_tag//./\_}"
  643. # 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.
  644. if [[ $(grep -o '_' <<< "$default_jamfile" | wc -l) -le 1 ]]; then
  645. default_jamfile="RC_${default_jamfile}"
  646. elif [[ $(grep -o '_' <<< "$default_jamfile" | wc -l) -ge 2 ]]; then
  647. default_jamfile="RC_${default_jamfile%_*}"
  648. fi
  649. #
  650. qbittorrent_patch_tag="${qbittorrent_github_tag#release-}" # qbittorrent has a consistent tag format of release-4.3.1.
  651. #
  652. 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.
  653. return
  654. fi
  655. #
  656. if [[ "${patch_app_name}" == 'bootstrap' ]]; then
  657. mkdir -p "${qbt_install_dir}/patches/libtorrent/${libtorrent_patch_tag}"
  658. mkdir -p "${qbt_install_dir}/patches/qbittorrent/${qbittorrent_patch_tag}"
  659. echo
  660. echo -e " ${cly}Using the defaults, these directories have been created:${cend}"
  661. echo
  662. echo -e " ${clc}$qbt_install_dir_short/patches/libtorrent/${libtorrent_patch_tag}${cend}"
  663. echo
  664. echo -e " ${clc}$qbt_install_dir_short/patches/qbittorrent/${qbittorrent_patch_tag}${cend}"
  665. echo
  666. 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."
  667. else
  668. patch_tag="${patch_app_name}_patch_tag"
  669. patch_dir="${qbt_install_dir}/patches/${patch_app_name}/${!patch_tag}"
  670. patch_file="${patch_dir}/patch"
  671. patch_file_url="https://raw.githubusercontent.com/${qbt_patches_url}/master/patches/${patch_app_name}/${!patch_tag}/patch"
  672. patch_jamfile="${qbt_install_dir}/libtorrent/Jamfile"
  673. patch_jamfile_url="https://raw.githubusercontent.com/${qbt_patches_url}/master/patches/${patch_app_name}/${!patch_tag}/Jamfile"
  674. #
  675. [[ ! -d "${patch_dir}" ]] && mkdir -p "${patch_dir}"
  676. #
  677. if [[ -f "${patch_file}" ]]; then
  678. echo
  679. echo -e " ${utick} ${cr}Using ${!patch_tag} existing patch file${cend}"
  680. [[ "${patch_app_name}" == 'qbittorrent' ]] && echo # purely comsetic
  681. else
  682. if curl_curl "${patch_file_url}" -o "${patch_file}"; then
  683. echo
  684. echo -e " ${utick} ${cr}Using ${!patch_tag} downloaded patch file${cend}"
  685. [[ "${patch_app_name}" == 'qbittorrent' ]] && echo # purely comsetic
  686. fi
  687. fi
  688. #
  689. if [[ "${patch_app_name}" == 'libtorrent' ]]; then
  690. if [[ -f "${patch_dir}/Jamfile" ]]; then
  691. cp -f "${patch_dir}/Jamfile" "${patch_jamfile}"
  692. echo
  693. echo -e " ${utick} ${cr}Using existing custom Jamfile file${cend}"
  694. echo
  695. elif curl_curl "${patch_jamfile_url}" -o "${patch_jamfile}"; then
  696. echo
  697. echo -e " ${utick} ${cr}Using downloaded custom Jamfile file${cend}"
  698. echo
  699. else
  700. curl_curl "https://raw.githubusercontent.com/arvidn/libtorrent/${default_jamfile}/Jamfile" -o "${patch_jamfile}"
  701. echo
  702. echo -e " ${utick} ${cr}Using libtorrent branch master Jamfile file${cend}"
  703. echo
  704. fi
  705. fi
  706. #
  707. [[ -f "${patch_file}" ]] && patch -p1 < "${patch_file}"
  708. fi
  709. }
  710. #######################################################################################################################################################
  711. # This function is to test a directory exists before attemtping to cd and fail with and exit code if it doesn't.
  712. #######################################################################################################################################################
  713. _cd() {
  714. if ! cd "${1}" > /dev/null 2>&1; then
  715. echo -e "This directory does not exist. There is a problem"
  716. echo
  717. echo -e "${clr}${1}${cend}"
  718. echo
  719. exit 1
  720. fi
  721. }
  722. #######################################################################################################################################################
  723. # This function is for downloading source code archives
  724. #######################################################################################################################################################
  725. download_file() {
  726. if [[ -n "${1}" ]]; then
  727. url_filename="${2}"
  728. [[ -n "${3}" ]] && subdir="/${3}" || subdir=""
  729. echo -e "${tn} ${uplus}${cg} Installing $1${cend}${tn}"
  730. file_name="${qbt_install_dir}/${1}.tar.gz"
  731. [[ -f "${file_name}" ]] && rm -rf {"${qbt_install_dir:?}/$(tar tf "${file_name}" | grep -Eom1 "(.*)[^/]")","${file_name}"}
  732. curl "${url_filename}" -o "${file_name}"
  733. _cmd tar xf "${file_name}" -C "${qbt_install_dir}"
  734. app_dir="${qbt_install_dir}/$(tar tf "${file_name}" | head -1 | cut -f1 -d"/")${subdir}"
  735. mkdir -p "${app_dir}"
  736. [[ "${1}" != 'boost' ]] && _cd "${app_dir}"
  737. else
  738. echo
  739. echo "You must provide a filename name for the function - download_file"
  740. echo "It creates the name from the appname_github_tag variable set in the URL section"
  741. echo
  742. echo "download_file filename url"
  743. echo
  744. exit
  745. fi
  746. }
  747. #######################################################################################################################################################
  748. # This function is for downloading git releases based on their tag.
  749. #######################################################################################################################################################
  750. download_folder() {
  751. if [[ -n "${1}" ]]; then
  752. github_tag="${1}_github_tag"
  753. url_github="${2}"
  754. [[ -n "${3}" ]] && subdir="/${3}" || subdir=""
  755. echo -e "${tn} ${uplus}${cg} Installing ${1}${cend}${tn}"
  756. folder_name="${qbt_install_dir}/${1}"
  757. folder_inc="${qbt_install_dir}/include/${1}"
  758. [[ -d "${folder_name}" ]] && rm -rf "${folder_name}"
  759. [[ "${1}" == 'libtorrent' && -d "${folder_inc}" ]] && rm -rf "${folder_inc}"
  760. git config --global advice.detachedHead false
  761. _cmd git clone --no-tags --single-branch --branch "${!github_tag}" --shallow-submodules --recurse-submodules -j"$(nproc)" --depth 1 "${url_github}" "${folder_name}"
  762. mkdir -p "${folder_name}${subdir}"
  763. [[ -d "${folder_name}${subdir}" ]] && _cd "${folder_name}${subdir}"
  764. else
  765. echo
  766. echo "You must provide a tag name for the function - download_folder"
  767. echo "It creates the tag from the appname_github_tag variable set in the URL section"
  768. echo
  769. echo "download_folder tagname url subdir"
  770. echo
  771. exit
  772. fi
  773. }
  774. #######################################################################################################################################################
  775. # This function is for removing files and folders we no longer need
  776. #######################################################################################################################################################
  777. delete_function() {
  778. if [[ -n "${1}" ]]; then
  779. if [[ -z "${qbt_skip_delete}" ]]; then
  780. [[ "$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}"
  781. #
  782. file_name="${qbt_install_dir}/${1}.tar.gz"
  783. folder_name="${qbt_install_dir}/${1}"
  784. [[ -f "${file_name}" ]] && rm -rf {"${qbt_install_dir:?}/$(tar tf "${file_name}" | grep -Eom1 "(.*)[^/]")","${file_name}"}
  785. [[ -d "${folder_name}" ]] && rm -rf "${folder_name}"
  786. [[ -d "${qbt_working_dir}" ]] && _cd "${qbt_working_dir}"
  787. else
  788. [[ "${2}" = 'last' ]] && echo -e "${tn} ${uyc}${clr} Skipping $1 deletion${cend}${tn}" || echo -e "${tn} ${uyc}${clr} Skipping ${1} deletion${cend}"
  789. fi
  790. else
  791. echo
  792. echo "The delete_function works in tandem with the application_name function"
  793. echo "Set the appname using the application_name function then use this function."
  794. echo
  795. echo "delete_function appname"
  796. echo
  797. exit
  798. fi
  799. }
  800. #######################################################################################################################################################
  801. # This function sets the name of the application to be used with the functions download_file/folder and delete_function
  802. #######################################################################################################################################################
  803. application_name() {
  804. last_app_name="skip_${app_name}"
  805. app_name="${1}"
  806. app_name_skip="skip_${app_name}"
  807. app_url="${app_name}_url"
  808. app_github_url="${app_name}_github_url"
  809. }
  810. #######################################################################################################################################################
  811. # This function skips the deletion of the -n flag is supplied
  812. #######################################################################################################################################################
  813. application_skip() {
  814. if [[ "${1}" = 'last' ]]; then
  815. echo -e "${tn} ${uyc} Skipping ${clm}$app_name${cend} module installation${tn}"
  816. else
  817. echo -e "${tn} ${uyc} Skipping ${clm}$app_name${cend} module installation"
  818. fi
  819. }
  820. #######################################################################################################################################################
  821. # This function installs qt
  822. #######################################################################################################################################################
  823. install_qbittorrent() {
  824. if [[ -f "${qbt_install_dir}/completed/qbittorrent-nox" ]]; then
  825. #
  826. if [[ "$(id -un)" = 'root' ]]; then
  827. mkdir -p "/usr/local/bin"
  828. cp -rf "${qbt_install_dir}/completed/qbittorrent-nox" "/usr/local/bin"
  829. else
  830. mkdir -p "${HOME}/bin"
  831. cp -rf "${qbt_install_dir}/completed/qbittorrent-nox" "${LOCAL_USER_HOME}/bin"
  832. fi
  833. #
  834. echo -e "${tn} ${uplus} qbittorrent-nox has been installed!${cend}${tn}"
  835. echo -e " Run it using this command:${tn}"
  836. #
  837. [[ "$(id -un)" = 'root' ]] && echo -e " ${cg}qbittorrent-nox${cend}${tn}" || echo -e " ${cg}~/bin/qbittorrent-nox${cend}${tn}"
  838. #
  839. exit
  840. else
  841. echo -e "${tn}qbittorrent-nox has not been built to the defined install directory:${tn}"
  842. echo -e "${cg}${qbt_install_dir_short}/completed${cend}${tn}"
  843. echo -e "Please build it using the script first then install${tn}"
  844. #
  845. exit
  846. fi
  847. }
  848. #######################################################################################################################################################
  849. # wtf is wrong now?
  850. #######################################################################################################################################################
  851. _cmd() {
  852. if ! "${@}"; then
  853. echo
  854. exit 1
  855. fi
  856. }
  857. #######################################################################################################################################################
  858. # build command test
  859. #######################################################################################################################################################
  860. post_command() {
  861. outcome="${PIPESTATUS[0]}"
  862. [[ -n "${1}" ]] && command_type="${1}"
  863. if [[ ${outcome} -gt '0' ]]; then
  864. echo -e "${tn} ${urc} ${clr}Error: The ${command_type} command produced an exit code greater than 0 - Check the logs${cend}${tn}"
  865. exit "${outcome}"
  866. fi
  867. }
  868. #######################################################################################################################################################
  869. # Multi Arch
  870. #######################################################################################################################################################
  871. _multi_arch() {
  872. if [[ "${qbt_cross_name}" =~ ^(x86_64|armhf|armv7|aarch64)$ ]]; then
  873. if [[ "${what_id}" =~ ^(alpine|debian|ubuntu)$ ]]; then
  874. #
  875. [[ "${1}" != 'bootstrap' ]] && echo -e "${tn} ${ugc}${cly} Using multiarch - arch: ${qbt_cross_name} host: ${what_id} target: ${qbt_cross_target}${cend}"
  876. #
  877. case "${qbt_cross_name}" in
  878. armhf)
  879. case "${qbt_cross_target}" in
  880. alpine)
  881. cross_arch="armhf"
  882. qbt_cross_host="arm-linux-musleabihf"
  883. qbt_zlib_arch="armv5"
  884. ;;&
  885. debian | ubuntu)
  886. cross_arch="armel"
  887. qbt_cross_host="arm-linux-gnueabi"
  888. ;;&
  889. *)
  890. qbt_cross_openssl="linux-armv4"
  891. qbt_cross_boost="arm"
  892. qbt_cross_qtbase="linux-arm-gnueabi-g++"
  893. ;;
  894. esac
  895. ;;
  896. armv7)
  897. case "${qbt_cross_target}" in
  898. alpine)
  899. cross_arch="armv7"
  900. qbt_cross_host="armv7r-linux-musleabihf"
  901. qbt_zlib_arch="armv7"
  902. ;;&
  903. debian | ubuntu)
  904. cross_arch="armhf"
  905. qbt_cross_host="arm-linux-gnueabihf"
  906. ;;&
  907. *)
  908. qbt_cross_openssl="linux-armv4"
  909. qbt_cross_boost="arm"
  910. qbt_cross_qtbase="linux-arm-gnueabi-g++"
  911. ;;
  912. esac
  913. ;;
  914. aarch64)
  915. case "${qbt_cross_target}" in
  916. alpine)
  917. cross_arch="aarch64"
  918. qbt_cross_host="aarch64-linux-musl"
  919. qbt_zlib_arch="aarch64"
  920. ;;&
  921. debian | ubuntu)
  922. cross_arch="arm64"
  923. qbt_cross_host="aarch64-linux-gnu"
  924. ;;&
  925. *)
  926. qbt_cross_openssl="linux-aarch64"
  927. qbt_cross_boost="arm"
  928. qbt_cross_qtbase="linux-aarch64-gnu-g++"
  929. ;;
  930. esac
  931. ;;
  932. x86_64)
  933. case "${qbt_cross_target}" in
  934. alpine)
  935. cross_arch="x86_64"
  936. qbt_cross_host="x86_64-linux-musl"
  937. qbt_zlib_arch="x86_64"
  938. ;;&
  939. debian | ubuntu)
  940. cross_arch="x86_64"
  941. qbt_cross_host="x86_64-linux-gnu"
  942. ;;&
  943. *)
  944. qbt_cross_openssl="linux-x86_64"
  945. qbt_cross_boost="x86_64"
  946. qbt_cross_qtbase="linux-g++-64"
  947. ;;
  948. esac
  949. ;;
  950. esac
  951. #
  952. [[ "${1}" == 'bootstrap' ]] && return
  953. #
  954. CHOST="${qbt_cross_host}"
  955. CC="${qbt_cross_host}-gcc"
  956. AR="${qbt_cross_host}-ar"
  957. CXX="${qbt_cross_host}-g++"
  958. #
  959. mkdir -p "${qbt_install_dir}/logs"
  960. #
  961. if [[ "${qbt_cross_target}" =~ ^(alpine)$ && ! -f "${qbt_install_dir}/${qbt_cross_host}.tar.gz" ]]; then
  962. curl "https://github.com/userdocs/musl-cross-make/releases/latest/download/${qbt_cross_host}.tar.gz" > "${qbt_install_dir}/${qbt_cross_host}.tar.gz"
  963. tar xf "${qbt_install_dir}/${qbt_cross_host}.tar.gz" --strip-components=1 -C "${qbt_install_dir}"
  964. fi
  965. #
  966. _fix_multiarch_static_links "${qbt_cross_host}"
  967. #
  968. multi_bison=("--host=${qbt_cross_host}") # ${multi_bison[@]}
  969. #
  970. multi_gawk=("--host=${qbt_cross_host}") # ${multi_gawk[@]}
  971. #
  972. multi_glibc=("--host=${qbt_cross_host}") # ${multi_glibc[@]}
  973. #
  974. multi_iconv=("--host=${qbt_cross_host}") # ${multi_iconv[@]}
  975. #
  976. multi_icu=("--host=${qbt_cross_host}" "-with-cross-build=${qbt_install_dir}/icu/cross") # ${multi_icu[@]}
  977. #
  978. multi_openssl=("./Configure" "${qbt_cross_openssl}") # ${multi_openssl[@]}
  979. #
  980. multi_qtbase=("-xplatform" "${qbt_cross_qtbase}") # ${multi_qtbase[@]}
  981. #
  982. if [[ "${qbt_build_tool}" = 'cmake' ]]; then
  983. multi_libtorrent=("-D CMAKE_CXX_COMPILER=${qbt_cross_host}-g++") # ${multi_libtorrent[@]}
  984. multi_qbittorrent=("-D CMAKE_CXX_COMPILER=${qbt_cross_host}-g++") # ${multi_qbittorrent[@]}
  985. else
  986. b2_toolset="gcc-arm"
  987. 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"
  988. multi_libtorrent=("toolset=${b2_toolset}") # ${multi_libtorrent[@]}
  989. #
  990. multi_qbittorrent=("--host=${qbt_cross_host}") # ${multi_qbittorrent[@]}
  991. fi
  992. return
  993. else
  994. echo
  995. echo -e " ${ulrc} Multiarch only works with Alpine Linux (native or docker)${cend}"
  996. echo
  997. exit 1
  998. fi
  999. else
  1000. multi_openssl=("./config") # ${multi_openssl[@]}
  1001. return
  1002. fi
  1003. return
  1004. }
  1005. #######################################################################################################################################################
  1006. # Github Actions release info
  1007. #######################################################################################################################################################
  1008. _release_info() {
  1009. _error_tag
  1010. #
  1011. echo -e "${tn} ${ugc} ${cly}Release boot-strapped${cend}"
  1012. #
  1013. release_info_dir="${qbt_install_dir}/release_info"
  1014. #
  1015. mkdir -p "${release_info_dir}"
  1016. #
  1017. cat > "${release_info_dir}/tag.md" <<- TAG_INFO
  1018. ${qbittorrent_github_tag#v}_${libtorrent_github_tag}
  1019. TAG_INFO
  1020. #
  1021. cat > "${release_info_dir}/title.md" <<- TITLE_INFO
  1022. qbittorrent ${qbittorrent_github_tag#release-} libtorrent ${libtorrent_github_tag#v}
  1023. TITLE_INFO
  1024. #
  1025. cat > "${release_info_dir}/release.md" <<- RELEASE_INFO
  1026. ## Build info
  1027. Qbittorrent: ${qbittorrent_github_tag#release-}
  1028. Qt: ${qbt_qt_full_version#v} - see notes
  1029. Libtorrent: ${libtorrent_github_tag#v}
  1030. Boost: ${boost_version#v}
  1031. OpenSSL: ${openssl_version}
  1032. zlib-ng: ${zlib_version%.*}
  1033. ## Architectures and build info
  1034. These builds were created on Alpine linux using [custom prebuilt musl toolchains](https://github.com/userdocs/musl-cross-make) for:
  1035. | Arch | Alpine Cross build files |
  1036. | :-----: | :----------------------: |
  1037. | armhf | arm-linux-musleabihf |
  1038. | armv7 | armv7r-linux-musleabihf |
  1039. | aarch64 | aarch64-linux-musl |
  1040. | x86_64 | x86_64-linux-musl |
  1041. ## Build matrix for libtorrent ${libtorrent_github_tag}
  1042. ℹ️ With Qbittorrent 4.4.0 onwards all cmake build use Qt6 and qmake builds use Qt5 until phased out.
  1043. ℹ️ [Check the build table for more info](https://github.com/userdocs/qbittorrent-nox-static#build-table---dependencies---arch---os---build-tools)
  1044. ⚠️ Binary builds are not stripped by default to preserve stacktrace / debugging features built into qBittorrent.
  1045. RELEASE_INFO
  1046. #
  1047. return
  1048. }
  1049. #######################################################################################################################################################
  1050. # cmake installation
  1051. #######################################################################################################################################################
  1052. _cmake() {
  1053. if [[ "${qbt_build_tool}" == 'cmake' ]]; then
  1054. echo -e "${tn} ${ulbc}${clr} Checking if cmake and ninja need to be installed${cend}"
  1055. mkdir -p "${qbt_install_dir}/bin"
  1056. _cd "${qbt_install_dir}"
  1057. #
  1058. if [[ "${what_id}" =~ ^(debian|ubuntu)$ ]]; then
  1059. if [[ "$(cmake --version 2> /dev/null | awk 'NR==1{print $3}')" != "${cmake_debian_version}" ]]; then
  1060. curl "https://github.com/userdocs/cmake-qbittorrent-nox-static/releases/latest/download/${what_id}-${what_version_codename}-cmake-$(dpkg --print-architecture).tar.gz" > "${what_id}-${what_version_codename}-cmake-$(dpkg --print-architecture).tar.gz"
  1061. post_command "Debian cmake and ninja installation"
  1062. tar xf "${what_id}-${what_version_codename}-cmake-$(dpkg --print-architecture).tar.gz" --strip-components=1 -C "${qbt_install_dir}"
  1063. rm -f "${what_id}-${what_version_codename}-cmake-$(dpkg --print-architecture).deb"
  1064. #
  1065. echo -e "${tn} ${uyc} Installed cmake: ${cly}${cmake_debian_version}${tn}"
  1066. echo -e " ${uyc} Installed ninja: ${cly}${ninja_debian_version}"
  1067. else
  1068. echo -e "${tn} ${uyc} Using cmake: ${cly}${cmake_debian_version}${tn}"
  1069. echo -e " ${uyc} Using ninja: ${cly}${ninja_debian_version}"
  1070. fi
  1071. fi
  1072. #
  1073. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  1074. if [[ "$("${qbt_install_dir}/bin/ninja" --version 2> /dev/null)" != "${ninja_version}" ]]; then
  1075. download_folder ninja https://github.com/ninja-build/ninja.git
  1076. cmake -Wno-dev -Wno-deprecated -B build \
  1077. -D CMAKE_BUILD_TYPE="release" \
  1078. -D CMAKE_CXX_STANDARD="${standard}" \
  1079. -D CMAKE_CXX_FLAGS="${CXXFLAGS}" \
  1080. -D CMAKE_INSTALL_PREFIX="${qbt_install_dir}" |& tee -a "${qbt_install_dir}/logs/ninja.log.txt"
  1081. cmake --build build -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/ninja.log.txt"
  1082. #
  1083. post_command build
  1084. #
  1085. cmake --install build |& tee -a "${qbt_install_dir}/logs/ninja.log.txt"
  1086. _cd "${qbt_install_dir}" && rm -rf "${qbt_install_dir}/ninja"
  1087. fi
  1088. fi
  1089. #
  1090. echo -e "${tn} ${ugc}${clr} cmake and ninja are installed and ready to use${cend}"
  1091. fi
  1092. }
  1093. #######################################################################################################################################################
  1094. # 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
  1095. #######################################################################################################################################################
  1096. _fix_static_links() {
  1097. log_name="$1"
  1098. mapfile -t library_list < <(find "${lib_dir}" -maxdepth 1 -exec bash -c 'basename "$0" ".${0##*.}"' {} \; | sort | uniq -d)
  1099. for file in "${library_list[@]}"; do
  1100. if [[ "$(readlink "${lib_dir}/${file}.so")" != "${file}.a" ]]; then
  1101. ln -fsn "${file}.a" "${lib_dir}/${file}.so"
  1102. echo "${lib_dir}${file}.so changed to point to ${file}.a" >> "${qbt_install_dir}/logs/${log_name}-fix-static-links.log.txt"
  1103. fi
  1104. done
  1105. return
  1106. }
  1107. _fix_multiarch_static_links() {
  1108. if [[ -d "${qbt_install_dir}/${qbt_cross_host}" ]]; then
  1109. log_name="$1"
  1110. multiarch_lib_dir="${qbt_install_dir}/${qbt_cross_host}/lib"
  1111. mapfile -t library_list < <(find "${multiarch_lib_dir}" -maxdepth 1 -exec bash -c 'basename "$0" ".${0##*.}"' {} \; | sort | uniq -d)
  1112. for file in "${library_list[@]}"; do
  1113. if [[ "$(readlink "${multiarch_lib_dir}/${file}.so")" != "${file}.a" ]]; then
  1114. ln -fsn "${file}.a" "${multiarch_lib_dir}/${file}.so"
  1115. echo "${multiarch_lib_dir}${file}.so changed to point to ${file}.a" >> "${qbt_install_dir}/logs/${log_name}-fix-static-links.log.txt"
  1116. fi
  1117. done
  1118. return
  1119. fi
  1120. }
  1121. #######################################################################################################################################################
  1122. # error functions
  1123. #######################################################################################################################################################
  1124. _error_url() {
  1125. [[ "${url_test}" = "error_url" ]] && {
  1126. echo
  1127. echo -e " ${cy}There is an issue with your proxy settings or network connection${cend}"
  1128. echo
  1129. exit
  1130. }
  1131. }
  1132. #
  1133. _error_tag() {
  1134. [[ "${libtorrent_github_tag}" = "error_tag" || "${qbittorrent_github_tag}" = "error_tag" ]] && {
  1135. echo
  1136. exit
  1137. }
  1138. }
  1139. #######################################################################################################################################################
  1140. # Functions part 1: Use some of our functions
  1141. #######################################################################################################################################################
  1142. set_default_values "${@}" # see functions
  1143. #
  1144. check_dependencies # see functions
  1145. #
  1146. set_build_directory # see functions
  1147. #
  1148. set_module_urls # see functions
  1149. #######################################################################################################################################################
  1150. # This section controls our flags that we can pass to the script to modify some variables and behavior.
  1151. #######################################################################################################################################################
  1152. while (("${#}")); do
  1153. case "${1}" in
  1154. -bs | --boot-strap)
  1155. apply_patches bootstrap
  1156. shift
  1157. ;;
  1158. -bs-c | --boot-strap-cmake)
  1159. qbt_build_tool="cmake"
  1160. _cmake
  1161. shift
  1162. ;;
  1163. -bs-r | --boot-strap-release)
  1164. _release_info
  1165. shift
  1166. ;;
  1167. -bs-ma | --boot-strap-multi-arch)
  1168. if [[ -n "${2}" && "${2}" =~ ^(x86_64|armhf|armv7|aarch64)$ ]]; then
  1169. qbt_cross_name="${2}"
  1170. shift 2
  1171. else
  1172. echo
  1173. echo -e " ${ulrc} You must provide a valid arch option when using${cend} ${clb}-ma${cend}"
  1174. echo
  1175. echo -e " ${ulyc} armhf${cend}"
  1176. echo -e " ${ulyc} armv7${cend}"
  1177. echo -e " ${ulyc} aarch64${cend}"
  1178. echo -e " ${ulyc} x86_64${cend}"
  1179. echo
  1180. echo -e " ${ulgc} example usage:${clb} -ma aarch64${cend}"
  1181. echo
  1182. exit 1
  1183. fi
  1184. _multi_arch
  1185. shift
  1186. ;;
  1187. -bs-a | --boot-strap-all)
  1188. apply_patches bootstrap
  1189. _release_info
  1190. _cmake
  1191. _multi_arch
  1192. shift
  1193. ;;
  1194. -d | --debug)
  1195. lt_debug="debug-symbols=on"
  1196. qbt_debug="--enable-debug"
  1197. shift
  1198. ;;
  1199. -n | --no-delete)
  1200. qbt_skip_delete='yes'
  1201. shift
  1202. ;;
  1203. -m | --master)
  1204. libtorrent_github_tag="$(git "${libtorrent_github_url}" -t "RC_${libtorrent_version//./_}")"
  1205. test_git_ouput "${libtorrent_github_tag}" "RC_${libtorrent_version//./_}" "libtorrent"
  1206. #
  1207. qbittorrent_github_tag="$(git "${qbittorrent_github_url}" -t "master")"
  1208. test_git_ouput "${qbittorrent_github_tag}" "master" "qbittorrent"
  1209. shift
  1210. ;;
  1211. -lm | --libtorrent-master)
  1212. libtorrent_github_tag="$(git "${libtorrent_github_url}" -t "RC_${libtorrent_version//./_}")"
  1213. test_git_ouput "${libtorrent_github_tag}" "RC_${libtorrent_version//./_}" "libtorrent"
  1214. shift
  1215. ;;
  1216. -lt | --libtorrent-tag)
  1217. libtorrent_github_tag="$(git "${libtorrent_github_url}" -t "$2")"
  1218. test_git_ouput "${libtorrent_github_tag}" "$2" "libtorrent"
  1219. shift 2
  1220. ;;
  1221. -pr | --patch-repo)
  1222. if [[ "$(curl "https://github.com/${2}")" != 'error_url' ]]; then
  1223. qbt_patches_url="${2}"
  1224. else
  1225. echo
  1226. echo -e " ${cy}This repo does not exist:${cend}"
  1227. echo
  1228. echo -e " https://github.com/${2}"
  1229. echo
  1230. echo -e " ${cy}Please provide a valid username and repo.${cend}"
  1231. echo
  1232. exit
  1233. fi
  1234. shift 2
  1235. ;;
  1236. -qm | --qbittorrent-master)
  1237. qbittorrent_github_tag="$(git "${qbittorrent_github_url}" -t "master")"
  1238. test_git_ouput "${qbittorrent_github_tag}" "master" "qbittorrent"
  1239. shift
  1240. ;;
  1241. -qt | --qbittorrent-tag)
  1242. qbittorrent_github_tag="$(git "${qbittorrent_github_url}" -t "$2")"
  1243. test_git_ouput "${qbittorrent_github_tag}" "$2" "qbittorrent"
  1244. shift 2
  1245. ;;
  1246. -s | --strip)
  1247. qbt_strip_qmake='strip'
  1248. qbt_strip_flags='-s'
  1249. shift
  1250. ;;
  1251. -h | --help)
  1252. echo
  1253. echo -e " ${tb}${tu}Here are a list of available options${cend}"
  1254. echo
  1255. echo -e " ${cg}Use:${cend} ${clb}-b${cend} ${td}or${cend} ${clb}--build-directory${cend} ${cy}Help:${cend} ${clb}-h-b${cend} ${td}or${cend} ${clb}--help-build-directory${cend}"
  1256. echo -e " ${cg}Use:${cend} ${clb}-bv${cend} ${td}or${cend} ${clb}--boost-version${cend} ${cy}Help:${cend} ${clb}-h-bv${cend} ${td}or${cend} ${clb}--help-boost-version${cend}"
  1257. echo -e " ${cg}Use:${cend} ${clb}-c${cend} ${td}or${cend} ${clb}--cmake${cend} ${cy}Help:${cend} ${clb}-h-c${cend} ${td}or${cend} ${clb}--help-cmake${cend}"
  1258. echo -e " ${cg}Use:${cend} ${clb}-d${cend} ${td}or${cend} ${clb}--debug${cend} ${cy}Help:${cend} ${clb}-h-d${cend} ${td}or${cend} ${clb}--help-debug${cend}"
  1259. echo -e " ${cg}Use:${cend} ${clb}-bs${cend} ${td}or${cend} ${clb}--boot-strap${cend} ${cy}Help:${cend} ${clb}-h-bs${cend} ${td}or${cend} ${clb}--help-boot-strap${cend}"
  1260. echo -e " ${cg}Use:${cend} ${clb}-bs-c${cend} ${td}or${cend} ${clb}--boot-strap-cmake${cend} ${cy}Help:${cend} ${clb}-h-bs-c${cend} ${td}or${cend} ${clb}--help-boot-strap-cmake${cend}"
  1261. echo -e " ${cg}Use:${cend} ${clb}-bs-r${cend} ${td}or${cend} ${clb}--boot-strap-release${cend} ${cy}Help:${cend} ${clb}-h-bs-r${cend} ${td}or${cend} ${clb}--help-boot-strap-release${cend}"
  1262. echo -e " ${cg}Use:${cend} ${clb}-bs-ma${cend} ${td}or${cend} ${clb}--boot-strap-multi-arch${cend} ${cy}Help:${cend} ${clb}-h-bs-ma${cend} ${td}or${cend} ${clb}--help-boot-strap-multi-arch${cend}"
  1263. echo -e " ${cg}Use:${cend} ${clb}-bs-a${cend} ${td}or${cend} ${clb}--boot-strap-all${cend} ${cy}Help:${cend} ${clb}-h-bs-a${cend} ${td}or${cend} ${clb}--help-boot-strap-all${cend}"
  1264. echo -e " ${cg}Use:${cend} ${clb}-i${cend} ${td}or${cend} ${clb}--icu${cend} ${cy}Help:${cend} ${clb}-h-i${cend} ${td}or${cend} ${clb}--help-icu${cend}"
  1265. echo -e " ${cg}Use:${cend} ${clb}-lm${cend} ${td}or${cend} ${clb}--libtorrent-master${cend} ${cy}Help:${cend} ${clb}-h-lm${cend} ${td}or${cend} ${clb}--help-libtorrent-master${cend}"
  1266. echo -e " ${cg}Use:${cend} ${clb}-lt${cend} ${td}or${cend} ${clb}--libtorrent-tag${cend} ${cy}Help:${cend} ${clb}-h-lt${cend} ${td}or${cend} ${clb}--help-libtorrent-tag${cend}"
  1267. echo -e " ${cg}Use:${cend} ${clb}-m${cend} ${td}or${cend} ${clb}--master${cend} ${cy}Help:${cend} ${clb}-h-m${cend} ${td}or${cend} ${clb}--help-master${cend}"
  1268. echo -e " ${cg}Use:${cend} ${clb}-ma${cend} ${td}or${cend} ${clb}--multi-arch${cend} ${cy}Help:${cend} ${clb}-h-ma${cend} ${td}or${cend} ${clb}--help-multi-arch${cend}"
  1269. echo -e " ${cg}Use:${cend} ${clb}-n${cend} ${td}or${cend} ${clb}--no-delete${cend} ${cy}Help:${cend} ${clb}-h-n${cend} ${td}or${cend} ${clb}--help-no-delete${cend}"
  1270. echo -e " ${cg}Use:${cend} ${clb}-o${cend} ${td}or${cend} ${clb}--optimize${cend} ${cy}Help:${cend} ${clb}-h-o${cend} ${td}or${cend} ${clb}--help-optimize${cend}"
  1271. echo -e " ${cg}Use:${cend} ${clb}-p${cend} ${td}or${cend} ${clb}--proxy${cend} ${cy}Help:${cend} ${clb}-h-p${cend} ${td}or${cend} ${clb}--help-proxy${cend}"
  1272. echo -e " ${cg}Use:${cend} ${clb}-pr${cend} ${td}or${cend} ${clb}--patch-repo${cend} ${cy}Help:${cend} ${clb}-h-pr${cend} ${td}or${cend} ${clb}--help-patch-repo${cend}"
  1273. echo -e " ${cg}Use:${cend} ${clb}-qm${cend} ${td}or${cend} ${clb}--qbittorrent-master${cend} ${cy}Help:${cend} ${clb}-h-qm${cend} ${td}or${cend} ${clb}--help-qbittorrent-master${cend}"
  1274. echo -e " ${cg}Use:${cend} ${clb}-qt${cend} ${td}or${cend} ${clb}--qbittorrent-tag${cend} ${cy}Help:${cend} ${clb}-h-qt${cend} ${td}or${cend} ${clb}--help-qbittorrent-tag${cend}"
  1275. echo -e " ${cg}Use:${cend} ${clb}-s${cend} ${td}or${cend} ${clb}--strip${cend} ${cy}Help:${cend} ${clb}-h-s${cend} ${td}or${cend} ${clb}--help-strip${cend}"
  1276. echo
  1277. echo -e " ${tb}${tu}Module specific help - flags are used with the modules listed here.${cend}"
  1278. echo
  1279. echo -e " ${cg}Use:${cend} ${clm}all${cend} ${td}or${cend} ${clm}module-name${cend} ${cg}Usage:${cend} ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clm}all${cend} ${clb}-i${cend}"
  1280. echo
  1281. echo -e " ${td}${clm}all${cend} ${td}-${cend} ${td}${cly}optional${cend} ${td}Recommended method to install all modules${cend}"
  1282. echo -e " ${td}${clm}install${cend} ${td}-${cend} ${td}${cly}optional${cend} ${td}Install the ${td}${clc}${qbt_install_dir_short}/completed/qbittorrent-nox${cend} ${td}binary${cend}"
  1283. [[ "${what_id}" =~ ^(alpine)$ ]] && echo -e "${td} ${clm}libexecinfo${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build libexecinfo${cend}"
  1284. [[ "${what_id}" =~ ^(debian|ubuntu)$ ]] && echo -e "${td} ${clm}bison${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build bison${cend}"
  1285. [[ "${what_id}" =~ ^(debian|ubuntu)$ ]] && echo -e " ${td}${clm}gawk${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build gawk${cend}"
  1286. [[ "${what_id}" =~ ^(debian|ubuntu)$ ]] && echo -e " ${td}${clm}glibc${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build libc locally to statically link nss${cend}"
  1287. echo -e " ${td}${clm}zlib${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build zlib locally${cend}"
  1288. echo -e " ${td}${clm}iconv${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build iconv locally${cend}"
  1289. echo -e " ${td}${clm}icu${cend} ${td}-${cend} ${td}${cly}optional${cend} ${td}Build ICU locally${cend}"
  1290. echo -e " ${td}${clm}openssl${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build openssl locally${cend}"
  1291. echo -e " ${td}${clm}boost${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Download, extract and build the boost library files${cend}"
  1292. echo -e " ${td}${clm}libtorrent${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build libtorrent locally${cend}"
  1293. echo -e " ${td}${clm}qtbase${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build qtbase locally${cend}"
  1294. echo -e " ${td}${clm}qttools${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build qttools locally${cend}"
  1295. echo -e " ${td}${clm}qbittorrent${cend} ${td}-${cend} ${td}${clr}required${cend} ${td}Build qbittorrent locally${cend}"
  1296. echo
  1297. exit
  1298. ;;
  1299. -h-b | --help-build-directory)
  1300. echo
  1301. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1302. echo
  1303. echo -e " Default build location: ${cc}${qbt_install_dir_short}${cend}"
  1304. echo
  1305. echo -e " ${clb}-b${cend} or ${clb}--build-directory${cend} to set the location of the build directory."
  1306. echo
  1307. echo -e " ${cy}Paths are relative to the script location. I recommend that you use a full path.${cend}"
  1308. echo
  1309. echo -e " ${td}Example:${cend} ${td}${cg}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${td}${clm}all${cend} ${td}- Will install all modules and build libtorrent to the default build location${cend}"
  1310. echo
  1311. echo -e " ${td}Example:${cend} ${td}${cg}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${td}${clm}all ${clb}-b${cend} ${td}${clc}\"\$HOME/build\"${cend} ${td}- Will specify a build directory and install all modules to that custom location${cend}"
  1312. echo
  1313. echo -e " ${td}Example:${cend} ${td}${cg}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${td}${clm}module${cend} ${td}- Will install a single module to the default build location${cend}"
  1314. echo
  1315. echo -e " ${td}Example:${cend} ${td}${cg}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${td}${clm}module${cend} ${clb}-b${cend} ${td}${clc}\"\$HOME/build\"${cend} ${td}- will specify a custom build directory and install a specific module use to that custom location${cend}"
  1316. #
  1317. echo
  1318. exit
  1319. ;;
  1320. -h-bs | --help-boot-strap)
  1321. apply_patches bootstrap-help
  1322. echo
  1323. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1324. echo
  1325. echo -e " Creates dirs in this structure: ${cc}${qbt_install_dir_short}/patches/APPNAME/TAG/patch${cend}"
  1326. echo
  1327. echo -e " Add your patches there, for example."
  1328. echo
  1329. echo -e " ${cc}${qbt_install_dir_short}/patches/libtorrent/${libtorrent_patch_tag}/patch${cend}"
  1330. echo
  1331. echo -e " ${cc}${qbt_install_dir_short}/patches/qbittorrent/${qbittorrent_patch_tag}/patch${cend}"
  1332. echo
  1333. exit
  1334. ;;
  1335. -h-bs-c | --help-boot-cmake)
  1336. echo
  1337. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1338. echo
  1339. echo -e " This bootstrap will install cmake and ninja build to the build directory"
  1340. echo
  1341. echo -e "${clg} Usage:${cend} ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs-c${cend}"
  1342. echo
  1343. exit
  1344. ;;
  1345. -h-bs-r | --help-boot-strap-release)
  1346. echo
  1347. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1348. echo
  1349. echo -e "${clr} Github action specific. You probably dont need it${cend}"
  1350. echo
  1351. echo -e " This switch creates some github release template files in this directory"
  1352. echo
  1353. echo -e " ${qbt_install_dir_short}/release_info"
  1354. echo
  1355. echo -e "${clg} Usage:${cend} ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs-r${cend}"
  1356. echo
  1357. exit
  1358. ;;
  1359. -h-bs-ma | --help-boot-strap-multi-arch)
  1360. echo
  1361. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1362. echo
  1363. echo -e " ${urc}${clr} Github action and ALpine specific. You probably dont need it${cend}"
  1364. echo
  1365. echo -e " This switch bootstraps the musl cross build files needed for any provided and supported architecture"
  1366. echo
  1367. echo -e " ${uyc} armhf"
  1368. echo -e " ${uyc} armv7"
  1369. echo -e " ${uyc} aarch64"
  1370. echo
  1371. echo -e "${clg} Usage:${cend} ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs-ma ${qbt_cross_name:-aarch64}${cend}"
  1372. echo
  1373. echo -e " ${uyc} You can also set it as a variable to trigger cross building: ${clb}export qbt_cross_name=${qbt_cross_name:-aarch64}${cend}"
  1374. echo
  1375. exit
  1376. ;;
  1377. -h-bs-a | --help-boot-strap-all)
  1378. echo
  1379. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1380. echo
  1381. echo -e " ${urc}${clr} Github action specific and Apine only. You probably dont need it${cend}"
  1382. echo
  1383. echo -e " Performs all bootstrapping options"
  1384. echo
  1385. echo -e "${clg} Usage:${cend} ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs-a${cend}"
  1386. echo
  1387. echo -e " ${uyc} ${cly}Patches${cend}"
  1388. echo -e " ${uyc} ${cly}Release info${cend}"
  1389. echo -e " ${uyc} ${cly}Cmake and ninja build${cend} if the ${clb}-c${cend} flag is passed"
  1390. echo -e " ${uyc} ${cly}Multi arch${cend} if the ${clb}-ma${cend} flag is passed"
  1391. echo
  1392. echo -e " Equivalent of doing: ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs -bs-r${cend}"
  1393. echo
  1394. echo -e " And with ${clb}-c${cend} and ${clb}-ma${cend} : ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs -bs-c -bs-ma -bs-r ${cend}"
  1395. echo
  1396. exit
  1397. ;;
  1398. -h-c | --help-cmake)
  1399. echo
  1400. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1401. echo
  1402. echo -e " This flag can change the build process in a few ways."
  1403. echo
  1404. echo -e " ${uyc} Use cmake to build libtorrent."
  1405. echo -e " ${uyc} Use cmake to build qbittorrent."
  1406. echo
  1407. echo -e " ${uyc} You can use this flag with ICU and qtbase will use ICU instead of iconv."
  1408. echo
  1409. exit
  1410. ;;
  1411. -h-d | --help-debug)
  1412. echo
  1413. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1414. echo
  1415. echo -e " Enables debug symbols for libtorrent and qbitorrent when building"
  1416. echo
  1417. exit
  1418. ;;
  1419. -h-n | --help-no-delete)
  1420. echo
  1421. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1422. echo
  1423. echo -e " Skip all delete functions for selected modules to leave source code directories behind."
  1424. echo
  1425. echo -e " ${td}This flag is provided with no arguments.${cend}"
  1426. echo
  1427. echo -e " ${clb}-n${cend}"
  1428. echo
  1429. exit
  1430. ;;
  1431. -h-i | --help-icu)
  1432. echo
  1433. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1434. echo
  1435. echo -e " Use ICU libraries when building qBittorrent. Final binary size will be around ~50Mb"
  1436. echo
  1437. echo -e " ${td}This flag is provided with no arguments.${cend}"
  1438. echo
  1439. echo -e " ${clb}-i${cend}"
  1440. echo
  1441. exit
  1442. ;;
  1443. -h-m | --help-master)
  1444. echo
  1445. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1446. echo
  1447. echo -e " Always use the master branch for ${cg}libtorrent RC_${libtorrent_version//./_}${cend}"
  1448. echo
  1449. echo -e " Always use the master branch for ${cg}qBittorrent ${qbittorrent_github_tag/release-/}${cend}"
  1450. echo
  1451. echo -e " ${td}This flag is provided with no arguments.${cend}"
  1452. echo
  1453. echo -e " ${clb}-lm${cend}"
  1454. echo
  1455. exit
  1456. ;;
  1457. -h-ma | --help-multi-arch)
  1458. echo
  1459. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1460. echo
  1461. echo -e " ${urc}${clr} Github action and ALpine specific. You probably dont need it${cend}"
  1462. echo
  1463. echo -e " This switch will make the script use the cross build configuration for these supported architectures"
  1464. echo
  1465. echo -e " ${uyc} armhf"
  1466. echo -e " ${uyc} armv7"
  1467. echo -e " ${uyc} aarch64"
  1468. echo
  1469. echo -e "${clg} Usage:${cend} ${clc}${qbt_working_dir_short}/$(basename -- "$0")${cend} ${clb}-bs-ma ${qbt_cross_name:-aarch64}${cend}"
  1470. echo
  1471. echo -e " ${uyc} You can also set it as a variable to trigger cross building: ${clb}export qbt_cross_name=${qbt_cross_name:-aarch64}${cend}"
  1472. echo
  1473. exit
  1474. ;;
  1475. -h-lm | --help-libtorrent-master)
  1476. echo
  1477. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1478. echo
  1479. echo -e " Always use the master branch for ${cg}libtorrent-$libtorrent_version${cend}"
  1480. echo
  1481. echo -e " This master that will be used is: ${cg}RC_${libtorrent_version//./_}${cend}"
  1482. echo
  1483. echo -e " ${td}This flag is provided with no arguments.${cend}"
  1484. echo
  1485. echo -e " ${clb}-lm${cend}"
  1486. echo
  1487. exit
  1488. ;;
  1489. -h-lt | --help-libtorrent-tag)
  1490. echo
  1491. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1492. echo
  1493. echo -e " Use a provided libtorrent tag when cloning from github."
  1494. echo
  1495. echo -e " ${cy}You can use this flag with this help command to see the value if called before the help option.${cend}"
  1496. echo
  1497. echo -e " ${cg}${qbt_working_dir_short}/$(basename -- "$0")${cend}${clb} -lt ${clc}${libtorrent_github_tag}${cend} ${clb}-h-lt${cend}"
  1498. if [[ ! "${libtorrent_github_tag}" =~ (error_tag|error_22) ]]; then
  1499. echo
  1500. echo -e " ${td}This is tag that will be used is: ${cg}${libtorrent_github_tag}${cend}"
  1501. fi
  1502. echo
  1503. echo -e " ${td}This flag must be provided with arguments.${cend}"
  1504. echo
  1505. echo -e " ${clb}-lt${cend} ${clc}${libtorrent_github_tag}${cend}"
  1506. echo
  1507. exit
  1508. ;;
  1509. -h-pr | --help-patch-repo)
  1510. apply_patches bootstrap-help
  1511. echo
  1512. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1513. echo
  1514. echo -e " Specify a username and repo to use patches hosted on github${cend}"
  1515. echo
  1516. echo -e " ${cg}Example:${cend} ${clb}-pr${cend} ${clc}usnerame/repo${cend}"
  1517. echo
  1518. echo -e " ${cy}There is a specific github directory format you need to use with this flag${cend}"
  1519. echo
  1520. echo -e " ${clc}patches/libtorrent/$libtorrent_patch_tag/patch${cend}"
  1521. echo -e " ${clc}patches/libtorrent/$libtorrent_patch_tag/Jamfile${cend} ${clr}(defaults to branch master)${cend}"
  1522. echo
  1523. echo -e " ${clc}patches/qbittorrent/$qbittorrent_patch_tag/patch${cend}"
  1524. echo
  1525. echo -e " ${cy}If an installation tag matches a hosted tag patch file, it will be automaticlaly used.${cend}"
  1526. echo
  1527. echo -e " The tag name will alway be an abbreviated version of the default or specificed tag.${cend}"
  1528. echo
  1529. exit
  1530. ;;
  1531. -h-qm | --help-qbittorrent-master)
  1532. echo
  1533. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1534. echo
  1535. echo -e " Always use the master branch for ${cg}qBittorrent${cend}"
  1536. echo
  1537. echo -e " This master that will be used is: ${cg}master${cend}"
  1538. echo
  1539. echo -e " ${td}This flag is provided with no arguments.${cend}"
  1540. echo
  1541. echo -e " ${clb}-qm${cend}"
  1542. echo
  1543. exit
  1544. ;;
  1545. -h-qt | --help-qbittorrent-tag)
  1546. echo
  1547. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1548. echo
  1549. echo -e " Use a provided qBittorrent tag when cloning from github."
  1550. echo
  1551. echo -e " ${cy}You can use this flag with this help command to see the value if called before the help option.${cend}"
  1552. echo
  1553. echo -e " ${cg}${qbt_working_dir_short}/$(basename -- "$0")${cend}${clb} -qt ${clc}${qbittorrent_github_tag}${cend} ${clb}-h-qt${cend}"
  1554. #
  1555. if [[ ! "${qbittorrent_github_tag}" =~ (error_tag|error_22) ]]; then
  1556. echo
  1557. echo -e " ${td}This tag that will be used is: ${cg}${qbittorrent_github_tag}${cend}"
  1558. fi
  1559. echo
  1560. echo -e " ${td}This flag must be provided with arguments.${cend}"
  1561. echo
  1562. echo -e " ${clb}-qt${cend} ${clc}${qbittorrent_github_tag}${cend}"
  1563. echo
  1564. exit
  1565. ;;
  1566. -h-s | --help-strip)
  1567. echo
  1568. echo -e " ${ulcc} ${tb}${tu}Here is the help description for this flag:${cend}"
  1569. echo
  1570. echo -e " Strip the qbittorrent-nox binary of unneeded symbols to decrease file size"
  1571. echo
  1572. echo -e " ${uyc} This will reduce the size of the file by about 15MB but break the built in stacktrace features of qbittorrent"
  1573. echo
  1574. echo -e " ${td}This flag is provided with no arguments.${cend}"
  1575. echo
  1576. echo -e " ${clb}-s${cend}"
  1577. echo
  1578. exit
  1579. ;;
  1580. --) # end argument parsing
  1581. shift
  1582. break
  1583. ;;
  1584. -*) # unsupported flags
  1585. echo -e "${tn}Error: Unsupported flag ${cr}$1${cend} - use ${cg}-h${cend} or ${cg}--help${cend} to see the valid options${tn}" >&2
  1586. exit 1
  1587. ;;
  1588. *) # preserve positional arguments
  1589. params2+=("${1}")
  1590. shift
  1591. ;;
  1592. esac
  1593. done
  1594. #
  1595. set -- "${params2[@]}" # Set positional arguments in their proper place.
  1596. #######################################################################################################################################################
  1597. # Functions part 2: Use some of our functions
  1598. #######################################################################################################################################################
  1599. [[ "${*}" =~ ([[:space:]]|^)"install"([[:space:]]|$) ]] && install_qbittorrent "${@}" # see functions
  1600. #######################################################################################################################################################
  1601. # Lets dip out now if we find that any github tags failed validation or the urls are invalid
  1602. #######################################################################################################################################################
  1603. _error_url
  1604. #
  1605. _error_tag
  1606. #######################################################################################################################################################
  1607. # Functions part 3: Use some of our functions
  1608. #######################################################################################################################################################
  1609. installation_modules "${@}" # see functions
  1610. #
  1611. _cmake
  1612. #
  1613. _multi_arch
  1614. #######################################################################################################################################################
  1615. # libexecinfo installation
  1616. #######################################################################################################################################################
  1617. application_name libexecinfo
  1618. #
  1619. if [[ "${!app_name_skip:-yes}" = 'no' ]] || [[ "${1}" = "${app_name}" ]]; then
  1620. echo -e "${tn} ${uplus}${cg} Installing ${app_name}${cend}"
  1621. #
  1622. curl "${libexecinfo_dev_url}" -o "${qbt_install_dir}/libexecinfo_dev_${cross_arch}.apk"
  1623. curl "${libexecinfo_static_url}" -o "${qbt_install_dir}/libexecinfo_static_${cross_arch}.apk"
  1624. #
  1625. tar xf "${qbt_install_dir}/libexecinfo_dev_${cross_arch}.apk" --strip-components=1 -C "${qbt_install_dir}"
  1626. tar xf "${qbt_install_dir}/libexecinfo_static_${cross_arch}.apk" --strip-components=1 -C "${qbt_install_dir}"
  1627. #
  1628. _fix_static_links "${app_name}"
  1629. else
  1630. application_skip
  1631. fi
  1632. #######################################################################################################################################################
  1633. # bison installation
  1634. #######################################################################################################################################################
  1635. application_name bison
  1636. #
  1637. if [[ "${!app_name_skip:-yes}" = 'no' || "${1}" = "${app_name}" ]]; then
  1638. custom_flags_set
  1639. download_file "${app_name}" "${!app_url}"
  1640. #
  1641. ./configure "${multi_bison[@]}" --prefix="${qbt_install_dir}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1642. make -j"$(nproc)" CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1643. #
  1644. post_command build
  1645. #
  1646. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1647. #
  1648. delete_function "${app_name}"
  1649. else
  1650. application_skip
  1651. fi
  1652. #######################################################################################################################################################
  1653. # gawk installation
  1654. #######################################################################################################################################################
  1655. application_name gawk
  1656. #
  1657. if [[ "${!app_name_skip:-yes}" = 'no' || "$1" = "${app_name}" ]]; then
  1658. custom_flags_set
  1659. download_file "${app_name}" "${!app_url}"
  1660. #
  1661. ./configure "${multi_gawk[@]}" --prefix="$qbt_install_dir" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1662. make -j"$(nproc)" CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1663. #
  1664. post_command build
  1665. #
  1666. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1667. #
  1668. _fix_static_links "${app_name}"
  1669. #
  1670. delete_function "${app_name}"
  1671. else
  1672. application_skip
  1673. fi
  1674. #######################################################################################################################################################
  1675. # glibc installation
  1676. #######################################################################################################################################################
  1677. application_name glibc
  1678. #
  1679. if [[ "${!app_name_skip:-yes}" = 'no' || "${1}" = "${app_name}" ]]; then
  1680. custom_flags_reset
  1681. download_file "${app_name}" "${!app_url}"
  1682. #
  1683. mkdir -p build
  1684. _cd "${app_dir}/build"
  1685. #
  1686. "${app_dir}/configure" "${multi_glibc[@]}" --prefix="${qbt_install_dir}" --enable-static-nss --disable-nscd |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1687. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/$app_name.log.txt"
  1688. #
  1689. post_command build
  1690. #
  1691. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1692. #
  1693. _fix_static_links "${app_name}"
  1694. #
  1695. delete_function "${app_name}"
  1696. else
  1697. application_skip
  1698. fi
  1699. #######################################################################################################################################################
  1700. # zlib installation
  1701. #######################################################################################################################################################
  1702. application_name zlib
  1703. #
  1704. if [[ "${!app_name_skip:-yes}" = 'no' || "${1}" = "${app_name}" ]]; then
  1705. custom_flags_set
  1706. download_folder "${app_name}" "${!app_github_url}"
  1707. #
  1708. if [[ "${qbt_build_tool}" == 'cmake' ]]; then
  1709. mkdir -p "${qbt_install_dir}/graphs/${zlib_version}"
  1710. #
  1711. # force set some ARCH when using zlib-ng, cmake and musl-cross since it does detect the arch correctly.
  1712. [[ "${qbt_cross_target}" =~ ^(alpine)$ ]] && echo -e "\narchfound ${qbt_zlib_arch:-x86_64}" >> "${qbt_install_dir}/zlib/cmake/detect-arch.c"
  1713. #
  1714. cmake -Wno-dev -Wno-deprecated --graphviz="${qbt_install_dir}/graphs/${zlib_version}/dep-graph.dot" -G Ninja -B build \
  1715. -D CMAKE_VERBOSE_MAKEFILE="${qbt_cmake_debug:-OFF}" \
  1716. -D CMAKE_CXX_STANDARD="${standard}" \
  1717. -D CMAKE_PREFIX_PATH="${qbt_install_dir}" \
  1718. -D BUILD_SHARED_LIBS=OFF \
  1719. -D ZLIB_COMPAT=ON \
  1720. -D CMAKE_INSTALL_PREFIX="${qbt_install_dir}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1721. cmake --build build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1722. #
  1723. post_command build
  1724. #
  1725. cmake --install build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1726. #
  1727. dot -Tpng -o "${qbt_install_dir}/completed/${app_name}-graph.png" "${qbt_install_dir}/graphs/${zlib_version}/dep-graph.dot"
  1728. #
  1729. else
  1730. # force set some ARCH when using zlib-ng, configure and musl-cross since it does detect the arch correctly.
  1731. [[ "${qbt_cross_target}" =~ ^(alpine)$ ]] && sed "s| CFLAGS=\"-O2 \${CFLAGS}\"| ARCH=${qbt_zlib_arch:-x86_64}\n CFLAGS=\"-O2 \${CFLAGS}\"|g" -i "${qbt_install_dir}/zlib/configure"
  1732. #
  1733. ./configure --prefix="${qbt_install_dir}" --static --zlib-compat |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1734. make -j"$(nproc)" CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1735. #
  1736. post_command build
  1737. #
  1738. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1739. fi
  1740. #
  1741. _fix_static_links "${app_name}"
  1742. #
  1743. delete_function "${app_name}"
  1744. else
  1745. application_skip
  1746. fi
  1747. #######################################################################################################################################################
  1748. # iconv installation
  1749. #######################################################################################################################################################
  1750. application_name iconv
  1751. #
  1752. if [[ "${!app_name_skip:-yes}" = 'no' || "${1}" = "${app_name}" ]]; then
  1753. custom_flags_reset
  1754. download_file "${app_name}" "${!app_url}"
  1755. #
  1756. ./configure "${multi_iconv[@]}" --prefix="${qbt_install_dir}" --disable-shared --enable-static CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1757. #
  1758. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1759. #
  1760. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1761. #
  1762. _fix_static_links "${app_name}"
  1763. #
  1764. post_command build
  1765. #
  1766. delete_function "${app_name}"
  1767. else
  1768. application_skip
  1769. fi
  1770. #######################################################################################################################################################
  1771. # ICU installation
  1772. #######################################################################################################################################################
  1773. application_name icu
  1774. #
  1775. if [[ "${!app_name_skip:-yes}" = 'no' || "${1}" = "${app_name}" ]]; then
  1776. custom_flags_reset
  1777. download_file "${app_name}" "${!app_url}" "/source"
  1778. #
  1779. if [[ "${qbt_cross_name}" =~ ^(x86_64|armhf|armv7|aarch64)$ ]]; then
  1780. mkdir -p "${qbt_install_dir}/${app_name}/cross"
  1781. _cd "${qbt_install_dir}/${app_name}/cross"
  1782. "${qbt_install_dir}/${app_name}/source/runConfigureICU" Linux/gcc
  1783. make -j"$(nproc)"
  1784. _cd "${qbt_install_dir}/${app_name}/source"
  1785. fi
  1786. #
  1787. ./configure "${multi_icu[@]}" --prefix="${qbt_install_dir}" --disable-shared --enable-static --disable-samples --disable-tests --with-data-packaging=static CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1788. #
  1789. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1790. #
  1791. post_command build
  1792. #
  1793. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1794. #
  1795. _fix_static_links "${app_name}"
  1796. #
  1797. delete_function "${app_name}"
  1798. else
  1799. application_skip
  1800. fi
  1801. #######################################################################################################################################################
  1802. # openssl installation
  1803. #######################################################################################################################################################
  1804. application_name openssl
  1805. #
  1806. if [[ "${!app_name_skip:-yes}" = 'no' || "${1}" = "${app_name}" ]]; then
  1807. custom_flags_set
  1808. download_file "${app_name}" "${!app_url}"
  1809. #
  1810. "${multi_openssl[@]}" --prefix="${qbt_install_dir}" --libdir="${lib_dir}" --openssldir="/etc/ssl" threads no-shared no-dso no-comp CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1811. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1812. #
  1813. post_command build
  1814. #
  1815. make install_sw |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1816. #
  1817. _fix_static_links "${app_name}"
  1818. #
  1819. delete_function "${app_name}"
  1820. else
  1821. application_skip
  1822. fi
  1823. #######################################################################################################################################################
  1824. # boost libraries install
  1825. #######################################################################################################################################################
  1826. application_name boost
  1827. #
  1828. if [[ "${!app_name_skip:-yes}" = 'no' ]] || [[ "${1}" = "${app_name}" ]]; then
  1829. custom_flags_set
  1830. #
  1831. [[ -d "${qbt_install_dir}/boost" ]] && delete_function "${app_name}"
  1832. #
  1833. if [[ "${boost_url_status}" =~ (200) ]]; then
  1834. download_file "${app_name}" "${boost_url}"
  1835. mv -f "${qbt_install_dir}/boost_${boost_version//./_}/" "${qbt_install_dir}/boost"
  1836. _cd "${qbt_install_dir}/boost"
  1837. fi
  1838. #
  1839. if [[ "${boost_url_status}" =~ (403|404) ]]; then
  1840. download_folder "${app_name}" "${!app_github_url}"
  1841. fi
  1842. #
  1843. if [[ "${qbt_build_tool}" != 'cmake' ]]; then
  1844. "${qbt_install_dir}/boost/bootstrap.sh" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1845. ln -s "${qbt_install_dir}/boost/boost" "${qbt_install_dir}/boost/include"
  1846. else
  1847. echo -e " ${uyc} Skipping b2 as we are using cmake"
  1848. fi
  1849. #
  1850. if [[ "${boost_url_status}" =~ (403|404) ]]; then
  1851. "${qbt_install_dir}/boost/b2" headers |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1852. fi
  1853. else
  1854. application_skip
  1855. fi
  1856. #######################################################################################################################################################
  1857. # libtorrent installation
  1858. #######################################################################################################################################################
  1859. application_name libtorrent
  1860. #
  1861. if [[ "${!app_name_skip:-yes}" = 'no' ]] || [[ "${1}" = "${app_name}" ]]; then
  1862. if [[ ! -d "${qbt_install_dir}/boost" ]]; then
  1863. echo -e "${tn} ${urc} ${clr}Warning${cend} This module depends on the boost module. Use them together: ${clm}boost libtorrent${cend}"
  1864. else
  1865. custom_flags_set
  1866. download_folder "${app_name}" "${!app_github_url}"
  1867. #
  1868. apply_patches "${app_name}"
  1869. #
  1870. BOOST_ROOT="${qbt_install_dir}/boost"
  1871. BOOST_INCLUDEDIR="${qbt_install_dir}/boost"
  1872. BOOST_BUILD_PATH="${qbt_install_dir}/boost"
  1873. #
  1874. if [[ "${qbt_build_tool}" == 'cmake' ]]; then
  1875. mkdir -p "${qbt_install_dir}/graphs/${libtorrent_github_tag}"
  1876. cmake -Wno-dev -Wno-deprecated --graphviz="${qbt_install_dir}/graphs/${libtorrent_github_tag}/dep-graph.dot" -G Ninja -B build \
  1877. "${multi_libtorrent[@]}" \
  1878. -D CMAKE_VERBOSE_MAKEFILE="${qbt_cmake_debug:-OFF}" \
  1879. -D CMAKE_BUILD_TYPE="Release" \
  1880. -D CMAKE_CXX_STANDARD="${standard}" \
  1881. -D CMAKE_PREFIX_PATH="${qbt_install_dir};${qbt_install_dir}/boost" \
  1882. -D Boost_NO_BOOST_CMAKE=TRUE \
  1883. -D CMAKE_CXX_FLAGS="${CXXFLAGS}" \
  1884. -D BUILD_SHARED_LIBS=OFF \
  1885. -D Iconv_LIBRARY="${lib_dir}/libiconv.a" \
  1886. -D CMAKE_INSTALL_PREFIX="${qbt_install_dir}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1887. cmake --build build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1888. #
  1889. post_command build
  1890. #
  1891. cmake --install build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1892. #
  1893. dot -Tpng -o "${qbt_install_dir}/completed/${app_name}-graph.png" "${qbt_install_dir}/graphs/${libtorrent_github_tag}/dep-graph.dot"
  1894. #
  1895. else
  1896. [[ ${qbt_cross_name} =~ ^(armhf|armv7)$ ]] && arm_libatomic="-l:libatomic.a"
  1897. #
  1898. if [[ "${libtorrent_github_tag}" =~ ^(RC_1_1|libtorrent-1_1_.*) ]]; then
  1899. libtorrent_library_filename="libtorrent.a"
  1900. else
  1901. libtorrent_library_filename="libtorrent-rasterbar.a"
  1902. fi
  1903. #
  1904. if [[ "${libtorrent_github_tag}" =~ ^(RC_2|v2\.0\..*) ]]; then
  1905. lt_version_options=()
  1906. libtorrent_libs="-l:libboost_system.a -l:${libtorrent_library_filename} -l:libtry_signal.a ${arm_libatomic}"
  1907. lt_cmake_flags="-DTORRENT_USE_LIBCRYPTO -DTORRENT_USE_OPENSSL -DTORRENT_USE_I2P=1 -DBOOST_ALL_NO_LIB -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_HAS_STD_CHRONO -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DTORRENT_SSL_PEERS -DBOOST_ASIO_NO_DEPRECATED"
  1908. else
  1909. lt_version_options=("iconv=on")
  1910. libtorrent_libs="-l:libboost_system.a -l:${libtorrent_library_filename} ${arm_libatomic} -l:libiconv.a"
  1911. lt_cmake_flags="-DTORRENT_USE_LIBCRYPTO -DTORRENT_USE_OPENSSL -DTORRENT_USE_I2P=1 -DBOOST_ALL_NO_LIB -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_HAS_STD_CHRONO -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DTORRENT_USE_ICONV=1"
  1912. fi
  1913. #
  1914. "${qbt_install_dir}/boost/b2" "${multi_libtorrent[@]}" -j"$(nproc)" "${lt_version_options[@]}" address-model="$(getconf LONG_BIT)" "${lt_debug}" optimization=speed cxxstd="${standard}" dht=on encryption=on crypto=openssl i2p=on extensions=on variant=release threading=multi link=static boost-link=static cxxflags="${CXXFLAGS}" cflags="${CPPFLAGS}" linkflags="${LDFLAGS}" install --prefix="${qbt_install_dir}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  1915. #
  1916. post_command build
  1917. #
  1918. libtorrent_strings_version="$(strings -d "${lib_dir}/${libtorrent_library_filename}" | grep -Eom1 "^libtorrent/[0-9]\.(.*)")" # ${libtorrent_strings_version#*/}
  1919. #
  1920. cat > "${PKG_CONFIG_PATH}/libtorrent-rasterbar.pc" <<- LIBTORRENT_PKG_CONFIG
  1921. prefix=${qbt_install_dir}
  1922. libdir=\${prefix}/lib
  1923. includedir=\${prefix}/include
  1924. Name: libtorrent-rasterbar
  1925. Description: The libtorrent-rasterbar libraries
  1926. Version: ${libtorrent_strings_version#*/}
  1927. Requires:
  1928. Libs: -L\${libdir} ${libtorrent_libs}
  1929. Cflags: -I\${includedir} -I${BOOST_ROOT} ${lt_cmake_flags}
  1930. LIBTORRENT_PKG_CONFIG
  1931. fi
  1932. #
  1933. _fix_static_links "${app_name}"
  1934. #
  1935. delete_function "${app_name}"
  1936. fi
  1937. else
  1938. application_skip
  1939. fi
  1940. #######################################################################################################################################################
  1941. # qtbase installation
  1942. #######################################################################################################################################################
  1943. application_name qtbase
  1944. #
  1945. if [[ "${!app_name_skip:-yes}" = 'no' ]] || [[ "${1}" = "${app_name}" ]]; then
  1946. custom_flags_set
  1947. #
  1948. if [[ "${qbt_qt_version}" =~ ^6\. ]]; then
  1949. download_file "${app_name}" "${!app_url}"
  1950. else
  1951. download_folder "${app_name}" "${!app_github_url}"
  1952. fi
  1953. #
  1954. case "${qbt_cross_name}" in
  1955. armhf | armv7)
  1956. sed "s|arm-linux-gnueabi|${qbt_cross_host}|g" -i "mkspecs/linux-arm-gnueabi-g++/qmake.conf"
  1957. ;;
  1958. aarch64)
  1959. sed "s|aarch64-linux-gnu|${qbt_cross_host}|g" -i "mkspecs/linux-aarch64-gnu-g++/qmake.conf"
  1960. ;;
  1961. esac
  1962. #
  1963. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  1964. libexecinfo="${lib_dir}/libexecinfo.a"
  1965. fi
  1966. #
  1967. if [[ "${qbt_build_tool}" == 'cmake' && "${qbt_qt_version}" =~ ^6\. ]]; then
  1968. mkdir -p "${qbt_install_dir}/graphs/${libtorrent_github_tag}"
  1969. cmake -Wno-dev -Wno-deprecated --graphviz="${qbt_install_dir}/graphs/${qbt_qt_full_version}/dep-graph.dot" -G Ninja -B build \
  1970. "${multi_libtorrent[@]}" \
  1971. -D CMAKE_VERBOSE_MAKEFILE="${qbt_cmake_debug:-OFF}" \
  1972. -D CMAKE_BUILD_TYPE="release" \
  1973. -D QT_FEATURE_optimize_full=on -D QT_FEATURE_static=on -D QT_FEATURE_shared=off \
  1974. -D QT_FEATURE_gui=off -D QT_FEATURE_openssl_linked=on \
  1975. -D QT_FEATURE_dbus=off -D QT_FEATURE_system_pcre2=off -D QT_FEATURE_widgets=off \
  1976. -D QT_FEATURE_testlib=off -D QT_BUILD_EXAMPLES=off -D QT_BUILD_TESTS=off \
  1977. -D CMAKE_CXX_STANDARD="${standard}" \
  1978. -D CMAKE_PREFIX_PATH="${qbt_install_dir}" \
  1979. -D CMAKE_CXX_FLAGS="${CXXFLAGS}" \
  1980. -D BUILD_SHARED_LIBS=OFF \
  1981. -D CMAKE_CXX_STANDARD_LIBRARIES="${libexecinfo}" \
  1982. -D CMAKE_SKIP_RPATH=on -D CMAKE_SKIP_INSTALL_RPATH=on \
  1983. -D CMAKE_INSTALL_PREFIX="${qbt_install_dir}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1984. cmake --build build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1985. #
  1986. post_command build
  1987. #
  1988. cmake --install build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  1989. #
  1990. dot -Tpng -o "${qbt_install_dir}/completed/${app_name}-graph.png" "${qbt_install_dir}/graphs/${qbt_qt_full_version}/dep-graph.dot"
  1991. elif [[ "${qbt_qt_version}" =~ ^(5\.[0-9]{1,2})$ ]]; then
  1992. if [[ "${qbt_skip_icu}" = 'no' ]]; then
  1993. icu=("-icu" "-no-iconv" "QMAKE_CXXFLAGS=-w -fpermissive")
  1994. else
  1995. icu=("-no-icu" "-iconv" "QMAKE_CXXFLAGS=-w -fpermissive")
  1996. fi
  1997. #
  1998. # If Alpine, add the QMAKE_LIBS_EXECINFO path so we can build qtbase with no errors whilst linking against libexecinfo
  1999. [[ "${what_id}" =~ ^(alpine)$ ]] && echo "QMAKE_LIBS_EXECINFO = ${lib_dir}/libexecinfo.a" >> "mkspecs/common/linux.conf"
  2000. #
  2001. # Don't strip by default by disabling these options. We will set it as off by default and use it with a switch
  2002. echo "CONFIG += ${qbt_strip_qmake:-nostrip}" >> "mkspecs/common/linux.conf"
  2003. #
  2004. ./configure "${multi_qtbase[@]}" -prefix "${qbt_install_dir}" "${icu[@]}" -opensource -confirm-license -release \
  2005. -openssl-linked -static -c++std "${cxx_standard}" -qt-pcre \
  2006. -no-feature-glib -no-feature-opengl -no-feature-dbus -no-feature-gui -no-feature-widgets -no-feature-testlib -no-compile-examples \
  2007. -skip tests -nomake tests -skip examples -nomake examples \
  2008. -I "${include_dir}" -L "${lib_dir}" QMAKE_LFLAGS="${LDFLAGS}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  2009. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2010. #
  2011. post_command build
  2012. #
  2013. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2014. else
  2015. echo -e "${tn} ${urc} Please use a correct qt and build tool combination${tn}"
  2016. echo -e " ${urc} ${utick} qt5 + qmake ${utick} qt6 + cmake ${ucross} qt5 + cmake ${ucross} qt6 + qmake${tn}"
  2017. exit 1
  2018. fi
  2019. #
  2020. _fix_static_links "${app_name}"
  2021. #
  2022. delete_function "${app_name}"
  2023. else
  2024. application_skip
  2025. fi
  2026. #######################################################################################################################################################
  2027. # qttools installation
  2028. #######################################################################################################################################################
  2029. application_name qttools
  2030. #
  2031. if [[ "${!app_name_skip:-yes}" = 'no' ]] || [[ "${1}" = "${app_name}" ]]; then
  2032. custom_flags_set
  2033. #
  2034. if [[ "${qbt_qt_version}" =~ ^6\. ]]; then
  2035. download_file "${app_name}" "${!app_url}"
  2036. else
  2037. download_folder "${app_name}" "${!app_github_url}"
  2038. fi
  2039. #
  2040. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  2041. libexecinfo="${lib_dir}/libexecinfo.a"
  2042. fi
  2043. #
  2044. if [[ "${qbt_build_tool}" == 'cmake' && "${qbt_qt_version}" =~ ^6\. ]]; then
  2045. mkdir -p "${qbt_install_dir}/graphs/${libtorrent_github_tag}"
  2046. cmake -Wno-dev -Wno-deprecated --graphviz="${qbt_install_dir}/graphs/${qbt_qt_full_version}/dep-graph.dot" -G Ninja -B build \
  2047. "${multi_libtorrent[@]}" \
  2048. -D CMAKE_VERBOSE_MAKEFILE="${qbt_cmake_debug:-OFF}" \
  2049. -D CMAKE_BUILD_TYPE="release" \
  2050. -D CMAKE_CXX_STANDARD="${standard}" \
  2051. -D CMAKE_PREFIX_PATH="${qbt_install_dir}" \
  2052. -D CMAKE_CXX_FLAGS="${CXXFLAGS}" \
  2053. -D BUILD_SHARED_LIBS=OFF \
  2054. -D CMAKE_CXX_STANDARD_LIBRARIES="${libexecinfo}" \
  2055. -D CMAKE_SKIP_RPATH=on -D CMAKE_SKIP_INSTALL_RPATH=on \
  2056. -D CMAKE_INSTALL_PREFIX="${qbt_install_dir}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2057. cmake --build build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2058. #
  2059. post_command build
  2060. #
  2061. cmake --install build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2062. #
  2063. dot -Tpng -o "${qbt_install_dir}/completed/${app_name}-graph.png" "${qbt_install_dir}/graphs/${qbt_qt_full_version}/dep-graph.dot"
  2064. elif [[ "${qbt_qt_version}" =~ ^(5\.[0-9]{1,2})$ ]]; then
  2065. "${qbt_install_dir}/bin/qmake" -set prefix "${qbt_install_dir}" |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  2066. #
  2067. "${qbt_install_dir}/bin/qmake" QMAKE_CXXFLAGS="-std=${cxx_standard} -static -w -fpermissive" QMAKE_LFLAGS="-static" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2068. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2069. #
  2070. post_command build
  2071. #
  2072. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2073. else
  2074. echo -e "${tn} ${urc} Please use a correct qt and build tool combination${tn}"
  2075. echo -e " ${urc} ${utick} qt5 + qmake ${utick} qt6 + cmake ${ucross} qt5 + cmake ${ucross} qt6 + qmake"
  2076. exit 1
  2077. fi
  2078. _fix_static_links "${app_name}"
  2079. #
  2080. delete_function "${app_name}"
  2081. else
  2082. application_skip
  2083. fi
  2084. #######################################################################################################################################################
  2085. # qBittorrent installation
  2086. #######################################################################################################################################################
  2087. application_name qbittorrent
  2088. #
  2089. if [[ "${!app_name_skip:-yes}" = 'no' ]] || [[ "${1}" = "${app_name}" ]]; then
  2090. if [[ ! -d "${qbt_install_dir}/boost" ]]; then
  2091. echo -e "${tn} ${urc} ${clr}Warning${cend} This module depends on the boost module. Use them together: ${clm}boost qbittorrent${cend}"
  2092. echo
  2093. else
  2094. custom_flags_set
  2095. #
  2096. download_folder "${app_name}" "${!app_github_url}"
  2097. #
  2098. apply_patches "${app_name}"
  2099. # patch v4.4.2
  2100. if [[ "${qbittorrent_github_tag}" == "release-4.4.2" ]]; then
  2101. cd ../
  2102. rm -rf ./qbittorrent
  2103. curl -sSL "https://raw.githubusercontent.com/MoeClub/Note/master/qBittorrent/src/qbittorrent_v4.4.2.tar.gz" |tar -zx
  2104. cd ./qbittorrent
  2105. fi
  2106. #
  2107. if [[ "${what_id}" =~ ^(alpine)$ ]]; then
  2108. libexecinfo="${lib_dir}/libexecinfo.a"
  2109. fi
  2110. #
  2111. if [[ "${qbt_build_tool}" == 'cmake' ]]; then
  2112. mkdir -p "${qbt_install_dir}/graphs/${qbittorrent_github_tag}"
  2113. cmake -Wno-dev -Wno-deprecated --graphviz="${qbt_install_dir}/graphs/${qbittorrent_github_tag}/dep-graph.dot" -G Ninja -B build \
  2114. "${multi_qbittorrent[@]}" \
  2115. -D CMAKE_VERBOSE_MAKEFILE="${qbt_cmake_debug:-OFF}" \
  2116. -D CMAKE_BUILD_TYPE="release" \
  2117. -D QT6="${qbt_use_qt6}" \
  2118. -D CMAKE_CXX_STANDARD="${standard}" \
  2119. -D CMAKE_PREFIX_PATH="${qbt_install_dir};${qbt_install_dir}/boost" \
  2120. -D Boost_NO_BOOST_CMAKE=TRUE \
  2121. -D CMAKE_CXX_FLAGS="${CXXFLAGS}" \
  2122. -D Iconv_LIBRARY="${lib_dir}/libiconv.a" \
  2123. -D CMAKE_CXX_STANDARD_LIBRARIES="${libexecinfo}" \
  2124. -D GUI=OFF \
  2125. -D CMAKE_INSTALL_PREFIX="${qbt_install_dir}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2126. cmake --build build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2127. #
  2128. post_command build
  2129. #
  2130. cmake --install build |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2131. #
  2132. dot -Tpng -o "${qbt_install_dir}/completed/${app_name}-graph.png" "${qbt_install_dir}/graphs/${qbittorrent_github_tag}/dep-graph.dot"
  2133. else
  2134. ./bootstrap.sh |& tee "${qbt_install_dir}/logs/${app_name}.log.txt"
  2135. ./configure \
  2136. QT_QMAKE="${qbt_install_dir}/bin" \
  2137. --prefix="${qbt_install_dir}" \
  2138. "${multi_qbittorrent[@]}" \
  2139. "${qbt_debug}" \
  2140. --disable-gui \
  2141. CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" \
  2142. --with-boost="${qbt_install_dir}/boost" --with-boost-libdir="${lib_dir}" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2143. make -j"$(nproc)" |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2144. #
  2145. post_command build
  2146. #
  2147. make install |& tee -a "${qbt_install_dir}/logs/${app_name}.log.txt"
  2148. fi
  2149. #
  2150. [[ -f "${qbt_install_dir}/bin/qbittorrent-nox" ]] && cp -f "${qbt_install_dir}/bin/qbittorrent-nox" "${qbt_install_dir}/completed/qbittorrent-nox"
  2151. #
  2152. strip -s "${qbt_install_dir}/completed/qbittorrent-nox"
  2153. delete_function boost
  2154. delete_function "${app_name}" last
  2155. fi
  2156. else
  2157. application_skip last
  2158. fi
  2159. #######################################################################################################################################################
  2160. # We are all done so now exit
  2161. #######################################################################################################################################################
  2162. exit