Message ID | 1519634813-8217-1-git-send-email-sami.hartikainen@teleste.com |
---|---|
State | Accepted |
Headers | show |
Series | shellscript handler: Pass data attribute value as argument | expand |
On 26/02/2018 09:46, Sami Hartikainen wrote: > If the optional data attribute is defined for a script of type > 'shellscript', 'postinstall' or 'preinstall', its value is passed > as the last argument(s) to the script. > > Signed-off-by: Sami Hartikainen <sami.hartikainen@teleste.com> > --- > doc/source/sw-description.rst | 7 ++++++- > handlers/shell_scripthandler.c | 2 +- > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst > index 709febd..42599ad 100644 > --- a/doc/source/sw-description.rst > +++ b/doc/source/sw-description.rst > @@ -472,6 +472,8 @@ Shell scripts are called via system command. > SWUpdate scans for all scripts and calls them before and after installing > the images. SWUpdate passes 'preinst' or 'postinst' as first argument to > the script. > +If the data attribute is defined, its value is passed as the last argument(s) > +to the script. > > preinstall > .......... > @@ -487,6 +489,8 @@ preinstall > > preinstall are shell scripts and called via system command. > SWUpdate scans for all scripts and calls them before installing the images. > +If the data attribute is defined, its value is passed as the last argument(s) > +to the script. > > postinstall > ........... > @@ -502,7 +506,8 @@ postinstall > > postinstall are shell scripts and called via system command. > SWUpdate scans for all scripts and calls them after installing the images. > - > +If the data attribute is defined, its value is passed as the last argument(s) > +to the script. > > bootloader > ---------- > diff --git a/handlers/shell_scripthandler.c b/handlers/shell_scripthandler.c > index 23097a2..746d320 100644 > --- a/handlers/shell_scripthandler.c > +++ b/handlers/shell_scripthandler.c > @@ -38,7 +38,7 @@ static int execute_shell_script(struct img_type *img, const char *fnname) > return -1; > } > snprintf(shellscript, sizeof(shellscript), > - "%s%s %s", tmp, img->fname, fnname); > + "%s%s %s %s", tmp, img->fname, fnname, img->type_data); > > ret = system(shellscript); > if (WIFEXITED(ret)) { > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 709febd..42599ad 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -472,6 +472,8 @@ Shell scripts are called via system command. SWUpdate scans for all scripts and calls them before and after installing the images. SWUpdate passes 'preinst' or 'postinst' as first argument to the script. +If the data attribute is defined, its value is passed as the last argument(s) +to the script. preinstall .......... @@ -487,6 +489,8 @@ preinstall preinstall are shell scripts and called via system command. SWUpdate scans for all scripts and calls them before installing the images. +If the data attribute is defined, its value is passed as the last argument(s) +to the script. postinstall ........... @@ -502,7 +506,8 @@ postinstall postinstall are shell scripts and called via system command. SWUpdate scans for all scripts and calls them after installing the images. - +If the data attribute is defined, its value is passed as the last argument(s) +to the script. bootloader ---------- diff --git a/handlers/shell_scripthandler.c b/handlers/shell_scripthandler.c index 23097a2..746d320 100644 --- a/handlers/shell_scripthandler.c +++ b/handlers/shell_scripthandler.c @@ -38,7 +38,7 @@ static int execute_shell_script(struct img_type *img, const char *fnname) return -1; } snprintf(shellscript, sizeof(shellscript), - "%s%s %s", tmp, img->fname, fnname); + "%s%s %s %s", tmp, img->fname, fnname, img->type_data); ret = system(shellscript); if (WIFEXITED(ret)) {
If the optional data attribute is defined for a script of type 'shellscript', 'postinstall' or 'preinstall', its value is passed as the last argument(s) to the script. Signed-off-by: Sami Hartikainen <sami.hartikainen@teleste.com> --- doc/source/sw-description.rst | 7 ++++++- handlers/shell_scripthandler.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)