Automated merge with http://waqas.ath.cx/

Sat, 29 Nov 2008 03:28:07 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 29 Nov 2008 03:28:07 +0000
changeset 469
72683281cbc4
parent 468
ab49cb6d0e92 (current diff)
parent 467
66f145f5c932 (diff)
child 470
2f9d42fdeffa

Automated merge with http://waqas.ath.cx/

--- a/Makefile	Sat Nov 29 08:25:34 2008 +0500
+++ b/Makefile	Sat Nov 29 03:28:07 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 08:25:34 2008 +0500
+++ b/configure	Sat Nov 29 03:28:07 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/configmanager.lua	Sat Nov 29 08:25:34 2008 +0500
+++ b/core/configmanager.lua	Sat Nov 29 03:28:07 2008 +0000
@@ -2,6 +2,7 @@
 local _G = _G;
 local 	setmetatable, loadfile, pcall, rawget, rawset, io = 
 		setmetatable, loadfile, pcall, rawget, rawset, io;
+
 module "configmanager"
 
 local parsers = {};
@@ -52,18 +53,21 @@
 
 function load(filename, format)
 	format = format or filename:match("%w+$");
+
 	if parsers[format] and parsers[format].load then
-		local f = io.open(filename);
+		local f, err = io.open(filename);
 		if f then 
 			local ok, err = parsers[format].load(f:read("*a"));
 			f:close();
 			return ok, err;
 		end
+		return f, err;
 	end
+
 	if not format then
 		return nil, "no parser specified";
 	else
-		return false, "no parser";
+		return nil, "no parser for "..(format);
 	end
 end
 
@@ -118,4 +122,4 @@
 	
 end
 
-return _M;
\ No newline at end of file
+return _M;
--- a/core/modulemanager.lua	Sat Nov 29 08:25:34 2008 +0500
+++ b/core/modulemanager.lua	Sat Nov 29 03:28:07 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 08:25:34 2008 +0500
+++ b/net/connlisteners.lua	Sat Nov 29 03:28:07 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 08:25:34 2008 +0500
+++ b/prosody	Sat Nov 29 03:28:07 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...")

mercurial