Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/bin/update-checksum
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ for package in "${@}"; do
done
))

if (( ${#new_checksum[@]} )); then
old_checksum_arraysize=($(
source "${buildsh_path}" 2>/dev/null
echo "${#TERMUX_PKG_SRCURL[@]}"
))
Comment on lines +79 to +82
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old_checksum_arraysize shouldn't be an array value.

Suggested change
old_checksum_arraysize=($(
source "${buildsh_path}" 2>/dev/null
echo "${#TERMUX_PKG_SRCURL[@]}"
))
old_checksum_arraysize="$( . "${buildsh_path}" 2>/dev/null; echo "${#TERMUX_PKG_SRCURL[@]}" )"


if (( ${#new_checksum[@]} )) && (( ${#new_checksum[@]} == ${old_checksum_arraysize} )); then
Copy link
Member

@TomJo2000 TomJo2000 Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(( )) supports logical AND and OR operators1, so this can be coalesced to a single arithmetic evaluation.

Suggested change
if (( ${#new_checksum[@]} )) && (( ${#new_checksum[@]} == ${old_checksum_arraysize} )); then
if (( ${#new_checksum[@]} && ${#new_checksum[@]} == ${old_checksum_arraysize} )); then

Keeping the check that ${#new_checksum[@]} is not 0 is a good precaution against edge cases where both are 0.

Footnotes

  1. https://man.archlinux.org/man/bash.1#ARITHMETIC_EVALhttps://man.archlinux.org/man/bash.1#ARITHMETIC_EVALUATION:~:text=bitwise%20OR-,%26%26,logical%20AND,-%7C%7C

# Replace old SHA-256.
if (( ${#new_checksum[@]} > 1 )); then
checksum="(\n$(printf '\\t%s\\n' "${new_checksum[@]}"))"
Expand Down