Automated merge with h-h.

Sun, 30 Nov 2008 15:18:45 +0100

author
Tobias Markmann <tm@ayena.de>
date
Sun, 30 Nov 2008 15:18:45 +0100
changeset 506
96f9f8dd9a45
parent 505
1b938e00412c (current diff)
parent 502
21dc299387a6 (diff)
child 507
4d3ccc6b5817

Automated merge with h-h.

--- a/Makefile	Sun Nov 30 02:26:37 2008 +0100
+++ b/Makefile	Sun Nov 30 15:18:45 2008 +0100
@@ -6,16 +6,18 @@
 MODULES = $(DESTDIR)$(PREFIX)/lib/prosody/modules
 SOURCE = $(DESTDIR)$(PREFIX)/lib/prosody
 
+DATADIR?=data
+
 INSTALLEDSOURCE = $(PREFIX)/lib/prosody
 INSTALLEDCONFIG = $(SYSCONFDIR)
 INSTALLEDMODULES = $(PREFIX)/lib/prosody/modules
-
+INSTALLEDDATA = $(DATADIR)
 
-all:
+all: prosody.install prosody.cfg.lua.install
 	$(MAKE) all -C util-src
 
-install: prosody.install prosody.cfg.lua util/encodings.so util/encodings.so
-	install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE)
+install: prosody.install prosody.cfg.lua.install util/encodings.so util/encodings.so
+	install -d $(BIN) $(CONFIG) $(MODULES) $(SOURCE) $(DATADIR)
 	install -d $(CONFIG)/certs
 	install -d $(SOURCE)/core $(SOURCE)/net $(SOURCE)/util
 	install ./prosody.install $(BIN)/prosody
@@ -25,12 +27,12 @@
 	install -m644 plugins/* $(MODULES)
 	install -m644 certs/* $(CONFIG)/certs
 	install -m644 plugins/* $(MODULES)
-	install -m644 prosody.cfg.lua $(CONFIG)/prosody.cfg.lua
+	test -e $(CONFIG)/prosody.cfg.lua || install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua
 	$(MAKE) install -C util-src
 
 clean:
 	rm -f prosody.install
-	rm -f prosody.cfg.lua
+	rm -f prosody.cfg.lua.install
 	$(MAKE) clean -C util-src
 
 util/encodings.so:
@@ -40,8 +42,13 @@
 	$(MAKE) install -C util-src
 
 prosody.install: prosody
-	sed "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|;s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" prosody > prosody.install
+	cp prosody prosody.install
+	sed -i "s|^CFG_SOURCEDIR=.*;$$|CFG_SOURCEDIR='$(INSTALLEDSOURCE)';|;" prosody.install
+	sed -i "s|^CFG_CONFIGDIR=.*;$$|CFG_CONFIGDIR='$(INSTALLEDCONFIG)';|;" prosody.install
+	sed -i "s|^CFG_DATADIR=.*;$$|CFG_DATADIR='$(INSTALLEDDATA)';|;" prosody.install
+	# The trailing slash is intentional in this one
+	sed -i "s|^CFG_PLUGINDIR=.*;$$|CFG_PLUGINDIR='$(INSTALLEDMODULES)/';|;" prosody.install
 
-prosody.cfg.lua:
-	sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua
+prosody.cfg.lua.install:
+	sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' prosody.cfg.lua.dist > prosody.cfg.lua.install
 
--- a/configure	Sun Nov 30 02:26:37 2008 +0100
+++ b/configure	Sun Nov 30 15:18:45 2008 +0100
@@ -4,13 +4,14 @@
 
 PREFIX=/usr/local
 SYSCONFDIR="$PREFIX/etc/prosody"
+DATADIR="$PREFIX/var/lib/prosody"
 LUA_SUFFIX=""
 LUA_DIR="/usr"
 LUA_BINDIR="/usr/bin"
 LUA_INCDIR="/usr/include"
 LUA_LIBDIR="/usr/lib"
 IDN_LIB=idn
-OPENSSL_LIB=ssl
+OPENSSL_LIB=crypto
 
 # Help
 
@@ -23,6 +24,8 @@
                             Default is $PREFIX
 --sysconfdir=DIR            Location where the config file should be installed.
                             Default is \$PREFIX/etc/prosody
+--datadir=DIR               Location where the server data should be stored.
+                            Default is \$PREFIX/var/lib/prosody
 --lua-suffix=SUFFIX         Versioning suffix to use in Lua filenames.
                             Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...)
 --with-lua=PREFIX           Use Lua from given prefix.
@@ -60,6 +63,10 @@
       PREFIX="$value"
       PREFIX_SET=yes
       ;;
+   --data-dir=*)
+   	DATADIR="$value"
+   	DATADIR_SET=yes
+      ;;
    --require-config)
       REQUIRE_CONFIG=yes
       ;;
@@ -100,6 +107,14 @@
    fi
 fi
 
+if [ "$PREFIX_SET" = "yes" -a ! "$DATADIR_SET" = "yes" ]
+then
+   if [ "$PREFIX" = "/usr" ]
+   then DATADIR=/var/lib/prosody
+   else DATADIR=$PREFIX/var/lib/prosody
+   fi
+fi
+
 find_program() {
    path="$PATH"
    item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`"
@@ -221,6 +236,7 @@
 
 PREFIX=$PREFIX
 SYSCONFDIR=$SYSCONFDIR
+DATADIR=$DATADIR
 LUA_SUFFIX=$LUA_SUFFIX
 LUA_DIR=$LUA_DIR
 LUA_INCDIR=$LUA_INCDIR
--- a/prosody	Sun Nov 30 02:26:37 2008 +0100
+++ b/prosody	Sun Nov 30 15:18:45 2008 +0100
@@ -5,28 +5,20 @@
 CFG_SOURCEDIR=nil;
 CFG_CONFIGDIR=nil;
 CFG_PLUGINDIR=nil;
+CFG_DATADIR=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.."/?.so;"..package.cpath
 end
 
-if CFG_CONFIGDIR then
+if CFG_DATADIR then
 	if os.getenv("HOME") then
-		CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME"));
+		CFG_DATADIR = CFG_DATADIR: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	
+end
 
 -- Required to be able to find packages installed with luarocks
 pcall(require, "luarocks.require")
@@ -56,7 +48,30 @@
 	end
 end
 
-require "util.datamanager".set_data_path(config.get("*", "core", "data_path") or "data");
+local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
+local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
+local _mkdir = {}
+function mkdir(path)
+	path = path:gsub("/", path_separator);
+	--print("mkdir",path);
+	local x = io.popen("mkdir "..path.." 2>&1"):read("*a");
+end
+function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end
+function mkdirs(host)
+	if not _mkdir[host] then
+		local host_dir = string.format("%s/%s", data_path, encode(host));
+		mkdir(host_dir);
+		mkdir(host_dir.."/accounts");
+		mkdir(host_dir.."/vcard");
+		mkdir(host_dir.."/roster");
+		mkdir(host_dir.."/private");
+		mkdir(host_dir.."/offline");
+		_mkdir[host] = true;
+	end
+end
+mkdir(data_path);
+
+require "util.datamanager".set_data_path(data_path);
 
 local server = require "net.server"
 
@@ -71,6 +86,7 @@
 for host, host_config in pairs(defined_hosts) do
 	if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then
 		hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} };
+		mkdirs(host);
 	end
 end
 
--- a/util-src/Makefile	Sun Nov 30 02:26:37 2008 +0100
+++ b/util-src/Makefile	Sun Nov 30 15:18:45 2008 +0100
@@ -21,8 +21,8 @@
 	rm -f ../util/*.so
 
 encodings.so: encodings.c
-	gcc -shared encodings.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(IDN_LIB) -o encodings.so
+	gcc -shared -fPIC encodings.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(IDN_LIB) -o encodings.so
 
 hashes.so: hashes.c
-	gcc -shared hashes.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(OPENSSL_LIB) -o hashes.so
+	gcc -shared -fPIC hashes.c -I$(LUA_INCDIR) -l$(LUA_LIB) -l$(OPENSSL_LIB) -o hashes.so
 	

mercurial