mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-11-16 10:47:55 +01:00
First steps towards package update support (current+available versions can be requested).
This commit is contained in:
parent
258770675e
commit
243655b634
6
opkg.conf
Normal file
6
opkg.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#src/gz wifibox http://doodle3d.com/static/wifibox-packages
|
||||||
|
src/gz wifibox http://192.168.5.2/~wouter/wifibox-packages
|
||||||
|
dest root /
|
||||||
|
dest ram /tmp
|
||||||
|
lists_dir ext /var/opkg-lists
|
||||||
|
option overlay_root /overlay
|
19
src/rest/api/api_info.lua
Normal file
19
src/rest/api/api_info.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
local M = {
|
||||||
|
isApi = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function M._global(request, response)
|
||||||
|
response:setSuccess()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.firmware(request, response)
|
||||||
|
--response:setSuccess()
|
||||||
|
-- can return (essentially all wraps ipkg output):
|
||||||
|
-- available (list)
|
||||||
|
-- current
|
||||||
|
-- latest
|
||||||
|
-- upgradable
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
52
src/rest/api/api_system.lua
Normal file
52
src/rest/api/api_system.lua
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
local M = {
|
||||||
|
isApi = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO: this function has been duplicated from test/test_wlanconfig.lua
|
||||||
|
local function captureCommandOutput(cmd)
|
||||||
|
local f = assert(io.popen(cmd, 'r'))
|
||||||
|
local output = assert(f:read('*all'))
|
||||||
|
--TODO: test if this works to obtain the return code (http://stackoverflow.com/questions/7607384/getting-return-status-and-program-output)
|
||||||
|
--local rv = assert(f:close())
|
||||||
|
--return output,rv[3]
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
function M._global(request, response)
|
||||||
|
response:setSuccess()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.fwversions(request, response)
|
||||||
|
local pkgName = 'wifibox'
|
||||||
|
local opkg = 'opkg -f /usr/share/lua/wifibox/opkg.conf'
|
||||||
|
local output, rv
|
||||||
|
|
||||||
|
response:setSuccess()
|
||||||
|
|
||||||
|
output = captureCommandOutput(opkg .. ' list-installed wifibox')
|
||||||
|
local version = output:match('^wifibox %- (.*)\n$')
|
||||||
|
response:addData('current', version)
|
||||||
|
|
||||||
|
rv = os.execute(opkg .. ' update >/dev/null')
|
||||||
|
if rv == 0 then
|
||||||
|
output = captureCommandOutput(opkg .. ' list wifibox')
|
||||||
|
local versions = {}
|
||||||
|
for v in output:gmatch('wifibox %- (%d+\.%d+\.%d+%-%d+) %- ') do
|
||||||
|
versions[#versions+1] = v
|
||||||
|
end
|
||||||
|
response:addData('all_versions', versions)
|
||||||
|
else
|
||||||
|
response:setFail("could not fetch update list")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- functie maken om mbv 'opkg compare-versions <v1> <op> <v2>' versies te vergelijken?
|
||||||
|
-- of intern vergelijken? (uitsplitsen naar major/minor/patch/pkgrel)
|
||||||
|
-- met comparefunctie (voor table.sort())
|
||||||
|
|
||||||
|
-- TO UPGRADE to version x (e.g. 0.1.0-7) (met force-optie):
|
||||||
|
-- 'opkg update'
|
||||||
|
-- 'opkg upgrade wifibox' (state versions explicitly?)
|
||||||
|
|
||||||
|
return M
|
Loading…
Reference in New Issue
Block a user