@@ -149,7 +149,42 @@ if ! $installer_unattended; then
clear
fi
-if ! bmaptool copy ${bmap_options} "$installer_image_uri" "${installer_target_dev}"; then
+# Function to compare version numbers
+version_ge() {
+ if [ "$(printf '%s\n' "$1"X "$2" | sort -V | head -n 1)" != "$1"X ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+# Get bmap-tools version using dpkg-query
+bmap_version=$(dpkg-query -W -f='${Version}' bmap-tools | awk -F'[~+-]' '{ print $1 }')
+
+if version_ge "$bmap_version" "3.8"; then
+ # Create a named pipe for progress communication
+ progress_pipe="/tmp/progress"
+ if ! mkfifo "$progress_pipe"; then
+ echo "Error: Failed to create named pipe $progress_pipe"
+ exit 1
+ fi
+
+ # Add psplash pipe to bmap_options
+ bmap_options="$bmap_options --psplash-pipe=$progress_pipe"
+
+ # Initialize the dialog gauge and update it dynamically
+ (
+ while true; do
+ if read -r line < "$progress_pipe"; then
+ percentage=$(echo "$line" | awk '{ print $2 }')
+ echo "$percentage"
+ fi
+ done
+ ) | dialog --gauge "Flashing image, please wait..." 10 70 0 &
+
+fi
+
+if ! bmaptool copy ${bmap_options} "$installer_image_uri" "$installer_target_dev"; then
exit 1
fi
- Added support for a progress gauge using a named pipe to capture and display percentage progress when using `bmaptool`. - The progress bar is displayed only when the `bmaptool` version is 3.8 or above, as versions prior to 3.8 has some issues with `--psplash-pipe` flag. - For `bmaptool` versions below 3.8, the image copy process continues without a progress bar to maintain compatibility. - The gauge uses `dialog --gauge` to dynamically update the progress based on output from the `bmaptool` process. Signed-off-by: Kasturi Shekar <kasturi.shekar@siemens.com> --- .../files/usr/bin/deploy-image-wic.sh | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)