From: John Melton - G0ORX/N6LYT Date: Sun, 11 Dec 2016 20:11:11 +0000 (+0000) Subject: start of code update X-Git-Url: https://git.rkrishnan.org/uri/vdrive/%3C?a=commitdiff_plain;h=395c11d2bcc739e0ee88a68f820d79dfa8fa13ff;p=pihpsdr.git start of code update --- diff --git a/Makefile b/Makefile index 8383099..a67664c 100644 --- a/Makefile +++ b/Makefile @@ -192,7 +192,8 @@ vfo.c \ waterfall.c \ wdsp_init.c \ button_text.c \ -vox.c +vox.c \ +update.c HEADERS= \ @@ -251,7 +252,8 @@ vfo.h \ waterfall.h \ wdsp_init.h \ button_text.h \ -vox.h +vox.h \ +update.h OBJS= \ @@ -308,7 +310,8 @@ vfo.o \ waterfall.o \ wdsp_init.o \ button_text.o \ -vox.o +vox.o \ +update.o all: prebuild $(PROGRAM) $(HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES) @@ -331,4 +334,5 @@ install: cp pihpsdr ./release/pihpsdr cd release; tar cvf pihpsdr_$(GIT_VERSION).tar pihpsdr cd release; tar cvf pihpsdr.tar pihpsdr + cd release; echo $(GIT_VERSION) > pihpsdr/latest diff --git a/new_menu.c b/new_menu.c index dc65b2a..1509f71 100644 --- a/new_menu.c +++ b/new_menu.c @@ -417,11 +417,9 @@ static gboolean new_menu_pressed_event_cb (GtkWidget *widget, g_signal_connect (agc_b, "button-press-event", G_CALLBACK(agc_cb), NULL); gtk_grid_attach(GTK_GRID(grid),agc_b,5,4,1,1); -/* GtkWidget *test_b=gtk_button_new_with_label("Test"); g_signal_connect (test_b, "button-press-event", G_CALLBACK(test_cb), NULL); gtk_grid_attach(GTK_GRID(grid),test_b,0,5,1,1); -*/ gtk_container_add(GTK_CONTAINER(content),grid); diff --git a/test_menu.c b/test_menu.c index 2b0191a..197f28a 100644 --- a/test_menu.c +++ b/test_menu.c @@ -22,6 +22,7 @@ #include #include "new_menu.h" +#include "update.h" static GtkWidget *parent_window=NULL; @@ -37,7 +38,15 @@ static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer dat } static gboolean test_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { - gtk_window_iconify(GTK_WINDOW(parent_window)); + + int result=check_update(); + fprintf(stderr,"check_update returned %d\n",result); + + if(result>0) { + result=load_update(); + fprintf(stderr,"load_update returned %d\n",result); + } + return TRUE; } diff --git a/update.c b/update.c new file mode 100644 index 0000000..59de7ff --- /dev/null +++ b/update.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include + +#include "update.h" +#include "version.h" + +char new_version[128]; + +int check_update() { + + int rc=system("/usr/bin/wget -N https://github.com/g0orx/pihpsdr/raw/master/release/pihpsdr/latest"); + fprintf(stderr,"rc=%d\n", rc); + if(rc==-1) { + fprintf(stderr,"wget: errno=%d\n", errno); + } + + fprintf(stderr,"check_version: current version is %s\n",version); + strcpy(new_version,""); + + FILE* f=fopen("latest","r"); + if(f) { + fgets(new_version,sizeof(new_version),f); + fclose(f); + } else { + fprintf(stderr,"check_update: could not read latest version\n"); + return -1; + } + + if(strlen(new_version)==0) { + return -2; + } + + if(strlen(new_version)>0) { + if(new_version[strlen(new_version)-1]=='\n') { + new_version[strlen(new_version)-1]='\0'; + } + } + + fprintf(stderr,"check_version: latest version is %s\n",new_version); + + fprintf(stderr,"check_version: length of version=%d length of new_version=%d\n", strlen(version), strlen(new_version)); + rc=strcmp(version,new_version); + + return rc; +} + +int load_update() { + char command[1024]; + sprintf(command,"/usr/sbin/wget -N https://github.com/g0orx/pihpsdr/raw/master/release/pihpsdr_%s.tar",new_version); + +fprintf(stderr,"load_update: %s\n",command); + int rc=system(command); + fprintf(stderr,"rc=%d\n", rc); + if(rc==-1) { + fprintf(stderr,"wget: errnoc=%d\n", errno); + } else { + fprintf(stderr,"load_update: %s loaded\n", new_version); + } + return rc; +} diff --git a/update.h b/update.h new file mode 100644 index 0000000..ef4a5ed --- /dev/null +++ b/update.h @@ -0,0 +1,4 @@ +char new_version[]; + +extern int check_update(); +extern int load_update();