diff mbox series

[2/4] Wrong count of total steps

Message ID 20230228124709.2629819-2-sbabic@denx.de
State Accepted
Headers show
Series [1/4] Revert "core/stream_interface.c: increment progress step" | expand

Commit Message

Stefano Babic Feb. 28, 2023, 12:47 p.m. UTC
The count for steps to be run is wrong. Each script runs twice, even if
one run can be skipped if it is just a pre- or postinstall script. This
increases the number of steps to be run.

Note that partitions are already counted because they are just like
artifact that must be installed first.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/parser.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/core/parser.c b/core/parser.c
index 4dec0a9..33d4f2d 100644
--- a/core/parser.c
+++ b/core/parser.c
@@ -249,7 +249,14 @@  int parse(struct swupdate_cfg *sw, const char *descfile)
 	 * Compute the total number of installer
 	 * to initialize the progress bar
 	 */
-	swupdate_progress_init(count_elem_list(&sw->images) + count_elem_list(&sw->scripts));
+	unsigned int totalsteps = count_elem_list(&sw->images) +
+					2 * count_elem_list(&sw->scripts);
+	swupdate_progress_init(totalsteps);
+
+	TRACE("Number of found artifacts: %d", count_elem_list(&sw->images));
+	TRACE("Number of scripts: %d", count_elem_list(&sw->scripts));
+	TRACE("Number of steps to be run: %d", totalsteps);
+
 
 	/*
 	 * Send the version string as first message to progress interface