From 2bbc4eb3c33c3590433174c599ec9418bdb8f38a Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 12 Sep 2008 16:12:23 +0000 Subject: [PATCH] Revert "Redesigned firmware upgrade process" --- .../package/luci-addons/dist/sbin/luci-flash | 4 ++++ i18n/english/luasrc/i18n/admin-core.en.lua | 2 +- i18n/english/luasrc/i18n/admin-core.en.xml | 2 +- i18n/german/luasrc/i18n/admin-core.de.lua | 2 +- i18n/german/luasrc/i18n/admin-core.de.xml | 2 +- libs/sgi-cgi/luasrc/sgi/cgi.lua | 1 - libs/sys/luasrc/sys.lua | 18 +++--------------- .../luasrc/controller/admin/system.lua | 9 +++++---- .../luasrc/view/admin_system/upgrade.htm | 18 ++++++++++++------ .../luasrc/controller/mini/system.lua | 9 +++++---- .../admin-mini/luasrc/view/mini/upgrade.htm | 18 ++++++++++++------ 11 files changed, 45 insertions(+), 40 deletions(-) diff --git a/contrib/package/luci-addons/dist/sbin/luci-flash b/contrib/package/luci-addons/dist/sbin/luci-flash index 07434b507..79bc834b4 100755 --- a/contrib/package/luci-addons/dist/sbin/luci-flash +++ b/contrib/package/luci-addons/dist/sbin/luci-flash @@ -85,5 +85,9 @@ done [ -n "$sysupgrade_init_conffiles" ] && do_save_conffiles run_hooks "" $sysupgrade_pre_upgrade +ask_bool() { + false +} + v "Switching to ramdisk..." run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade' diff --git a/i18n/english/luasrc/i18n/admin-core.en.lua b/i18n/english/luasrc/i18n/admin-core.en.lua index c260b59b4..88d6249c6 100644 --- a/i18n/english/luasrc/i18n/admin-core.en.lua +++ b/i18n/english/luasrc/i18n/admin-core.en.lua @@ -70,7 +70,7 @@ a_s_flash_flashed = 'Firmware successfully flashed. Rebooting device...' a_s_flash_flasherr = 'Failed to flash' a_s_flash_fwimage = 'Firmwareimage' a_s_flash_received = 'Image received. About to start flashing process. DO NOT POWER OFF THE DEVICE!' -a_s_flash_inprogress = 'Now writing firmware. Depending on your hardware this can take up to 20 minutes or more. Please check your device from time to time to see whether the writing process has completed.' +a_s_flash_inprogress = 'Writing firmware...' a_s_flash_fwupgrade = 'Flash Firmware' a_s_flash_keepcfg = 'Keep configuration files' a_s_flash_notimplemented = 'Sorry, this function is not (yet) available for your platform.' diff --git a/i18n/english/luasrc/i18n/admin-core.en.xml b/i18n/english/luasrc/i18n/admin-core.en.xml index 322185d97..c161a948c 100644 --- a/i18n/english/luasrc/i18n/admin-core.en.xml +++ b/i18n/english/luasrc/i18n/admin-core.en.xml @@ -74,7 +74,7 @@ Failed to flash Firmwareimage Image received. About to start flashing process. DO NOT POWER OFF THE DEVICE! -Now writing firmware. Depending on your hardware this can take up to 20 minutes or more. Please check your device from time to time to see whether the writing process has completed. +Writing firmware... Flash Firmware Keep configuration files Sorry, this function is not (yet) available for your platform. diff --git a/i18n/german/luasrc/i18n/admin-core.de.lua b/i18n/german/luasrc/i18n/admin-core.de.lua index 5221b9a39..30258fbff 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.lua +++ b/i18n/german/luasrc/i18n/admin-core.de.lua @@ -40,7 +40,7 @@ a_s_flash_flashed = 'Flashvorgang erfolgreich. Router startet neu...' a_s_flash_flasherr = 'Flashvorgang fehlgeschlagen' a_s_flash_fwimage = 'Firmwareimage' a_s_flash_received = 'Abbild empfangen. Starte Flashvorgang. SCHALTEN SIE DAS GERÄT NICHT AUS!' -a_s_flash_inprogress = 'Die Firmware wird nun geschrieben. Abhängig von der Hardware kann dieser Prozess bis zu 20 Minuten und länger dauern. Bitte prüfen sie das Gerät von Zeit zu Zeit, um zu sehen, ob der Schreibvorgang beendet ist.' +a_s_flash_inprogress = 'Schreibe Firmware...' a_s_flash_fwupgrade = 'Firmware aktualisieren' a_s_flash_keepcfg = 'Konfigurationsdateien übernehmen' a_s_flash_notimplemented = 'Diese Funktion steht leider (noch) nicht zur Verfügung.' diff --git a/i18n/german/luasrc/i18n/admin-core.de.xml b/i18n/german/luasrc/i18n/admin-core.de.xml index f963d0359..3a821c3fd 100644 --- a/i18n/german/luasrc/i18n/admin-core.de.xml +++ b/i18n/german/luasrc/i18n/admin-core.de.xml @@ -44,7 +44,7 @@ Flashvorgang fehlgeschlagen Firmwareimage Abbild empfangen. Starte Flashvorgang. SCHALTEN SIE DAS GERÄT NICHT AUS! -Die Firmware wird nun geschrieben. Abhängig von der Hardware kann dieser Prozess bis zu 20 Minuten und länger dauern. Bitte prüfen sie das Gerät von Zeit zu Zeit, um zu sehen, ob der Schreibvorgang beendet ist. +Schreibe Firmware... Firmware aktualisieren Konfigurationsdateien übernehmen Diese Funktion steht leider (noch) nicht zur Verfügung. diff --git a/libs/sgi-cgi/luasrc/sgi/cgi.lua b/libs/sgi-cgi/luasrc/sgi/cgi.lua index f78adeaed..d36d43fb5 100644 --- a/libs/sgi-cgi/luasrc/sgi/cgi.lua +++ b/libs/sgi-cgi/luasrc/sgi/cgi.lua @@ -61,7 +61,6 @@ function run() elseif id == 4 then io.write(data1) elseif id == 5 then - io.close() active = false end end diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index cf7fbc05f..e27e1c4e8 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -60,27 +60,15 @@ exec = luci.util.exec --- Invoke the luci-flash executable to write an image to the flash memory. -- @param image Local path or URL to image file -- @param kpattern Pattern of files to keep over flash process --- @return boolean indicating status --- @return error message if any +-- @return Return value of os.execute() function flash(image, kpattern) local cmd = "luci-flash " if kpattern then cmd = cmd .. "-k '" .. kpattern:gsub("'", "") .. "' " end - cmd = cmd .. "'" .. image:gsub("'", "") .. "' 2>/dev/null &" + cmd = cmd .. "'" .. image:gsub("'", "") .. "' >/dev/null 2>&1" - local fp = io.popen(cmd) - fp:setvbuf("no") - - local line = fp:read() - - if line == "Invalid image type" then - fp:close() - return false, line - else - fp:close() - return true - end + return os.execute(cmd) end --- Retrieve information about currently mounted file systems. diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index 55087a017..5d64336e0 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -182,7 +182,7 @@ end function action_upgrade() require("luci.model.uci") - local ret, err + local ret local plat = luci.fs.mtime("/lib/upgrade/platform.sh") local tmpfile = "/tmp/firmware.img" local broadcom = os.execute('grep brcm_ /lib/upgrade/platform.sh >/dev/null 2>&1') == 0 @@ -208,11 +208,12 @@ function action_upgrade() local keepcfg = keep_avail and luci.http.formvalue("keepcfg") if plat and fname then - ret, err = luci.sys.flash(tmpfile, keepcfg and _keep_pattern()) + ret = function() + return luci.sys.flash(tmpfile, keepcfg and _keep_pattern()) + end end - luci.template.render("admin_system/upgrade", {sysupgrade=plat, - ret=ret, err=err, keep_avail=keep_avail}) + luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail}) end function _keep_pattern() diff --git a/modules/admin-full/luasrc/view/admin_system/upgrade.htm b/modules/admin-full/luasrc/view/admin_system/upgrade.htm index 40f3ec984..a3d97d649 100644 --- a/modules/admin-full/luasrc/view/admin_system/upgrade.htm +++ b/modules/admin-full/luasrc/view/admin_system/upgrade.htm @@ -17,7 +17,7 @@ $Id$

<%:a_s_flash%>

<%:a_s_flash_upgrade1%>


-<% if sysupgrade and ret == nil then %> +<% if sysupgrade and not ret then %>
<%:a_s_flash_fwimage%>:
@@ -33,14 +33,20 @@ $Id$
-<% elseif ret ~= nil then %> - <% if ret then %> -

<%:a_s_flash_received%>

-

<%:a_s_flash_inprogress%>

+<% elseif ret then %> +

<%:a_s_flash_received%>

+

<%:a_s_flash_inprogress%>

+ + + <% %> + <% local ret = ret() + if ret == 0 then %> +
<%:a_s_flash_flashed%>
<% else %> -
<%:a_s_flash_flasherr%>! (<%=err%>)
+
<%:a_s_flash_flasherr%>! (<%:code%> <%=ret%>)
<% end %> <% else %>
<%:a_s_flash_notimplemented%>
<% end %> <%+footer%> +<% if ret == 0 then luci.sys.reboot() end %> diff --git a/modules/admin-mini/luasrc/controller/mini/system.lua b/modules/admin-mini/luasrc/controller/mini/system.lua index d68283cc6..6d16ef865 100644 --- a/modules/admin-mini/luasrc/controller/mini/system.lua +++ b/modules/admin-mini/luasrc/controller/mini/system.lua @@ -79,7 +79,7 @@ end function action_upgrade() require("luci.model.uci") - local ret, err + local ret = nil local plat = luci.fs.mtime("/lib/upgrade/platform.sh") local tmpfile = "/tmp/firmware.img" local broadcom = os.execute('grep brcm_ /lib/upgrade/platform.sh >/dev/null 2>&1') == 0 @@ -105,11 +105,12 @@ function action_upgrade() local keepcfg = keep_avail and luci.http.formvalue("keepcfg") if plat and fname then - ret, err = luci.sys.flash(tmpfile, keepcfg and _keep_pattern()) + ret = function() + return luci.sys.flash(tmpfile, keepcfg and _keep_pattern()) + end end - luci.template.render("admin_system/upgrade", {sysupgrade=plat, - ret=ret, err=err, keep_avail=keep_avail}) + luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret, keep_avail=keep_avail}) end function _keep_pattern() diff --git a/modules/admin-mini/luasrc/view/mini/upgrade.htm b/modules/admin-mini/luasrc/view/mini/upgrade.htm index 40f3ec984..a3d97d649 100644 --- a/modules/admin-mini/luasrc/view/mini/upgrade.htm +++ b/modules/admin-mini/luasrc/view/mini/upgrade.htm @@ -17,7 +17,7 @@ $Id$

<%:a_s_flash%>

<%:a_s_flash_upgrade1%>


-<% if sysupgrade and ret == nil then %> +<% if sysupgrade and not ret then %>
<%:a_s_flash_fwimage%>:
@@ -33,14 +33,20 @@ $Id$
-<% elseif ret ~= nil then %> - <% if ret then %> -

<%:a_s_flash_received%>

-

<%:a_s_flash_inprogress%>

+<% elseif ret then %> +

<%:a_s_flash_received%>

+

<%:a_s_flash_inprogress%>

+ + + <% %> + <% local ret = ret() + if ret == 0 then %> +
<%:a_s_flash_flashed%>
<% else %> -
<%:a_s_flash_flasherr%>! (<%=err%>)
+
<%:a_s_flash_flasherr%>! (<%:code%> <%=ret%>)
<% end %> <% else %>
<%:a_s_flash_notimplemented%>
<% end %> <%+footer%> +<% if ret == 0 then luci.sys.reboot() end %> -- 2.25.1