From 2a79bc29d0764294a1eba01a59595a1d6ff7be31 Mon Sep 17 00:00:00 2001 From: David Escalona Date: Wed, 28 Dec 2016 16:59:10 +0100 Subject: [PATCH] swupdate: add patch to include command line support to progress client - This patch comes from the sw-update upstream and adds command line support to the progress client binary. https://github.com/sbabic/swupdate/commit/a11e6f2b8066566d28cef0585be55bcfba6b3b4b https://jira.digi.com/browse/DEL-3356 Signed-off-by: David Escalona --- ...ss_client-add-command-line-parameter.patch | 133 ++++++++++++++++++ .../swupdate/swupdate_git.bbappend | 2 + 2 files changed, 135 insertions(+) create mode 100644 meta-digi-dey/recipes-support/swupdate/swupdate/0001-progress_client-add-command-line-parameter.patch diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate/0001-progress_client-add-command-line-parameter.patch b/meta-digi-dey/recipes-support/swupdate/swupdate/0001-progress_client-add-command-line-parameter.patch new file mode 100644 index 000000000..a45429c2f --- /dev/null +++ b/meta-digi-dey/recipes-support/swupdate/swupdate/0001-progress_client-add-command-line-parameter.patch @@ -0,0 +1,133 @@ +From: Stefano Babic +Date: Wed, 30 Nov 2016 18:04:21 +0100 +Subject: [PATCH] progress_client: add command line parameter + +Add command lin eparameter to: +- waiting forever for a connection with SWUpdate +- make psplash optional + +Signed-off-by: Stefano Babic +Signed-off-by: David Escalona +--- + progress_client/progress.c | 67 +++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 60 insertions(+), 7 deletions(-) + +diff --git a/progress_client/progress.c b/progress_client/progress.c +index b057a8f..c587dd6 100644 +--- a/progress_client/progress.c ++++ b/progress_client/progress.c +@@ -34,11 +34,30 @@ + #include + #include + #include ++#include + + #include + + #define PSPLASH_MSG_SIZE 64 + ++static struct option long_options[] = { ++ {"psplash", no_argument, NULL, 'p'}, ++ {"wait", no_argument, NULL, 'w'}, ++ {NULL, 0, NULL, 0} ++}; ++ ++static void usage(char *programname) ++{ ++ fprintf(stdout, "%s (compiled %s)\n", programname, __DATE__); ++ fprintf(stdout, "Usage %s [OPTION]\n", ++ programname); ++ fprintf(stdout, ++ " -w, --wait : wait for a connection with SWUpdate\n" ++ " -p, --psplash : send info to the psplash process\n" ++ " -h, --help : print this help and exit\n" ++ ); ++} ++ + static int psplash_init(char *pipe) + { + int psplash_pipe_fd; +@@ -123,7 +142,8 @@ static void psplash_progress(char *pipe, struct progress_msg *pmsg) + free(buf); + } + +-int main(void) { ++int main(int argc, char **argv) ++{ + int connfd; + struct sockaddr_un servaddr; + struct progress_msg msg; +@@ -135,7 +155,31 @@ int main(void) { + int percent = 0; + char bar[60]; + int filled_len; ++ int opt_w = 0; ++ int opt_p = 0; ++ int c; + ++ /* Process options with getopt */ ++ while ((c = getopt_long(argc, argv, "wph", ++ long_options, NULL)) != EOF) { ++ switch (c) { ++ case 'w': ++ opt_w = 1; ++ break; ++ case 'p': ++ opt_p = 1; ++ break; ++ case 'h': ++ usage(argv[0]); ++ exit(0); ++ break; ++ default: ++ usage(argv[0]); ++ exit(1); ++ break; ++ } ++ } ++ + tmpdir = getenv("TMPDIR"); + if (!tmpdir) + tmpdir = "/tmp"; +@@ -150,10 +194,18 @@ int main(void) { + servaddr.sun_family = AF_LOCAL; + strcpy(servaddr.sun_path, SOCKET_PROGRESS_PATH); + +- ret = connect(connfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); +- if (ret < 0) { +- fprintf(stderr, "no communication with swupdate\n"); +- } ++ /* Connection to SWUpdate */ ++ do { ++ ret = connect(connfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); ++ if (ret == 0) ++ break; ++ if (!opt_w) { ++ fprintf(stderr, "no communication with swupdate\n"); ++ exit(1); ++ } ++ ++ sleep(1); ++ } while (1); + + while (1) { + ret = read(connfd, &msg, sizeof(msg)); +@@ -161,7 +213,7 @@ int main(void) { + close(connfd); + exit(1); + } +- if (!psplash_ok) { ++ if (!psplash_ok && opt_p) { + psplash_ok = psplash_init(psplash_pipe_path); + } + +@@ -193,7 +245,8 @@ int main(void) { + fprintf(stdout, "\n\n%s !\n", msg.status == SUCCESS + ? "SUCCESS" + : "FAILURE"); +- psplash_progress(psplash_pipe_path, &msg); ++ if (psplash_ok) ++ psplash_progress(psplash_pipe_path, &msg); + psplash_ok = 0; + break; + case DONE: diff --git a/meta-digi-dey/recipes-support/swupdate/swupdate_git.bbappend b/meta-digi-dey/recipes-support/swupdate/swupdate_git.bbappend index cc0d47745..f973e1df0 100644 --- a/meta-digi-dey/recipes-support/swupdate/swupdate_git.bbappend +++ b/meta-digi-dey/recipes-support/swupdate/swupdate_git.bbappend @@ -6,6 +6,8 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" SRCREV = "edd6559728d2e234ebdc03ba1d5444449ae2b92b" PV = "2016.10+git${SRCPV}" +SRC_URI += "file://0001-progress_client-add-command-line-parameter.patch" + do_install_append() { # The 'progress' command is new starting in version '2016.10', but we # don't need to do a version check here because the bbappend is version