Changeset

467:66f145f5c932

Update Makefile to now pass config paths to prosody. Update prosody, modulemanager and connectionlisteners to obey these paths.
author Matthew Wild <mwild1@gmail.com>
date Sat, 29 Nov 2008 03:27:50 +0000
parents 466:0ecfd89c2cc0
children 469:72683281cbc4
files Makefile configure core/modulemanager.lua net/connlisteners.lua prosody
diffstat 5 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sat Nov 29 03:26:46 2008 +0000
+++ b/Makefile	Sat Nov 29 03:27:50 2008 +0000
@@ -9,11 +9,10 @@
 all:
 	$(MAKE) all -C util-src
 
-install: prosody util/encodings.so util/encodings.so
-
+install: prosody.install util/encodings.so util/encodings.so
 	install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE)
 	install -d $(SOURCE)/core $(SOURCE)/net $(SOURCE)/util
-	install ./prosody $(BIN)
+	install ./prosody.install $(BIN)/prosody
 	install -m644 core/* $(SOURCE)/core
 	install -m644 net/* $(SOURCE)/net
 	install -m644 util/* $(SOURCE)/util
@@ -22,6 +21,7 @@
 	$(MAKE) install -C util-src
 
 clean:
+	rm -f prosody.install
 	$(MAKE) clean -C util-src
 
 util/encodings.so:
@@ -29,3 +29,7 @@
 
 util/hashes.so:
 	$(MAKE) install -C util-src
+
+prosody.install: prosody
+	sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(SOURCE)';|;s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(CONFIG)';|;s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(MODULES)/';|;" prosody > prosody.install
+
--- a/configure	Sat Nov 29 03:26:46 2008 +0000
+++ b/configure	Sat Nov 29 03:27:50 2008 +0000
@@ -125,7 +125,7 @@
 
 if [ "$LUA_SUFFIX_SET" != "yes" ]
 then
-   for suffix in "" "5.1" "51" ""
+   for suffix in "5.1" "51" ""
    do
       LUA_SUFFIX="$suffix"
       if [ "$LUA_DIR_SET" = "yes" ]
--- a/core/modulemanager.lua	Sat Nov 29 03:26:46 2008 +0000
+++ b/core/modulemanager.lua	Sat Nov 29 03:27:50 2008 +0000
@@ -1,4 +1,5 @@
 
+local plugin_dir = CFG_PLUGINDIR or "./plugins/";
 
 local logger = require "util.logger";
 local log = logger.init("modulemanager")
@@ -11,8 +12,8 @@
 
 local tostring, print = tostring, print;
 
+-- We need this to let modules access the real global namespace
 local _G = _G;
-local debug = debug;
 
 module "modulemanager"
 
@@ -30,7 +31,7 @@
 	if not (host and module_name) then
 		return nil, "insufficient-parameters";
 	end
-	local mod, err = loadfile("plugins/mod_"..module_name..".lua");
+	local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua");
 	if not mod then
 		log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
 		return nil, err;
--- a/net/connlisteners.lua	Sat Nov 29 03:26:46 2008 +0000
+++ b/net/connlisteners.lua	Sat Nov 29 03:27:50 2008 +0000
@@ -1,4 +1,5 @@
 
+local listeners_dir = (CFG_SOURCEDIR or "").."/net/";
 local server_add = require "net.server".add;
 local log = require "util.logger".init("connlisteners");
 
@@ -26,7 +27,7 @@
 function get(name)
 	local h = listeners[name];
 	if not h then
-		pcall(dofile, "net/"..name:gsub("[^%w%-]", "_").."_listener.lua");
+		pcall(dofile, listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua");
 		h = listeners[name];
 	end
 	return h;
@@ -42,4 +43,4 @@
 				(udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil );
 end
 
-return _M;
\ No newline at end of file
+return _M;
--- a/prosody	Sat Nov 29 03:26:46 2008 +0000
+++ b/prosody	Sat Nov 29 03:27:50 2008 +0000
@@ -2,15 +2,32 @@
 
 -- Config here --
 
-
+CFG_SOURCEDIR=nil;
+CFG_CONFIGDIR=nil;
+CFG_PLUGINDIR=nil;
 
 -- -- -- -- -- --
 
 if CFG_SOURCEDIR then
+	if os.getenv("HOME") then
+		CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME"));
+	end
 	package.path = CFG_SOURCEDIR.."/?.lua;"..package.path
-	package.cpath = CFG_SOURCEDIR.."/?.lua;"..package.cpath
+	package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath
 end
 
+if CFG_CONFIGDIR then
+	if os.getenv("HOME") then
+		CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME"));
+	end
+end	
+
+if CFG_PLUGINDIR then
+	if os.getenv("HOME") then
+		CFG_PLUGINDIR = CFG_PLUGINDIR:gsub("^~", os.getenv("HOME"));
+	end
+end	
+
 -- Required to be able to find packages installed with luarocks
 pcall(require, "luarocks.require")
 
@@ -21,7 +38,7 @@
 do
 	-- TODO: Check for other formats when we add support for them
 	-- Use lfs? Make a new conf/ dir?
-	local ok, err = config.load("lxmppd.cfg.lua");
+	local ok, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
 	if not ok then
 		log("error", "Couldn't load config file: %s", err);
 		log("info", "Falling back to old config file format...")