build: adapt mkbasepot.sh to new structure
[project/luci.git] / build / setup.lua
1 local SYSROOT = os.getenv("LUCI_SYSROOT")
2
3 -- override uci access
4 local uci_core  = require "uci"
5 local uci_model = require "luci.model.uci"
6
7 uci_model.cursor = function(config, save)
8         return uci_core.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci")
9 end
10
11 uci_model.cursor_state = function()
12         return uci_core.cursor(SYSROOT .. "/etc/config", SYSROOT .. "/var/state")
13 end
14
15 uci_model.inst = uci_model.cursor()
16 uci_model.inst_state = uci_model.cursor_state()
17
18 -- allow any password in local sdk
19 local sys = require "luci.sys"
20 sys.user.checkpasswd = function() return true end
21 sys.user.getpasswd   = function() return "x"  end
22
23 -- dummy sysinfo on Darwin
24 require "nixio"
25
26 if not nixio.sysinfo then
27         function nixio.sysinfo()
28                 return {
29                         bufferram = 0,
30                         freehigh = 0,
31                         freeram = 0,
32                         freeswap = 0,
33                         loads = { 0.0, 0.0, 0.0 },
34                         mem_unit = 1024,
35                         procs = 0,
36                         sharedram = 0,
37                         totalhigh = 0
38                 }
39         end
40 end
41
42 -- override nixio.fs.access() to check sysroot first
43 local _access = nixio.fs.access
44 function nixio.fs.access(file)
45         return _access(SYSROOT .. "/" .. file) or _access(file)
46 end