From a16b14ef0789c3f8fee471f5ad72713594b2253c Mon Sep 17 00:00:00 2001 From: userdocs <16525024+userdocs@users.noreply.github.com> Date: Mon, 12 Feb 2024 19:54:37 +0000 Subject: [PATCH] v2.0.7 --- changelog.md | 7 ++ qbittorrent-nox-static.sh | 136 ++++++++++++++++++++++---------------- 2 files changed, 87 insertions(+), 56 deletions(-) diff --git a/changelog.md b/changelog.md index 6d937cfe..2938bf10 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +### 2.0.7 - 12-02-2024 + +Added: a boost download function to combine some logic around fallback urls and minimise external calls. +Added: a check to build combos for qt + cmake to prevent env files trying to build a known bad combo. +fixed: modules check for whole word and not accept partial matches +fixed: associative arrays declared earlier and in a group to allow changing settings via functions + ### 2.0.6 - 2024-01-27 New flag: `-si` / `--static-ish` for Debian, Ubuntu, and Alpine platforms. This flag disables LDFLAG static linking, allowing the OS libc to be dynamically linked. diff --git a/qbittorrent-nox-static.sh b/qbittorrent-nox-static.sh index 0e2055e6..35f326ac 100644 --- a/qbittorrent-nox-static.sh +++ b/qbittorrent-nox-static.sh @@ -17,7 +17,7 @@ ################################################################################################################################################# # Script version = Major minor patch ################################################################################################################################################# -script_version="2.0.6" +script_version="2.0.7" ################################################################################################################################################# # Set some script features - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html ################################################################################################################################################# @@ -199,30 +199,6 @@ _set_default_values() { # 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 delete_pkgs=() - - # A function to print some env values of the script dynamically. Used in the help section and script output. - _print_env() { - printf '\n%b\n\n' " ${unicode_yellow_circle} Default env settings${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_libtorrent_version=\"${color_green_light}${qbt_libtorrent_version}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_qt_version=\"${color_green_light}${qbt_qt_version}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_build_tool=\"${color_green_light}${qbt_build_tool}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_cross_name=\"${color_green_light}${qbt_cross_name}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_patches_url=\"${color_green_light}${qbt_patches_url}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_skip_icu=\"${color_green_light}${qbt_skip_icu}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_boost_tag=\"${color_green_light}${github_tag[boost]}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_libtorrent_tag=\"${color_green_light}${github_tag[libtorrent]}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_qt_tag=\"${color_green_light}${github_tag[qtbase]}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_qbittorrent_tag=\"${color_green_light}${github_tag[qbittorrent]}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_libtorrent_master_jamfile=\"${color_green_light}${qbt_libtorrent_master_jamfile}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_workflow_files=\"${color_green_light}${qbt_workflow_files}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_workflow_artifacts=\"${color_green_light}${qbt_workflow_artifacts}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_cache_dir=\"${color_green_light}${qbt_cache_dir}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_optimise_strip=\"${color_green_light}${qbt_optimise_strip}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_build_debug=\"${color_green_light}${qbt_build_debug}${color_yellow_light}\"${color_end}" - printf '%b\n' " ${color_yellow_light} qbt_standard=\"${color_green_light}${qbt_standard}${color_yellow_light}\"${color_end}" - printf '%b\n\n' " ${color_yellow_light} qbt_static_ish=\"${color_green_light}${qbt_static_ish}${color_yellow_light}\"${color_end}" - } - # Dynamic tests to change settings based on the use of qmake,cmake,strip and debug if [[ "${qbt_build_debug}" = "yes" ]]; then qbt_optimise_strip="no" @@ -449,6 +425,30 @@ _semantic_version() { printf "%d%03d%03d%03d" "${test_array[@]}" } ####################################################################################################################################################### +# _print_env +####################################################################################################################################################### +_print_env() { + printf '\n%b\n\n' " ${unicode_yellow_circle} Default env settings${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_libtorrent_version=\"${color_green_light}${qbt_libtorrent_version}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_qt_version=\"${color_green_light}${qbt_qt_version}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_build_tool=\"${color_green_light}${qbt_build_tool}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_cross_name=\"${color_green_light}${qbt_cross_name}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_patches_url=\"${color_green_light}${qbt_patches_url}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_skip_icu=\"${color_green_light}${qbt_skip_icu}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_boost_tag=\"${color_green_light}${github_tag[boost]}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_libtorrent_tag=\"${color_green_light}${github_tag[libtorrent]}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_qt_tag=\"${color_green_light}${github_tag[qtbase]}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_qbittorrent_tag=\"${color_green_light}${github_tag[qbittorrent]}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_libtorrent_master_jamfile=\"${color_green_light}${qbt_libtorrent_master_jamfile}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_workflow_files=\"${color_green_light}${qbt_workflow_files}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_workflow_artifacts=\"${color_green_light}${qbt_workflow_artifacts}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_cache_dir=\"${color_green_light}${qbt_cache_dir}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_optimise_strip=\"${color_green_light}${qbt_optimise_strip}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_build_debug=\"${color_green_light}${qbt_build_debug}${color_yellow_light}\"${color_end}" + printf '%b\n' " ${color_yellow_light} qbt_standard=\"${color_green_light}${qbt_standard}${color_yellow_light}\"${color_end}" + printf '%b\n\n' " ${color_yellow_light} qbt_static_ish=\"${color_green_light}${qbt_static_ish}${color_yellow_light}\"${color_end}" +} +####################################################################################################################################################### # These functions set the cxx standard dynmically based on the libtorrent versions, qt version and qbittorrent combinations ####################################################################################################################################################### _qt_std_cons() { @@ -599,6 +599,35 @@ _test_git_ouput() { fi } ####################################################################################################################################################### +# Boost URL test function +####################################################################################################################################################### +_boost_url() { + if [[ "${github_tag[boost]}" =~ \.beta ]]; then + local boost_asset="${github_tag[boost]/\.beta/\.b}" + local boost_asset_type="beta" + else + local boost_asset="${github_tag[boost]}" + local boost_asset_type="release" + fi + + local boost_url_array=( + "https://boostorg.jfrog.io/artifactory/main/${boost_asset_type}/${github_tag[boost]/boost-/}/source/${boost_asset//[-\.]/_}.tar.gz" + "https://archives.boost.io/${boost_asset_type}/${github_tag[boost]/boost-/}/source/${boost_asset//[-\.]/_}.tar.gz" + ) + + for url in "${boost_url_array[@]}"; do + if _curl -sfLI "${url}" &> /dev/null; then + boost_url_status="200" + source_archive_url[boost]="${url}" + source_default[boost]="file" + break + else + boost_url_status="403" + source_default[boost]="folder" + fi + done +} +####################################################################################################################################################### # Debug stuff ####################################################################################################################################################### _debug() { @@ -744,9 +773,12 @@ _set_module_urls() { # Update check url for the _script_version function script_url="https://raw.githubusercontent.com/userdocs/qbittorrent-nox-static/master/qbittorrent-nox-static.sh" ########################################################################################################################################################## - # Create the github_url associative array for all the applications this script uses and we call them as ${github_url[app_name]} + # Create all the arrays now + ########################################################################################################################################################## + declare -gA github_url github_tag app_version source_archive_url qbt_workflow_archive_url qbt_workflow_override source_default + ########################################################################################################################################################## + # Configure the github_url associative array for all the applications this script uses and we call them as ${github_url[app_name]} ########################################################################################################################################################## - declare -gA github_url if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then github_url[cmake_ninja]="https://github.com/userdocs/qbt-cmake-ninja-crossbuilds.git" github_url[glibc]="https://sourceware.org/git/glibc.git" @@ -764,9 +796,8 @@ _set_module_urls() { github_url[qttools]="https://github.com/qt/qttools.git" github_url[qbittorrent]="https://github.com/qbittorrent/qBittorrent.git" ########################################################################################################################################################## - # Create the github_tag associative array for all the applications this script uses and we call them as ${github_tag[app_name]} + # Configure the github_tag associative array for all the applications this script uses and we call them as ${github_tag[app_name]} ########################################################################################################################################################## - declare -gA github_tag if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then github_tag[cmake_ninja]="$(_git_git ls-remote -q -t --refs "${github_url[cmake_ninja]}" | awk '{sub("refs/tags/", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)" if [[ "${os_version_codename}" =~ ^(bullseye|focal)$ ]]; then @@ -789,9 +820,8 @@ _set_module_urls() { github_tag[qttools]="$(_git_git ls-remote -q -t --refs "${github_url[qttools]}" | awk '/'"v${qbt_qt_version}"'/{sub("refs/tags/", "");sub("(.*)(-a|-b|-r)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)" github_tag[qbittorrent]="$(_git_git ls-remote -q -t --refs "${github_url[qbittorrent]}" | awk '{sub("refs/tags/", "");sub("(.*)(-[^0-9].*|rc|alpha|beta)(.*)", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)" ########################################################################################################################################################## - # Create the app_version associative array for all the applications this script uses and we call them as ${app_version[app_name]} + # Configure the app_version associative array for all the applications this script uses and we call them as ${app_version[app_name]} ########################################################################################################################################################## - declare -gA app_version if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then app_version[cmake_debian]="${github_tag[cmake_ninja]%_*}" app_version[ninja_debian]="${github_tag[cmake_ninja]#*_}" @@ -811,9 +841,8 @@ _set_module_urls() { app_version[qttools]="$(printf '%s' "${github_tag[qttools]#v}" | sed 's/-lts-lgpl//g')" app_version[qbittorrent]="${github_tag[qbittorrent]#release-}" ########################################################################################################################################################## - # Create the source_archive_url associative array for all the applications this script uses and we call them as ${source_archive_url[app_name]} + # Configure the source_archive_url associative array for all the applications this script uses and we call them as ${source_archive_url[app_name]} ########################################################################################################################################################## - declare -gA source_archive_url if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then source_archive_url[cmake_ninja]="https://github.com/userdocs/qbt-cmake-ninja-crossbuilds/releases/latest/download/${os_id}-${os_version_codename}-cmake-$(dpkg --print-architecture).tar.xz" source_archive_url[glibc]="https://ftpmirror.gnu.org/gnu/libc/${github_tag[glibc]}.tar.xz" @@ -823,7 +852,7 @@ _set_module_urls() { source_archive_url[icu]="https://github.com/unicode-org/icu/releases/download/${github_tag[icu]}/icu4c-${app_version[icu]/-/_}-src.tgz" source_archive_url[double_conversion]="https://github.com/google/double-conversion/archive/refs/tags/${github_tag[double_conversion]}.tar.gz" source_archive_url[openssl]="https://github.com/openssl/openssl/releases/download/${github_tag[openssl]}/${github_tag[openssl]}.tar.gz" - source_archive_url[boost]="https://boostorg.jfrog.io/artifactory/main/release/${github_tag[boost]/boost-/}/source/${github_tag[boost]//[-\.]/_}.tar.gz" + _boost_url # function to test and set the boost url and more source_archive_url[libtorrent]="https://github.com/arvidn/libtorrent/releases/download/${github_tag[libtorrent]}/libtorrent-rasterbar-${github_tag[libtorrent]#v}.tar.gz" read -ra qt_version_short_array <<< "${app_version[qtbase]//\./ }" @@ -839,9 +868,8 @@ _set_module_urls() { source_archive_url[qbittorrent]="https://github.com/qbittorrent/qBittorrent/archive/refs/tags/${github_tag[qbittorrent]}.tar.gz" ########################################################################################################################################################## - # Create the qbt_workflow_archive_url associative array for all the applications this script uses and we call them as ${qbt_workflow_archive_url[app_name]} + # Configure the qbt_workflow_archive_url associative array for all the applications this script uses and we call them as ${qbt_workflow_archive_url[app_name]} ########################################################################################################################################################## - declare -gA qbt_workflow_archive_url if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then qbt_workflow_archive_url[cmake_ninja]="${source_archive_url[cmake_ninja]}" qbt_workflow_archive_url[glibc]="https://github.com/userdocs/qbt-workflow-files/releases/latest/download/glibc.${github_tag[glibc]#glibc-}.tar.xz" @@ -857,9 +885,8 @@ _set_module_urls() { qbt_workflow_archive_url[qttools]="https://github.com/userdocs/qbt-workflow-files/releases/latest/download/qt${qbt_qt_version:0:1}tools.tar.xz" qbt_workflow_archive_url[qbittorrent]="https://github.com/userdocs/qbt-workflow-files/releases/latest/download/qbittorrent.tar.xz" ########################################################################################################################################################## - # Workflow override options + # Configure workflow override options ########################################################################################################################################################## - declare -gA qbt_workflow_override if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then qbt_workflow_override[cmake_ninja]="no" qbt_workflow_override[glibc]="no" @@ -875,9 +902,8 @@ _set_module_urls() { qbt_workflow_override[qttools]="no" qbt_workflow_override[qbittorrent]="no" ########################################################################################################################################################## - # The default source type we use for the download function + # Configure the default source type we use for the download function ########################################################################################################################################################## - declare -gA source_default if [[ "${os_id}" =~ ^(debian|ubuntu)$ ]]; then source_default[cmake_ninja]="file" source_default[glibc]="file" @@ -892,10 +918,9 @@ _set_module_urls() { source_default[qtbase]="file" source_default[qttools]="file" source_default[qbittorrent]="file" - ################################################################################################################################################### - # Define some test URLs we use to check or test the status of some URLs - ################################################################################################################################################### - boost_url_status="$(_curl -so /dev/null --head --write-out '%{http_code}' "https://boostorg.jfrog.io/artifactory/main/release/${app_version[boost]}/source/boost_${app_version[boost]//./_}.tar.gz")" + ########################################################################################################################################################## + # + ########################################################################################################################################################## return } ####################################################################################################################################################### @@ -912,7 +937,7 @@ _installation_modules() { # For any modules params passed, test that they exist in the qbt_modules array or set qbt_modules_test to fail for passed_params in "${@}"; do - if [[ ! "${qbt_modules[*]}" =~ ${passed_params} ]]; then + if [[ ! "${qbt_modules[*]}" =~ (^|[^[:alpha:]])${passed_params}([^[:alpha:]]|$) ]]; then qbt_modules_test="fail" fi done @@ -1885,15 +1910,7 @@ while (("${#}")); do if [[ -n "${2}" ]]; then github_tag[boost]="$(_git "${github_url[boost]}" -t "${2}")" app_version[boost]="${github_tag[boost]#boost-}" - if [[ "${app_version[boost]}" =~ \.beta ]]; then - boost_url="${app_version[boost]//\./_}" boost_url="${boost_url/beta1/b1}" boost_url="${boost_url/beta2/b2}" - source_archive_url[boost]="https://boostorg.jfrog.io/artifactory/main/beta/${app_version[boost]}/source/boost_${boost_url}.tar.gz" - else - source_archive_url[boost]="https://boostorg.jfrog.io/artifactory/main/release/${app_version[boost]}/source/boost_${app_version[boost]//\./_}.tar.gz" - fi - if ! _curl -I "${source_archive_url[boost]}" &> /dev/null; then - source_default[libtorrent]="folder" - fi + _boost_url qbt_workflow_override[boost]="yes" _test_git_ouput "${github_tag[boost]}" "boost" "${2}" shift 2 @@ -2007,6 +2024,13 @@ while (("${#}")); do qt_version_short="${qt_version_short_array[0]}.${qt_version_short_array[1]}" _test_git_ouput "${github_tag[qtbase]}" "qtbase" "${2}" _test_git_ouput "${github_tag[qttools]}" "qttools" "${2}" + + if [[ $qbt_build_tool == "cmake" && "${2}" =~ ^v5 ]]; then + printf '\n%b\n' " ${unicode_red_circle} Please use a correct qt and build tool combination" + printf '\n%b\n' " ${unicode_green_circle} qt5 + qmake ${unicode_green_circle} qt6 + cmake ${unicode_red_circle} qt5 + cmake ${unicode_red_circle} qt6 + qmake" + _print_env + exit 1 + fi shift 2 else printf '\n%b\n\n' " ${unicode_red_circle} ${color_yellow_light}You must provide a tag for this switch:${color_end} ${color_blue_light}${1} TAG ${color_end}" @@ -2634,7 +2658,7 @@ _qtbase() { make install |& _tee -a "${qbt_install_dir}/logs/${app_name}.log" else printf '\n%b\n' " ${unicode_red_circle} Please use a correct qt and build tool combination" - printf '\n%b\n\n' " ${unicode_red_circle} ${unicode_green_circle} qt5 + qmake ${unicode_green_circle} qt6 + cmake ${unicode_red_circle} qt5 + cmake ${unicode_red_circle} qt6 + qmake" + printf '\n%b\n\n' " ${unicode_green_circle} qt5 + qmake ${unicode_green_circle} qt6 + cmake ${unicode_red_circle} qt5 + cmake ${unicode_red_circle} qt6 + qmake" exit 1 fi } @@ -2665,7 +2689,7 @@ _qttools() { make install |& _tee -a "${qbt_install_dir}/logs/${app_name}.log" else printf '\n%b\n' " ${unicode_red_circle} Please use a correct qt and build tool combination" - printf '\n%b\n' " ${unicode_red_circle} ${unicode_green_circle} qt5 + qmake ${unicode_green_circle} qt6 + cmake ${unicode_red_circle} qt5 + cmake ${unicode_red_circle} qt6 + qmake" + printf '\n%b\n\n' " ${unicode_green_circle} qt5 + qmake ${unicode_green_circle} qt6 + cmake ${unicode_red_circle} qt5 + cmake ${unicode_red_circle} qt6 + qmake" exit 1 fi }