Skip to content

Commit 827e996

Browse files
committed
fix: boost url function and install function
boost: url was improperly formed when using beta. install: needed to be updated to newer root/sudo methods Now supports custom destinations.
1 parent 93f224d commit 827e996

File tree

1 file changed

+90
-28
lines changed

1 file changed

+90
-28
lines changed

qbt-nox-static.bash

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ _set_default_values() {
161161
export TZ="Europe/London"
162162
fi
163163

164-
# qbt mcm docker images - these env settings tell the script that the host env is the crossbuild containers
165-
# Otherwise the script thinks the crossbuild container host is native and applies the wrong settings.
164+
# qbt mcm docker images - these env settings tell the script that the host env is the cross build containers
165+
# Otherwise the script thinks the cross build container host is native and applies the wrong settings.
166166
QBT_MCM_DOCKER="${QBT_MCM_DOCKER:-}"
167167
QBT_MCM_TARGET="${QBT_MCM_TARGET:-}"
168168
QBT_CROSS_NAME="${QBT_CROSS_NAME:-}"
@@ -713,7 +713,6 @@ _check_dependencies() {
713713
fi
714714
return 1
715715
fi
716-
717716
}
718717

719718
_check_dependency_status() {
@@ -793,7 +792,6 @@ _check_dependencies() {
793792
printf '%b\n' " $unicode_blue_circle ${color_blue_light}$script_basename${color_end} ${color_green_light}bootstrap_deps${color_end} ---- ${color_yellow}install_test${color_end} + ${color_magenta}install_core${color_end}"
794793
fi
795794
fi
796-
797795
else
798796
printf '\n%b\n\n' " $unicode_red_circle ${color_yellow}Warning${color_end}: No root or sudo privileges detected. Nothing to do"
799797
printf '%b\n' " $unicode_red_circle ${color_yellow}Warning${color_end}: ${color_magenta}test_tools${color_end} are required to access basic features of the script.${color_end}"
@@ -860,7 +858,6 @@ _check_dependencies() {
860858
fi
861859

862860
_check_dependency_status silent "${@}"
863-
864861
else
865862
printf '\n%b\n' " ${text_bold}Please request or install the missing core dependencies before using this script${color_end}"
866863
if [[ ${os_id} =~ ^(alpine)$ ]]; then
@@ -908,6 +905,7 @@ _cmd() {
908905
#######################################################################################################################################################
909906
# This is a command test function to test build commands for failure
910907
#######################################################################################################################################################
908+
# shellcheck disable=SC2317,SC2329
911909
_post_command() {
912910
outcome=("${PIPESTATUS[@]}")
913911
[[ -n ${1} ]] && command_type="${1}"
@@ -1011,17 +1009,17 @@ _test_git_ouput() {
10111009
# Boost URL test function
10121010
#######################################################################################################################################################
10131011
_boost_url() {
1012+
local boost_asset_type="release"
1013+
local boost_archiveio_asset="${github_tag[boost]//[-\.]/_}"
1014+
10141015
if [[ ${github_tag[boost]} =~ \.beta ]]; then
1015-
local boost_asset="${github_tag[boost]/\.beta/\.b}"
1016-
local boost_asset_type="beta"
1017-
else
1018-
local boost_asset="${github_tag[boost]}"
1019-
local boost_asset_type="release"
1016+
boost_asset_type="beta"
1017+
boost_archiveio_asset="${boost_archiveio_asset/_beta/_b}"
10201018
fi
10211019

10221020
local boost_url_array=(
1023-
"https://github.com/boostorg/boost/${boost_asset_type}s/download/${github_tag[boost]}/${github_tag[boost]}-b2-nodocs.tar.xz"
1024-
"https://archives.boost.io/${boost_asset_type}/${github_tag[boost]/boost-/}/source/${boost_asset//[-\.]/_}.tar.gz"
1021+
"https://github.com/boostorg/boost/releases/download/${github_tag[boost]}/${github_tag[boost]}-b2-nodocs.tar.xz"
1022+
"https://archives.boost.io/${boost_asset_type}/${github_tag[boost]#boost-}/source/${boost_archiveio_asset}.tar.gz"
10251023
)
10261024

10271025
for url in "${boost_url_array[@]}"; do
@@ -1174,7 +1172,7 @@ _custom_flags() {
11741172
export CXX="${qbt_cross_host}-g++"
11751173
fi
11761174

1177-
# If cross compiling (qbt_cross_host is set) without qemu make sure the _host_deps modules use host gcc to build native build deps for icu/qtbase crossbuilding
1175+
# If cross compiling (qbt_cross_host is set) without qemu make sure the _host_deps modules use host gcc to build native build deps for icu/qtbase cross building
11781176
if [[ ${app_name} =~ "_host_deps" ]]; then
11791177
export CHOST=""
11801178
export CC="/usr/bin/gcc"
@@ -1280,21 +1278,85 @@ _custom_flags() {
12801278
#######################################################################################################################################################
12811279
_install_qbittorrent() {
12821280
if [[ -f "${qbt_install_dir}/completed/qbittorrent-nox" ]]; then
1283-
if [[ ${qbt_privileges_required[root]} == 'true' ]] || [[ ${qbt_privileges_required[sudo]} == 'true' ]]; then
1284-
mkdir -p "/usr/local/bin"
1285-
cp -rf "${qbt_install_dir}/completed/qbittorrent-nox" "/usr/local/bin"
1286-
else
1287-
mkdir -p "${HOME}/bin"
1288-
cp -rf "${qbt_install_dir}/completed/qbittorrent-nox" "${LOCAL_USER_HOME}/bin"
1281+
case "$2" in
1282+
root)
1283+
method="${2}"
1284+
mkdir_command=("${command_privilege[@]}" "mkdir" "-p" "/usr/local/bin")
1285+
install_command=("${command_privilege[@]}" "cp" "-rf" "${qbt_install_dir}/completed/qbittorrent-nox" "/usr/local/bin")
1286+
chmod_command=("${command_privilege[@]}" "chmod" "+x" "-R" "/usr/local/bin/qbittorrent-nox")
1287+
chown_command=()
1288+
;;
1289+
custom)
1290+
method="${2}"
1291+
if [[ -z ${3} ]]; then
1292+
printf '\n%b\n\n' " ${unicode_red_circle} Provide a path as the third arugment${color_end}"
1293+
exit 1
1294+
fi
1295+
1296+
mkdir_command=("${command_privilege[@]}" "mkdir" "-p" "${3}")
1297+
install_command=("${command_privilege[@]}" "cp" "-rf" "${qbt_install_dir}/completed/qbittorrent-nox" "${3}")
1298+
chmod_command=("${command_privilege[@]}" "chmod" "+x" "-R" "${3}/qbittorrent-nox")
1299+
1300+
# Check if path is relative or within user's home directory
1301+
# if yes then chown file as the local user nor sudo or root
1302+
if [[ ! ${3} =~ ^/ ]] || [[ ${3} =~ ^"${LOCAL_USER_HOME}" ]]; then
1303+
chown_command=("${command_privilege[@]}" "chown" "$(id -nu):$(id -ng)" "-R" "${3}")
1304+
fi
1305+
;;
1306+
*)
1307+
method="local"
1308+
mkdir_command=("mkdir" "-p" "${LOCAL_USER_HOME}/bin")
1309+
install_command=("cp" "-rf" "${qbt_install_dir}/completed/qbittorrent-nox" "${LOCAL_USER_HOME}/bin")
1310+
chmod_command=("chmod" "+x" "-R" "${LOCAL_USER_HOME}/bin/qbittorrent-nox")
1311+
chown_command=()
1312+
;;
1313+
esac
1314+
1315+
"${mkdir_command[@]}" || exit 1
1316+
"${install_command[@]}" || exit 1
1317+
"${chmod_command[@]}" || exit 1
1318+
1319+
# Only run chown when it has been set (avoids syntax error when empty)
1320+
if ((${#chown_command[@]})); then
1321+
"${chown_command[@]}" || exit 1
12891322
fi
12901323

12911324
printf '\n%b\n' " ${unicode_blue_light_circle} qbittorrent-nox has been installed!${color_end}"
1325+
1326+
printf '\n%b\n' " ${unicode_yellow_light_circle} Installed using method: ${color_cyan}${method}${color_end}"
1327+
printf '\n%b\n' " ${unicode_yellow_light_circle} Installed using command: ${color_cyan}${install_command[*]}${color_end}"
1328+
12921329
printf '\n%b\n' " Run it using this command:"
1293-
if [[ ${qbt_privileges_required[root]} == 'true' ]] || [[ ${qbt_privileges_required[sudo]} == 'true' ]]; then
1294-
printf '\n%b\n\n' " ${color_green}qbittorrent-nox${color_end}"
1330+
1331+
# Determine the local user's PATH for checking (prefer preserved paths if available)
1332+
local_path="${qbt_local_paths:-$PATH}"
1333+
1334+
# Determine the install dir based on method
1335+
case "${method}" in
1336+
local)
1337+
install_dir="${LOCAL_USER_HOME}/bin"
1338+
;;
1339+
custom)
1340+
install_dir="${3}"
1341+
# Expand leading ~ to the local user's home for comparison
1342+
[[ ${install_dir} == "~"* ]] && install_dir="${install_dir/#\~/${LOCAL_USER_HOME}}"
1343+
;;
1344+
root)
1345+
install_dir="/usr/local/bin"
1346+
;;
1347+
esac
1348+
1349+
# Normalize (remove trailing slash)
1350+
install_dir="${install_dir%/}"
1351+
1352+
# If install_dir is in PATH, we can run by name; otherwise, show the full path
1353+
if [[ ":${local_path}:" == *":${install_dir}:"* ]]; then
1354+
run_cmd="qbittorrent-nox"
12951355
else
1296-
printf '\n%b\n\n' " ${color_green}~/bin/qbittorrent-nox${color_end}"
1356+
run_cmd="${install_dir}/qbittorrent-nox"
12971357
fi
1358+
1359+
printf '\n%b\n\n' " ${color_green}${run_cmd}${color_end}"
12981360
exit
12991361
else
13001362
printf '\n%b\n\n' " ${unicode_red_circle} qbittorrent-nox has not been built to the defined install directory:"
@@ -1317,7 +1379,7 @@ _test_url() {
13171379
}
13181380
#######################################################################################################################################################
13191381
# The _qbt_host_deps function will pull in a statically (musl) prebuilt dependency package to allow cross building qt6 without needing qemu.
1320-
# It will install a qt6 host platform prebuilt version for native tooling used during the cmake crossbuild of qt6.
1382+
# It will install a qt6 host platform prebuilt version for native tooling used during the cmake cross build of qt6.
13211383
# This mostly solves the issue of using containers in Github workflows where you cannot modify the how image before the container is deployed.
13221384
#
13231385
# Since the package is synced to the workflow file releases it can also be used to speed up building as it fulfills dependency requirements.
@@ -1873,13 +1935,13 @@ _download_file() {
18731935
fi
18741936

18751937
if [[ ${qbt_cache_dir_options} != "bs" && ! -f ${qbt_dl_file_path} ]]; then
1876-
printf '\n%b\n' " ${unicode_blue_light_circle} Downloading ${color_magenta_light}${app_name}${color_end} using ${color_yellow_light}${source_type}${color_end} files to ${color_cyan_light}${qbt_dl_file_path}${color_end} - ${color_yellow_light}${qbt_dl_source_url}${color_end}"
1938+
printf '\n%b\n\n' " ${unicode_blue_light_circle} Downloading ${color_magenta_light}${app_name}${color_end} using ${color_yellow_light}${source_type}${color_end} files to ${color_cyan_light}${qbt_dl_file_path}${color_end} - ${color_yellow_light}${qbt_dl_source_url}${color_end}"
18771939
elif [[ -n ${qbt_cache_dir} && ${qbt_cache_dir_options} == "bs" && ! -f ${qbt_dl_file_path} ]]; then
1878-
printf '\n%b\n' " ${unicode_blue_light_circle} Caching ${color_magenta_light}${app_name}${color_end} ${color_yellow_light}${source_type}${color_end} files to ${color_cyan_light}${qbt_cache_dir}/${app_name}.tar.xz${color_end} - ${color_yellow_light}${qbt_dl_source_url}${color_end}"
1940+
printf '\n%b\n\n' " ${unicode_blue_light_circle} Caching ${color_magenta_light}${app_name}${color_end} ${color_yellow_light}${source_type}${color_end} files to ${color_cyan_light}${qbt_cache_dir}/${app_name}.tar.xz${color_end} - ${color_yellow_light}${qbt_dl_source_url}${color_end}"
18791941
elif [[ -n ${qbt_cache_dir} && ${qbt_cache_dir_options} == "bs" && -f ${qbt_dl_file_path} ]]; then
18801942
[[ ${qbt_cache_dir_options} == "bs" ]] && printf '\n%b\n' " ${unicode_blue_light_circle} Updating ${color_magenta_light}${app_name}${color_end} cached ${color_yellow_light}${source_type}${color_end} files from - ${color_cyan_light}${qbt_cache_dir}/${app_name}.tar.xz${color_end}"
18811943
elif [[ -n ${qbt_cache_dir} && ${qbt_cache_dir_options} != "bs" && -f ${qbt_dl_file_path} ]]; then
1882-
printf '\n%b\n' " ${unicode_blue_light_circle} Extracting ${color_magenta_light}${app_name}${color_end} cached ${color_yellow_light}${source_type}${color_end} files from - ${color_cyan_light}${qbt_cache_dir}/${app_name}.tar.xz${color_end}"
1944+
printf '\n%b\n\n' " ${unicode_blue_light_circle} Extracting ${color_magenta_light}${app_name}${color_end} cached ${color_yellow_light}${source_type}${color_end} files from - ${color_cyan_light}${qbt_cache_dir}/${app_name}.tar.xz${color_end}"
18831945
fi
18841946

18851947
# download the remote source file using curl
@@ -1944,12 +2006,12 @@ _fix_multiarch_static_links() {
19442006
#######################################################################################################################################################
19452007
_delete_function() {
19462008
if [[ ${qbt_skip_delete} != "yes" ]]; then
1947-
printf '%b\n' " ${unicode_green_circle}${color_red_light} Deleting ${app_name} uncached installation files and folders${color_end}"
2009+
printf '\n%b\n' " ${unicode_green_circle}${color_red_light} Deleting ${app_name} uncached installation files and folders${color_end}"
19482010
[[ -f ${qbt_dl_file_path} ]] && rm -rf {"${qbt_install_dir:?}/$(tar tf "${qbt_dl_file_path}" | grep -Eom1 "(.*)[^/]")","${qbt_install_dir}/${app_name}.tar.xz"}
19492011
[[ -d ${qbt_dl_folder_path} ]] && rm -rf "${qbt_install_dir}/${app_name:?}"
19502012
_pushd "${qbt_working_dir}"
19512013
else
1952-
printf '%b\n' " ${unicode_yellow_circle}${color_red_light} Skipping ${app_name} deletion${color_end}"
2014+
printf '\n%b\n' " ${unicode_yellow_circle}${color_red_light} Skipping ${app_name} deletion${color_end}"
19532015
fi
19542016
}
19552017
#######################################################################################################################################################

0 commit comments

Comments
 (0)