diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-11-14 14:07:41 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-11-14 20:46:04 +0100 |
commit | 391e82d6a3f62ac721aa385e58f90b9ac803874e (patch) | |
tree | 43766bc5abcdec28f8dbfcbfb5f5dfc0c48bfd78 | |
parent | ff7bcda5bc8aea49a7c3a0e6df041194f46cae61 (diff) |
luci-mod-system: replace builtin opkg support with luci-app-opkg
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
5 files changed, 1 insertions, 412 deletions
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 <steven@midlink.org> --- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org> --- 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 <steven@midlink.org> - Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> - Licensed to the public under the Apache License 2.0. --%> - -<ul class="cbi-tabmenu"> - <li class="cbi-tab-disabled"><a href="<%=url("admin/system/packages")%>"><%:Actions%></a></li> - <li class="cbi-tab"><a href="#"><%:Configuration%></a></li> -</ul> 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 <steven@midlink.org> - Copyright 2008-2010 Jo-Philipp Wich <jow@openwrt.org> - 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%> - - -<h2 name="content"><%:Software%></h2> - -<div class="cbi-map"> - - <ul class="cbi-tabmenu"> - <li class="cbi-tab"><a href="#"><%:Actions%></a></li> - <li class="cbi-tab-disabled"><a href="<%=REQUEST_URI%>/ipkg"><%:Configuration%></a></li> - </ul> - - <form method="post" action="<%=REQUEST_URI%>"> - <input type="hidden" name="exec" value="1" /> - <input type="hidden" name="token" value="<%=token%>" /> - - <div class="cbi-section"> - <div class="cbi-section-node"> - <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %> - <div class="cbi-value"> - <% if #stdout > 0 then %><pre><%=pcdata(stdout)%></pre><% end %> - <% if #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %> - </div> - <% end %> - - <% if querypat then %> - <div class="cbi-value"> - <%:Displaying only packages containing%> <strong>"<%=pcdata(query)%>"</strong> - <input type="button" onclick="location.href='?display=<%=luci.http.urlencode(display)%>'" href="#" class="cbi-button cbi-button-reset" style="margin-left:1em" value="<%:Reset%>" /> - <br style="clear:both" /> - </div> - <% end %> - - <% if no_lists or old_lists then %> - <div class="cbi-value"> - <% if old_lists then %> - <%:Package lists are older than 24 hours%> - <% else %> - <%:No package lists available%> - <% end %> - <input type="submit" name="update" href="#" class="cbi-button cbi-button-apply" style="margin-left:3em" value="<%:Update lists%>" /> - </div> - <% end %> - - <div class="cbi-value cbi-value-last"> - <%:Free space%>: <strong><%=(100-used_perc)%>%</strong> (<strong><%=wa.byte_format(free_byte)%></strong>) - <div style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080" id="swfreespace"> - <div style="background-color:#F08080; border-right:1px solid #000000; height:100%; width:<%=used_perc%>%"> </div> - </div> - </div> - </div> - - <br /> - - <div class="cbi-section-node"> - <input type="hidden" name="display" value="<%=pcdata(display)%>" /> - - <div class="cbi-value"> - <label class="cbi-value-title"><%:Download and install package%>:</label> - <div class="cbi-value-field"> - <span><input type="text" name="url" size="30" <% if no_lists then %>disabled="disabled" placeholder="<%:Please update package lists first%>"<% end %> value="" /></span> - <input class="cbi-button cbi-button-save" type="submit" name="go" <% if no_lists then %>disabled="disabled"<% end %> value="<%:OK%>" /> - </div> - </div> - - <div class="cbi-value cbi-value-last"> - <label class="cbi-value-title"><%:Filter%>:</label> - <div class="cbi-value-field"> - <span><input type="text" name="query" size="20" <% if no_lists then %>disabled="disabled" placeholder="<%:Please update package lists first%>"<% else %>value="<%=pcdata(query)%>"<% end %> /></span> - <input type="submit" class="cbi-button cbi-button-action" name="search" <% if no_lists then %>disabled="disabled"<% end %> value="<%:Find package%>" /> - </div> - </div> - </div> - </div> - </form> - - - <h3><%:Status%></h3> - - - <ul class="cbi-tabmenu"> - <li class="cbi-tab<% if display ~= "available" then %>-disabled<% end %>"><a href="?display=available&query=<%=pcdata(query)%>"><%:Available packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li> - <li class="cbi-tab<% if display ~= "installed" then %>-disabled<% end %>"><a href="?display=installed&query=<%=pcdata(query)%>"><%:Installed packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li> - </ul> - - <% if display ~= "available" then %> - <div class="cbi-section"> - <div class="cbi-section-node"> - <div class="table"> - <div class="tr cbi-section-table-titles"> - <div class="th left"><%:Package name%></div> - <div class="th left"><%:Version%></div> - <div class="th cbi-section-actions"> </div> - </div> - <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %> - <div class="tr cbi-rowstyle-<%=rowstyle()%>"> - <div class="td left"><%=luci.util.pcdata(n)%></div> - <div class="td left"><%=luci.util.pcdata(v)%></div> - <div class="td cbi-section-actions"> - <form method="post" class="inline" action="<%=REQUEST_URI%>"> - <input type="hidden" name="exec" value="1" /> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="remove" value="<%=pcdata(n)%>" /> - <input class="cbi-button cbi-button-remove" type="submit" onclick="window.confirm('<%:Remove%> "<%=luci.util.pcdata(n)%>" ?') && this.parentNode.submit(); return false" value="<%:Remove%>" /> - </form> - </div> - </div> - <% end) %> - <% if empty then %> - <div class="tr cbi-section-table-row"> - <div class="td left"> </div> - <div class="td left"><em><%:none%></em></div> - <div class="td left"><em><%:none%></em></div> - </div> - <% end %> - </div> - </div> - </div> - <% else %> - <div class="cbi-section"> - <% if not querypat then %> - <ul class="cbi-tabmenu" style="flex-wrap:wrap"> - <% local i; for i = 65, 90 do %> - <li class="cbi-tab<% if letter ~= i then %>-disabled<% end %>"><a href="?display=available&letter=<%=string.char(i)%>"><%=string.char(i)%></a></li> - <% end %> - <li class="cbi-tab<% if letter ~= 35 then %>-disabled<% end %>"><a href="?display=available&letter=%23">#</a></li> - </ul> - <% end %> - <div class="cbi-section-node cbi-section-node-tabbed"> - <div class="table"> - <div class="tr cbi-section-table-titles"> - <div class="th col-2 left"><%:Package name%></div> - <div class="th col-2 left"><%:Version%></div> - <div class="th col-1 center"><%:Size (.ipk)%></div> - <div class="th col-10 left"><%:Description%></div> - <div class="th cbi-section-actions"> </div> - </div> - <% local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %> - <div class="tr cbi-rowstyle-<%=rowstyle()%>"> - <div class="td col-2 left"><%=luci.util.pcdata(n)%></div> - <div class="td col-2 left"><%=luci.util.pcdata(v)%></div> - <div class="td col-1 center"><%=luci.util.pcdata(s)%></div> - <div class="td col-10 left"><%=luci.util.pcdata(d)%></div> - <div class="td cbi-section-actions"> - <form method="post" class="inline" action="<%=REQUEST_URI%>"> - <input type="hidden" name="exec" value="1" /> - <input type="hidden" name="token" value="<%=token%>" /> - <input type="hidden" name="install" value="<%=pcdata(n)%>" /> - <input class="cbi-button cbi-button-apply" type="submit" onclick="window.confirm('<%:Install%> "<%=luci.util.pcdata(n)%>" ?') && this.parentNode.submit(); return false" value="<%:Install%>" /> - </form> - </div> - </div> - <% end) %> - <% if empty then %> - <div class="tr"> - <div class="td left"> </div> - <div class="td left"><em><%:none%></em></div> - <div class="td left"><em><%:none%></em></div> - <div class="td right"><em><%:none%></em></div> - <div class="td left"><em><%:none%></em></div> - </div> - <% end %> - </div> - </div> - </div> - <% end %> -</div> - -<%+footer%> |