waterfall.c \
wdsp_init.c \
button_text.c \
-vox.c
+vox.c \
+update.c
HEADERS= \
waterfall.h \
wdsp_init.h \
button_text.h \
-vox.h
+vox.h \
+update.h
OBJS= \
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)
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
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);
#include <string.h>
#include "new_menu.h"
+#include "update.h"
static GtkWidget *parent_window=NULL;
}
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;
}
--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <errno.h>
+
+#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;
+}