diff mbox series

Don't run pre/post update commands in dry run mode

Message ID 20201120190400.91609-1-christian.storm@siemens.com
State Accepted
Headers show
Series Don't run pre/post update commands in dry run mode | expand

Commit Message

Storm, Christian Nov. 20, 2020, 7:04 p.m. UTC
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 core/installer.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/core/installer.c b/core/installer.c
index 82b5d60..981a21d 100644
--- a/core/installer.c
+++ b/core/installer.c
@@ -469,8 +469,12 @@  void cleanup_files(struct swupdate_cfg *software) {
 int preupdatecmd(struct swupdate_cfg *swcfg)
 {
 	if (swcfg) {
-		DEBUG("Running Pre-update command");
-		return run_system_cmd(swcfg->globals.preupdatecmd);
+		if (swcfg->globals.dry_run) {
+			DEBUG("Dry run, skipping Pre-update command");
+		} else {
+			DEBUG("Running Pre-update command");
+			return run_system_cmd(swcfg->globals.preupdatecmd);
+		}
 	}
 
 	return 0;
@@ -481,8 +485,13 @@  int postupdate(struct swupdate_cfg *swcfg, const char *info)
 	swupdate_progress_done(info);
 
 	if (swcfg) {
-		DEBUG("Running Post-update command");
-		return run_system_cmd(swcfg->globals.postupdatecmd);
+		if (swcfg->globals.dry_run) {
+			DEBUG("Dry run, skipping Post-update command");
+		} else {
+			DEBUG("Running Post-update command");
+			return run_system_cmd(swcfg->globals.postupdatecmd);
+		}
+
 	}
 
 	return 0;