Skip to content

Commit 599ebd8

Browse files
committed
fix: sudo
1 parent 33c8b61 commit 599ebd8

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

.github/workflows/ci-alpine-build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
qbt_cross_name: ["armhf", "armv7", "aarch64", "riscv64", "x86_64", "x86"]
3737
qbt_libtorrent_version: ["1.2", "2.0"]
3838
qbt_build_tool: [""]
39-
qbt_qt_version: ["6"]
39+
qbt_qbittorrent_tag: [""]
4040
include:
4141
- qbt_build_tool: ""
4242
qbt_qt_version_name: ""
@@ -61,6 +61,11 @@ jobs:
6161
with:
6262
persist-credentials: false
6363

64+
# - name: Download qbt-nox-static.bash
65+
# run: |
66+
# curl -LO "https://raw.githubusercontent.com/userdocs/qbittorrent-nox-static/refs/heads/main/${script_name}"
67+
# chmod +x "${script_name}"
68+
6469
- name: Host - Create Docker template env file ${{ inputs.distinct_id }}
6570
run: |
6671
printf '%s\n' "qbt_revision_url=${{ github.repository }}" > env.custom

qbt-nox-static.bash

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ multi_arch_options["loongarch64"]="loongarch64"
158158
_set_default_values() {
159159
# For debian based docker deploys to not get prompted to set the timezone.
160160
if [[ ${os_id} =~ ^(debian|ubuntu)$ ]]; then
161-
export DEBIAN_FRONTEND="noninteractive" && TZ="Europe/London"
161+
export DEBIAN_FRONTEND="noninteractive"
162+
export TZ="Europe/London"
162163
fi
163164

164165
# qbt mcm docker images - these env settings tell the script that the host env is the crossbuild containers
@@ -641,17 +642,11 @@ _script_version() {
641642
# This function will check for a list of defined dependencies from the qbt_core_deps array. Apps like python3-dev are dynamically set
642643
#######################################################################################################################################################
643644
_check_dependencies() {
644-
if [[ $os_id =~ (debian|ubuntu) ]]; then
645-
local command_test_tool=("dpkg" "-s")
646-
local command_install_deps=("apt-get" "install" "-y")
647-
local command_update_upgrade_os=("bash" "-c" "apt-get update && apt-get upgrade -y && apt-get autoremove -y")
648-
local install_simulation=("apt" "install" "--simulate")
649-
elif [[ $os_id == "alpine" ]]; then
650-
local command_test_tool=("apk" "info" "-e" "--no-cache")
651-
local command_install_deps=("apk" "add" "-u" "--no-cache" "--repository=${CDN_URL}")
652-
local command_update_upgrade_os=("bash" "-c" "apk update --no-cache && apk upgrade --no-cache --repository=${CDN_URL} && apk fix")
653-
local install_simulation=("apk" "add" "--simulate" "--no-cache")
654-
fi
645+
local pkgman=()
646+
local command_test_tool=()
647+
local command_install_deps=()
648+
local command_update_upgrade_os=()
649+
local install_simulation=()
655650

656651
_privilege_check() {
657652
printf '\n%b\n' " ${unicode_blue_light_circle} ${text_bold}Checking: ${color_red_light}available privileges${color_end}"
@@ -671,6 +666,20 @@ _check_dependencies() {
671666
else
672667
printf '%b\n' " $unicode_red_circle ${color_red_light}sudo${color_end}"
673668
fi
669+
670+
if [[ $os_id =~ (debian|ubuntu) ]]; then
671+
pkgman+=("${command_privilege[@]}" "dpkg" "-s")
672+
command_test_tool+=("${command_privilege[@]}" "dpkg" "-s")
673+
command_install_deps+=("${command_privilege[@]}" "apt-get" "install" "-y")
674+
command_update_upgrade_os+=("${command_privilege[@]}" "bash" "-c" "apt-get update && apt-get upgrade -y && apt-get autoremove -y")
675+
install_simulation+=("${command_privilege[@]}" "apt" "install" "--simulate")
676+
elif [[ $os_id == "alpine" ]]; then
677+
pkgman+=("${command_privilege[@]}" "apk" "info" "-e" "--no-cache")
678+
command_test_tool+=("${command_privilege[@]}" "apk" "info" "-e" "--no-cache")
679+
command_install_deps+=("${command_privilege[@]}" "apk" "add" "-u" "--no-cache" "--repository=${CDN_URL}")
680+
command_update_upgrade_os+=("${command_privilege[@]}" "bash" "-c" "apk update --no-cache && apk upgrade --no-cache --repository=${CDN_URL} && apk fix")
681+
install_simulation+=("${command_privilege[@]}" "apk" "add" "--simulate" "--no-cache")
682+
fi
674683
}
675684

676685
_check_tools_work() {
@@ -736,13 +745,7 @@ _check_dependencies() {
736745
# This checks over the qbt_core_deps array for the OS specified dependencies to see if they are installed
737746
while IFS= read -r pkg; do
738747

739-
if [[ ${os_id} =~ ^(alpine)$ ]]; then
740-
pkgman() { "${command_privilege[@]}" apk info -e --no-cache "${pkg}"; }
741-
fi
742-
743-
if [[ ${os_id} =~ ^(debian|ubuntu)$ ]]; then
744-
pkgman() { "${command_privilege[@]}" dpkg -s "${pkg}"; }
745-
fi
748+
pkgman() { "${pkgman[@]}" "${pkg}"; }
746749

747750
if pkgman > /dev/null 2>&1; then
748751
[[ ${silent} != 'silent' ]] && printf '%b\n' " ${unicode_green_circle} ${color_magenta}${pkg}${color_end}"
@@ -757,10 +760,10 @@ _check_dependencies() {
757760
done < <(printf '%s\n' "${!qbt_core_deps[@]}" | sort)
758761
}
759762

760-
_check_dependency_status "${@}"
761-
762763
_privilege_check
763764

765+
_check_dependency_status "${@}"
766+
764767
if [[ ${qbt_privileges_required["root"]} == "true" || ${qbt_privileges_required["sudo"]} == "true" ]]; then
765768

766769
if [[ ${qbt_core_deps[*]} =~ "false" ]]; then
@@ -801,7 +804,7 @@ _check_dependencies() {
801804

802805
_update_os() {
803806
printf '\n%b\n\n' " ${unicode_blue_light_circle} ${color_green}Updating${color_end}"
804-
"${command_privilege[@]}" "${command_update_upgrade_os[@]}"
807+
"${command_update_upgrade_os[@]}"
805808
# needed to use these functions in the -bs flags
806809
declare -fx _update_os
807810
}

0 commit comments

Comments
 (0)