diff mbox series

swupdate: run pre-update command hook earlier

Message ID 20200207093432.4638-1-ceggers@arri.de
State Accepted
Headers show
Series swupdate: run pre-update command hook earlier | expand

Commit Message

Christian Eggers Feb. 7, 2020, 9:34 a.m. UTC
The pre-update command hook must be run from extract_files(). Otherwise
it will be too late for images in streaming mode.

Fixes: 07811c7b57 ("swupdate: add pre-update command hook")
Signed-off-by: Christian Eggers <ceggers@arri.de>
---
 corelib/stream_interface.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Stefano Babic Feb. 7, 2020, 9:46 a.m. UTC | #1
On 07.02.20 10:34, Christian Eggers wrote:
> The pre-update command hook must be run from extract_files(). Otherwise
> it will be too late for images in streaming mode.
> 
> Fixes: 07811c7b57 ("swupdate: add pre-update command hook")
> Signed-off-by: Christian Eggers <ceggers@arri.de>
> ---
>  corelib/stream_interface.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/corelib/stream_interface.c b/corelib/stream_interface.c
> index 87840ca..ff2f6d0 100644
> --- a/corelib/stream_interface.c
> +++ b/corelib/stream_interface.c
> @@ -162,6 +162,9 @@ static int extract_files(int fd, struct swupdate_cfg *software)
>  				ERROR("SW not compatible with hardware");
>  				return -1;
>  			}
> +			if (preupdatecmd(software)) {
> +				return -1;
> +			}
>  			status = STREAM_DATA;
>  			break;
>  
> @@ -522,10 +525,6 @@ void *network_initializer(void *data)
>  		}
>  		close(inst.fd);
>  
> -		if (ret == 0) {
> -			ret = preupdatecmd(software);
> -		}
> -
>  		/* do carry out the installation (flash programming) */
>  		if (ret == 0) {
>  			TRACE("Valid image found: copying to FLASH");
> 

NAK - this breaks install from local file when the option -i is used.

Best regards,
Stefano Babic
Christian Eggers Feb. 7, 2020, 10:46 a.m. UTC | #2
Am Freitag, 7. Februar 2020, 10:46:21 CET schrieb Stefano Babic:
> NAK - this breaks install from local file when the option -i is used.

I think that "install from file" should not be affected:
- preupdatecmd() is still called from install_from_file() (nothing changed)
- preupdatecmd() is not called from extract_files() because extract_files() 
seems not to be used when installing from local file

Did I miss something?

Regards
Christian
Stefano Babic Feb. 7, 2020, 10:48 a.m. UTC | #3
On 07.02.20 11:46, Christian Eggers wrote:
> Am Freitag, 7. Februar 2020, 10:46:21 CET schrieb Stefano Babic:
>> NAK - this breaks install from local file when the option -i is used.
> 
> I think that "install from file" should not be affected:
> - preupdatecmd() is still called from install_from_file() (nothing changed)

Ouch, you're right - nothing is broken..

> - preupdatecmd() is not called from extract_files() because extract_files() 
> seems not to be used when installing from local file
> 
> Did I miss something?
> 

No, you're right - patch is ok.

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/stream_interface.c b/corelib/stream_interface.c
index 87840ca..ff2f6d0 100644
--- a/corelib/stream_interface.c
+++ b/corelib/stream_interface.c
@@ -162,6 +162,9 @@  static int extract_files(int fd, struct swupdate_cfg *software)
 				ERROR("SW not compatible with hardware");
 				return -1;
 			}
+			if (preupdatecmd(software)) {
+				return -1;
+			}
 			status = STREAM_DATA;
 			break;
 
@@ -522,10 +525,6 @@  void *network_initializer(void *data)
 		}
 		close(inst.fd);
 
-		if (ret == 0) {
-			ret = preupdatecmd(software);
-		}
-
 		/* do carry out the installation (flash programming) */
 		if (ret == 0) {
 			TRACE("Valid image found: copying to FLASH");