From 391e82d6a3f62ac721aa385e58f90b9ac803874e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 14 Nov 2018 14:07:41 +0100 Subject: [PATCH] luci-mod-system: replace builtin opkg support with luci-app-opkg Signed-off-by: Jo-Philipp Wich --- collections/luci/Makefile | 2 +- .../luasrc/controller/admin/system.lua | 124 ---------- .../luasrc/model/cbi/admin_system/ipkg.lua | 64 ------ .../luasrc/view/admin_system/ipkg.htm | 10 - .../luasrc/view/admin_system/packages.htm | 213 ------------------ 5 files changed, 1 insertion(+), 412 deletions(-) delete mode 100644 modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua delete mode 100644 modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm delete mode 100644 modules/luci-mod-system/luasrc/view/admin_system/packages.htm diff --git a/collections/luci/Makefile b/collections/luci/Makefile index c3174e8b9..739eb51bc 100644 --- a/collections/luci/Makefile +++ b/collections/luci/Makefile @@ -13,7 +13,7 @@ LUCI_TITLE:=LuCI interface with Uhttpd as Webserver (default) LUCI_DESCRIPTION:=Standard OpenWrt set including full admin with ppp support and the default Bootstrap theme LUCI_DEPENDS:= \ +uhttpd +luci-mod-admin-full +luci-theme-bootstrap \ - +luci-app-firewall +luci-proto-ppp +libiwinfo-lua +IPV6:luci-proto-ipv6 \ + +luci-app-firewall +luci-app-opkg +luci-proto-ppp +libiwinfo-lua +IPV6:luci-proto-ipv6 \ +rpcd-mod-rrdns PKG_LICENSE:=Apache-2.0 diff --git a/modules/luci-mod-system/luasrc/controller/admin/system.lua b/modules/luci-mod-system/luasrc/controller/admin/system.lua index 07d916c0a..68ca88b98 100644 --- a/modules/luci-mod-system/luasrc/controller/admin/system.lua +++ b/modules/luci-mod-system/luasrc/controller/admin/system.lua @@ -11,12 +11,6 @@ function index() entry({"admin", "system", "clock_status"}, post_on({ set = true }, "action_clock_status")) entry({"admin", "system", "admin"}, cbi("admin_system/admin"), _("Administration"), 2) - - if fs.access("/bin/opkg") then - entry({"admin", "system", "packages"}, post_on({ exec = "1" }, "action_packages"), _("Software"), 10) - entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg")) - end - entry({"admin", "system", "startup"}, form("admin_system/startup"), _("Startup"), 45) entry({"admin", "system", "crontab"}, form("admin_system/crontab"), _("Scheduled Tasks"), 46) @@ -61,124 +55,6 @@ function action_clock_status() luci.http.write_json({ timestring = os.date("%c") }) end -function action_packages() - local fs = require "nixio.fs" - local ipkg = require "luci.model.ipkg" - local submit = (luci.http.formvalue("exec") == "1") - local update, upgrade - local changes = false - local install = { } - local remove = { } - local stdout = { "" } - local stderr = { "" } - local out, err - - -- Display - local display = luci.http.formvalue("display") or "available" - - -- Letter - local letter = string.byte(luci.http.formvalue("letter") or "A", 1) - letter = (letter == 35 or (letter >= 65 and letter <= 90)) and letter or 65 - - -- Search query - local query = luci.http.formvalue("query") - query = (query ~= '') and query or nil - - - -- Modifying actions - if submit then - -- Packets to be installed - local ninst = luci.http.formvalue("install") - local uinst = nil - - -- Install from URL - local url = luci.http.formvalue("url") - if url and url ~= '' then - uinst = url - end - - -- Do install - if ninst then - install[ninst], out, err = ipkg.install(ninst) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - - if uinst then - local pkg - for pkg in luci.util.imatch(uinst) do - install[uinst], out, err = ipkg.install(pkg) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - end - - -- Remove packets - local rem = luci.http.formvalue("remove") - if rem then - remove[rem], out, err = ipkg.remove(rem) - stdout[#stdout+1] = out - stderr[#stderr+1] = err - changes = true - end - - - -- Update all packets - update = luci.http.formvalue("update") - if update then - update, out, err = ipkg.update() - stdout[#stdout+1] = out - stderr[#stderr+1] = err - end - - - -- Upgrade all packets - upgrade = luci.http.formvalue("upgrade") - if upgrade then - upgrade, out, err = ipkg.upgrade() - stdout[#stdout+1] = out - stderr[#stderr+1] = err - end - end - - - -- List state - local no_lists = true - local old_lists = false - if fs.access("/var/opkg-lists/") then - local list - for list in fs.dir("/var/opkg-lists/") do - no_lists = false - if (fs.stat("/var/opkg-lists/"..list, "mtime") or 0) < (os.time() - (24 * 60 * 60)) then - old_lists = true - break - end - end - end - - - luci.template.render("admin_system/packages", { - display = display, - letter = letter, - query = query, - install = install, - remove = remove, - update = update, - upgrade = upgrade, - no_lists = no_lists, - old_lists = old_lists, - stdout = table.concat(stdout, ""), - stderr = table.concat(stderr, "") - }) - - -- Remove index cache - if changes then - fs.unlink("/tmp/luci-indexcache") - end -end - local function image_supported(image) return (os.execute("sysupgrade -T %q >/dev/null" % image) == 0) end diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua deleted file mode 100644 index 7c6d7e1c6..000000000 --- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/ipkg.lua +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright 2008 Steven Barth --- Copyright 2008-2011 Jo-Philipp Wich --- Licensed to the public under the Apache License 2.0. - -local ipkgfile = "/etc/opkg.conf" -local distfeeds = "/etc/opkg/distfeeds.conf" -local customfeeds = "/etc/opkg/customfeeds.conf" - -f = SimpleForm("ipkgconf", translate("OPKG-Configuration"), translate("General options for opkg")) - -f:append(Template("admin_system/ipkg")) - -t = f:field(TextValue, "lines") -t.wrap = "off" -t.rows = 10 -function t.cfgvalue() - return nixio.fs.readfile(ipkgfile) or "" -end - -function t.write(self, section, data) - return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n")) -end - -function f.handle(self, state, data) - return true -end - -g = SimpleForm("distfeedconf", translate("Distribution feeds"), - translate("Build/distribution specific feed definitions. This file will NOT be preserved in any sysupgrade.")) - -d = g:field(TextValue, "lines2") -d.wrap = "off" -d.rows = 10 -function d.cfgvalue() - return nixio.fs.readfile(distfeeds) or "" -end - -function d.write(self, section, data) - return nixio.fs.writefile(distfeeds, data:gsub("\r\n", "\n")) -end - -function g.handle(self, state, data) - return true -end - -h = SimpleForm("customfeedconf", translate("Custom feeds"), - translate("Custom feed definitions, e.g. private feeds. This file can be preserved in a sysupgrade.")) - -c = h:field(TextValue, "lines3") -c.wrap = "off" -c.rows = 10 -function c.cfgvalue() - return nixio.fs.readfile(customfeeds) or "" -end - -function c.write(self, section, data) - return nixio.fs.writefile(customfeeds, data:gsub("\r\n", "\n")) -end - -function h.handle(self, state, data) - return true -end - -return f, g, h diff --git a/modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm b/modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm deleted file mode 100644 index a7ff4e50b..000000000 --- a/modules/luci-mod-system/luasrc/view/admin_system/ipkg.htm +++ /dev/null @@ -1,10 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - - diff --git a/modules/luci-mod-system/luasrc/view/admin_system/packages.htm b/modules/luci-mod-system/luasrc/view/admin_system/packages.htm deleted file mode 100644 index 9e364d69a..000000000 --- a/modules/luci-mod-system/luasrc/view/admin_system/packages.htm +++ /dev/null @@ -1,213 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2010 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%- -local opkg = require "luci.model.ipkg" -local fs = require "nixio.fs" -local wa = require "luci.tools.webadmin" -local rowcnt = 1 - -function rowstyle() - rowcnt = rowcnt + 1 - return (rowcnt % 2) + 1 -end - -local fstat = fs.statvfs(opkg.overlay_root()) -local space_total = fstat and fstat.blocks or 0 -local space_free = fstat and fstat.bfree or 0 -local space_used = space_total - space_free - -local used_perc = math.floor(0.5 + ((space_total > 0) and ((100 / space_total) * space_used) or 100)) -local free_byte = space_free * fstat.frsize - -local filter = { } - - -local opkg_list = luci.model.ipkg.list_all -local querypat -if query and #query > 0 then - querypat = '*%s*' % query - opkg_list = luci.model.ipkg.find -end - -local letterpat -if letter == 35 then - letterpat = "[^a-z]*" -else - letterpat = string.char(letter, 42) -- 'A' '*' -end - --%> - -<%+header%> - - -

<%:Software%>

- -
- - - -
- - - -
-
- <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %> -
- <% if #stdout > 0 then %>
<%=pcdata(stdout)%>
<% end %> - <% if #stderr > 0 then %>
<%=pcdata(stderr)%>
<% end %> -
- <% end %> - - <% if querypat then %> -
- <%:Displaying only packages containing%> "<%=pcdata(query)%>" - -
-
- <% end %> - - <% if no_lists or old_lists then %> -
- <% if old_lists then %> - <%:Package lists are older than 24 hours%> - <% else %> - <%:No package lists available%> - <% end %> - -
- <% end %> - -
- <%:Free space%>: <%=(100-used_perc)%>% (<%=wa.byte_format(free_byte)%>) -
-
 
-
-
-
- -
- -
- - -
- -
- disabled="disabled" placeholder="<%:Please update package lists first%>"<% end %> value="" /> - disabled="disabled"<% end %> value="<%:OK%>" /> -
-
- -
- -
- disabled="disabled" placeholder="<%:Please update package lists first%>"<% else %>value="<%=pcdata(query)%>"<% end %> /> - disabled="disabled"<% end %> value="<%:Find package%>" /> -
-
-
-
-
- - -

<%:Status%>

- - - - - <% if display ~= "available" then %> -
-
-
-
-
<%:Package name%>
-
<%:Version%>
-
 
-
- <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %> -
-
<%=luci.util.pcdata(n)%>
-
<%=luci.util.pcdata(v)%>
-
-
- - - - -
-
-
- <% end) %> - <% if empty then %> -
-
 
-
<%:none%>
-
<%:none%>
-
- <% end %> -
-
-
- <% else %> -
- <% if not querypat then %> - - <% end %> -
-
-
-
<%:Package name%>
-
<%:Version%>
-
<%:Size (.ipk)%>
-
<%:Description%>
-
 
-
- <% local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %> -
-
<%=luci.util.pcdata(n)%>
-
<%=luci.util.pcdata(v)%>
-
<%=luci.util.pcdata(s)%>
-
<%=luci.util.pcdata(d)%>
-
-
- - - - -
-
-
- <% end) %> - <% if empty then %> -
-
 
-
<%:none%>
-
<%:none%>
-
<%:none%>
-
<%:none%>
-
- <% end %> -
-
-
- <% end %> -
- -<%+footer%> -- 2.25.1