Luci opkg/packages: Show package size in list of available packages
[project/luci.git] / modules / luci-base / luasrc / model / ipkg.lua
index 41633c4..2ed92ca 100644 (file)
@@ -127,15 +127,15 @@ local function _list(action, pat, cb)
                (pat and (" '%s'" % pat:gsub("'", "")) or ""))
 
        if fd then
                (pat and (" '%s'" % pat:gsub("'", "")) or ""))
 
        if fd then
-               local name, version, desc
+               local name, version, sz, desc
                while true do
                        local line = fd:read("*l")
                        if not line then break end
 
                while true do
                        local line = fd:read("*l")
                        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 = ""
                        end
 
                                desc = ""
                        end
 
@@ -143,10 +143,11 @@ local function _list(action, pat, cb)
                                version = version:sub(1,21) .. ".." .. version:sub(-3,-1)
                        end
 
                                version = version:sub(1,21) .. ".." .. version:sub(-3,-1)
                        end
 
-                       cb(name, version, desc)
+                       cb(name, version, sz, desc)
 
                        name    = nil
                        version = nil
 
                        name    = nil
                        version = nil
+                       sz      = nil
                        desc    = nil
                end
 
                        desc    = nil
                end
 
@@ -155,15 +156,15 @@ local function _list(action, pat, cb)
 end
 
 function list_all(pat, cb)
 end
 
 function list_all(pat, cb)
-       _list("list", pat, cb)
+       _list("list --size", pat, cb)
 end
 
 function list_installed(pat, cb)
 end
 
 function list_installed(pat, cb)
-       _list("list_installed", pat, cb)
+       _list("list_installed --size", pat, cb)
 end
 
 function find(pat, cb)
 end
 
 function find(pat, cb)
-       _list("find", pat, cb)
+       _list("find --size", pat, cb)
 end
 
 
 end