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.
a11e6f2b80
https://jira.digi.com/browse/DEL-3356
Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
parent
f4ece3821e
commit
2a79bc29d0
|
|
@ -0,0 +1,133 @@
|
|||
From: Stefano Babic <sbabic@denx.de>
|
||||
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 <sbabic@denx.de>
|
||||
Signed-off-by: David Escalona <david.escalona@digi.com>
|
||||
---
|
||||
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 <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pthread.h>
|
||||
+#include <getopt.h>
|
||||
|
||||
#include <progress.h>
|
||||
|
||||
#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:
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue