X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=build%2Fsetup.lua;h=f4ed76954817787878f139eb448bc4aec1391a11;hb=d0fd58a4415bee73dde84b57f729b5be064a71ef;hp=a3e64f3d19050e755db5b86a5c80876c18e7344a;hpb=2baab00b19fc6eb4e0aca4da035292e37d94a640;p=project%2Fluci.git diff --git a/build/setup.lua b/build/setup.lua index a3e64f3d1..f4ed76954 100644 --- a/build/setup.lua +++ b/build/setup.lua @@ -1,13 +1,46 @@ - local SYSROOT = os.getenv("LUCI_SYSROOT") - require "uci" - require "luci.model.uci".cursor = function(config, save) - return uci.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci") - end - - local x = require "luci.uvl".UVL.__init__ - require "luci.uvl".UVL.__init__ = function(self, schemedir) - x(self, schemedir or SYSROOT .. "/lib/uci/schema") - end - - local sys = require "luci.sys" - sys.user.checkpasswd = function() return true end +local SYSROOT = os.getenv("LUCI_SYSROOT") + +-- override uci access +local uci_core = require "uci" +local uci_model = require "luci.model.uci" + +uci_model.cursor = function(config, save) + return uci_core.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci") +end + +uci_model.cursor_state = function() + return uci_core.cursor(SYSROOT .. "/etc/config", SYSROOT .. "/var/state") +end + +uci_model.inst = uci_model.cursor() +uci_model.inst_state = uci_model.cursor_state() + +-- allow any password in local sdk +local sys = require "luci.sys" +sys.user.checkpasswd = function() return true end +sys.user.getpasswd = function() return "x" end + +-- dummy sysinfo on Darwin +require "nixio" + +if not nixio.sysinfo then + function nixio.sysinfo() + return { + bufferram = 0, + freehigh = 0, + freeram = 0, + freeswap = 0, + loads = { 0.0, 0.0, 0.0 }, + mem_unit = 1024, + procs = 0, + sharedram = 0, + totalhigh = 0 + } + end +end + +-- override nixio.fs.access() to check sysroot first +local _access = nixio.fs.access +function nixio.fs.access(file) + return _access(SYSROOT .. "/" .. file) or _access(file) +end