# HG changeset patch # User Kim Alvefur # Date 1686209821 -7200 # Node ID 879a6a33c21b1b59950eea601c4b1a0edb9699f9 # Parent 451cb119026e156ffb47800982862135ef65a896 tools: Update imports to use new prosody.* namespace diff -r 451cb119026e -r 879a6a33c21b tools/cfgdump.lua --- a/tools/cfgdump.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/cfgdump.lua Thu Jun 08 09:37:01 2023 +0200 @@ -1,21 +1,24 @@ #!/usr/bin/env lua -- cfgdump.lua prosody.cfg.lua [[host] option] +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end local s_format, print = string.format, print; local printf = function(fmt, ...) return print(s_format(fmt, ...)); end -local it = require "util.iterators"; +local it = require "prosody.util.iterators"; local function sort_anything(a, b) local typeof_a, typeof_b = type(a), type(b); if typeof_a ~= typeof_b then return typeof_a < typeof_b end return a < b -- should work for everything in a config file end -local serialization = require "util.serialization"; +local serialization = require "prosody.util.serialization"; local serialize = serialization.new and serialization.new({ unquoted = true, table_iterator = function(t) return it.sorted_pairs(t, sort_anything); end, }) or serialization.serialize; -local configmanager = require"core.configmanager"; -local startup = require "util.startup"; +local configmanager = require"prosody.core.configmanager"; +local startup = require "prosody.util.startup"; startup.set_function_metatable(); local config_filename, onlyhost, onlyoption = ...; diff -r 451cb119026e -r 879a6a33c21b tools/dnsregistry.lua --- a/tools/dnsregistry.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/dnsregistry.lua Thu Jun 08 09:37:01 2023 +0200 @@ -1,5 +1,8 @@ -- Generate util/dnsregistry.lua from IANA HTTP status code registry -local xml = require "util.xml"; +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end +local xml = require "prosody.util.xml"; local registries = xml.parse(io.read("*a"), { allow_processing_instructions = true }); print("-- Source: https://www.iana.org/assignments/dns-parameters/dns-parameters.xml"); diff -r 451cb119026e -r 879a6a33c21b tools/ejabberdsql2prosody.lua --- a/tools/ejabberdsql2prosody.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/ejabberdsql2prosody.lua Thu Jun 08 09:37:01 2023 +0200 @@ -16,13 +16,16 @@ package.path = package.path..";"..my_name:gsub("[^/\\]+$", "../?.lua"); package.cpath = package.cpath..";"..my_name:gsub("[^/\\]+$", "../?.so"); end +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end -local serialize = require "util.serialization".serialize; -local st = require "util.stanza"; -local parse_xml = require "util.xml".parse; -package.loaded["util.logger"] = {init = function() return function() end; end} -local dm = require "util.datamanager" +local serialize = require "prosody.util.serialization".serialize; +local st = require "prosody.util.stanza"; +local parse_xml = require "prosody.util.xml".parse; +package.loaded["prosody.util.logger"] = {init = function() return function() end; end} +local dm = require "prosody.util.datamanager" dm.set_data_path("data"); function parseFile(filename) diff -r 451cb119026e -r 879a6a33c21b tools/form2table.lua --- a/tools/form2table.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/form2table.lua Thu Jun 08 09:37:01 2023 +0200 @@ -1,4 +1,7 @@ -- Read an XML dataform and spit out a serialized Lua table of it +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end local function from_stanza(stanza) local layout = { @@ -45,4 +48,5 @@ return layout; end -print("dataforms.new " .. require "util.serialization".serialize(from_stanza(require "util.xml".parse(io.read("*a"))), { unquoted = true })) +print("dataforms.new " .. require"prosody.util.serialization".serialize(from_stanza(require"prosody.util.xml".parse(io.read("*a"))), + { unquoted = true })) diff -r 451cb119026e -r 879a6a33c21b tools/http-status-codes.lua --- a/tools/http-status-codes.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/http-status-codes.lua Thu Jun 08 09:37:01 2023 +0200 @@ -1,6 +1,9 @@ -- Generate net/http/codes.lua from IANA HTTP status code registry +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end -local xml = require "util.xml"; +local xml = require "prosody.util.xml"; local registry = xml.parse(io.read("*a"), { allow_processing_instructions = true }); io.write([[ diff -r 451cb119026e -r 879a6a33c21b tools/jabberd14sql2prosody.lua --- a/tools/jabberd14sql2prosody.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/jabberd14sql2prosody.lua Thu Jun 08 09:37:01 2023 +0200 @@ -1,4 +1,7 @@ #!/usr/bin/env lua +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end do @@ -447,13 +450,13 @@ end package.loaded["util.logger"] = {init = function() return function() end; end} -local dm = require "util.datamanager"; +local dm = require "prosody.util.datamanager"; dm.set_data_path("data"); -local datetime = require "util.datetime"; +local datetime = require "prosody.util.datetime"; -local st = require "util.stanza"; -local parse_xml = require "util.xml".parse; +local st = require "prosody.util.stanza"; +local parse_xml = require "prosody.util.xml".parse; function store_password(username, host, password) -- create or update account for username@host diff -r 451cb119026e -r 879a6a33c21b tools/migration/migrator/jabberd14.lua --- a/tools/migration/migrator/jabberd14.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/migration/migrator/jabberd14.lua Thu Jun 08 09:37:01 2023 +0200 @@ -1,7 +1,10 @@ +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end local lfs = require "lfs"; -local st = require "util.stanza"; -local parse_xml = require "util.xml".parse; +local st = require "prosody.util.stanza"; +local parse_xml = require "prosody.util.xml".parse; local os_getenv = os.getenv; local io_open = io.open; local assert = assert; diff -r 451cb119026e -r 879a6a33c21b tools/migration/prosody-migrator.lua --- a/tools/migration/prosody-migrator.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/migration/prosody-migrator.lua Thu Jun 08 09:37:01 2023 +0200 @@ -43,7 +43,11 @@ print("If no stores are specified, 'input' and 'output' are used."); end -local startup = require "util.startup"; +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end + +local startup = require "prosody.util.startup"; do startup.parse_args({ short_params = { v = "verbose", h = "help", ["?"] = "help" }; @@ -79,7 +83,7 @@ -- Command-line parsing local options = prosody.opts; -local envloadfile = require "util.envload".envloadfile; +local envloadfile = require "prosody.util.envload".envloadfile; local config_file = options.config or default_config; local from_store = arg[1] or "input"; @@ -132,8 +136,8 @@ os.exit(1); end -local async = require "util.async"; -local server = require "net.server"; +local async = require "prosody.util.async"; +local server = require "prosody.net.server"; local watchers = { error = function (_, err) error(err); @@ -143,10 +147,10 @@ end; }; -local cm = require "core.configmanager"; -local hm = require "core.hostmanager"; -local sm = require "core.storagemanager"; -local um = require "core.usermanager"; +local cm = require "prosody.core.configmanager"; +local hm = require "prosody.core.hostmanager"; +local sm = require "prosody.core.storagemanager"; +local um = require "prosody.core.usermanager"; local function users(store, host) if store.users then @@ -200,7 +204,7 @@ end if options["keep-going"] then - local xpcall = require "util.xpcall".xpcall; + local xpcall = require "prosody.util.xpcall".xpcall; for t, f in pairs(migrate_once) do migrate_once[t] = function (origin, destination, user, ...) local function log_err(err) diff -r 451cb119026e -r 879a6a33c21b tools/openfire2prosody.lua --- a/tools/openfire2prosody.lua Sat Jun 10 13:06:05 2023 +0200 +++ b/tools/openfire2prosody.lua Thu Jun 08 09:37:01 2023 +0200 @@ -15,6 +15,10 @@ package.cpath = package.cpath..";"..my_name:gsub("[^/\\]+$", "../?.so"); end +if not pcall(require, "prosody.loader") then + pcall(require, "loader"); +end + -- ugly workaround for getting datamanager to work outside of prosody :( prosody = { }; prosody.platform = "unknown"; @@ -24,12 +28,12 @@ prosody.platform = "posix"; end -local parse_xml = require "util.xml".parse; +local parse_xml = require "prosody.util.xml".parse; ----------------------------------------------------------------------- package.loaded["util.logger"] = {init = function() return function() end; end} -local dm = require "util.datamanager" +local dm = require "prosody.util.datamanager" dm.set_data_path("data"); local arg = ...;