luci.model.ipkg.status/lookup doesn't handle opkg failures
See original GitHub issueAs mentioned in the comments, opkg sucks. I had been executing opkg status <pkg-name>
directly myself, but after getting errors like
* opkg_conf_load: Could not lock /var/lock/opkg.lock: Resource temporarily unavailable.
I was trying to use luci.model.ipkg.status(xxx) instead, and when calling this in rapid succession for numerous packages, I was, now simply getting a returned data block that was empty.
This is because the “os.execute(“opkg status”…” line doesn’t check the return code, and throws away stderr. See https://github.com/openwrt/luci/blob/master/modules/luci-base/luasrc/model/ipkg.lua#L87
A potential improvement would be…
local rc = os.execute(cmd .. (" >%s 2>>/tmp/opkg.fails.lua.log" % tmpfile))
local data
if rc == 0 then
data = _parselist(io.lines(tmpfile))
else
data = nil
end
os.remove(tmpfile)
return data
But that doesn’t really help fix the problem that opkg is just sucking on this. What I’ve done instead is get opkg status for the entire system, and parse that myself for the pkgs I care about.
Footnote, what on earth is the difference between opkg status and opkg info?!
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
I ended up parsing lists manually. The opkg program itself is too inefficient to be relied upon for any status querying.
My workaround of fetching the entire list is still in place, but you’re deprecating the entire class right? Are the alternatives: a) execute opkg directly, and b) convert to client side via… ? There’s nothing obvious under https://openwrt.github.io/luci/jsapi/index.html, i presume it’s declaring some effectively undocumented ubus method?