Skip to content

Commit

Permalink
[merge] from unstable into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
OneCDOnly committed Oct 1, 2024
2 parents 91b24c0 + 599e642 commit b11886e
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 31 deletions.
Binary file modified objects.tar.gz
Binary file not shown.
Binary file modified sherpa-manager.tar.gz
Binary file not shown.
114 changes: 85 additions & 29 deletions support/sherpa-manager.source
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ DebugLogEnv()
fi

DebugInfoMinSepr
DebugHardware ok model "$(get_display_name)"
DebugHardware ok 'NAS model' "$(get_display_name)"
DebugHardware ok CPU "$(HardwareGetCPUInfo)"
DebugHardware ok 'CPU cores' "$r_cpu_cores"
DebugHardware ok 'CPU architecture' "$r_nas_arch"
Expand Down Expand Up @@ -834,8 +834,8 @@ DebugLogEnv()
DebugOS ok 'load averages' "$(OsGetSysLoadAverages)"
fi

DebugUserspace ok LIBC "$(UserGetLIBC)"
DebugUserspace ok 'LIBC copyright' "$(UserGetLIBCCopyright)"
DebugUserspace ok libc "$(UserGetLIBC)"
DebugUserspace ok 'libc copyright' "$(UserGetLIBCCopyright)"

if OsIsSupportSudo; then
DebugUserspace ok '$SUDO_UID' "$(UserGetSudoUID)"
Expand Down Expand Up @@ -1818,25 +1818,21 @@ SetMaxForks()
case ${1:-} in
?(re)install|upgrade) # Don't execute these actions async: installer for each package eventually aborts (QPKGs can only be managed one-at-a-time, else packages overwrite each other, and package source files end-up in the wrong install paths).
max_forks=1
reason="'$1'"
;;
clean) # Precautionary: don't make too-many calls to PyPI at the same time.
max_forks=$(((max_forks+1)/2))
reason="'$1'"
max_forks=$(((r_concurrency+1)/2))
;;
backup|deactivate|download|uninstall) # Low-resource actions, so allow multiple forks, even on ARMv5.
max_forks=4
reason="'$1'"
;;
@(dis|en)able?(au)|rebuild|sign|status) # Really-low-resource actions.
max_forks=8
reason="'$1'"
esac

[[ -n $reason ]] && reason+=' action was requested'
[[ $max_forks -ne $r_concurrency ]] && reason="'$1' was requested"
fi

[[ -n $reason ]] && DebugInfo "limiting \$max_forks to $max_forks because $reason"
[[ -n $reason ]] && DebugInfo "setting \$max_forks to $max_forks because $reason"
DebugVar max_forks

}
Expand Down Expand Up @@ -3981,6 +3977,8 @@ _ExecOneActionWithManyForks_()
local -a c=("$@")
fork_id=0

# Launching loop.

for qpkg_name in "${c[@]}"; do
[[ ! -e $r_action_abort_pathfile ]] || break

Expand All @@ -4004,15 +4002,16 @@ _ExecOneActionWithManyForks_()
UpdateForkProgress
done

# All action forks have launched, just need to wait for them to exit.
# Monitoring loop.
# All action forks have launched, now wait for them to exit.

while [[ $fork_count -gt 0 ]]; do
[[ ! -e $r_action_abort_pathfile ]] || break
sleep .2
UpdateForkProgress # Update display while running forks complete.
UpdateForkProgress # Update display while running forks complete their tasks.
done

# All forks have exited.
# All action forks have exited.

FuncForkExit

Expand Down Expand Up @@ -5779,6 +5778,10 @@ GenerateFeaturesReportTitleLine()
a='Enhanced?'
printf "%-$((r_report_lazy_column_width+2+$(LenANSIDiff "$a")))s" "$a"

# column 10: QPKG unpacks itself to unique path?
a='UniqueUnpack?'
printf "%-$((r_report_lazy_column_width+2+$(LenANSIDiff "$a")))s" "$a"

printf '\n'

}
Expand All @@ -5790,6 +5793,7 @@ GenerateFeaturesReportDataLine()

# Inputs: (global)
# $qpkg_name
# $r_report_flags_path

local active_test=false
local active_test_msg=$r_chars_blank
Expand All @@ -5811,6 +5815,8 @@ GenerateFeaturesReportDataLine()
local sherpa_compatible_msg=$r_chars_blank
local tier=false
local tier_msg=$r_chars_blank
local uniqueunpack=false
local uniqueunpack_msg=$r_chars_blank

if QpkgIsInstalledMissing; then
mode=missing
Expand Down Expand Up @@ -5854,6 +5860,7 @@ GenerateFeaturesReportDataLine()
restart_to_update=N/A
sherpa_compatible=N/A
tier=N/A
uniqueunpack=N/A

# Assign field messages.
active_test_msg+=$active_test
Expand All @@ -5864,6 +5871,7 @@ GenerateFeaturesReportDataLine()
restart_to_update_msg+=$restart_to_update
sherpa_compatible_msg+=$sherpa_compatible
tier_msg+=$tier
uniqueunpack_msg+=$uniqueunpack

# Highlight field messages.
active_test_msg=$(TextDarkGrey "$active_test_msg")
Expand All @@ -5874,6 +5882,7 @@ GenerateFeaturesReportDataLine()
restart_to_update_msg=$(TextDarkGrey "$restart_to_update_msg")
sherpa_compatible_msg=$(TextDarkGrey "$sherpa_compatible_msg")
tier_msg=$(TextDarkGrey "$tier_msg")
uniqueunpack_msg=$(TextDarkGrey "$uniqueunpack_msg")
;;
normal)
# Set field values.
Expand All @@ -5897,11 +5906,12 @@ GenerateFeaturesReportDataLine()
if QpkgIsDatabaseCanRestartToUpdate; then
restart_to_update=true
elif [[ $qpkg_name = sherpa ]]; then
restart_to_update=true # sherpa always auto-updates and this can't be disabled.
restart_to_update=true # sherpa always auto-updates and this can't be disabled.
fi

QpkgIsDatabaseSherpaCompatible && sherpa_compatible=true
QpkgIsDatabaseIndependent && tier=true
QpkgIsDatabaseUniqueUnpack && uniqueunpack=true

# Assign field messages.
active_test_msg+=$active_test
Expand All @@ -5912,6 +5922,7 @@ GenerateFeaturesReportDataLine()
restart_to_update_msg+=$restart_to_update
sherpa_compatible_msg+=$sherpa_compatible
tier_msg+=$tier
uniqueunpack_msg+=$uniqueunpack

# Highlight field messages.

Expand Down Expand Up @@ -5958,7 +5969,7 @@ GenerateFeaturesReportDataLine()
fi

if OsIsSupportAutowidthTableColumns; then
echo "$name_msg|$backup_msg|$clean_msg|$restart_to_update_msg|$autoupdate_msg|$active_test_msg|$tier_msg|$compatible_msg|$sherpa_compatible_msg"
echo "$name_msg|$backup_msg|$clean_msg|$restart_to_update_msg|$autoupdate_msg|$active_test_msg|$tier_msg|$compatible_msg|$sherpa_compatible_msg|$uniqueunpack_msg"
else
# column 1: package name.
printf "%-$((r_report_qpkg_name_column_width+$(LenANSIDiff "$name_msg")))s" "$name_msg"
Expand Down Expand Up @@ -5995,6 +6006,10 @@ GenerateFeaturesReportDataLine()
printf "%$((r_report_column_spacing))s"
printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$sherpa_compatible_msg")))s" "$sherpa_compatible_msg"

# column 10: QPKG will unpack to unique path?
printf "%$((r_report_column_spacing))s"
printf "%-$((r_report_lazy_column_width+$(LenANSIDiff "$uniqueunpack_msg")))s" "$uniqueunpack_msg"

printf '\n'
fi

Expand Down Expand Up @@ -7844,7 +7859,7 @@ ShowReportFeatures()
ResetReportsPath &> /dev/null

if OsIsSupportAutowidthTableColumns; then
printf -v a '\n%s\n' 'QPKG name:|CanBack?|CanClean?|StartUpd?|AutoUpd?|LiveTest?|Indep?|Compat?|Enhanced?'
printf -v a '\n%s\n' 'QPKG name:|CanBack?|CanClean?|StartUpd?|AutoUpd?|LiveTest?|Indep?|Compat?|Enhanced?|UniqueUnpack?'
else
printf -v a '\n%s\n' "$(GenerateFeaturesReportTitleLine)"
fi
Expand Down Expand Up @@ -9647,7 +9662,7 @@ _QPKG:install_()
z=$?

LogQpkgServiceResult
QpkgIsDatabaseCanLog && ! QpkgInstalledServiceResultWasOk && z=1
QpkgIsDatabaseWillLog && ! QpkgInstalledServiceResultWasOk && z=1

[[ $qpkg_name = Entware ]] && IsNtSysFileExist $OPKG_CMD && z=1 # Entware installation has failed.

Expand Down Expand Up @@ -9744,7 +9759,7 @@ _QPKG:reinstall_()
z=$?

LogQpkgServiceResult
QpkgIsDatabaseCanLog && ! QpkgInstalledServiceResultWasOk && z=1
QpkgIsDatabaseWillLog && ! QpkgInstalledServiceResultWasOk && z=1

[[ $qpkg_name = Entware ]] && IsNtSysFileExist $OPKG_CMD && z=1

Expand Down Expand Up @@ -9882,7 +9897,7 @@ _QPKG:upgrade_()
z=$?

LogQpkgServiceResult
QpkgIsDatabaseCanLog && ! QpkgInstalledServiceResultWasOk && z=1
QpkgIsDatabaseWillLog && ! QpkgInstalledServiceResultWasOk && z=1

[[ $qpkg_name = Entware ]] && IsNtSysFileExist $OPKG_CMD && z=1

Expand Down Expand Up @@ -10054,7 +10069,7 @@ _QPKG:activate_()
elif [[ $useropt_debug = true ]]; then
RunAndLog "${a}${service_pathfile} start" "$r_log_pathfile" log:failure-only
z=$?
elif QpkgIsDatabaseCanLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update.
elif QpkgIsDatabaseWillLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update.
RunAndLog "/sbin/qpkg_service${timeout} start $qpkg_name" "$r_log_pathfile" log:failure-only
QpkgInstalledServiceResultWasOk && z=0 || z=1
else
Expand Down Expand Up @@ -10142,7 +10157,7 @@ _QPKG:reactivate_()
elif [[ $useropt_debug = true ]]; then
RunAndLog "${a}${service_pathfile} restart" "$r_log_pathfile" log:failure-only
z=$?
elif QpkgIsDatabaseCanLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update.
elif QpkgIsDatabaseWillLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update.
RunAndLog "/sbin/qpkg_service${timeout} restart $qpkg_name" "$r_log_pathfile" log:failure-only
QpkgInstalledServiceResultWasOk && z=0 || z=1
else
Expand Down Expand Up @@ -10221,7 +10236,7 @@ _QPKG:deactivate_()
elif [[ $useropt_debug = true ]]; then
RunAndLog "${a}${service_pathfile} stop" "$r_log_pathfile" log:failure-only
z=$?
elif QpkgIsDatabaseCanLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update.
elif QpkgIsDatabaseWillLog; then # Use `qpkg_service` if-possible, so package icon in App Center will dynamically update.
RunAndLog "/sbin/qpkg_service${timeout} stop $qpkg_name" "$r_log_pathfile" log:failure-only
QpkgInstalledServiceResultWasOk && z=0 || z=1
else
Expand Down Expand Up @@ -12186,6 +12201,7 @@ QpkgIsDatabaseSherpaCompatible()
# $qpkg_default_index
# $qpkg_index
# $qpkg_name (default for $1)
# $r_qpkg_is_sherpa_compatible[]

# Outputs: (local)
# $? = true/false
Expand All @@ -12209,10 +12225,47 @@ QpkgIsDatabaseSherpaCompatible()

}

QpkgIsDatabaseCanLog()
QpkgIsDatabaseUniqueUnpack()
{

# Was this QPKG built to extract itself to a unique path? Requires QDK 2.3.14 or-later.
# If true, then this QPKG can be installed/reinstalled/upgraded concurrently with other QPKGs.

# Inputs: (local)
# $1 (string, optional override for $qpkg_name) = QPKG name: if $1 is explicitly stated, lookup $1 in package lists, ignoring current $qpkg_name and $qpkg_index.

# Inputs: (global)
# $qpkg_default_index
# $qpkg_index
# $qpkg_name (default for $1)
# $r_qpkg_is_unique_unpack[]

# Outputs: (local)
# $? = true/false

local a=''
local -i i=0

if [[ -n ${1:-} ]]; then
for i in "${!r_qpkg_name[@]}"; do
[[ ${r_qpkg_name[$i]} = "$1" ]] || continue
a=${r_qpkg_is_unique_unpack[$i]} # Always grab first found as default.
break
done
else
a=${r_qpkg_is_unique_unpack[$qpkg_index]}
[[ $a = default ]] && a=${r_qpkg_is_unique_unpack[$qpkg_default_index]}
fi

[[ -n $a ]] || a=none
[[ $a = true ]]

}

QpkgIsDatabaseWillLog()
{

# Does this QPKG service-script support logging of actions? When an action fails, this means user can be directed to check the service-script log.
# Does this QPKG service-script log all actions? If so, when an action fails, user can be directed to check the service-script log.

# Inputs: (local)
# $1 (string, optional override for $qpkg_name) = QPKG name: if $1 is explicitly stated, lookup $1 in package lists, ignoring current $qpkg_name and $qpkg_index.
Expand All @@ -12227,7 +12280,7 @@ QpkgIsDatabaseCanLog()

for i in "${!r_qpkg_name[@]}"; do
[[ ${r_qpkg_name[$i]} = "${1:-${qpkg_name:?${FUNCNAME[0]}'()': undefined package name}}" ]] || continue
${r_qpkg_can_log[$i]} && return 0 || break
${r_qpkg_will_log[$i]} && return 0 || break
done

return 1
Expand Down Expand Up @@ -13942,7 +13995,7 @@ ShowAsActionLogDetail()
DisplayAsIndentActionResultDurationReason "$3" "$2 $package_type" "$5" "$6"
;;
*)
if QpkgIsDatabaseCanLog "$2"; then
if QpkgIsDatabaseWillLog "$2"; then
DisplayAsIndentActionResultDurationReason "$3" "$2 $package_type" "$5" "For more information: /etc/init.d/$($BASENAME_CMD "$(QpkgGetInstalledServicePathFile "$2")") log"
else
DisplayAsIndentActionResultDurationReason "$3" "$2 $package_type" "$5" "$6"
Expand Down Expand Up @@ -14409,13 +14462,13 @@ LoadPackages()
unset r_qpkg_author_email
unset r_qpkg_can_backup
unset r_qpkg_can_clean
unset r_qpkg_can_log
unset r_qpkg_can_restart_to_update
unset r_qpkg_conflicts_with
unset r_qpkg_depends_on
unset r_qpkg_description
unset r_qpkg_hash
unset r_qpkg_is_sherpa_compatible
unset r_qpkg_is_unique_unpack
unset r_qpkg_max_os_version
unset r_qpkg_min_os_version
unset r_qpkg_min_ram_kb
Expand All @@ -14425,6 +14478,7 @@ LoadPackages()
unset r_qpkg_test_for_active
unset r_qpkg_url
unset r_qpkg_version
unset r_qpkg_will_log

r_packages_epoch=undefined

Expand All @@ -14439,13 +14493,13 @@ LoadPackages()
r_qpkg_author_email+=('') # Email address of the package maintainer.
r_qpkg_can_backup+=('') # 'true'/'false': this QPKG service-script supports configuration 'backup' and 'restore' actions.
r_qpkg_can_clean+=('') # 'true'/'false': the internal application can be cleaned and re-downloaded.
r_qpkg_can_log+=('') # 'true'/'false': the service-script has a log.
r_qpkg_can_restart_to_update+=('') # 'true'/'false': the internal application can be updated by restarting the QPKG.
r_qpkg_conflicts_with+=('') # Abort if these QPKGs are installed.
r_qpkg_depends_on+=('') # Require these QPKGs to be installed first. Use 'none' if package is independent. Separate alternatives with '|'.
r_qpkg_description+=('') # QPKG description.
r_qpkg_hash+=('') # MD5 checksum.
r_qpkg_is_sherpa_compatible+=('') # 'true'/'false': the service-script responds to enhanced sherpa actions.
r_qpkg_is_unique_unpack+=('') # 'true'/'false': QPKG will self-extract contents to a unique path. Requires build with QDK 2.3.14 or-later.
r_qpkg_max_os_version+=('') # The maximum QTS/QuTS version supported by this QPKG.
r_qpkg_min_os_version+=('') # The minimum QTS/QuTS version supported by this QPKG.
r_qpkg_min_ram_kb+=('') # QPKG requires at-least this much RAM installed in kiB. Use 'none' if no minimum.
Expand All @@ -14455,6 +14509,7 @@ LoadPackages()
r_qpkg_test_for_active+=('') # Test command-string to determine if this QPKG is active or inactive. Use 'builtin' if QPKG has its own status tests.
r_qpkg_url+=('') # Remote URL.
r_qpkg_version+=('') # QPKG version.
r_qpkg_will_log+=('') # 'true'/'false': the service-script keeps a log of all actions.

# Third, source remaining elements from packages file.

Expand All @@ -14471,13 +14526,13 @@ LoadPackages()
readonly r_qpkg_author_email
readonly r_qpkg_can_backup
readonly r_qpkg_can_clean
readonly r_qpkg_can_log
readonly r_qpkg_can_restart_to_update
readonly r_qpkg_conflicts_with
readonly r_qpkg_depends_on
readonly r_qpkg_description
readonly r_qpkg_hash
readonly r_qpkg_is_sherpa_compatible
readonly r_qpkg_is_unique_unpack
readonly r_qpkg_max_os_version
readonly r_qpkg_min_os_version
readonly r_qpkg_min_ram_kb
Expand All @@ -14487,6 +14542,7 @@ LoadPackages()
readonly r_qpkg_test_for_active
readonly r_qpkg_url
readonly r_qpkg_version
readonly r_qpkg_will_log

packages_loaded=true

Expand Down
2 changes: 1 addition & 1 deletion workshop/ideas.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Update sherpa service control script terminal output so it matches QPKG library functions.
* Put 'sherpa about' display into a report window.

* Check OOM killed pids against inactive daemons and report as-such on status report.

Expand Down
2 changes: 1 addition & 1 deletion workshop/issues.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Observed issues:

* Packages report (report-footer off) has 3 linespaces between last QPKG name and abbreviations reminder text.
* Packages report (with 'report-footer off') has 3 linespaces between last QPKG name and abbreviations reminder text.

* If IPK install stalls, seconds stalled display is not accurate.
- Need to calculate actual seconds elapsed since stall began, instead of using an accumulator and `sleep 1`.
Expand Down

0 comments on commit b11886e

Please sign in to comment.