recovery-utils: reset URI for local SWU update packages
Internal recovery-utils.git SHA1: e30c2a3c9729 https://jira.digi.com/browse/DEL-3466 Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
b2abb5bc80
commit
0cd1c803ce
|
|
@ -17,6 +17,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE /* For GNU version of basename */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -25,6 +27,8 @@
|
||||||
|
|
||||||
#include <libubootenv/ubootenv.h>
|
#include <libubootenv/ubootenv.h>
|
||||||
|
|
||||||
|
#define FILE_PREFIX "file://"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function: append_recovery_command
|
* Function: append_recovery_command
|
||||||
* Description: append configuration to the 'recovery_command' variable
|
* Description: append configuration to the 'recovery_command' variable
|
||||||
|
|
@ -78,6 +82,7 @@ err:
|
||||||
int update_firmware(const char *swu_path)
|
int update_firmware(const char *swu_path)
|
||||||
{
|
{
|
||||||
char *fwupdate_cmd;
|
char *fwupdate_cmd;
|
||||||
|
int file_prefix_len = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/* Verify input parameter */
|
/* Verify input parameter */
|
||||||
|
|
@ -86,14 +91,23 @@ int update_firmware(const char *swu_path)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If file is local reset the path */
|
||||||
|
if (!access(swu_path, F_OK)) {
|
||||||
|
file_prefix_len = strlen(FILE_PREFIX);
|
||||||
|
swu_path = basename(swu_path);
|
||||||
|
}
|
||||||
|
|
||||||
fwupdate_cmd =
|
fwupdate_cmd =
|
||||||
calloc(1, strlen("update_package=") + strlen(swu_path) + 1);
|
calloc(1,
|
||||||
|
strlen("update_package=") + file_prefix_len +
|
||||||
|
strlen(swu_path) + 1);
|
||||||
if (!fwupdate_cmd) {
|
if (!fwupdate_cmd) {
|
||||||
fprintf(stderr, "Error: calloc 'fwupdate_cmd'\n");
|
fprintf(stderr, "Error: calloc 'fwupdate_cmd'\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(fwupdate_cmd, "update_package=%s", swu_path);
|
sprintf(fwupdate_cmd, "update_package=%s%s",
|
||||||
|
file_prefix_len ? FILE_PREFIX : "", swu_path);
|
||||||
|
|
||||||
ret = append_recovery_command(fwupdate_cmd);
|
ret = append_recovery_command(fwupdate_cmd);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue