armbian-next: squash some shellcheck warnings; don't local and assign subshell value in same statement, that masks errors (declare/local almost-always works)

This commit is contained in:
Ricardo Pardini 2023-01-30 21:23:36 +01:00
parent 010760fa92
commit 68d76d6f3a
No known key found for this signature in database
GPG Key ID: 3D38CA12A66C5D02
5 changed files with 26 additions and 18 deletions

View File

@ -17,7 +17,8 @@ function desktop_element_supported() {
local support_level_filepath="${desktop_element_path}/support"
export desktop_element_supported_result=0
if [[ -f "${support_level_filepath}" ]]; then
local support_level="$(cat "${support_level_filepath}")"
local support_level
support_level="$(cat "${support_level_filepath}")"
if [[ "${support_level}" != "supported" && "${EXPERT}" != "yes" ]]; then
desktop_element_supported_result=65
return 0

View File

@ -11,7 +11,7 @@ function interactive_config_prepare_terminal() {
fi
fi
# We'll use this title on all menus
export backtitle="Armbian building script, https://www.armbian.com | https://docs.armbian.com | (c) 2013-2023 Igor Pecovnik "
declare -g -r backtitle="Armbian building script, https://www.armbian.com | https://docs.armbian.com | (c) 2013-2023 Igor Pecovnik "
}
function interactive_finish() {
@ -121,7 +121,8 @@ function interactive_config_ask_board_list() {
declare WIP_BUTTON='CSC/WIP/EOS/TVB'
declare STATE_DESCRIPTION=' - boards with high level of software maturity'
declare temp_rc=$(mktemp) # @TODO: this is a _very_ early call to mktemp - no TMPDIR set yet - it needs to be cleaned-up somehow
declare temp_rc
temp_rc=$(mktemp) # @TODO: this is a _very_ early call to mktemp - no TMPDIR set yet - it needs to be cleaned-up somehow
while true; do
declare -a arr_all_board_names=() arr_all_board_options=() # arrays

View File

@ -33,7 +33,7 @@ function dialog_if_terminal_set_vars() {
set -e # back to normal
set -o errtrace # back to normal
set -o errexit # back to normal
# clear the screen after dialog exits; that way we can see the log output that comes after it?
clear
@ -92,12 +92,14 @@ function distro_menu() {
local distrib_dir="${1}"
if [[ -d "${distrib_dir}" && -f "${distrib_dir}/support" ]]; then
local support_level="$(cat "${distrib_dir}/support")"
local support_level
support_level="$(cat "${distrib_dir}/support")"
if [[ "${support_level}" != "supported" && $EXPERT != "yes" ]]; then
:
else
local distro_codename="$(basename "${distrib_dir}")"
local distro_fullname="$(cat "${distrib_dir}/name")"
local distro_codename distro_fullname
distro_codename="$(basename "${distrib_dir}")"
distro_fullname="$(cat "${distrib_dir}/name")"
local expert_infos=""
[[ $EXPERT == "yes" ]] && expert_infos="(${support_level})"
options+=("${distro_codename}" "${distro_fullname} ${expert_infos}")

View File

@ -85,7 +85,7 @@ function download_and_verify_internal() {
--file-allocation=trunc
# Connection
--disable-ipv6=$DISABLE_IPV6
"--disable-ipv6=${DISABLE_IPV6}"
--connect-timeout=10
--timeout=10
--allow-piece-length-change=true
@ -121,8 +121,10 @@ function download_and_verify_internal() {
return $rc
fi
[[ ${USE_TORRENT} == "yes" ]] &&
local torrent="$(get_urls "${catalog}" "${filename}.torrent")"
if [[ ${USE_TORRENT} == "yes" ]]; then
local torrent
torrent="$(get_urls "${catalog}" "${filename}.torrent")"
fi
fi
# download torrent first
@ -135,7 +137,7 @@ function download_and_verify_internal() {
--dir="${localdir}" \
${torrent}
[[ $? -eq 0 ]] && direct=no
direct=no
fi
@ -171,7 +173,7 @@ function download_and_verify_internal() {
gpg --homedir "${SRC}/cache/.gpg" --no-permission-warning \
--list-keys "${key}" ||
gpg --homedir "${SRC}/cache/.gpg" --no-permission-warning \
${http_proxy:+--keyserver-options http-proxy="${http_proxy}"} \
${http_proxy:+--keyserver-options http-proxy="${http_proxy:-""}"} \
--keyserver "hkp://keyserver.ubuntu.com:80" \
--recv-keys "${key}" ||
exit_with_error "Failed to receive key" "${key}"

View File

@ -114,9 +114,10 @@ function prepare_partitions() {
Last chance to set `USE_HOOK_FOR_PARTITION`=yes and then implement create_partition_table hook_point.
PREPARE_IMAGE_SIZE
local sdsize
if [[ -n $FIXED_IMAGE_SIZE && $FIXED_IMAGE_SIZE =~ ^[0-9]+$ ]]; then
display_alert "Using user-defined image size" "$FIXED_IMAGE_SIZE MiB" "info"
local sdsize=$FIXED_IMAGE_SIZE
sdsize=$FIXED_IMAGE_SIZE
# basic sanity check
if [[ $ROOTFS_TYPE != nfs && $sdsize -lt $rootfs_size ]]; then
exit_with_error "User defined image size is too small" "$sdsize <= $rootfs_size"
@ -126,9 +127,9 @@ function prepare_partitions() {
# Hardcoded overhead +25% is needed for desktop images,
# for CLI it could be lower. Align the size up to 4MiB
if [[ $BUILD_DESKTOP == yes ]]; then
local sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.35) / 1 + 0) / 4 + 1) * 4")
sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.35) / 1 + 0) / 4 + 1) * 4")
else
local sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.30) / 1 + 0) / 4 + 1) * 4")
sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.30) / 1 + 0) / 4 + 1) * 4")
fi
fi
@ -245,12 +246,13 @@ function prepare_partitions() {
display_alert "Mounting rootfs" "$rootdevice"
run_host_command_logged mount ${fscreateopt} $rootdevice $MOUNT/
# create fstab (and crypttab) entry
local rootfs
if [[ $CRYPTROOT_ENABLE == yes ]]; then
# map the LUKS container partition via its UUID to be the 'cryptroot' device
echo "$ROOT_MAPPER UUID=$(blkid -s UUID -o value ${LOOP}p${rootpart}) none luks" >> $SDCARD/etc/crypttab
local rootfs=$rootdevice # used in fstab
rootfs=$rootdevice # used in fstab
else
local rootfs="UUID=$(blkid -s UUID -o value $rootdevice)"
rootfs="UUID=$(blkid -s UUID -o value $rootdevice)"
fi
echo "$rootfs / ${mkfs[$ROOTFS_TYPE]} defaults,noatime${mountopts[$ROOTFS_TYPE]} 0 1" >> $SDCARD/etc/fstab
else
@ -313,7 +315,7 @@ function prepare_partitions() {
display_alert "Found boot.ini" "${SDCARD}/boot/boot.ini" "debug"
sed -i -e "s/rootfstype \"ext4\"/rootfstype \"$ROOTFS_TYPE\"/" $SDCARD/boot/boot.ini
if [[ $CRYPTROOT_ENABLE == yes ]]; then
local rootpart="UUID=$(blkid -s UUID -o value ${LOOP}p${rootpart})"
rootpart="UUID=$(blkid -s UUID -o value ${LOOP}p${rootpart})"
sed -i 's/^setenv rootdev .*/setenv rootdev "\/dev\/mapper\/'$ROOT_MAPPER' cryptdevice='$rootpart':'$ROOT_MAPPER'"/' $SDCARD/boot/boot.ini
else
sed -i 's/^setenv rootdev .*/setenv rootdev "'$rootfs'"/' $SDCARD/boot/boot.ini