X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=applications%2Fluci-app-opkg%2Fluasrc%2Fcontroller%2Fopkg.lua;h=ebdcf1b09c82a584491934750f50a239c5f808b3;hb=359379078e8ea786610d9dc1520f14f35239409c;hp=74aa166184c7448b0da40512a525018e21c01828;hpb=b6e240d8c372b98d0aa097bf325253b83ead6f56;p=oweals%2Fluci.git diff --git a/applications/luci-app-opkg/luasrc/controller/opkg.lua b/applications/luci-app-opkg/luasrc/controller/opkg.lua index 74aa16618..ebdcf1b09 100644 --- a/applications/luci-app-opkg/luasrc/controller/opkg.lua +++ b/applications/luci-app-opkg/luasrc/controller/opkg.lua @@ -3,21 +3,26 @@ module("luci.controller.opkg", package.seeall) -function index() - entry({"admin", "system", "opkg"}, template("opkg"), _("Software"), 30) - entry({"admin", "system", "opkg", "list"}, call("action_list")).leaf = true - entry({"admin", "system", "opkg", "exec"}, post("action_exec")).leaf = true - entry({"admin", "system", "opkg", "statvfs"}, call("action_statvfs")).leaf = true - entry({"admin", "system", "opkg", "config"}, post_on({ data = true }, "action_config")).leaf = true -end - function action_list(mode) + local util = require "luci.util" local cmd if mode == "installed" then cmd = { "/bin/cat", "/usr/lib/opkg/status" } else - cmd = { "/bin/sh", "-c", [[find /tmp/opkg-lists/ -type f '!' -name '*.sig' | xargs -r gzip -cd]] } + local lists_dir = nil + + local fd = io.popen([[sed -rne 's#^lists_dir \S+ (\S+)#\1#p' /etc/opkg.conf /etc/opkg/*.conf 2>/dev/null]], "r") + if fd then + lists_dir = fd:read("*l") + fd:close() + end + + if not lists_dir or #lists_dir == 0 then + lists_dir = "/tmp/opkg-lists" + end + + cmd = { "/bin/sh", "-c", [[find %s -type f '!' -name '*.sig' | xargs -r gzip -cd]] % util.shellquote(lists_dir) } end luci.http.prepare_content("text/plain; charset=utf-8") @@ -26,13 +31,17 @@ end function action_exec(command, package) local sys = require "luci.sys" - local cmd = { "/bin/opkg", "--force-removal-of-dependent-packages", "--force-overwrite" } + local cmd = { "/bin/opkg", "--force-removal-of-dependent-packages" } local pkg = luci.http.formvalue("package") if luci.http.formvalue("autoremove") == "true" then cmd[#cmd + 1] = "--autoremove" end + if luci.http.formvalue("overwrite") == "true" then + cmd[#cmd + 1] = "--force-overwrite" + end + cmd[#cmd + 1] = command if pkg then