aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-04-05 14:38:08 +0100
committerMatthew Wild <mwild1@gmail.com>2011-04-05 14:38:08 +0100
commit55a1e9a4e2a78ad7d6a5a2a15c708dfaf0fcaaa0 (patch)
tree59ee455eed836439659c9f0fe7840831cbee4100
parent1cfb734e0ecde10fcd5f457c1394ecb3b7a28e2a (diff)
parentc1e4f6fbdabf5fb3569498877647200daaa6867f (diff)
downloadprosody-55a1e9a4e2a78ad7d6a5a2a15c708dfaf0fcaaa0.tar.gz
prosody-55a1e9a4e2a78ad7d6a5a2a15c708dfaf0fcaaa0.zip
Merge 0.8 -> trunk
-rw-r--r--tools/migration/migrator/prosody_files.lua3
-rw-r--r--tools/migration/prosody-migrator.lua12
2 files changed, 13 insertions, 2 deletions
diff --git a/tools/migration/migrator/prosody_files.lua b/tools/migration/migrator/prosody_files.lua
index 0a610d0e..4e42f564 100644
--- a/tools/migration/migrator/prosody_files.lua
+++ b/tools/migration/migrator/prosody_files.lua
@@ -13,6 +13,7 @@ local mtools = require "migrator.mtools";
local next = next;
local pairs = pairs;
local json = require "util.json";
+local os_getenv = os.getenv;
prosody = {};
local dm = require "util.datamanager"
@@ -22,7 +23,7 @@ module "prosody_files"
local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end
local function is_file(path) return lfs.attributes(path, "mode") == "file"; end
local function clean_path(path)
- return path:gsub("\\", "/"):gsub("//+", "/");
+ return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os_getenv("HOME") or "~");
end
local encode, decode; do
local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end });
diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua
index 20631fb1..2a8bf1c3 100644
--- a/tools/migration/prosody-migrator.lua
+++ b/tools/migration/prosody-migrator.lua
@@ -3,6 +3,15 @@
CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR");
CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR");
+-- Substitute ~ with path to home directory in paths
+if CFG_CONFIGDIR then
+ CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME"));
+end
+
+if CFG_SOURCEDIR then
+ CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME"));
+end
+
local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua";
-- Command-line parsing
@@ -116,9 +125,10 @@ local writer = require("migrator."..otype).writer(config[to_store]);
local json = require "util.json";
+io.stderr:write("Migrating...\n");
for x in reader do
--print(json.encode(x))
writer(x);
end
writer(nil); -- close
-
+io.stderr:write("Done!\n");