local ipkg = require("luci.model.ipkg")
local void = nil
local submit = luci.http.formvalue("submit")
+ local changes = false
-- Search query
install = {}
end
install[url] = 1
+ changes = true
end
-- Do install
for k, v in pairs(install) do
void, install[k] = ipkg.install(k)
end
+ changes = true
end
if remove then
for k, v in pairs(remove) do
void, remove[k] = ipkg.remove(k)
- end
+ end
+ changes = true
end
end
luci.template.render("admin_system/packages", {pkgs=pkgs, query=query,
- install=install, remove=remove, update=update, upgrade=upgrade})
+ install=install, remove=remove, update=update, upgrade=upgrade})
+
+ -- Remove index cache
+ if changes then
+ luci.fs.unlink("/tmp/luci-indexcache")
+ end
end
function action_backup()
-- previous pages should arrange the stuff as required.
if step == 4 then
if has_platform and has_image and has_support then
- -- Next line is to bypass luci.http layer
- luci.http.context.eoh = true
-
-- Now invoke sysupgrade
local keepcfg = keep_avail and luci.http.formvalue("keepcfg") == "1"
- os.execute("/sbin/luci-flash %s %q" %{
+ local fd = io.popen("/sbin/luci-flash %s %q" %{
keepcfg and "-k %q" % _keep_pattern() or "", tmpfile
})
+ if fd then
+ while true do
+ local ln = fd:read("*l")
+ if not ln then break end
+ luci.http.write(ln)
+ end
+ fd:close()
+ end
+
-- Make sure the device is rebooted
luci.sys.reboot()
end