Message ID | 1554358800-22904-1-git-send-email-awais_belal@mentor.com |
---|---|
State | Accepted |
Headers | show |
Series | [v3] client: allow to run post-update actions | expand |
On Thursday, 4 April 2019 17:20:21 UTC+11, Awais Belal wrote: > > This now provides a commandline argument (-p) which can be > used to run the ipc_postupdate hook if the update succeeds. > The variable is unset by default in order to align with the > earlier behavior. > > Signed-off-by: Awais Belal <awais...@mentor.com <javascript:>> > --- > tools/client.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/tools/client.c b/tools/client.c > index 6dd378c..ebea1a8 100644 > --- a/tools/client.c > +++ b/tools/client.c > @@ -41,6 +41,7 @@ char buf[256]; > int fd; > int verbose = 1; > bool dryrun = false; > +bool run_postupdate = false; > int end_status = EXIT_SUCCESS; > > pthread_mutex_t mymutex; > @@ -79,7 +80,8 @@ static int printstatus(ipc_message *msg) > > /* > * this is called at the end reporting the status > - * of the upgrade > + * of the upgrade and running any post-update actions > + * if successful > */ > static int end(RECOVERY_STATUS status) > { > @@ -89,6 +91,13 @@ static int end(RECOVERY_STATUS status) > status == FAILURE ? "*failed* !" : > "was successful !"); > > + if (status == SUCCESS && run_postupdate) { > + printf("Executing post-update actions.\n"); > + ipc_message msg; > + if (ipc_postupdate(&msg) != 0) > + printf("Running post-update failed!\n"); > + } > + > pthread_mutex_unlock(&mymutex); > > return 0; > @@ -135,7 +144,7 @@ int main(int argc, char *argv[]) { > pthread_mutex_init(&mymutex, NULL); > > /* parse command line options */ > - while ((c = getopt(argc, argv, "dhqv")) != EOF) { > + while ((c = getopt(argc, argv, "dhqvp")) != EOF) { > switch (c) { > case 'd': > dryrun = true; > @@ -149,6 +158,9 @@ int main(int argc, char *argv[]) { > case 'v': > verbose++; > break; > + case 'p': > + run_postupdate = true; > + break; > default: > usage(); > return -1; > -- > 2.7.4 > > Tested-by: Austin Phillips <austin.phillips@planetinnovation.com.au>
diff --git a/tools/client.c b/tools/client.c index 6dd378c..ebea1a8 100644 --- a/tools/client.c +++ b/tools/client.c @@ -41,6 +41,7 @@ char buf[256]; int fd; int verbose = 1; bool dryrun = false; +bool run_postupdate = false; int end_status = EXIT_SUCCESS; pthread_mutex_t mymutex; @@ -79,7 +80,8 @@ static int printstatus(ipc_message *msg) /* * this is called at the end reporting the status - * of the upgrade + * of the upgrade and running any post-update actions + * if successful */ static int end(RECOVERY_STATUS status) { @@ -89,6 +91,13 @@ static int end(RECOVERY_STATUS status) status == FAILURE ? "*failed* !" : "was successful !"); + if (status == SUCCESS && run_postupdate) { + printf("Executing post-update actions.\n"); + ipc_message msg; + if (ipc_postupdate(&msg) != 0) + printf("Running post-update failed!\n"); + } + pthread_mutex_unlock(&mymutex); return 0; @@ -135,7 +144,7 @@ int main(int argc, char *argv[]) { pthread_mutex_init(&mymutex, NULL); /* parse command line options */ - while ((c = getopt(argc, argv, "dhqv")) != EOF) { + while ((c = getopt(argc, argv, "dhqvp")) != EOF) { switch (c) { case 'd': dryrun = true; @@ -149,6 +158,9 @@ int main(int argc, char *argv[]) { case 'v': verbose++; break; + case 'p': + run_postupdate = true; + break; default: usage(); return -1;
This now provides a commandline argument (-p) which can be used to run the ipc_postupdate hook if the update succeeds. The variable is unset by default in order to align with the earlier behavior. Signed-off-by: Awais Belal <awais_belal@mentor.com> --- tools/client.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)