2013-09-30 18:08:02 +02:00
|
|
|
local utils = require('util.utils')
|
|
|
|
|
2013-07-24 16:36:27 +02:00
|
|
|
local M = {
|
|
|
|
isApi = true
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2013-09-30 18:08:02 +02:00
|
|
|
output = utils.captureCommandOutput(opkg .. ' list-installed wifibox')
|
2013-07-24 16:36:27 +02:00
|
|
|
local version = output:match('^wifibox %- (.*)\n$')
|
|
|
|
response:addData('current', version)
|
|
|
|
|
|
|
|
rv = os.execute(opkg .. ' update >/dev/null')
|
|
|
|
if rv == 0 then
|
2013-09-30 18:08:02 +02:00
|
|
|
output = utils.captureCommandOutput(opkg .. ' list wifibox')
|
2013-07-24 16:36:27 +02:00
|
|
|
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
|