From e820c23f8bd1986a2fe18c89e35b4b29328ae4e3 Mon Sep 17 00:00:00 2001 From: Paul Rathgeb Date: Thu, 22 Oct 2015 11:40:19 +0200 Subject: [PATCH 01/18] Updater search only for a script file (update.sh) --- handlers/updaterHandler.py | 123 +++++++++---------------------------- www/libs/weio/updater.js | 29 +-------- 2 files changed, 33 insertions(+), 119 deletions(-) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 773e901e..7c50d79f 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -90,7 +90,6 @@ def __init__(self, *args, **kwargs): # key is comming from socket and call associated function self.callbacks = { 'checkVersion' : self.checkForUpdates, - 'downloadUpdate' : self.downloadUpdate, 'reinstallFw' : self.reinstallFw } @@ -105,9 +104,9 @@ def __init__(self, *args, **kwargs): self.fwSizeWatcherThread = None if (platform.machine()=="mips") : - self.fwPath = "/tmp/weio_recovery.bin" + self.fwPath = "/tmp/update.sh" else : - self.fwPath = "./weio_recovery.bin" + self.fwPath = "./update.sh" def isConnected(self, address): try: @@ -139,19 +138,9 @@ def checkForUpdates(self, rq): data = {} if (self.isConnected("we-io.net") or self.isConnected("www.github.com")): config = weioConfig.getConfiguration() - repository = "" - print "REPO", config["weio_update_use_official_repository"] - if (config["weio_update_use_official_repository"] == "YES") : - repository = config["weio_update_official_repository"] - else : - repository = config["weio_update_alternate_repository"] + repository = config["weio_update_official_repository"] - h = httputil.HTTPHeaders({"Accept" : "application/vnd.github.v3+json","User-Agent" : "weio"}) - req = None - if (config["weio_update_use_official_repository"] == "YES"): - req = httpclient.HTTPRequest(repository, headers=h) - else : - req = httpclient.HTTPRequest(repository) + req = httpclient.HTTPRequest(repository) http_client = httpclient.AsyncHTTPClient() http_client.fetch(req, callback=self.checkVersion) @@ -173,14 +162,17 @@ def checkVersion(self, response): config = weioConfig.getConfiguration() data = json.loads(response.body) - #f = open("github.json", "w") - #f.write(json.dumps(data, indent=4, sort_keys=True)) - #f.close() - #print json.dumps(data, indent=4, sort_keys=True) + lastUpdate = data[0] + + # Fetch the distant version + # XXX it supposes that the distant version number is prefixed with 'v' + # The updater will break here if this prefix is removed in the future distantVersion = float(lastUpdate["tag_name"].split("v")[1]) + # Check the current version currentVersion = float(config["weio_version"]) + print "current",currentVersion,"distant", distantVersion rsp = {} @@ -189,7 +181,7 @@ def checkVersion(self, response): rsp['distantVersion'] = str(distantVersion) if (distantVersion > currentVersion): - print "OK update is needed" + print "Update is available" # OK we have to update weio version rsp['needsUpdate'] = "YES" rsp['description'] = lastUpdate["name"] @@ -197,83 +189,24 @@ def checkVersion(self, response): rsp['install_duration'] = self.estimatedInstallTime self.downloadUpdateLink = "" - for file in lastUpdate["assets"]: - if ("weio.tar.gz" in file["name"]): - self.downloadUpdateLink = file["browser_download_url"] - self.updateDownloadSize = file["size"] - print self.updateDownloadSize, "size", file["size"] + # XXX weio.tar.gz is not used anymore ? + #for file in lastUpdate["assets"]: + # if ("weio.tar.gz" in file["name"]): + # self.downloadUpdateLink = file["browser_download_url"] + # self.updateDownloadSize = file["size"] + # print self.updateDownloadSize, "size", file["size"] else : rsp['needsUpdate'] = "NO" # You can always reflash with last version even if there are no new updates for file in lastUpdate["assets"]: - if ("weio_recovery.bin" in file["name"]): - print "found weio_recovery" + if ("update.sh" in file["name"]): + print "found update script" self.fwDownloadLink = file["browser_download_url"] self.fwDownloadSize = file["size"] self.send(json.dumps(rsp)) - @weioUnblock.unblock - def downloadUpdate(self, data): - config = weioConfig.getConfiguration() - - # ok now save binary in /tmp (folder in RAM) - print "downloaded" - - fileToStoreUpdate = "" - if (platform.machine()=="mips") : - fileToStoreUpdate = "/tmp/weioUpdate.tar.gz" - pathToDecompressUpdate = "/tmp" - else : - fileToStoreUpdate = "./weioUpdate.tar.gz" - pathToDecompressUpdate = "./" - - if not(self.downloadUpdateLink is None): - - sw = functools.partial(self.sizeWatcher, fileToStoreUpdate, self.updateDownloadSize) - sizeCheckerCallback = ioloop.PeriodicCallback(sw, 500) - sizeCheckerCallback.start() - self.startDownload(self.downloadUpdateLink, fileToStoreUpdate) - sizeCheckerCallback.stop() - - # Check is file size is the same as on the server - sizeOnDisk = os.path.getsize(fileToStoreUpdate) - print "comparing sizes", sizeOnDisk, self.updateDownloadSize - if (sizeOnDisk == self.updateDownloadSize): - # OK - print "File size is OK" - self.progressInfo("50%", "File size OK") - print "Bundle decompressing" - tar = tarfile.open(fileToStoreUpdate) - tar.extractall(pathToDecompressUpdate) - tar.close() - print "Bundle decompressed" - #self.progressInfo("80%", "WeIO Bundle decompressed") - - # kill arhive that we don't need anymore to free RAM - os.remove(fileToStoreUpdate) - global currentWeioConfigurator - print "Setting kill flag to YES in current config.weio" - print "Now I'm ready to exit Tornado and install new version" - config["kill_flag"] = "YES" - weioConfig.saveConfiguration(config) - #self.progressInfo("81%", "WeIO installing") - # Now quit Tornado and leave script to do his job - ioloop.IOLoop.instance().stop() - exit() - - else : - print "MD5 checksum is not OK, retrying..." - if (self.downloadTries<2): - self.progressInfo("5%", "Downloading Bundle again, MD5 checkum was not correct") - self.downloadUpdate(None) - else: - print "Something went wrong. Check Internet connection and try again later" - self.progressInfo("0%", "Something went wrong. Check Internet connection and try again later") - - self.downloadTries+=1 - # Automatic status sender def progressInfo(self, progress, info): data = {} @@ -286,6 +219,7 @@ def progressInfo(self, progress, info): @weioUnblock.unblock def reinstallFw(self, data): if not(self.fwDownloadLink is None): + # XXX Is it to check the internet connection ? if (self.isConnected("we-io.net") or self.isConnected("www.github.com")): print "will download fw from", self.fwDownloadLink @@ -307,18 +241,21 @@ def reinstallFw(self, data): sizeOnDisk = os.path.getsize(self.fwPath) print "Size matching", self.fwDownloadSize, sizeOnDisk if (self.fwDownloadSize == sizeOnDisk): + p = subprocess.Popen(["sh", self.fwPath]) + # XXX following should be moved in the remote script # protect user files # kill all symlinks first - p = subprocess.Popen(["sh", "/weio/scripts/userProjectsLinking.sh"]) - print p.communicate() + #p = subprocess.Popen(["sh", "/weio/scripts/userProjectsLinking.sh"]) + #print p.communicate() # move to new directory - os.rename("/weioUser/flash", "/weioUserBackup") + #os.rename("/weioUser/flash", "/weioUserBackup") # update FW - p = subprocess.Popen(["sysupgrade", "-v", self.fwPath]) + #p = subprocess.Popen(["sysupgrade", "-v", self.fwPath]) # don't protect user files #p = subprocess.Popen(["sysupgrade", "-v", "-n", self.fwPath]) - print p.communicate() + #print p.communicate() else : + # XXX errorDownloading need to be linked to a modal view a = {} a['serverPush'] = "errorDownloading" a['data'] = "" @@ -392,4 +329,4 @@ def serve(self, rq): def on_close(self) : global clients # Remove client from the clients list and broadcast leave message - clients.remove(self) \ No newline at end of file + clients.remove(self) diff --git a/www/libs/weio/updater.js b/www/libs/weio/updater.js index 659bd083..be947d96 100644 --- a/www/libs/weio/updater.js +++ b/www/libs/weio/updater.js @@ -115,7 +115,6 @@ $(document).ready(function() { callbacksUpdater[instruction](data); } else if ("serverPush" in data) { // this is instruction that was echoed from server + data as response - instruction = data.serverPush; if (instruction in callbacksUpdater) callbacksUpdater[instruction](data); @@ -136,41 +135,18 @@ $(document).ready(function() { /** * Update check. Asks server to compare it's own version with distant one */ - function updateCheck() { $("#needsUpdateStatus").html(" Checking updates..."); var rq = { "request": "checkVersion"}; updaterSocket.send(JSON.stringify(rq)); } - -function runUpdateProcedure() { - var rq = { "request": "checkVersion"}; - updaterSocket.send(JSON.stringify(rq)); - - $("#updateWeio").modal("hide"); - if (weioNeedsUpdate) { - $("#updateWeioProcedure").modal("show"); - var rq = { "request": "downloadUpdate"}; - updaterSocket.send(JSON.stringify(rq)); - updateMode = true; - $("#reloadMeButton").hide(); - } - -} - function updateProgressBar(data) { - //$("#progressStatus").html(data.info + " " + data.progress); - //$("#updateProgressBar").css("width", data.progress); - //estimatedInstallTime = data.estimatedInstallTime; - updaterTimerInterval = setInterval(function(){countTimeTillReload()},1000); - } function countTimeTillReload(data) { // normal update needs 35 secs to be done - delayTime = 100.0/estimatedInstallTime; weioUpdaterTimeTillReload+=delayTime; @@ -254,6 +230,7 @@ function noInternet() { * Define callbacks here and request keys * Each key is binded to coresponding function */ + // XXX need a modal view for errorDownloading var callbacksUpdater = { "checkVersion": checkVersion, "updateProgress" : updateProgressBar, @@ -277,7 +254,8 @@ function checkVersion(data) { $("#needsUpdateStatus").html("WeIO update is available!"); $("#updateButton").html("Update WeIO"); - + + // XXX Where is this message displayed ? txt = ""; txt+="Your current version is " + data.localVersion + " and the latest available is " + data.distantVersion; txt+="
"; @@ -303,7 +281,6 @@ function checkVersion(data) { function bringUpdater(){ if (modalIsPopulated && weioNeedsUpdate) { - //$("#updateWeio").modal("show"); $("#reinstallFw").modal("show"); } } From 9faea34598022a149351d82f8914ef584f780703 Mon Sep 17 00:00:00 2001 From: Paul Rathgeb Date: Thu, 22 Oct 2015 12:12:22 +0200 Subject: [PATCH 02/18] Added a MD5 check instead of size check --- handlers/updaterHandler.py | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 7c50d79f..570685fd 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -56,7 +56,6 @@ # pure websocket implementation #from tornado import websocket - from sockjs.tornado import SockJSRouter, SockJSConnection from weioLib import weioFiles @@ -179,31 +178,25 @@ def checkVersion(self, response): rsp['requested'] = "checkVersion" rsp['localVersion'] = str(currentVersion) rsp['distantVersion'] = str(distantVersion) + rsp['needsUpdate'] = "NO" if (distantVersion > currentVersion): print "Update is available" # OK we have to update weio version - rsp['needsUpdate'] = "YES" rsp['description'] = lastUpdate["name"] rsp['whatsnew'] = lastUpdate["body"] rsp['install_duration'] = self.estimatedInstallTime self.downloadUpdateLink = "" - # XXX weio.tar.gz is not used anymore ? - #for file in lastUpdate["assets"]: - # if ("weio.tar.gz" in file["name"]): - # self.downloadUpdateLink = file["browser_download_url"] - # self.updateDownloadSize = file["size"] - # print self.updateDownloadSize, "size", file["size"] - else : - rsp['needsUpdate'] = "NO" - - # You can always reflash with last version even if there are no new updates - for file in lastUpdate["assets"]: - if ("update.sh" in file["name"]): - print "found update script" - self.fwDownloadLink = file["browser_download_url"] - self.fwDownloadSize = file["size"] + for file in lastUpdate["assets"]: + if ("update.sh" in file["name"]): + # An update script is present in the server, so update can + # be performed + rsp['needsUpdate'] = "YES" + print "found update script" + self.fwDownloadLink = file["browser_download_url"] + self.fwDownloadSize = file["size"] + self.fwDownloadMD5 = file["md5"] self.send(json.dumps(rsp)) @@ -238,9 +231,10 @@ def reinstallFw(self, data): a['data'] = "" self.send(json.dumps(a)) - sizeOnDisk = os.path.getsize(self.fwPath) - print "Size matching", self.fwDownloadSize, sizeOnDisk - if (self.fwDownloadSize == sizeOnDisk): + fileMD5 = self.getMd5sum(self.fwPath) + print "MD5 matching", self.fwDownloadMD5, fileMD5 + if (self.fwDownloadMD5 == fileMD5): + print "MD5 match !" p = subprocess.Popen(["sh", self.fwPath]) # XXX following should be moved in the remote script # protect user files From 2e5d9b6377f5cc5ce6dc245a05dd7cefb89a1188 Mon Sep 17 00:00:00 2001 From: Paul Rathgeb Date: Thu, 22 Oct 2015 13:09:24 +0200 Subject: [PATCH 03/18] The script name is not hardcoded anymore, and can be any executable file --- handlers/updaterHandler.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 570685fd..31a60455 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -47,7 +47,7 @@ # ### -import os, signal, sys, platform, subprocess, urllib2 +import os, stat, signal, sys, platform, subprocess, urllib2 from tornado import web, ioloop, iostream, gen, httpclient, httputil sys.path.append(r'./'); @@ -102,10 +102,12 @@ def __init__(self, *args, **kwargs): self.fwDownloadSize = None self.fwSizeWatcherThread = None + self.updateScript = None + if (platform.machine()=="mips") : - self.fwPath = "/tmp/update.sh" + self.fwPath = "/tmp/" else : - self.fwPath = "./update.sh" + self.fwPath = "./" def isConnected(self, address): try: @@ -189,14 +191,13 @@ def checkVersion(self, response): self.downloadUpdateLink = "" for file in lastUpdate["assets"]: - if ("update.sh" in file["name"]): - # An update script is present in the server, so update can - # be performed - rsp['needsUpdate'] = "YES" - print "found update script" - self.fwDownloadLink = file["browser_download_url"] - self.fwDownloadSize = file["size"] - self.fwDownloadMD5 = file["md5"] + # Get the update script + self.updateScript = self.fwPath + file["name"] + rsp['needsUpdate'] = "YES" + print "found update script" + self.fwDownloadLink = file["browser_download_url"] + self.fwDownloadSize = file["size"] + self.fwDownloadMD5 = file["md5"] self.send(json.dumps(rsp)) @@ -216,10 +217,10 @@ def reinstallFw(self, data): if (self.isConnected("we-io.net") or self.isConnected("www.github.com")): print "will download fw from", self.fwDownloadLink - sw = functools.partial(self.sizeWatcher, self.fwPath, self.fwDownloadSize) + sw = functools.partial(self.sizeWatcher, self.updateScript, self.fwDownloadSize) sizeCheckerCallback = ioloop.PeriodicCallback(sw, 1000) sizeCheckerCallback.start() - self.startDownload(self.fwDownloadLink, self.fwPath) + self.startDownload(self.fwDownloadLink, self.updateScript) sizeCheckerCallback.stop() a = {} a['serverPush'] = "downloadingFw" @@ -231,11 +232,13 @@ def reinstallFw(self, data): a['data'] = "" self.send(json.dumps(a)) - fileMD5 = self.getMd5sum(self.fwPath) + fileMD5 = self.getMd5sum(self.updateScript) print "MD5 matching", self.fwDownloadMD5, fileMD5 if (self.fwDownloadMD5 == fileMD5): print "MD5 match !" - p = subprocess.Popen(["sh", self.fwPath]) + # Make the file executable + os.chmod(self.updateScript, 0755) + p = subprocess.Popen([self.updateScript]) # XXX following should be moved in the remote script # protect user files # kill all symlinks first From b090f1bcda761def5e74957462916179de25f84d Mon Sep 17 00:00:00 2001 From: Paul Rathgeb Date: Thu, 22 Oct 2015 13:18:40 +0200 Subject: [PATCH 04/18] Added a new item in the json assets to find the script --- handlers/updaterHandler.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 31a60455..499940a3 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -191,13 +191,14 @@ def checkVersion(self, response): self.downloadUpdateLink = "" for file in lastUpdate["assets"]: - # Get the update script - self.updateScript = self.fwPath + file["name"] - rsp['needsUpdate'] = "YES" - print "found update script" - self.fwDownloadLink = file["browser_download_url"] - self.fwDownloadSize = file["size"] - self.fwDownloadMD5 = file["md5"] + if file["script"] == 1: + # Get the update script + self.updateScript = self.fwPath + file["name"] + rsp['needsUpdate'] = "YES" + print "found update script" + self.fwDownloadLink = file["browser_download_url"] + self.fwDownloadSize = file["size"] + self.fwDownloadMD5 = file["md5"] self.send(json.dumps(rsp)) From b3dca873399a373ef83c83f2d09e3345ae8b39ee Mon Sep 17 00:00:00 2001 From: Paul Rathgeb Date: Thu, 22 Oct 2015 13:20:18 +0200 Subject: [PATCH 05/18] s/browser_download_url/download_url/ --- handlers/updaterHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 499940a3..59d9752e 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -196,7 +196,7 @@ def checkVersion(self, response): self.updateScript = self.fwPath + file["name"] rsp['needsUpdate'] = "YES" print "found update script" - self.fwDownloadLink = file["browser_download_url"] + self.fwDownloadLink = file["download_url"] self.fwDownloadSize = file["size"] self.fwDownloadMD5 = file["md5"] From f3f7f86e9f014e3b3c7d6908f65b8e2613d5549a Mon Sep 17 00:00:00 2001 From: Paul Rathgeb Date: Thu, 22 Oct 2015 13:22:17 +0200 Subject: [PATCH 06/18] Removed an unused import --- handlers/updaterHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 59d9752e..230de5d5 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -47,7 +47,7 @@ # ### -import os, stat, signal, sys, platform, subprocess, urllib2 +import os, signal, sys, platform, subprocess, urllib2 from tornado import web, ioloop, iostream, gen, httpclient, httputil sys.path.append(r'./'); From 37e365d0c29bafcd07600cca7e1d834cdb928c7f Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Sun, 25 Oct 2015 21:21:33 +0100 Subject: [PATCH 07/18] New updater from local we-io server --- config.weio | 16 +++---- handlers/updaterHandler.py | 75 +++++++++++++++++++----------- productionScripts/prepareUpdate.py | 50 ++++++++++++++++++++ 3 files changed, 105 insertions(+), 36 deletions(-) create mode 100755 productionScripts/prepareUpdate.py diff --git a/config.weio b/config.weio index 47309c27..1bf9c856 100755 --- a/config.weio +++ b/config.weio @@ -1,6 +1,6 @@ { - "absolut_root_path": "", - "auto_to_ap": "YES", + "absolut_root_path": "/Users/uros/workNow/nodesign/WeIO/weio/weio", + "auto_to_ap": "YES", "debug_mode": "False", "dependencies_path": "www", "dns_name": "weio.local", @@ -8,7 +8,7 @@ "extern_projects_path_flash": "/weioUser/flash", "extern_projects_path_sd": "/weioUser/sd", "extern_projects_path_usbFlash": "/weioUser/usbFlash", - "first_time_run": "YES", + "first_time_run": "NO", "https": "NO", "ip": "0.0.0.0", "kill_flag": "YES", @@ -18,18 +18,18 @@ ], "last_opened_project": "", "login_required": "NO", - "password": "", + "password": "weio", "play_composition_on_server_boot": "NO", "port": 8080, "remote": "", - "timezone": "CET-1CEST,M3.5.0,M10.5.0/3", - "user": "", + "timezone": "GMT0", + "user": "ukicar", "userAppPort": 80, "userApp_debug_mode": "False", "weio_board": "WeIO", "weio_lib_path": "weioLib", - "weio_update_alternate_repository": "http://we-io.net/downloads/updates.json", - "weio_update_official_repository": "https://api.github.com/repos/nodesign/weio/releases", + "weio_update_alternate_repository": "http://we-io.net/downloads/updateWeio.json", + "weio_update_official_repository": "http://we-io.net/downloads/updateWeio.json", "weio_update_use_official_repository": "YES", "weio_version": "1.1" } diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index 230de5d5..f1de39d6 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -92,8 +92,8 @@ def __init__(self, *args, **kwargs): 'reinstallFw' : self.reinstallFw } - self.downloadTries = 0 - self.estimatedInstallTime = 80 +# self.downloadTries = 0 +# self.estimatedInstallTime = 80 self.fwMd5 = None self.downloadUpdateLink = None @@ -102,13 +102,17 @@ def __init__(self, *args, **kwargs): self.fwDownloadSize = None self.fwSizeWatcherThread = None - self.updateScript = None + self.updateFileName = None if (platform.machine()=="mips") : + # put file to RAM self.fwPath = "/tmp/" else : + # this is where file will be saved on the PC self.fwPath = "./" + # check if there is Internet connection + # give some address as parameter, file to download address is welcome def isConnected(self, address): try: # see if we can resolve the host name -- tells us if there is @@ -122,28 +126,35 @@ def isConnected(self, address): pass return False - # checkForUpdates is entering point for updater + # This is entering point for updater # First it will download only update.weio to check if there is need for an update # If yes than archive will be downloaded and decompressed # Put flag in current config.weio that tells to OS that old weio will be removed # at next restart of system def checkForUpdates(self, rq): + # default mode is offline wifiMode = "ap" + #check hardware platform if (platform.machine() == 'mips') : + # check network state, if is STA then we can check if there is Internet wifiMode = weioIdeGlobals.WIFI.mode print "WIFI MODE ", wifiMode else : + # for local purposes only, testing on PC wifiMode = "sta" # local setting if (wifiMode=="sta"): data = {} - if (self.isConnected("we-io.net") or self.isConnected("www.github.com")): + # check if our server is reachable + if (self.isConnected("we-io.net")): config = weioConfig.getConfiguration() repository = config["weio_update_official_repository"] + # make request for a json file req = httpclient.HTTPRequest(repository) http_client = httpclient.AsyncHTTPClient() + # start fetching file at the end execute checkVersion function http_client.fetch(req, callback=self.checkVersion) else : # not connected to the internet @@ -164,12 +175,12 @@ def checkVersion(self, response): data = json.loads(response.body) - lastUpdate = data[0] + lastUpdate = data - # Fetch the distant version + # Read version form json file # XXX it supposes that the distant version number is prefixed with 'v' # The updater will break here if this prefix is removed in the future - distantVersion = float(lastUpdate["tag_name"].split("v")[1]) + distantVersion = float(lastUpdate["version"].split("v")[1]) # Check the current version currentVersion = float(config["weio_version"]) @@ -182,23 +193,26 @@ def checkVersion(self, response): rsp['distantVersion'] = str(distantVersion) rsp['needsUpdate'] = "NO" + # version differs so we need an update if (distantVersion > currentVersion): print "Update is available" # OK we have to update weio version - rsp['description'] = lastUpdate["name"] + rsp['description'] = lastUpdate["title"] rsp['whatsnew'] = lastUpdate["body"] - rsp['install_duration'] = self.estimatedInstallTime + #rsp['install_duration'] = self.estimatedInstallTime self.downloadUpdateLink = "" - for file in lastUpdate["assets"]: - if file["script"] == 1: - # Get the update script - self.updateScript = self.fwPath + file["name"] - rsp['needsUpdate'] = "YES" - print "found update script" - self.fwDownloadLink = file["download_url"] - self.fwDownloadSize = file["size"] - self.fwDownloadMD5 = file["md5"] + # set all parameters for download, but DON'T download yet + # this is a just version check + self.updateFileName = self.fwPath + "weio_recovery.bin" + rsp['needsUpdate'] = "YES" + print "setting parameters :" + self.fwDownloadLink = lastUpdate["download_url"] + print "download url", self.fwDownloadLink + self.fwDownloadSize = lastUpdate["size"] + print "file size", self.fwDownloadSize + self.fwDownloadMD5 = lastUpdate["md5"] + print "md5 checksum", self.fwDownloadSize self.send(json.dumps(rsp)) @@ -215,13 +229,17 @@ def progressInfo(self, progress, info): def reinstallFw(self, data): if not(self.fwDownloadLink is None): # XXX Is it to check the internet connection ? - if (self.isConnected("we-io.net") or self.isConnected("www.github.com")): + if (self.isConnected("we-io.net")): print "will download fw from", self.fwDownloadLink - sw = functools.partial(self.sizeWatcher, self.updateScript, self.fwDownloadSize) + # prepare for download + sw = functools.partial(self.sizeWatcher, self.updateFileName, self.fwDownloadSize) + # each second i'll be checking size on the disk and target size of the file sizeCheckerCallback = ioloop.PeriodicCallback(sw, 1000) + # start donwloading! sizeCheckerCallback.start() - self.startDownload(self.fwDownloadLink, self.updateScript) + # when finished downloading + self.startDownload(self.fwDownloadLink, self.updateFileName) sizeCheckerCallback.stop() a = {} a['serverPush'] = "downloadingFw" @@ -232,14 +250,14 @@ def reinstallFw(self, data): a['serverPush'] = "readyToReinstallFw" a['data'] = "" self.send(json.dumps(a)) - - fileMD5 = self.getMd5sum(self.updateScript) + print self.updateFileName + fileMD5 = self.getMd5sum(self.updateFileName) print "MD5 matching", self.fwDownloadMD5, fileMD5 if (self.fwDownloadMD5 == fileMD5): print "MD5 match !" - # Make the file executable - os.chmod(self.updateScript, 0755) - p = subprocess.Popen([self.updateScript]) + print "now exiting Tornado and executing update procedure" + ioloop.IOLoop.instance().stop() + exit() # XXX following should be moved in the remote script # protect user files # kill all symlinks first @@ -254,9 +272,10 @@ def reinstallFw(self, data): #print p.communicate() else : # XXX errorDownloading need to be linked to a modal view + print "MD5 don't match!!! Please retry" a = {} a['serverPush'] = "errorDownloading" - a['data'] = "" + a['data'] = "MD5 don't march. Please retry later" self.send(json.dumps(data)) else : data = {} diff --git a/productionScripts/prepareUpdate.py b/productionScripts/prepareUpdate.py new file mode 100755 index 00000000..583d8bfc --- /dev/null +++ b/productionScripts/prepareUpdate.py @@ -0,0 +1,50 @@ +import hashlib, sys, os, json + +# Get MD5 checksum from file +def getMd5sum(filename): + md5 = hashlib.md5() + with open(filename,'rb') as f: + for chunk in iter(lambda: f.read(128*md5.block_size), b''): + md5.update(chunk) + return md5.hexdigest() + +def checkIfFileExists(path): + if (os.path.exists(path)) : + return True + else : + return False + + +def saveConfiguration(path, conf): + inputFile = open(path+"/updateWeio.json", 'w') + print(inputFile) + ret = inputFile.write(json.dumps(conf, indent=4, sort_keys=True)) + inputFile.close() + + +if (len(sys.argv)==3): + + filePath = sys.argv[1] + directoryPath = None + + version = sys.argv[2] + + # check if file exists : + if (checkIfFileExists(filePath)): + # path exists + # extract directroy name for path where json will be created later + directoryPath = os.path.dirname(filePath) + + weioConfig = {} + weioConfig['download_url'] = 'http://we-io.net/downloads/'+version+"/weio_recovery.bin" + weioConfig['version'] = version + weioConfig['md5'] = getMd5sum(filePath) + weioConfig['size'] = os.path.getsize(filePath) + weioConfig['title'] = "Update to " + version + weioConfig['body'] = "This is a brand new version of WeIO great software" + + saveConfiguration(directoryPath, weioConfig) + else : + print "Filename is incorrect! Please provide valid path and filename" +else: + print "Enter filename of your binary first then version number (for example /somePath/weio_recovery.bin v1.2)" \ No newline at end of file From 28d60f412d3241b8079c917e487258d910be2d71 Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Sun, 25 Oct 2015 22:55:05 +0100 Subject: [PATCH 08/18] Introduced recipe concept in upgrading new os --- handlers/updaterHandler.py | 24 ++----- productionScripts/prepareUpdate.py | 36 +++++----- productionScripts/recipe | 110 +++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 33 deletions(-) create mode 100755 productionScripts/recipe diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index f1de39d6..fe238663 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -175,7 +175,7 @@ def checkVersion(self, response): data = json.loads(response.body) - lastUpdate = data + lastUpdate = data["recipe"] # Read version form json file # XXX it supposes that the distant version number is prefixed with 'v' @@ -204,7 +204,7 @@ def checkVersion(self, response): # set all parameters for download, but DON'T download yet # this is a just version check - self.updateFileName = self.fwPath + "weio_recovery.bin" + self.updateFileName = self.fwPath + "recipe" rsp['needsUpdate'] = "YES" print "setting parameters :" self.fwDownloadLink = lastUpdate["download_url"] @@ -255,21 +255,11 @@ def reinstallFw(self, data): print "MD5 matching", self.fwDownloadMD5, fileMD5 if (self.fwDownloadMD5 == fileMD5): print "MD5 match !" - print "now exiting Tornado and executing update procedure" - ioloop.IOLoop.instance().stop() - exit() - # XXX following should be moved in the remote script - # protect user files - # kill all symlinks first - #p = subprocess.Popen(["sh", "/weio/scripts/userProjectsLinking.sh"]) - #print p.communicate() - # move to new directory - #os.rename("/weioUser/flash", "/weioUserBackup") - # update FW - #p = subprocess.Popen(["sysupgrade", "-v", self.fwPath]) - # don't protect user files - #p = subprocess.Popen(["sysupgrade", "-v", "-n", self.fwPath]) - #print p.communicate() + print "now executing update procedure" + # Make the file executable + os.chmod(self.updateFileName, 0755) + p = subprocess.call(self.updateFileName) + # after this tornado will be killed from recipe script... else : # XXX errorDownloading need to be linked to a modal view print "MD5 don't match!!! Please retry" diff --git a/productionScripts/prepareUpdate.py b/productionScripts/prepareUpdate.py index 583d8bfc..45ccb6ab 100755 --- a/productionScripts/prepareUpdate.py +++ b/productionScripts/prepareUpdate.py @@ -14,7 +14,6 @@ def checkIfFileExists(path): else : return False - def saveConfiguration(path, conf): inputFile = open(path+"/updateWeio.json", 'w') print(inputFile) @@ -24,25 +23,30 @@ def saveConfiguration(path, conf): if (len(sys.argv)==3): - filePath = sys.argv[1] - directoryPath = None - + directoryPath = sys.argv[1] version = sys.argv[2] # check if file exists : - if (checkIfFileExists(filePath)): + if (checkIfFileExists(directoryPath)): # path exists - # extract directroy name for path where json will be created later - directoryPath = os.path.dirname(filePath) - - weioConfig = {} - weioConfig['download_url'] = 'http://we-io.net/downloads/'+version+"/weio_recovery.bin" - weioConfig['version'] = version - weioConfig['md5'] = getMd5sum(filePath) - weioConfig['size'] = os.path.getsize(filePath) - weioConfig['title'] = "Update to " + version - weioConfig['body'] = "This is a brand new version of WeIO great software" - + recipePath = directoryPath+"recipe" + recoveryPath = directoryPath+"weio_recovery.bin" + + # Put all relevant files here for update + weioRecipe = {} + weioRecipe['download_url'] = 'http://we-io.net/downloads/'+version+"/recipe" + weioRecipe['version'] = version + weioRecipe['md5'] = getMd5sum(recipePath) + weioRecipe['size'] = os.path.getsize(recipePath) + weioRecipe['title'] = "Update to " + version + weioRecipe['body'] = "This is a brand new version of WeIO great software" + + weioRecovery = {} + weioRecovery['download_url'] = 'http://we-io.net/downloads/'+version+"/weio_recovery.bin" + weioRecovery['md5'] = getMd5sum(recoveryPath) + weioRecovery['size'] = os.path.getsize(recoveryPath) + + weioConfig = {"recipe":weioRecipe, "recovery":weioRecovery} saveConfiguration(directoryPath, weioConfig) else : print "Filename is incorrect! Please provide valid path and filename" diff --git a/productionScripts/recipe b/productionScripts/recipe new file mode 100755 index 00000000..2864214e --- /dev/null +++ b/productionScripts/recipe @@ -0,0 +1,110 @@ +#!/usr/bin/python +### +# +# WEIO Web Of Things Platform +# Copyright (C) 2013 Nodesign.net, Uros PETREVSKI, Drasko DRASKOVIC +# All rights reserved +# +# ## ## ######## #### ####### +# ## ## ## ## ## ## ## +# ## ## ## ## ## ## ## +# ## ## ## ###### ## ## ## +# ## ## ## ## ## ## ## +# ## ## ## ## ## ## ## +# ### ### ######## #### ####### +# +# Web Of Things Platform +# +# This file is part of WEIO and is published under BSD license. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the WeIO project. +# 4. Neither the name of the WeIO nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY WEIO PROJECT AUTHORS AND CONTRIBUTORS ''AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL WEIO PROJECT AUTHORS AND CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Authors : +# Uros PETREVSKI +# Drasko DRASKOVIC +# +### +import urllib2, urllib, subprocess, platform, json, hashlib + +def startDownload(fwUrl, targetFile): + print "download init" + try: + req = urllib2.Request(fwUrl) + handle = urllib2.urlopen(req) + except urllib2.HTTPError, e: + print "Can't download firmware, error code - %s." % e.code + return + except urllib2.URLError: + print "Bad URL for firmware file: %s" % fwUrl + return + else: + print "download starts" + urllib.urlretrieve(fwUrl, targetFile) + print "download finished" + +def getMd5sum(filename): + md5 = hashlib.md5() + with open(filename,'rb') as f: + for chunk in iter(lambda: f.read(128*md5.block_size), b''): + md5.update(chunk) + return md5.hexdigest() + +def getJsonFromDisk(path): + inputFile = open(path, 'r') + rawData = inputFile.read() + inputFile.close() + return json.loads(rawData) + +targetPath = None + +if (platform.machine() == 'mips') : + # On WeIO save to RAM + targetPath = "/tmp" +else: + # On PC save in the place + targetPath = "./" + +# get json to extract MD5 data +print "getting JSON configuration from WeIO server" +startDownload("http://we-io.net/downloads/updateWeio.json", targetPath+"/updateWeio.json") + +data = getJsonFromDisk(targetPath+"/updateWeio.json") + +print "\ngetting new firmware from WeIO server" +startDownload(data["recovery"]["download_url"], targetPath+"/weio_recovery.bin") +recoveryMd5Distant = data["recovery"]["md5"] +recoveryMd5Local = getMd5sum(targetPath+"/weio_recovery.bin") + +if (recoveryMd5Distant == recoveryMd5Local): + print "MD5 matches. Starting sysupgrade procedure" + if (platform.machine() == 'mips') : + print "killing WeIO application to free RAM" + # do we need this as sysupgrade kills every process that is currently running? + p = subprocess.Popen(["/etc/init.d/weio_run", "stop"]) + # start upgrade + p = subprocess.Popen(["sysupgrade", "-v", targetPath+"/weio_recovery.bin"]) + print p.communicate() + From 71e088efc386b2736d44bc40ec5839ba805c618b Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Sun, 25 Oct 2015 22:59:24 +0100 Subject: [PATCH 09/18] Replaced files in their right place --- .../prepareForWeIOServer}/prepareUpdate.py | 0 {productionScripts => updateMaker/prepareForWeIOServer}/recipe | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {productionScripts => updateMaker/prepareForWeIOServer}/prepareUpdate.py (100%) rename {productionScripts => updateMaker/prepareForWeIOServer}/recipe (100%) diff --git a/productionScripts/prepareUpdate.py b/updateMaker/prepareForWeIOServer/prepareUpdate.py similarity index 100% rename from productionScripts/prepareUpdate.py rename to updateMaker/prepareForWeIOServer/prepareUpdate.py diff --git a/productionScripts/recipe b/updateMaker/prepareForWeIOServer/recipe similarity index 100% rename from productionScripts/recipe rename to updateMaker/prepareForWeIOServer/recipe From ad176e35344ef68a8bc915dada2e83e8fa6929f9 Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Mon, 26 Oct 2015 20:29:08 +0100 Subject: [PATCH 10/18] UpdateRecipe and no more versioning on our server --- handlers/updaterHandler.py | 2 +- updateMaker/prepareForWeIOServer/prepareUpdate.py | 8 +++++--- updateMaker/prepareForWeIOServer/{recipe => updateRecipe} | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) rename updateMaker/prepareForWeIOServer/{recipe => updateRecipe} (96%) diff --git a/handlers/updaterHandler.py b/handlers/updaterHandler.py index fe238663..965465b4 100644 --- a/handlers/updaterHandler.py +++ b/handlers/updaterHandler.py @@ -204,7 +204,7 @@ def checkVersion(self, response): # set all parameters for download, but DON'T download yet # this is a just version check - self.updateFileName = self.fwPath + "recipe" + self.updateFileName = self.fwPath + "updateRecipe" rsp['needsUpdate'] = "YES" print "setting parameters :" self.fwDownloadLink = lastUpdate["download_url"] diff --git a/updateMaker/prepareForWeIOServer/prepareUpdate.py b/updateMaker/prepareForWeIOServer/prepareUpdate.py index 45ccb6ab..fb967538 100755 --- a/updateMaker/prepareForWeIOServer/prepareUpdate.py +++ b/updateMaker/prepareForWeIOServer/prepareUpdate.py @@ -29,20 +29,22 @@ def saveConfiguration(path, conf): # check if file exists : if (checkIfFileExists(directoryPath)): # path exists - recipePath = directoryPath+"recipe" + recipePath = directoryPath+"updateRecipe" recoveryPath = directoryPath+"weio_recovery.bin" # Put all relevant files here for update + # RECIPE weioRecipe = {} - weioRecipe['download_url'] = 'http://we-io.net/downloads/'+version+"/recipe" + weioRecipe['download_url'] = 'http://we-io.net/downloads/update/bundle/updateRecipe' weioRecipe['version'] = version weioRecipe['md5'] = getMd5sum(recipePath) weioRecipe['size'] = os.path.getsize(recipePath) weioRecipe['title'] = "Update to " + version weioRecipe['body'] = "This is a brand new version of WeIO great software" + # RECOVERY weioRecovery = {} - weioRecovery['download_url'] = 'http://we-io.net/downloads/'+version+"/weio_recovery.bin" + weioRecovery['download_url'] = 'http://we-io.net/downloads/update/bundle/weio_recovery.bin' weioRecovery['md5'] = getMd5sum(recoveryPath) weioRecovery['size'] = os.path.getsize(recoveryPath) diff --git a/updateMaker/prepareForWeIOServer/recipe b/updateMaker/prepareForWeIOServer/updateRecipe similarity index 96% rename from updateMaker/prepareForWeIOServer/recipe rename to updateMaker/prepareForWeIOServer/updateRecipe index 2864214e..f1456383 100755 --- a/updateMaker/prepareForWeIOServer/recipe +++ b/updateMaker/prepareForWeIOServer/updateRecipe @@ -89,7 +89,7 @@ else: # get json to extract MD5 data print "getting JSON configuration from WeIO server" -startDownload("http://we-io.net/downloads/updateWeio.json", targetPath+"/updateWeio.json") +startDownload("http://we-io.net/downloads/update/updateWeio.json", targetPath+"/updateWeio.json") data = getJsonFromDisk(targetPath+"/updateWeio.json") @@ -107,4 +107,6 @@ if (recoveryMd5Distant == recoveryMd5Local): # start upgrade p = subprocess.Popen(["sysupgrade", "-v", targetPath+"/weio_recovery.bin"]) print p.communicate() - + else: + print "Doing nothing on PC, exiting" + exit() From 430a2c837f2cbce26126d808d877ca98b604448e Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Mon, 26 Oct 2015 21:47:29 +0100 Subject: [PATCH 11/18] Freeing memory before download --- updateMaker/prepareForWeIOServer/updateRecipe | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/updateMaker/prepareForWeIOServer/updateRecipe b/updateMaker/prepareForWeIOServer/updateRecipe index f1456383..ba376ca0 100755 --- a/updateMaker/prepareForWeIOServer/updateRecipe +++ b/updateMaker/prepareForWeIOServer/updateRecipe @@ -87,6 +87,10 @@ else: # On PC save in the place targetPath = "./" +# Kill WeIO at FIRST! +p = subprocess.Popen(["/etc/init.d/weio_run", "stop"]) +print p.communicate() + # get json to extract MD5 data print "getting JSON configuration from WeIO server" startDownload("http://we-io.net/downloads/update/updateWeio.json", targetPath+"/updateWeio.json") @@ -102,8 +106,6 @@ if (recoveryMd5Distant == recoveryMd5Local): print "MD5 matches. Starting sysupgrade procedure" if (platform.machine() == 'mips') : print "killing WeIO application to free RAM" - # do we need this as sysupgrade kills every process that is currently running? - p = subprocess.Popen(["/etc/init.d/weio_run", "stop"]) # start upgrade p = subprocess.Popen(["sysupgrade", "-v", targetPath+"/weio_recovery.bin"]) print p.communicate() From 9f5d43fea98c03d15ac139596e16d0f627126b07 Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Tue, 27 Oct 2015 19:06:46 +0100 Subject: [PATCH 12/18] Correct address for repository --- config.weio | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.weio b/config.weio index 1bf9c856..dd3a2cb6 100755 --- a/config.weio +++ b/config.weio @@ -29,7 +29,7 @@ "weio_board": "WeIO", "weio_lib_path": "weioLib", "weio_update_alternate_repository": "http://we-io.net/downloads/updateWeio.json", - "weio_update_official_repository": "http://we-io.net/downloads/updateWeio.json", + "weio_update_official_repository": "http://we-io.net/downloads/update/updateWeio.json", "weio_update_use_official_repository": "YES", "weio_version": "1.1" -} +} \ No newline at end of file From efb518fb1b5c26566aa75c76bf6c5f57dc7210d1 Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Wed, 28 Oct 2015 23:33:55 +0100 Subject: [PATCH 13/18] Deleted alternative repository as it's no more used --- config.weio | 2 -- 1 file changed, 2 deletions(-) diff --git a/config.weio b/config.weio index dd3a2cb6..5207405e 100755 --- a/config.weio +++ b/config.weio @@ -28,8 +28,6 @@ "userApp_debug_mode": "False", "weio_board": "WeIO", "weio_lib_path": "weioLib", - "weio_update_alternate_repository": "http://we-io.net/downloads/updateWeio.json", "weio_update_official_repository": "http://we-io.net/downloads/update/updateWeio.json", - "weio_update_use_official_repository": "YES", "weio_version": "1.1" } \ No newline at end of file From 71e7e716c7b4f101e9e4bb40a819d0a0706868e2 Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Wed, 28 Oct 2015 23:35:35 +0100 Subject: [PATCH 14/18] Added backup phase for userfiles and weio configuration --- updateMaker/prepareForWeIOServer/updateRecipe | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/updateMaker/prepareForWeIOServer/updateRecipe b/updateMaker/prepareForWeIOServer/updateRecipe index ba376ca0..49741b77 100755 --- a/updateMaker/prepareForWeIOServer/updateRecipe +++ b/updateMaker/prepareForWeIOServer/updateRecipe @@ -47,7 +47,7 @@ # Drasko DRASKOVIC # ### -import urllib2, urllib, subprocess, platform, json, hashlib +import urllib2, urllib, subprocess, platform, json, hashlib, os, shutil def startDownload(fwUrl, targetFile): print "download init" @@ -91,6 +91,22 @@ else: p = subprocess.Popen(["/etc/init.d/weio_run", "stop"]) print p.communicate() +# Now we can start update procedure + +# SAFE HOUSE +# Backup config.weio and userProjects +# this will be backuped after flashing with run_weio script (first time) +if (platform.machine() == 'mips') : + bckpdir = "/weioUserBackup" + # kill all symlinks in user projects otherwise it's not possible to move them or copy + p = subprocess.Popen(["sh", "/weio/scripts/killUserProjectSymlinks.sh"]) + print p.communicate() + # move user projects to the backup directory + shutil.move("/weioUser/flash", bckpdir) + # add config.weio to the safe house + shutil.copyfile("/weio/config.weio", bckpdir+"/config.weio") + +# DOWNLOADING PROCEDURE # get json to extract MD5 data print "getting JSON configuration from WeIO server" startDownload("http://we-io.net/downloads/update/updateWeio.json", targetPath+"/updateWeio.json") @@ -102,6 +118,7 @@ startDownload(data["recovery"]["download_url"], targetPath+"/weio_recovery.bin") recoveryMd5Distant = data["recovery"]["md5"] recoveryMd5Local = getMd5sum(targetPath+"/weio_recovery.bin") +# SYSTEM UPGRADE if (recoveryMd5Distant == recoveryMd5Local): print "MD5 matches. Starting sysupgrade procedure" if (platform.machine() == 'mips') : From 4770e45a66bec8c472d4aa2e54da10afe6a0ca98 Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Thu, 29 Oct 2015 19:11:06 +0100 Subject: [PATCH 15/18] This allows to upgrade an extrooted system. --- openWrt/files/lib/upgrade/keep.d/base-files | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openWrt/files/lib/upgrade/keep.d/base-files b/openWrt/files/lib/upgrade/keep.d/base-files index 15968a76..5da6b117 100644 --- a/openWrt/files/lib/upgrade/keep.d/base-files +++ b/openWrt/files/lib/upgrade/keep.d/base-files @@ -9,4 +9,5 @@ /etc/shadow /etc/dropbear/ /etc/crontabs/ -/weioUserBackup/ \ No newline at end of file +/weioUserBackup/ +/etc/config/fstab \ No newline at end of file From 2fefbb0721fb85038b78a4734361f0377adc9eaf Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Thu, 29 Oct 2015 19:15:21 +0100 Subject: [PATCH 16/18] Upgader added to Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a23175..2b0b78a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ WeIO 1.2, not released - System - Upgraded the system to OpenWRT Chaos Calmer (15.05). WeIO is now officially supported on OpenWRT, since version 15.05 (see git commit [here](http://git.openwrt.org/?p=15.05/openwrt.git;a=commit;h=21823760547b26d6b04a057583d25a0e346eced1)). Additionnal packages can now be installed via ```opkg``` from the official OpenWRT packages repository. - Added a way to extend the root filesystem to an SD Card ([How-to](https://github.com/nodesign/weio/wiki/How-to-extend-WeIO-flash-space)) + - Updater is part of the system and uses sysupgrade to upgrade firmware at each new version. User files and configuration are preserved - Firmware - The LPC Firmware can be compiled with ```make```, and now use ```newlib``` instead of ```redlib```. [LPC firmware repository](https://github.com/nodesign/UPER) From 7096270af4cfce1c4cad876041614ff2a0d089bb Mon Sep 17 00:00:00 2001 From: Uros Petrevski Date: Thu, 29 Oct 2015 19:16:41 +0100 Subject: [PATCH 17/18] Changed version to 1.2 --- config.weio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.weio b/config.weio index 5207405e..cf4a495b 100755 --- a/config.weio +++ b/config.weio @@ -29,5 +29,5 @@ "weio_board": "WeIO", "weio_lib_path": "weioLib", "weio_update_official_repository": "http://we-io.net/downloads/update/updateWeio.json", - "weio_version": "1.1" + "weio_version": "1.2" } \ No newline at end of file From d70f52da3e4a894499fbbb78c204f243b47464bc Mon Sep 17 00:00:00 2001 From: Drasko DRASKOVIC Date: Thu, 29 Oct 2015 19:19:48 +0100 Subject: [PATCH 18/18] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b0b78a0..c76bea29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ WeIO 1.2, not released - System - Upgraded the system to OpenWRT Chaos Calmer (15.05). WeIO is now officially supported on OpenWRT, since version 15.05 (see git commit [here](http://git.openwrt.org/?p=15.05/openwrt.git;a=commit;h=21823760547b26d6b04a057583d25a0e346eced1)). Additionnal packages can now be installed via ```opkg``` from the official OpenWRT packages repository. - Added a way to extend the root filesystem to an SD Card ([How-to](https://github.com/nodesign/weio/wiki/How-to-extend-WeIO-flash-space)) - - Updater is part of the system and uses sysupgrade to upgrade firmware at each new version. User files and configuration are preserved + - Modified system Updater to follow new OTA upgrade specification: https://github.com/nodesign/weio/wiki/Updater - Firmware - The LPC Firmware can be compiled with ```make```, and now use ```newlib``` instead of ```redlib```. [LPC firmware repository](https://github.com/nodesign/UPER)