2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 local bit = require "bit"
17 local opkg = require "luci.model.ipkg"
18 local fs = require "nixio.fs"
19 local wa = require "luci.tools.webadmin"
24 return (rowcnt % 2) + 1
27 function opkg_error(code)
28 code = bit.rshift(tonumber(code), 8)
29 return translate("OPKG error code %i" % code)
32 local fstat = fs.statvfs(opkg.overlay_root())
33 local space_total = fstat and fstat.blocks or 0
34 local space_free = fstat and fstat.bfree or 0
35 local space_used = space_total - space_free
37 local used_perc = math.floor(0.5 + ((space_total > 0) and ((100 / space_total) * space_used) or 100))
38 local free_byte = space_free * fstat.frsize
42 <h2><a id="content" name="content"><%:System%> - <%:Software%></a></h2>
44 <form method="post" action="<%=REQUEST_URI%>">
46 <fieldset class="cbi-section">
48 <li><a href="<%=REQUEST_URI%>/ipkg"><%:Edit package lists and installation targets%></a></li>
49 <li><a href="<%=REQUEST_URI%>?update=1"><%:Update package lists%></a></li>
52 <fieldset class="cbi-section-node">
53 <div class="cbi-value">
54 <label class="cbi-value-title"><%:Download and install package%>:</label>
55 <div class="cbi-value-field">
56 <input type="text" name="url" size="30" value="" />
57 <input class="cbi-input-save" type="submit" name="submit" value="<%:OK%>" />
61 <div class="cbi-value">
62 <label class="cbi-value-title"><%:Filter%>:</label>
63 <div class="cbi-value-field">
64 <input type="text" name="query" size="20" value="<%=query%>" />
65 <input type="submit" class="cbi-input-find" name="search" value="<%:Find package%>" />
73 <fieldset class="cbi-section">
74 <%:Free space%>: <strong><%=(100-used_perc)%>%</strong> (<strong><%=wa.byte_format(free_byte)%></strong>)
75 <div style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080">
76 <div style="background-color:#F08080; border-right:1px solid #000000; height:100%; width:<%=used_perc%>%"> </div>
79 <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
82 <%:Package lists updated%>: <% if update == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(update)%>)</span><% end %><br />
85 <%:Upgrade installed packages%>: <% if upgrade == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(upgrade)%>)</span><% end %><br />
87 <% if install then for k,v in pairs(install) do %>
88 <%:Install%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(v)%>)</span><% end %><br />
90 <% if remove then for k,v in pairs(remove) do %>
91 <%:Remove%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(v)%>)</span><% end %><br />
97 <h3><%:Installed packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %></h3>
99 <fieldset class="cbi-section">
100 <table class="cbi-section-table" style="width:100%">
101 <tr class="cbi-section-table-titles">
102 <th class="cbi-section-table-cell" style="text-align:left"> </th>
103 <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
104 <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
106 <% local empty = true; luci.model.ipkg.list_installed(query, function(n, v, d) empty = false %>
107 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
108 <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Remove%> "<%=luci.util.pcdata(n)%>" ?')" href="<%=REQUEST_URI%>?submit=1&remove=<%=luci.util.pcdata(n)%>"><%:Remove%></a></td>
109 <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
110 <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
114 <tr class="cbi-section-table-row">
115 <td style="text-align:left"> </td>
116 <td style="text-align:left"><em><%:none%></em></td>
117 <td style="text-align:left"><em><%:none%></em></td>
125 <h3><%:Available packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %></h3>
127 <fieldset class="cbi-section">
128 <table class="cbi-section-table" style="width:100%">
129 <tr class="cbi-section-table-titles">
130 <th class="cbi-section-table-cell" style="text-align:left"> </th>
131 <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
132 <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
133 <th class="cbi-section-table-cell" style="text-align:left"><%:Description%></th>
135 <% local empty = true; luci.model.ipkg.list_all(query, function(n, v, d) empty = false %>
136 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
137 <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Install%> "<%=luci.util.pcdata(n)%>" ?')" href="<%=REQUEST_URI%>?submit=1&install=<%=luci.util.pcdata(n)%>"><%:Install%></a></td>
138 <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
139 <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
140 <td style="text-align:left"><%=luci.util.pcdata(d)%></td>
144 <tr class="cbi-section-table-row">
145 <td style="text-align:left"> </td>
146 <td style="text-align:left"><em><%:none%></em></td>
147 <td style="text-align:left"><em><%:none%></em></td>
148 <td style="text-align:left"><em><%:none%></em></td>