Software / code / prosody
Comparison
prosodyctl @ 3999:58c0de7c6da0
prosody, prosodyctl: Filter out relative paths from package.(c)path when installed
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 04 Jan 2011 21:19:28 +0000 |
| parent | 3998:009d1ad84b49 |
| child | 4095:6ad7ed619d37 |
comparison
equal
deleted
inserted
replaced
| 3998:009d1ad84b49 | 3999:58c0de7c6da0 |
|---|---|
| 16 CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR"); | 16 CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR"); |
| 17 CFG_DATADIR=os.getenv("PROSODY_DATADIR"); | 17 CFG_DATADIR=os.getenv("PROSODY_DATADIR"); |
| 18 | 18 |
| 19 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | 19 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 20 | 20 |
| 21 local function is_relative(path) | |
| 22 local path_sep = package.config:sub(1,1); | |
| 23 return ((path_sep == "/" and path:sub(1,1) ~= "/") | |
| 24 or (path_sep == "\\" and (path:sub(1,1) ~= "/" and path:sub(2,3) ~= ":\\"))) | |
| 25 end | |
| 26 | |
| 21 -- Tell Lua where to find our libraries | 27 -- Tell Lua where to find our libraries |
| 22 if CFG_SOURCEDIR then | 28 if CFG_SOURCEDIR then |
| 23 package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; | 29 local function filter_relative_paths(path) |
| 24 package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; | 30 if is_relative(path) then return ""; end |
| 31 end | |
| 32 local function sanitise_paths(paths) | |
| 33 return (paths:gsub("[^;]+;?", filter_relative_paths):gsub(";;+", ";")); | |
| 34 end | |
| 35 package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path); | |
| 36 package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath); | |
| 25 end | 37 end |
| 26 | 38 |
| 27 -- Substitute ~ with path to home directory in data path | 39 -- Substitute ~ with path to home directory in data path |
| 28 if CFG_DATADIR then | 40 if CFG_DATADIR then |
| 29 if os.getenv("HOME") then | 41 if os.getenv("HOME") then |