for-15.05 opkg/packages: Show package size in list of available packages

CC15.05 opkg was patched by https://dev.openwrt.org/changeset/47196
to support the --size option. This commit backports the Luci features:

Add package *.ipk size information to package listing in Luci,
as opkg was today extended to support listing also the size information.
Visible fields are now: name, version, size, description

That will help users considering installation of a certain package
to assess its size impact on flash.

Note: Opkg data includes the size of the .ipk file, not the expanded size.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
(cherry picked from commit 3288fe76ab)
This commit is contained in:
Hannu Nyman 2015-09-16 12:47:48 +03:00
parent 3e199390f7
commit ce5c787989
2 changed files with 13 additions and 9 deletions

View file

@ -127,15 +127,15 @@ function _list(action, pat, cb)
(pat and (" '%s'" % pat:gsub("'", "")) or "")) (pat and (" '%s'" % pat:gsub("'", "")) or ""))
if fd then if fd then
local name, version, desc local name, version, sz, desc
while true do while true do
local line = fd:read("*l") local line = fd:read("*l")
if not line then break end if not line then break end
name, version, desc = line:match("^(.-) %- (.-) %- (.+)") name, version, sz, desc = line:match("^(.-) %- (.-) %- (.-) %- (.+)")
if not name then if not name then
name, version = line:match("^(.-) %- (.+)") name, version, sz = line:match("^(.-) %- (.-) %- (.+)")
desc = "" desc = ""
end end
@ -143,10 +143,11 @@ function _list(action, pat, cb)
version = version:sub(1,21) .. ".." .. version:sub(-3,-1) version = version:sub(1,21) .. ".." .. version:sub(-3,-1)
end end
cb(name, version, desc) cb(name, version, sz, desc)
name = nil name = nil
version = nil version = nil
sz = nil
desc = nil desc = nil
end end
@ -155,15 +156,15 @@ function _list(action, pat, cb)
end end
function list_all(pat, cb) function list_all(pat, cb)
_list("list", pat, cb) _list("list --size", pat, cb)
end end
function list_installed(pat, cb) function list_installed(pat, cb)
_list("list_installed", pat, cb) _list("list_installed --size", pat, cb)
end end
function find(pat, cb) function find(pat, cb)
_list("find", pat, cb) _list("find --size", pat, cb)
end end

View file

@ -132,7 +132,7 @@ end
<th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th> <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th> <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
</tr> </tr>
<% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, d) empty = false; filter[n] = true %> <% local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>"> <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
<td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Remove%> &quot;<%=luci.util.pcdata(n)%>&quot; ?')" href="<%=REQUEST_URI%>?submit=1&amp;remove=<%=luci.util.pcdata(n)%>"><%:Remove%></a></td> <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Remove%> &quot;<%=luci.util.pcdata(n)%>&quot; ?')" href="<%=REQUEST_URI%>?submit=1&amp;remove=<%=luci.util.pcdata(n)%>"><%:Remove%></a></td>
<td style="text-align:left"><%=luci.util.pcdata(n)%></td> <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
@ -164,13 +164,15 @@ end
<th class="cbi-section-table-cell" style="text-align:left">&#160;</th> <th class="cbi-section-table-cell" style="text-align:left">&#160;</th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th> <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th> <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
<th class="cbi-section-table-cell" style="text-align:right"><%:Size (.ipk)%></th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Description%></th> <th class="cbi-section-table-cell" style="text-align:left"><%:Description%></th>
</tr> </tr>
<% local empty = true; opkg_list(querypat or letterpat, function(n, v, d) if filter[n] then return end; empty = false %> <% local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>"> <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
<td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Install%> &quot;<%=luci.util.pcdata(n)%>&quot; ?')" href="<%=REQUEST_URI%>?submit=1&amp;install=<%=luci.util.pcdata(n)%>"><%:Install%></a></td> <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Install%> &quot;<%=luci.util.pcdata(n)%>&quot; ?')" href="<%=REQUEST_URI%>?submit=1&amp;install=<%=luci.util.pcdata(n)%>"><%:Install%></a></td>
<td style="text-align:left"><%=luci.util.pcdata(n)%></td> <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
<td style="text-align:left"><%=luci.util.pcdata(v)%></td> <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
<td style="text-align:right"><%=luci.util.pcdata(s)%></td>
<td style="text-align:left"><%=luci.util.pcdata(d)%></td> <td style="text-align:left"><%=luci.util.pcdata(d)%></td>
</tr> </tr>
<% end) %> <% end) %>
@ -179,6 +181,7 @@ end
<td style="text-align:left">&#160;</td> <td style="text-align:left">&#160;</td>
<td style="text-align:left"><em><%:none%></em></td> <td style="text-align:left"><em><%:none%></em></td>
<td style="text-align:left"><em><%:none%></em></td> <td style="text-align:left"><em><%:none%></em></td>
<td style="text-align:right"><em><%:none%></em></td>
<td style="text-align:left"><em><%:none%></em></td> <td style="text-align:left"><em><%:none%></em></td>
</tr> </tr>
<% end %> <% end %>