From 9e00b6c107a44b8565ca4e0c2c17dbf45a3b9b3a Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sun, 9 Nov 2025 19:33:25 +0100 Subject: [PATCH] Armbian install progress bar wasn't working for awhile --- packages/bsp/common/usr/bin/armbian-install | 28 +++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/bsp/common/usr/bin/armbian-install b/packages/bsp/common/usr/bin/armbian-install index b277849a8c..b197fcd5f1 100755 --- a/packages/bsp/common/usr/bin/armbian-install +++ b/packages/bsp/common/usr/bin/armbian-install @@ -181,7 +181,7 @@ create_armbian() # count files is needed for progress bar dialog --title " $title " --backtitle "$backtitle" --infobox "\n Counting files ... few seconds." 5 60 - TODO=$(rsync -avx --delete --stats --exclude-from=$EX_LIST / "${TempDir}"/rootfs | grep "Number of files:"|awk '{print $4}' | tr -d '.,') + TODO=$(rsync -anvx --delete --stats --exclude-from=$EX_LIST / "${TempDir}"/rootfs | grep "Number of files:"|awk '{print $4}' | tr -d '.,') echo -e "\nCopying ${TODO} files to $2. \c" >> $logfile # creating rootfs @@ -194,15 +194,21 @@ create_armbian() echo 0 >"${nsi_conn_progress}" echo no >"${nsi_conn_done}" - # Launch rsync in background - { \ - rsync -avx --delete --exclude-from=$EX_LIST / "${TempDir}"/rootfs | \ - nl | awk '{ printf "%.0f\n", 100*$1/"'"$TODO"'" }' \ - > "${nsi_conn_progress}" ; - # create empty persistent journal directory if it exists before install - [ -d /var/log.hdd/journal ] && mkdir "${TempDir}"/rootfs/var/log/journal - # save exit code from rsync - echo ${PIPESTATUS[0]} >"${nsi_conn_done}" + # Launch rsync in background and stream progress percentages + { + rsync -avx --delete --exclude-from="$EX_LIST" / "${TempDir}/rootfs" \ + | stdbuf -oL awk -v todo="${TODO:-1}" '{ + pct = int((100 * NR) / (todo == 0 ? 1 : todo)); + if (pct > 100) pct = 100; + print pct; + fflush(); # ensure the progress file gets new lines promptly + }' > "${nsi_conn_progress}" + + # create empty persistent journal dir if it existed before install + [ -d /var/log.hdd/journal ] && mkdir -p "${TempDir}/rootfs/var/log/journal" + + # save rsync exit code (first cmd in the pipe) + echo ${PIPESTATUS[0]} > "${nsi_conn_done}" } & # while variables @@ -241,7 +247,7 @@ create_armbian() This will take approximately $(( $((USAGE/300)) * 1 )) minutes to finish. Please wait!\n\n" 11 80 # run rsync again to silently catch outstanding changes between / and "${TempDir}"/rootfs/ - dialog --title "$title" --backtitle "$backtitle" --infobox "\n Cleaning up ... Almost done." 5 60 + dialog --title "$title" --backtitle "$backtitle" --infobox "\n Finalizing file sync ... Please wait." 5 60 rsync -avx --delete --exclude-from=$EX_LIST / "${TempDir}"/rootfs >/dev/null 2>&1 # mark OS as transferred