0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-06-02 08:24:33 +02:00

Change update site URL to be a setting.

Show release date in command-line info.
Remove development path from updater script.
This commit is contained in:
Wouter R 2014-02-25 14:26:31 +01:00
parent a5f0492a13
commit ef296218a2
4 changed files with 55 additions and 34 deletions

View File

@ -20,10 +20,10 @@ local lfs = require('lfs') -- assume this exists since it's required by penlight
-- CONSTANTS AND VARIABLES -- -- CONSTANTS AND VARIABLES --
----------------------------- -----------------------------
local SERVER_HOST = 'localhost' --local SERVER_HOST = 'localhost'
local SERVER_PATH = '~USERDIR/public_html/wifibox/updates' --local SERVER_PATH = '~USERDIR/public_html/wifibox/updates'
--local SERVER_HOST = 'doodle3d.com' local SERVER_HOST = 'doodle3d.com'
--local SERVER_PATH = 'doodle3d.com/DEFAULT/updates' local SERVER_PATH = 'doodle3d.com/DEFAULT/updates'
local D3D_REPO_FIRMWARE_NAME = 'doodle3d-firmware' local D3D_REPO_FIRMWARE_NAME = 'doodle3d-firmware'
local D3D_REPO_CLIENT_NAME = 'doodle3d-client' local D3D_REPO_CLIENT_NAME = 'doodle3d-client'
@ -391,6 +391,7 @@ local function main()
um.setUseCache(false) um.setUseCache(false)
um.setVerbosity(1) um.setVerbosity(1)
um.setCachePath(imageCachePath()) um.setCachePath(imageCachePath())
--um.setBaseUrl('http://localhost/~USERDIR/wifibox/updates')
local newVersion,msg = collectLocalInfo() local newVersion,msg = collectLocalInfo()
if not newVersion then if not newVersion then
@ -449,7 +450,7 @@ local function main()
-- runAction("Building package feed directory", "failed", 5, buildFeedDir) -- runAction("Building package feed directory", "failed", 5, buildFeedDir)
local answer = getYesNo("? Local updates directory will be synced to remote server, proceed? (y/n) ") local answer = getYesNo("? Local updates cache will be synced to remote server, proceed? (y/n) ")
if answer ~= true then if answer ~= true then
print("Did not get green light, quitting.") print("Did not get green light, quitting.")
quit(5) quit(5)

View File

@ -335,10 +335,16 @@ M.doodle3d_tour_enabled = {
description = 'Show tour to new users' description = 'Show tour to new users'
} }
M.doodle3d_includeBetas = { M.doodle3d_update_includeBetas = {
default = false, default = false,
type = 'bool', type = 'bool',
description = 'Update to beta releases', description = 'Include beta releases when updating'
}
M.doodle3d_update_baseUrl = {
default = 'http://doodle3d.com/updates',
type = 'string',
description = ''
} }
return M return M

View File

@ -47,9 +47,11 @@ end
function M.status(request, response) function M.status(request, response)
local includeBetas = settings.get('doodle3d.update.includeBetas')
local baseUrl = settings.get('doodle3d.update.baseUrl')
updater.setLogger(log) updater.setLogger(log)
updater.setBaseUrl(baseUrl)
updater.setUseCache(false) updater.setUseCache(false)
local includeBetas = settings.get('doodle3d.includeBetas')
local success,status,msg = updater.getStatus(includeBetas) local success,status,msg = updater.getStatus(includeBetas)
response:addData('current_version', updater.formatVersion(status.currentVersion)) response:addData('current_version', updater.formatVersion(status.currentVersion))
@ -89,12 +91,14 @@ function M.download_POST(request, response)
-- block access to prevent potential issues with printing (e.g. out of memory) -- block access to prevent potential issues with printing (e.g. out of memory)
if not operationsAccessOrFail(request, response) then return end if not operationsAccessOrFail(request, response) then return end
local includeBetas = settings.get('doodle3d.update.includeBetas')
local baseUrl = settings.get('doodle3d.update.baseUrl')
updater.setLogger(log) updater.setLogger(log)
updater.setBaseUrl(baseUrl)
updater.setState(updater.STATE.DOWNLOADING,"") updater.setState(updater.STATE.DOWNLOADING,"")
local vEnt, rv, msg local vEnt, rv, msg
local includeBetas = settings.get('doodle3d.includeBetas')
if not argVersion then if not argVersion then
local success,status,msg = updater.getStatus(includeBetas) local success,status,msg = updater.getStatus(includeBetas)
@ -159,12 +163,14 @@ function M.install_POST(request, response)
if not operationsAccessOrFail(request, response) then return end if not operationsAccessOrFail(request, response) then return end
local includeBetas = settings.get('doodle3d.update.includeBetas')
local baseUrl = settings.get('doodle3d.update.baseUrl')
updater.setBaseUrl(baseUrl)
updater.setLogger(log) updater.setLogger(log)
updater.setState(updater.STATE.INSTALLING,"") updater.setState(updater.STATE.INSTALLING,"")
--local ssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) --local ssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid'))
--local rv,msg = netconf.enableAccessPoint(ssid) --local rv,msg = netconf.enableAccessPoint(ssid)
local includeBetas = settings.get('doodle3d.includeBetas')
if not argVersion then if not argVersion then
local success,status,msg = updater.getStatus(includeBetas) local success,status,msg = updater.getStatus(includeBetas)

View File

@ -44,11 +44,10 @@ M.STATE_NAMES = {
[M.STATE.INSTALLING] = 'installing', [M.STATE.INSTALLED] = 'installed', [M.STATE.INSTALL_FAILED] = 'install_failed' [M.STATE.INSTALLING] = 'installing', [M.STATE.INSTALLED] = 'installed', [M.STATE.INSTALL_FAILED] = 'install_failed'
} }
--- The base URL to use for finding update files. --- The default base URL to use for finding update files.
-- This URL will usually contain both an OpenWRT feed directory and an `images` directory. -- This URL will usually contain both an OpenWRT feed directory and an `images` directory.
-- This script uses only the latter, and expects to find the files @{IMAGE_STABLE_INDEX_FILE} and @{IMAGE_BETA_INDEX_FILE} there. -- This script uses only the latter, and expects to find the files @{IMAGE_STABLE_INDEX_FILE} and @{IMAGE_BETA_INDEX_FILE} there.
M.DEFAULT_BASE_URL = 'http://doodle3d.com/updates' M.DEFAULT_BASE_URL = 'http://doodle3d.com/updates'
--M.DEFAULT_BASE_URL = 'http://localhost/~USERNAME/wifibox/updates'
--- The index file containing metadata on stable update images. --- The index file containing metadata on stable update images.
M.IMAGE_STABLE_INDEX_FILE = 'wifibox-image.index' M.IMAGE_STABLE_INDEX_FILE = 'wifibox-image.index'
@ -277,39 +276,39 @@ end
--- Parses command-line arguments and returns a table containing information distilled from them. --- Parses command-line arguments and returns a table containing information distilled from them.
-- @tparam table arglist A table in the same form as the [arg table](http://www.lua.org/pil/1.4.html) created by Lua. -- @tparam table arglist A table in the same form as the [arg table](http://www.lua.org/pil/1.4.html) created by Lua.
-- @tparam table defaults A table with defaults settings (actually the basis for the returned table)
-- @treturn table|nil A table containing information on what to do, or nil if invalid arguments were specified. -- @treturn table|nil A table containing information on what to do, or nil if invalid arguments were specified.
-- @treturn ?string Descriptive message on error. -- @treturn ?string Descriptive message on error.
local function parseCommandlineArguments(arglist) local function parseCommandlineArguments(arglist, defaults)
local result = { verbosity = 0, baseUrl = M.DEFAULT_BASE_URL, includeBetas = false, action = nil }
local nextIsVersion, nextIsUrl = false, false local nextIsVersion, nextIsUrl = false, false
for index,argument in ipairs(arglist) do for index,argument in ipairs(arglist) do
if nextIsVersion then if nextIsVersion then
result.version = argument; nextIsVersion = false defaults.version = argument; nextIsVersion = false
elseif nextIsUrl then elseif nextIsUrl then
result.baseUrl = argument; nextIsUrl = false defaults.baseUrl = argument; nextIsUrl = false
else else
if argument == '-h' then result.action = 'showHelp' if argument == '-h' then defaults.action = 'showHelp'
elseif argument == '-q' then result.verbosity = -1 elseif argument == '-q' then defaults.verbosity = -1
elseif argument == '-V' then result.verbosity = 1 elseif argument == '-V' then defaults.verbosity = 1
elseif argument == '-c' then result.useCache = true elseif argument == '-c' then defaults.useCache = true
elseif argument == '-C' then result.useCache = false elseif argument == '-C' then defaults.useCache = false
elseif argument == '-u' then nextIsUrl = true elseif argument == '-u' then nextIsUrl = true
elseif argument == '-b' then result.includeBetas = true elseif argument == '-b' then defaults.includeBetas = true
elseif argument == '-v' then result.action = 'showCurrentVersion' elseif argument == '-v' then defaults.action = 'showCurrentVersion'
elseif argument == '-s' then result.action = 'showStatus' elseif argument == '-s' then defaults.action = 'showStatus'
elseif argument == '-l' then result.action = 'showAvailableVersions' elseif argument == '-l' then defaults.action = 'showAvailableVersions'
elseif argument == '-i' then result.action = 'showVersionInfo'; nextIsVersion = true elseif argument == '-i' then defaults.action = 'showVersionInfo'; nextIsVersion = true
elseif argument == '-d' then result.action = 'imageDownload'; nextIsVersion = true elseif argument == '-d' then defaults.action = 'imageDownload'; nextIsVersion = true
elseif argument == '-f' then result.action = 'imageInstall'; nextIsVersion = true elseif argument == '-f' then defaults.action = 'imageInstall'; nextIsVersion = true
elseif argument == '-r' then result.action = 'clear' elseif argument == '-r' then defaults.action = 'clear'
else return nil,"unrecognized argument '" .. argument .. "'" else return nil,"unrecognized argument '" .. argument .. "'"
end end
end end
end end
if result.version then if defaults.version then
result.version = M.parseVersion(result.version) defaults.version = M.parseVersion(defaults.version)
if not result.version then if not defaults.version then
return nil,"error parsing specified version" return nil,"error parsing specified version"
end end
end end
@ -317,7 +316,7 @@ local function parseCommandlineArguments(arglist)
if nextIsVersion then return nil, "missing required version argument" end if nextIsVersion then return nil, "missing required version argument" end
if nextIsUrl then return nil, "missing required URL argument" end if nextIsUrl then return nil, "missing required URL argument" end
return result return defaults
end end
--- Determines if the system is OpenWrt or not by checking if `/etc/openwrt_release` exists. --- Determines if the system is OpenWrt or not by checking if `/etc/openwrt_release` exists.
@ -875,7 +874,15 @@ end
-- so this file can also be used as a library. -- so this file can also be used as a library.
-- Command-line arguments are expected to be present in the global `arg` variable. -- Command-line arguments are expected to be present in the global `arg` variable.
local function main() local function main()
local argTable,msg = parseCommandlineArguments(arg) -- NOTE: this require must be local to functions which are only executed on the wifibox (i.e., where we have uci)
package.path = package.path .. ';/usr/share/lua/wifibox/?.lua'
local settings = require('util.settings')
local defaults = { verbosity = 0, baseUrl = M.DEFAULT_BASE_URL, includeBetas = false, action = nil }
local confBaseUrl = settings.get('doodle3d.update.baseUrl')
if confBaseUrl and confBaseUrl:len() > 0 then defaults.baseUrl = confBaseUrl end
local argTable,msg = parseCommandlineArguments(arg, defaults)
if not argTable then if not argTable then
E("error interpreting command-line arguments, try '-h' for help (".. msg ..")") E("error interpreting command-line arguments, try '-h' for help (".. msg ..")")
@ -959,6 +966,7 @@ local function main()
P(1, " factoryFilename:\t" .. (vEnt.factoryFilename or '-')) P(1, " factoryFilename:\t" .. (vEnt.factoryFilename or '-'))
P(1, " factoryFileSize:\t" .. (vEnt.factoryFileSize or '-')) P(1, " factoryFileSize:\t" .. (vEnt.factoryFileSize or '-'))
P(1, " factoryMD5:\t\t" .. (vEnt.factoryMD5 or '-')) P(1, " factoryMD5:\t\t" .. (vEnt.factoryMD5 or '-'))
P(1, " releaseDate:\t\t" .. (vEnt.timestamp and M.formatDate(vEnt.timestamp) or '-'))
if vEnt.changelog then if vEnt.changelog then
P(1, "\n--- Changelog ---\n" .. vEnt.changelog .. '---') P(1, "\n--- Changelog ---\n" .. vEnt.changelog .. '---')
else else