diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-08-13 15:06:05 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-08-13 15:06:05 -0300 |
commit | 0ceec7025f4ddc47f4e2b9f23f88a4eba0e1f73b (patch) | |
tree | d3a275acbccb26c44004338fb21a9e227cfa6b1a | |
parent | ce34a1b875f219086dcf950c8af1a149691e30eb (diff) | |
download | luarocks-0ceec7025f4ddc47f4e2b9f23f88a4eba0e1f73b.tar.gz luarocks-0ceec7025f4ddc47f4e2b9f23f88a4eba0e1f73b.tar.bz2 luarocks-0ceec7025f4ddc47f4e2b9f23f88a4eba0e1f73b.zip |
Replace all print()'s by appropriate calls to send messages to stdout and stderr. Closes #11.
28 files changed, 210 insertions, 187 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index 5f9cf95c..0dcb74bb 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
@@ -62,12 +62,12 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
62 | local files = {} | 62 | local files = {} |
63 | for i, rockfile in ipairs(rockfiles) do | 63 | for i, rockfile in ipairs(rockfiles) do |
64 | if fs.exists(rockfile) then | 64 | if fs.exists(rockfile) then |
65 | print("Copying file "..rockfile.." to "..local_cache.."...") | 65 | util.printout("Copying file "..rockfile.." to "..local_cache.."...") |
66 | local absolute = fs.absolute_name(rockfile) | 66 | local absolute = fs.absolute_name(rockfile) |
67 | fs.copy(absolute, local_cache) | 67 | fs.copy(absolute, local_cache) |
68 | table.insert(files, dir.base_name(absolute)) | 68 | table.insert(files, dir.base_name(absolute)) |
69 | else | 69 | else |
70 | print("File "..rockfile.." not found") | 70 | util.printerr("File "..rockfile.." not found") |
71 | end | 71 | end |
72 | end | 72 | end |
73 | if #files == 0 then | 73 | if #files == 0 then |
@@ -76,9 +76,9 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
76 | 76 | ||
77 | fs.change_dir(local_cache) | 77 | fs.change_dir(local_cache) |
78 | 78 | ||
79 | print("Updating manifest...") | 79 | util.printout("Updating manifest...") |
80 | manif.make_manifest(local_cache) | 80 | manif.make_manifest(local_cache) |
81 | print("Updating index.html...") | 81 | util.printout("Updating index.html...") |
82 | index.make_index(local_cache) | 82 | index.make_index(local_cache) |
83 | 83 | ||
84 | local login_info = "" | 84 | local login_info = "" |
@@ -101,7 +101,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
101 | cmd = "curl "..login_info.." -T '{manifest,index.html,"..table.concat(files, ",").."}' "..login_url | 101 | cmd = "curl "..login_info.." -T '{manifest,index.html,"..table.concat(files, ",").."}' "..login_url |
102 | end | 102 | end |
103 | 103 | ||
104 | print(cmd) | 104 | util.printout(cmd) |
105 | fs.execute(cmd) | 105 | fs.execute(cmd) |
106 | 106 | ||
107 | return true | 107 | return true |
diff --git a/src/luarocks/admin_remove.lua b/src/luarocks/admin_remove.lua index 99852e36..95213ecc 100644 --- a/src/luarocks/admin_remove.lua +++ b/src/luarocks/admin_remove.lua | |||
@@ -55,11 +55,11 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
55 | for i, rockfile in ipairs(rockfiles) do | 55 | for i, rockfile in ipairs(rockfiles) do |
56 | local basename = dir.base_name(rockfile) | 56 | local basename = dir.base_name(rockfile) |
57 | local file = dir.path(local_cache, basename) | 57 | local file = dir.path(local_cache, basename) |
58 | print("Removing file "..file.."...") | 58 | util.printout("Removing file "..file.."...") |
59 | if fs.delete(file) then | 59 | if fs.delete(file) then |
60 | nr_files = nr_files + 1 | 60 | nr_files = nr_files + 1 |
61 | else | 61 | else |
62 | print("Failed removing "..file) | 62 | util.printerr("Failed removing "..file) |
63 | end | 63 | end |
64 | end | 64 | end |
65 | if nr_files == 0 then | 65 | if nr_files == 0 then |
@@ -68,15 +68,15 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
68 | 68 | ||
69 | fs.change_dir(local_cache) | 69 | fs.change_dir(local_cache) |
70 | 70 | ||
71 | print("Updating manifest...") | 71 | util.printout("Updating manifest...") |
72 | manif.make_manifest(local_cache) | 72 | manif.make_manifest(local_cache) |
73 | print("Updating index.html...") | 73 | util.printout("Updating index.html...") |
74 | index.make_index(local_cache) | 74 | index.make_index(local_cache) |
75 | 75 | ||
76 | local srv, path = server_path:match("([^/]+)(/.+)") | 76 | local srv, path = server_path:match("([^/]+)(/.+)") |
77 | local cmd = "rsync -Oavz --delete -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" | 77 | local cmd = "rsync -Oavz --delete -e ssh "..local_cache.."/ "..user.."@"..srv..":"..path.."/" |
78 | 78 | ||
79 | print(cmd) | 79 | util.printout(cmd) |
80 | fs.execute(cmd) | 80 | fs.execute(cmd) |
81 | 81 | ||
82 | return true | 82 | return true |
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 44f60df8..5bb3c3f7 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -79,7 +79,7 @@ function apply_patches(rockspec) | |||
79 | if build.patches then | 79 | if build.patches then |
80 | extract_from_rockspec(build.patches) | 80 | extract_from_rockspec(build.patches) |
81 | for patch, patchdata in util.sortedpairs(build.patches) do | 81 | for patch, patchdata in util.sortedpairs(build.patches) do |
82 | print("Applying patch "..patch.."...") | 82 | util.printout("Applying patch "..patch.."...") |
83 | local ok, err = fs.apply_patch(tostring(patch), patchdata) | 83 | local ok, err = fs.apply_patch(tostring(patch), patchdata) |
84 | if not ok then | 84 | if not ok then |
85 | return nil, "Failed applying patch "..patch | 85 | return nil, "Failed applying patch "..patch |
@@ -170,7 +170,7 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) | |||
170 | 170 | ||
171 | -- Temporary compatibility | 171 | -- Temporary compatibility |
172 | if build.type == "module" then | 172 | if build.type == "module" then |
173 | print("Do not use 'module' as a build type. Use 'builtin' instead.") | 173 | util.printout("Do not use 'module' as a build type. Use 'builtin' instead.") |
174 | build.type = "builtin" | 174 | build.type = "builtin" |
175 | end | 175 | end |
176 | 176 | ||
@@ -239,8 +239,8 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) | |||
239 | end | 239 | end |
240 | 240 | ||
241 | local root_dir = path.root_dir(cfg.rocks_dir) | 241 | local root_dir = path.root_dir(cfg.rocks_dir) |
242 | print() | 242 | util.printout() |
243 | print(name.." "..version.." is now built and installed in "..root_dir.." "..license) | 243 | util.printout(name.." "..version.." is now built and installed in "..root_dir.." "..license) |
244 | 244 | ||
245 | util.remove_scheduled_function(rollback) | 245 | util.remove_scheduled_function(rollback) |
246 | return true | 246 | return true |
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index 7fd1fcc8..295f5df6 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua | |||
@@ -39,15 +39,15 @@ function run(rockspec) | |||
39 | args = args .. ' -D' ..k.. '="' ..v.. '"' | 39 | args = args .. ' -D' ..k.. '="' ..v.. '"' |
40 | end | 40 | end |
41 | 41 | ||
42 | if not fs.execute("cmake . " ..args) then | 42 | if not fs.execute(rockspec.variables.CMAKE.." . " ..args) then |
43 | return nil, "Failed cmake." | 43 | return nil, "Failed cmake." |
44 | end | 44 | end |
45 | 45 | ||
46 | if not fs.execute("make -fMakefile") then | 46 | if not fs.execute(rockspec.variables.MAKE.." -fMakefile") then |
47 | return nil, "Failed building." | 47 | return nil, "Failed building." |
48 | end | 48 | end |
49 | 49 | ||
50 | if not fs.execute("make -fMakefile install") then | 50 | if not fs.execute(rockspec.variables.MAKE.." -fMakefile install") then |
51 | return nil, "Failed installing." | 51 | return nil, "Failed installing." |
52 | end | 52 | end |
53 | return true | 53 | return true |
diff --git a/src/luarocks/build/make.lua b/src/luarocks/build/make.lua index 37486e5d..80c0d4f4 100644 --- a/src/luarocks/build/make.lua +++ b/src/luarocks/build/make.lua | |||
@@ -13,7 +13,7 @@ local cfg = require("luarocks.cfg") | |||
13 | -- @param variables table: A table containing string-string key-value | 13 | -- @param variables table: A table containing string-string key-value |
14 | -- pairs representing variable assignments to be passed to make. | 14 | -- pairs representing variable assignments to be passed to make. |
15 | -- @return boolean: false if any errors occurred, true otherwise. | 15 | -- @return boolean: false if any errors occurred, true otherwise. |
16 | local function make_pass(pass, target, variables) | 16 | local function make_pass(make_cmd, pass, target, variables) |
17 | assert(type(pass) == "boolean") | 17 | assert(type(pass) == "boolean") |
18 | assert(type(target) == "string") | 18 | assert(type(target) == "string") |
19 | assert(type(variables) == "table") | 19 | assert(type(variables) == "table") |
@@ -23,7 +23,7 @@ local function make_pass(pass, target, variables) | |||
23 | table.insert(assignments, k.."="..v) | 23 | table.insert(assignments, k.."="..v) |
24 | end | 24 | end |
25 | if pass then | 25 | if pass then |
26 | return fs.execute(cfg.make.." "..target, unpack(assignments)) | 26 | return fs.execute(make_cmd.." "..target, unpack(assignments)) |
27 | else | 27 | else |
28 | return true | 28 | return true |
29 | end | 29 | end |
@@ -74,11 +74,14 @@ function run(rockspec) | |||
74 | end | 74 | end |
75 | end | 75 | end |
76 | 76 | ||
77 | local ok = make_pass(build.build_pass, build.build_target, build.build_variables) | 77 | -- backwards compatibility |
78 | local make_cmd = cfg.make or rockspec.variables.MAKE | ||
79 | |||
80 | local ok = make_pass(make_cmd, build.build_pass, build.build_target, build.build_variables) | ||
78 | if not ok then | 81 | if not ok then |
79 | return nil, "Failed building." | 82 | return nil, "Failed building." |
80 | end | 83 | end |
81 | ok = make_pass(build.install_pass, build.install_target, build.install_variables) | 84 | ok = make_pass(make_cmd, build.install_pass, build.install_target, build.install_variables) |
82 | if not ok then | 85 | if not ok then |
83 | return nil, "Failed installing." | 86 | return nil, "Failed installing." |
84 | end | 87 | end |
diff --git a/src/luarocks/cache.lua b/src/luarocks/cache.lua index 77c07d8b..d3fbdf5b 100644 --- a/src/luarocks/cache.lua +++ b/src/luarocks/cache.lua | |||
@@ -6,6 +6,7 @@ module("luarocks.cache", package.seeall) | |||
6 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
7 | local cfg = require("luarocks.cfg") | 7 | local cfg = require("luarocks.cfg") |
8 | local dir = require("luarocks.dir") | 8 | local dir = require("luarocks.dir") |
9 | local util = require("luarocks.util") | ||
9 | 10 | ||
10 | function split_server_url(server, url, user, password) | 11 | function split_server_url(server, url, user, password) |
11 | local protocol, server_path = dir.split_url(url) | 12 | local protocol, server_path = dir.split_url(url) |
@@ -40,7 +41,7 @@ function refresh_local_cache(server, url, user, password) | |||
40 | return nil, "Failed creating local cache dir." | 41 | return nil, "Failed creating local cache dir." |
41 | end | 42 | end |
42 | fs.change_dir(local_cache) | 43 | fs.change_dir(local_cache) |
43 | print("Refreshing cache "..local_cache.."...") | 44 | util.printout("Refreshing cache "..local_cache.."...") |
44 | 45 | ||
45 | -- TODO abstract away explicit 'wget' call | 46 | -- TODO abstract away explicit 'wget' call |
46 | local ok = false | 47 | local ok = false |
@@ -58,4 +59,3 @@ function refresh_local_cache(server, url, user, password) | |||
58 | end | 59 | end |
59 | return local_cache, protocol, server_path, user, password | 60 | return local_cache, protocol, server_path, user, password |
60 | end | 61 | end |
61 | |||
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index a9789e21..25f22e26 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | local rawset, next, table, pairs, print, require, io, os, setmetatable, pcall, ipairs, package, type, assert = | 2 | local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert = |
3 | rawset, next, table, pairs, print, require, io, os, setmetatable, pcall, ipairs, package, type, assert | 3 | rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, type, assert |
4 | 4 | ||
5 | --- Configuration for LuaRocks. | 5 | --- Configuration for LuaRocks. |
6 | -- Tries to load the user's configuration file and | 6 | -- Tries to load the user's configuration file and |
@@ -18,7 +18,7 @@ module("luarocks.cfg") | |||
18 | -- Load site-local global configurations | 18 | -- Load site-local global configurations |
19 | local ok, config = pcall(require, "luarocks.config") | 19 | local ok, config = pcall(require, "luarocks.config") |
20 | if not ok then | 20 | if not ok then |
21 | print("Site-local luarocks/config.lua file not found. Incomplete installation?") | 21 | io.stderr:write("Site-local luarocks/config.lua file not found. Incomplete installation?\n") |
22 | config = {} | 22 | config = {} |
23 | end | 23 | end |
24 | 24 | ||
@@ -35,8 +35,8 @@ if popen_ok then | |||
35 | popen_result:close() | 35 | popen_result:close() |
36 | end | 36 | end |
37 | else | 37 | else |
38 | print("Your version of Lua does not support io.popen,") | 38 | io.stderr:write("Your version of Lua does not support io.popen,\n") |
39 | print("which is required by LuaRocks. Please check your Lua installation.") | 39 | io.stderr:write("which is required by LuaRocks. Please check your Lua installation.\n") |
40 | os.exit(1) | 40 | os.exit(1) |
41 | end | 41 | end |
42 | 42 | ||
@@ -171,8 +171,8 @@ if detected.windows then | |||
171 | defaults.variables.LUA_INCDIR = config.LUA_INCDIR and config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" | 171 | defaults.variables.LUA_INCDIR = config.LUA_INCDIR and config.LUA_INCDIR:gsub("\\", "/") or "c:/lua5.1/include" |
172 | defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR and config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" | 172 | defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR and config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua5.1/lib" |
173 | defaults.cmake_generator = "MinGW Makefiles" | 173 | defaults.cmake_generator = "MinGW Makefiles" |
174 | defaults.make = "nmake" -- TODO: Split Windows flavors between mingw and msvc | ||
175 | defaults.makefile = "Makefile.win" | 174 | defaults.makefile = "Makefile.win" |
175 | defaults.variables.MAKE = "nmake" -- TODO: Split Windows flavors between mingw and msvc | ||
176 | defaults.variables.CC = "cl" | 176 | defaults.variables.CC = "cl" |
177 | defaults.variables.RC = "rc" | 177 | defaults.variables.RC = "rc" |
178 | defaults.variables.WRAPPER = config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.obj" | 178 | defaults.variables.WRAPPER = config.LUAROCKS_PREFIX .. "\\2.0\\rclauncher.obj" |
@@ -236,8 +236,8 @@ if detected.unix then | |||
236 | defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR or "/usr/local/lib" | 236 | defaults.variables.LUA_LIBDIR = config.LUA_LIBDIR or "/usr/local/lib" |
237 | defaults.variables.CFLAGS = "-O2" | 237 | defaults.variables.CFLAGS = "-O2" |
238 | defaults.cmake_generator = "Unix Makefiles" | 238 | defaults.cmake_generator = "Unix Makefiles" |
239 | defaults.make = "make" | ||
240 | defaults.platforms = { "unix" } | 239 | defaults.platforms = { "unix" } |
240 | defaults.variables.MAKE = "make" | ||
241 | defaults.variables.CC = "cc" | 241 | defaults.variables.CC = "cc" |
242 | defaults.variables.LD = "ld" | 242 | defaults.variables.LD = "ld" |
243 | defaults.variables.LIBFLAG = "-shared" | 243 | defaults.variables.LIBFLAG = "-shared" |
@@ -286,8 +286,8 @@ end | |||
286 | 286 | ||
287 | if detected.freebsd then | 287 | if detected.freebsd then |
288 | defaults.arch = "freebsd-"..proc | 288 | defaults.arch = "freebsd-"..proc |
289 | defaults.make = "gmake" | ||
290 | defaults.platforms = {"unix", "bsd", "freebsd"} | 289 | defaults.platforms = {"unix", "bsd", "freebsd"} |
290 | defaults.variables.MAKE = "gmake" | ||
291 | defaults.variables.CC = "gcc" | 291 | defaults.variables.CC = "gcc" |
292 | defaults.variables.LD = "gcc" | 292 | defaults.variables.LD = "gcc" |
293 | defaults.variables.LIBFLAG = "-shared" | 293 | defaults.variables.LIBFLAG = "-shared" |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 8b74a65f..50502257 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -15,9 +15,9 @@ local function die(message) | |||
15 | 15 | ||
16 | local ok, err = pcall(util.run_scheduled_functions) | 16 | local ok, err = pcall(util.run_scheduled_functions) |
17 | if not ok then | 17 | if not ok then |
18 | print("\nLuaRocks "..cfg.program_version.." internal bug (please report at luarocks-developers@lists.luaforge.net):\n"..err) | 18 | util.printerr("\nLuaRocks "..cfg.program_version.." internal bug (please report at luarocks-developers@lists.luaforge.net):\n"..err) |
19 | end | 19 | end |
20 | print("\nError: "..message) | 20 | util.printerr("\nError: "..message) |
21 | os.exit(1) | 21 | os.exit(1) |
22 | end | 22 | end |
23 | 23 | ||
@@ -70,9 +70,9 @@ function run_command(...) | |||
70 | local command | 70 | local command |
71 | 71 | ||
72 | if flags["version"] then | 72 | if flags["version"] then |
73 | print(program_name.." "..cfg.program_version) | 73 | util.printout(program_name.." "..cfg.program_version) |
74 | print(program_description) | 74 | util.printout(program_description) |
75 | print() | 75 | util.printout() |
76 | os.exit(0) | 76 | os.exit(0) |
77 | elseif flags["help"] or #nonflags == 0 then | 77 | elseif flags["help"] or #nonflags == 0 then |
78 | command = "help" | 78 | command = "help" |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 26c43047..27062cbb 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -17,6 +17,7 @@ local cfg = require("luarocks.cfg") | |||
17 | local manif_core = require("luarocks.manif_core") | 17 | local manif_core = require("luarocks.manif_core") |
18 | local path = require("luarocks.path") | 18 | local path = require("luarocks.path") |
19 | local dir = require("luarocks.dir") | 19 | local dir = require("luarocks.dir") |
20 | local util = require("luarocks.util") | ||
20 | 21 | ||
21 | local operators = { | 22 | local operators = { |
22 | ["=="] = "==", | 23 | ["=="] = "==", |
@@ -135,7 +136,7 @@ function parse_version(vstring) | |||
135 | -- extract a word | 136 | -- extract a word |
136 | token, rest = vstring:match("^(%a+)[%.%-%_]*(.*)") | 137 | token, rest = vstring:match("^(%a+)[%.%-%_]*(.*)") |
137 | if not token then | 138 | if not token then |
138 | print("Warning: version number '"..vstring.."' could not be parsed.") | 139 | util.printerr("Warning: version number '"..vstring.."' could not be parsed.") |
139 | version[i] = 0 | 140 | version[i] = 0 |
140 | break | 141 | break |
141 | end | 142 | end |
@@ -435,34 +436,34 @@ function fulfill_dependencies(rockspec) | |||
435 | local matched, missing, no_upgrade = match_deps(rockspec) | 436 | local matched, missing, no_upgrade = match_deps(rockspec) |
436 | 437 | ||
437 | if next(no_upgrade) then | 438 | if next(no_upgrade) then |
438 | print("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") | 439 | util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") |
439 | for _, dep in pairs(no_upgrade) do | 440 | for _, dep in pairs(no_upgrade) do |
440 | print(show_dep(dep)) | 441 | util.printerr(show_dep(dep)) |
441 | end | 442 | end |
442 | if next(missing) then | 443 | if next(missing) then |
443 | for _, dep in pairs(missing) do | 444 | for _, dep in pairs(missing) do |
444 | print(show_dep(dep)) | 445 | util.printerr(show_dep(dep)) |
445 | end | 446 | end |
446 | end | 447 | end |
447 | print() | 448 | util.printerr() |
448 | for _, dep in pairs(no_upgrade) do | 449 | for _, dep in pairs(no_upgrade) do |
449 | print("This version of "..rockspec.name.." is designed for use with") | 450 | util.printerr("This version of "..rockspec.name.." is designed for use with") |
450 | print(show_dep(dep)..", but is configured to avoid upgrading it") | 451 | util.printerr(show_dep(dep)..", but is configured to avoid upgrading it") |
451 | print("automatically. Please upgrade "..dep.name.." with") | 452 | util.printerr("automatically. Please upgrade "..dep.name.." with") |
452 | print(" luarocks install "..dep.name) | 453 | util.printerr(" luarocks install "..dep.name) |
453 | print("or choose an older version of "..rockspec.name.." with") | 454 | util.printerr("or choose an older version of "..rockspec.name.." with") |
454 | print(" luarocks search "..rockspec.name) | 455 | util.printerr(" luarocks search "..rockspec.name) |
455 | end | 456 | end |
456 | return nil, "Failed matching dependencies." | 457 | return nil, "Failed matching dependencies." |
457 | end | 458 | end |
458 | 459 | ||
459 | if next(missing) then | 460 | if next(missing) then |
460 | print() | 461 | util.printerr() |
461 | print("Missing dependencies for "..rockspec.name..":") | 462 | util.printerr("Missing dependencies for "..rockspec.name..":") |
462 | for _, dep in pairs(missing) do | 463 | for _, dep in pairs(missing) do |
463 | print(show_dep(dep)) | 464 | util.printerr(show_dep(dep)) |
464 | end | 465 | end |
465 | print() | 466 | util.printerr() |
466 | 467 | ||
467 | for _, dep in pairs(missing) do | 468 | for _, dep in pairs(missing) do |
468 | -- Double-check in case dependency was filled during recursion. | 469 | -- Double-check in case dependency was filled during recursion. |
diff --git a/src/luarocks/download.lua b/src/luarocks/download.lua index 79ff5394..6ae5f7af 100644 --- a/src/luarocks/download.lua +++ b/src/luarocks/download.lua | |||
@@ -72,10 +72,10 @@ function run(...) | |||
72 | end | 72 | end |
73 | return all_ok, any_err | 73 | return all_ok, any_err |
74 | else | 74 | else |
75 | print("Multiple search results were returned.") | 75 | util.printerr("Multiple search results were returned.") |
76 | print() | 76 | util.printout() |
77 | print("Search results:") | 77 | util.printout("Search results:") |
78 | print("---------------") | 78 | util.printout("---------------") |
79 | search.print_results(results) | 79 | search.print_results(results) |
80 | return nil, "Please narrow your query or use --all." | 80 | return nil, "Please narrow your query or use --all." |
81 | end | 81 | end |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index c5769bac..0930cadb 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -10,6 +10,7 @@ local fs = require("luarocks.fs") | |||
10 | local cfg = require("luarocks.cfg") | 10 | local cfg = require("luarocks.cfg") |
11 | local dir = require("luarocks.dir") | 11 | local dir = require("luarocks.dir") |
12 | local fs = require("luarocks.fs") | 12 | local fs = require("luarocks.fs") |
13 | local util = require("luarocks.util") | ||
13 | 14 | ||
14 | math.randomseed(os.time()) | 15 | math.randomseed(os.time()) |
15 | 16 | ||
@@ -103,7 +104,7 @@ function is_actual_binary(filename) | |||
103 | local first = file:read() | 104 | local first = file:read() |
104 | if not first then | 105 | if not first then |
105 | file:close() | 106 | file:close() |
106 | print("Warning: could not read "..filename) | 107 | util.printerr("Warning: could not read "..filename) |
107 | return false | 108 | return false |
108 | end | 109 | end |
109 | if first:match("#!.*lua") then | 110 | if first:match("#!.*lua") then |
diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua index 5162b917..a2e64b5d 100644 --- a/src/luarocks/help.lua +++ b/src/luarocks/help.lua | |||
@@ -25,7 +25,7 @@ function run(...) | |||
25 | local flags, command = util.parse_flags(...) | 25 | local flags, command = util.parse_flags(...) |
26 | 26 | ||
27 | if not command then | 27 | if not command then |
28 | print([[ | 28 | util.printout([[ |
29 | LuaRocks ]]..cfg.program_version..[[, a module deployment system for Lua | 29 | LuaRocks ]]..cfg.program_version..[[, a module deployment system for Lua |
30 | 30 | ||
31 | ]]..program_name..[[ - ]]..program_description..[[ | 31 | ]]..program_name..[[ - ]]..program_description..[[ |
@@ -51,18 +51,18 @@ Supported commands: | |||
51 | table.sort(names) | 51 | table.sort(names) |
52 | for _, name in ipairs(names) do | 52 | for _, name in ipairs(names) do |
53 | local command = commands[name] | 53 | local command = commands[name] |
54 | print(name, command.help_summary) | 54 | util.printout(name, command.help_summary) |
55 | end | 55 | end |
56 | else | 56 | else |
57 | command = command:gsub("-", "_") | 57 | command = command:gsub("-", "_") |
58 | if commands[command] then | 58 | if commands[command] then |
59 | local arguments = commands[command].help_arguments or "<argument>" | 59 | local arguments = commands[command].help_arguments or "<argument>" |
60 | print() | 60 | util.printout() |
61 | print(program_name.." "..command.." "..arguments) | 61 | util.printout(program_name.." "..command.." "..arguments) |
62 | print() | 62 | util.printout() |
63 | print(command.." - "..commands[command].help_summary) | 63 | util.printout(command.." - "..commands[command].help_summary) |
64 | print() | 64 | util.printout() |
65 | print(commands[command].help) | 65 | util.printout(commands[command].help) |
66 | else | 66 | else |
67 | return nil, "Unknown command '"..command.."'" | 67 | return nil, "Unknown command '"..command.."'" |
68 | end | 68 | end |
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index 016e73bb..d7d87192 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -85,8 +85,8 @@ function install_binary_rock(rock_file) | |||
85 | end | 85 | end |
86 | 86 | ||
87 | local root_dir = path.root_dir(cfg.rocks_dir) | 87 | local root_dir = path.root_dir(cfg.rocks_dir) |
88 | print() | 88 | util.printout() |
89 | print(name.." "..version.." is now installed in "..root_dir.." "..license) | 89 | util.printout(name.." "..version.." is now installed in "..root_dir.." "..license) |
90 | 90 | ||
91 | util.remove_scheduled_function(rollback) | 91 | util.remove_scheduled_function(rollback) |
92 | return true | 92 | return true |
@@ -123,14 +123,14 @@ function run(...) | |||
123 | return nil, err | 123 | return nil, err |
124 | elseif type(results) == "string" then | 124 | elseif type(results) == "string" then |
125 | local url = results | 125 | local url = results |
126 | print("Installing "..url.."...") | 126 | util.printout("Installing "..url.."...") |
127 | return run(url) | 127 | return run(url) |
128 | else | 128 | else |
129 | print() | 129 | util.printout() |
130 | print("Could not determine which rock to install.") | 130 | util.printerr("Could not determine which rock to install.") |
131 | print() | 131 | util.printout() |
132 | print("Search results:") | 132 | util.printout("Search results:") |
133 | print("---------------") | 133 | util.printout("---------------") |
134 | search.print_results(results) | 134 | search.print_results(results) |
135 | return nil, (next(results) and "Please narrow your query." or "No results found.") | 135 | return nil, (next(results) and "Please narrow your query." or "No results found.") |
136 | end | 136 | end |
diff --git a/src/luarocks/list.lua b/src/luarocks/list.lua index 567ee188..1943f932 100644 --- a/src/luarocks/list.lua +++ b/src/luarocks/list.lua | |||
@@ -26,10 +26,10 @@ function run(...) | |||
26 | for _, tree in ipairs(cfg.rocks_trees) do | 26 | for _, tree in ipairs(cfg.rocks_trees) do |
27 | search.manifest_search(results, path.rocks_dir(tree), query) | 27 | search.manifest_search(results, path.rocks_dir(tree), query) |
28 | end | 28 | end |
29 | print() | 29 | util.printout() |
30 | print("Installed rocks:") | 30 | util.printout("Installed rocks:") |
31 | print("----------------") | 31 | util.printout("----------------") |
32 | print() | 32 | util.printout() |
33 | search.print_results(results, false) | 33 | search.print_results(results, false) |
34 | return true | 34 | return true |
35 | end | 35 | end |
diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua index 258c45a2..c3cba55a 100644 --- a/src/luarocks/loader.lua +++ b/src/luarocks/loader.lua | |||
@@ -1,7 +1,7 @@ | |||
1 | 1 | ||
2 | local global_env = _G | 2 | local global_env = _G |
3 | local package, require, assert, ipairs, pairs, os, print, table, type, next, unpack = | 3 | local package, require, ipairs, pairs, table, type, next, unpack = |
4 | package, require, assert, ipairs, pairs, os, print, table, type, next, unpack | 4 | package, require, ipairs, pairs, table, type, next, unpack |
5 | 5 | ||
6 | module("luarocks.loader") | 6 | module("luarocks.loader") |
7 | 7 | ||
@@ -64,14 +64,14 @@ function add_context(name, version) | |||
64 | return nil | 64 | return nil |
65 | end | 65 | end |
66 | for _, dep in ipairs(pkgdeps) do | 66 | for _, dep in ipairs(pkgdeps) do |
67 | local package, constraints = dep.name, dep.constraints | 67 | local pkg, constraints = dep.name, dep.constraints |
68 | 68 | ||
69 | for _, tree in pairs(rocks_trees) do | 69 | for _, tree in pairs(rocks_trees) do |
70 | local entries = tree.manifest.repository[package] | 70 | local entries = tree.manifest.repository[pkg] |
71 | if entries then | 71 | if entries then |
72 | for version, packages in pairs(entries) do | 72 | for version, pkgs in pairs(entries) do |
73 | if (not constraints) or deps.match_constraints(deps.parse_version(version), constraints) then | 73 | if (not constraints) or deps.match_constraints(deps.parse_version(version), constraints) then |
74 | add_context(package, version) | 74 | add_context(pkg, version) |
75 | end | 75 | end |
76 | end | 76 | end |
77 | end | 77 | end |
diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index 4701a45a..07d2fd05 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua | |||
@@ -6,6 +6,7 @@ module("luarocks.make_manifest", package.seeall) | |||
6 | local manif = require("luarocks.manif") | 6 | local manif = require("luarocks.manif") |
7 | local index = require("luarocks.index") | 7 | local index = require("luarocks.index") |
8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
9 | local util = require("luarocks.util") | ||
9 | 10 | ||
10 | help_summary = "Compile a manifest file for a repository." | 11 | help_summary = "Compile a manifest file for a repository." |
11 | 12 | ||
@@ -22,11 +23,11 @@ function run(repo) | |||
22 | assert(type(repo) == "string" or not repo) | 23 | assert(type(repo) == "string" or not repo) |
23 | repo = repo or cfg.rocks_dir | 24 | repo = repo or cfg.rocks_dir |
24 | 25 | ||
25 | print("Making manifest for "..repo) | 26 | util.printout("Making manifest for "..repo) |
26 | 27 | ||
27 | local ok, err = manif.make_manifest(repo) | 28 | local ok, err = manif.make_manifest(repo) |
28 | if ok then | 29 | if ok then |
29 | print("Generating index.html for "..repo) | 30 | util.printout("Generating index.html for "..repo) |
30 | index.make_index(repo) | 31 | index.make_index(repo) |
31 | end | 32 | end |
32 | return ok, err | 33 | return ok, err |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index a7211d70..8ce555d8 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -190,9 +190,9 @@ local function update_dependencies(manifest) | |||
190 | if missing then | 190 | if missing then |
191 | for miss, _ in pairs(missing) do | 191 | for miss, _ in pairs(missing) do |
192 | if miss == current then | 192 | if miss == current then |
193 | print("Tree inconsistency detected: "..current.." has no rockspec.") | 193 | util.printerr("Tree inconsistency detected: "..current.." has no rockspec.") |
194 | else | 194 | else |
195 | print("Missing dependency for "..pkg.." "..version..": "..miss) | 195 | util.printerr("Missing dependency for "..pkg.." "..version..": "..miss) |
196 | end | 196 | end |
197 | end | 197 | end |
198 | end | 198 | end |
@@ -277,11 +277,11 @@ function update_manifest(name, version, repo) | |||
277 | assert(type(version) == "string") | 277 | assert(type(version) == "string") |
278 | repo = path.rocks_dir(repo or cfg.root_dir) | 278 | repo = path.rocks_dir(repo or cfg.root_dir) |
279 | 279 | ||
280 | print("Updating manifest for "..repo) | 280 | util.printout("Updating manifest for "..repo) |
281 | 281 | ||
282 | local manifest, err = load_manifest(repo) | 282 | local manifest, err = load_manifest(repo) |
283 | if not manifest then | 283 | if not manifest then |
284 | print("No existing manifest. Attempting to rebuild...") | 284 | util.printerr("No existing manifest. Attempting to rebuild...") |
285 | local ok, err = make_manifest(repo) | 285 | local ok, err = make_manifest(repo) |
286 | if not ok then | 286 | if not ok then |
287 | return nil, err | 287 | return nil, err |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 5546a649..e22bdc38 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -172,7 +172,7 @@ function run(...) | |||
172 | if err then | 172 | if err then |
173 | return nil, err | 173 | return nil, err |
174 | else | 174 | else |
175 | print("Packed: "..file) | 175 | util.printout("Packed: "..file) |
176 | return true | 176 | return true |
177 | end | 177 | end |
178 | end | 178 | end |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 3ff0db8a..83b84530 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -6,6 +6,7 @@ module("luarocks.path", package.seeall) | |||
6 | 6 | ||
7 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
9 | local util = require("luarocks.util") | ||
9 | 10 | ||
10 | help_summary = "Return the currently configured package path." | 11 | help_summary = "Return the currently configured package path." |
11 | help_arguments = "" | 12 | help_arguments = "" |
@@ -301,14 +302,15 @@ function versioned_name(file, prefix, name, version) | |||
301 | end | 302 | end |
302 | 303 | ||
303 | --- Driver function for "path" command. | 304 | --- Driver function for "path" command. |
305 | -- This platform distinction is not in fs to avoid depending on that module here. | ||
304 | -- @return boolean This function always succeeds. | 306 | -- @return boolean This function always succeeds. |
305 | function run(...) | 307 | function run(...) |
306 | if cfg.is_platform("unix") then | 308 | if cfg.is_platform("unix") then |
307 | print("export LUA_PATH='"..package.path.."'") | 309 | util.printout("export LUA_PATH='"..package.path.."'") |
308 | print("export LUA_CPATH='"..package.cpath.."'") | 310 | util.printout("export LUA_CPATH='"..package.cpath.."'") |
309 | elseif cfg.is_platform("windows") then | 311 | elseif cfg.is_platform("windows") then |
310 | print("SET LUA_PATH="..package.path) | 312 | util.printout("SET LUA_PATH="..package.path) |
311 | print("SET LUA_CPATH="..package.cpath) | 313 | util.printout("SET LUA_CPATH="..package.cpath) |
312 | end | 314 | end |
313 | return true | 315 | return true |
314 | end | 316 | end |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index d77f28fa..caa683ee 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua | |||
@@ -61,7 +61,7 @@ end | |||
61 | local function delete_versions(name, versions) | 61 | local function delete_versions(name, versions) |
62 | 62 | ||
63 | for version, _ in pairs(versions) do | 63 | for version, _ in pairs(versions) do |
64 | print("Removing "..name.." "..version.."...") | 64 | util.printout("Removing "..name.." "..version.."...") |
65 | local ok, err = rep.delete_version(name, version) | 65 | local ok, err = rep.delete_version(name, version) |
66 | if not ok then return nil, err end | 66 | if not ok then return nil, err end |
67 | end | 67 | end |
@@ -98,19 +98,19 @@ function run(...) | |||
98 | local version = next(versions) | 98 | local version = next(versions) |
99 | local second = next(versions, version) | 99 | local second = next(versions, version) |
100 | 100 | ||
101 | print("Checking stability of dependencies on the absence of") | 101 | util.printout("Checking stability of dependencies on the absence of") |
102 | print(name.." "..table.concat(util.keys(versions), ", ").."...") | 102 | util.printout(name.." "..table.concat(util.keys(versions), ", ").."...") |
103 | print() | 103 | util.printout() |
104 | 104 | ||
105 | local dependents = check_dependents(name, versions) | 105 | local dependents = check_dependents(name, versions) |
106 | 106 | ||
107 | if #dependents == 0 or flags["force"] then | 107 | if #dependents == 0 or flags["force"] then |
108 | if #dependents > 0 then | 108 | if #dependents > 0 then |
109 | print("The following packages may be broken by this forced removal:") | 109 | util.printerr("The following packages may be broken by this forced removal:") |
110 | for _, dependent in ipairs(dependents) do | 110 | for _, dependent in ipairs(dependents) do |
111 | print(dependent.name.." "..dependent.version) | 111 | util.printerr(dependent.name.." "..dependent.version) |
112 | end | 112 | end |
113 | print() | 113 | util.printerr() |
114 | end | 114 | end |
115 | local ok, err = delete_versions(name, versions) | 115 | local ok, err = delete_versions(name, versions) |
116 | if not ok then return nil, err end | 116 | if not ok then return nil, err end |
@@ -118,19 +118,20 @@ function run(...) | |||
118 | if not ok then return nil, err end | 118 | if not ok then return nil, err end |
119 | else | 119 | else |
120 | if not second then | 120 | if not second then |
121 | print("Will not remove "..name.." "..version..".") | 121 | util.printerr("Will not remove "..name.." "..version..".") |
122 | print("Removing it would break dependencies for: ") | 122 | util.printerr("Removing it would break dependencies for: ") |
123 | else | 123 | else |
124 | print("Will not remove all versions of "..name..".") | 124 | util.printerr("Will not remove all versions of "..name..".") |
125 | print("Removing them would break dependencies for: ") | 125 | util.printerr("Removing them would break dependencies for: ") |
126 | end | 126 | end |
127 | for _, dependent in ipairs(dependents) do | 127 | for _, dependent in ipairs(dependents) do |
128 | print(dependent.name.." "..dependent.version) | 128 | util.printerr(dependent.name.." "..dependent.version) |
129 | end | 129 | end |
130 | print() | 130 | util.printerr() |
131 | print("Use --force to force removal (warning: this may break modules).") | 131 | util.printerr("Use --force to force removal (warning: this may break modules).") |
132 | return nil, "Failed removing." | 132 | return nil, "Failed removing." |
133 | end | 133 | end |
134 | end | 134 | end |
135 | util.printout("Removal successful.") | ||
135 | return true | 136 | return true |
136 | end | 137 | end |
diff --git a/src/luarocks/rep.lua b/src/luarocks/rep.lua index 322ab166..8bbc1b52 100644 --- a/src/luarocks/rep.lua +++ b/src/luarocks/rep.lua | |||
@@ -153,7 +153,7 @@ function run_hook(rockspec, hook_name) | |||
153 | end | 153 | end |
154 | local hook = hooks[hook_name] | 154 | local hook = hooks[hook_name] |
155 | if hook then | 155 | if hook then |
156 | print(hook) | 156 | util.printout(hook) |
157 | if not fs.execute(hook) then | 157 | if not fs.execute(hook) then |
158 | return nil, "Failed running "..hook_name.." hook." | 158 | return nil, "Failed running "..hook_name.." hook." |
159 | end | 159 | end |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index f8188ee5..493c2f45 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -292,17 +292,17 @@ function print_results(results, show_repo, long) | |||
292 | show_repo = true -- show_repo == nil and true or show_repo | 292 | show_repo = true -- show_repo == nil and true or show_repo |
293 | 293 | ||
294 | for package, versions in util.sortedpairs(results) do | 294 | for package, versions in util.sortedpairs(results) do |
295 | print(package) | 295 | util.printout(package) |
296 | for version, repos in util.sortedpairs(versions, deps.compare_versions) do | 296 | for version, repos in util.sortedpairs(versions, deps.compare_versions) do |
297 | if show_repo then | 297 | if show_repo then |
298 | for _, repo in ipairs(repos) do | 298 | for _, repo in ipairs(repos) do |
299 | print(" "..version.." ("..repo.arch..") - "..repo.repo) | 299 | util.printout(" "..version.." ("..repo.arch..") - "..repo.repo) |
300 | end | 300 | end |
301 | else | 301 | else |
302 | print(" "..version) | 302 | util.printout(" "..version) |
303 | end | 303 | end |
304 | end | 304 | end |
305 | print() | 305 | util.printout() |
306 | end | 306 | end |
307 | end | 307 | end |
308 | 308 | ||
@@ -348,10 +348,10 @@ function act_on_src_or_rockspec(action, name, version) | |||
348 | if type(results) == "string" then | 348 | if type(results) == "string" then |
349 | return action(results) | 349 | return action(results) |
350 | elseif type(results) == "table" and next(results) then | 350 | elseif type(results) == "table" and next(results) then |
351 | print("Multiple search results were returned.") | 351 | util.printout("Multiple search results were returned.") |
352 | print() | 352 | util.printout() |
353 | print("Search results:") | 353 | util.printout("Search results:") |
354 | print("---------------") | 354 | util.printout("---------------") |
355 | print_results(results) | 355 | print_results(results) |
356 | return nil, "Please narrow your query." | 356 | return nil, "Please narrow your query." |
357 | else | 357 | else |
@@ -381,21 +381,21 @@ function run(...) | |||
381 | if not results then | 381 | if not results then |
382 | return nil, err | 382 | return nil, err |
383 | end | 383 | end |
384 | print() | 384 | util.printout() |
385 | print("Search results:") | 385 | util.printout("Search results:") |
386 | print("===============") | 386 | util.printout("===============") |
387 | print() | 387 | util.printout() |
388 | local sources, binaries = split_source_and_binary_results(results) | 388 | local sources, binaries = split_source_and_binary_results(results) |
389 | if next(sources) and not flags["binary"] then | 389 | if next(sources) and not flags["binary"] then |
390 | print("Rockspecs and source rocks:") | 390 | util.printout("Rockspecs and source rocks:") |
391 | print("---------------------------") | 391 | util.printout("---------------------------") |
392 | print() | 392 | util.printout() |
393 | print_results(sources, true) | 393 | print_results(sources, true) |
394 | end | 394 | end |
395 | if next(binaries) and not flags["source"] then | 395 | if next(binaries) and not flags["source"] then |
396 | print("Binary and pure-Lua rocks:") | 396 | util.printout("Binary and pure-Lua rocks:") |
397 | print("--------------------------") | 397 | util.printout("--------------------------") |
398 | print() | 398 | util.printout() |
399 | print_results(binaries, true) | 399 | print_results(binaries, true) |
400 | end | 400 | end |
401 | return true | 401 | return true |
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 34837c19..f968bec8 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua | |||
@@ -99,39 +99,39 @@ function run(...) | |||
99 | if not manifest then return nil,err end | 99 | if not manifest then return nil,err end |
100 | local minfo = manifest.repository[name][version][1] | 100 | local minfo = manifest.repository[name][version][1] |
101 | 101 | ||
102 | if flags["tree"] then print(repo) | 102 | if flags["tree"] then util.printout(repo) |
103 | elseif flags["rock-dir"] then print(directory) | 103 | elseif flags["rock-dir"] then util.printout(directory) |
104 | elseif flags["home"] then print(descript.homepage) | 104 | elseif flags["home"] then util.printout(descript.homepage) |
105 | elseif flags["modules"] then print(keys_as_string(minfo.modules)) | 105 | elseif flags["modules"] then util.printout(keys_as_string(minfo.modules)) |
106 | elseif flags["deps"] then print(keys_as_string(minfo.dependencies)) | 106 | elseif flags["deps"] then util.printout(keys_as_string(minfo.dependencies)) |
107 | elseif flags["rockspec"] then print(rockspec_file) | 107 | elseif flags["rockspec"] then util.printout(rockspec_file) |
108 | elseif flags["mversion"] then print(version) | 108 | elseif flags["mversion"] then util.printout(version) |
109 | else | 109 | else |
110 | print() | 110 | util.printout() |
111 | print(rockspec.package.." "..rockspec.version.." - "..descript.summary) | 111 | util.printout(rockspec.package.." "..rockspec.version.." - "..descript.summary) |
112 | print() | 112 | util.printout() |
113 | if descript.detailed then | 113 | if descript.detailed then |
114 | print(format_text(descript.detailed)) | 114 | util.printout(format_text(descript.detailed)) |
115 | print() | 115 | util.printout() |
116 | end | 116 | end |
117 | if descript.license then | 117 | if descript.license then |
118 | print("License: ", descript.license) | 118 | util.printout("License: ", descript.license) |
119 | end | 119 | end |
120 | if descript.homepage then | 120 | if descript.homepage then |
121 | print("Homepage: ", descript.homepage) | 121 | util.printout("Homepage: ", descript.homepage) |
122 | end | 122 | end |
123 | print("Installed in: ", repo) | 123 | util.printout("Installed in: ", repo) |
124 | if next(minfo.modules) then | 124 | if next(minfo.modules) then |
125 | print() | 125 | util.printout() |
126 | print("Modules:") | 126 | util.printout("Modules:") |
127 | print("\t"..keys_as_string(minfo.modules, "\n\t")) | 127 | util.printout("\t"..keys_as_string(minfo.modules, "\n\t")) |
128 | end | 128 | end |
129 | if next(minfo.dependencies) then | 129 | if next(minfo.dependencies) then |
130 | print() | 130 | util.printout() |
131 | print("Depends on:") | 131 | util.printout("Depends on:") |
132 | print("\t"..keys_as_string(minfo.dependencies, "\n\t")) | 132 | util.printout("\t"..keys_as_string(minfo.dependencies, "\n\t")) |
133 | end | 133 | end |
134 | print() | 134 | util.printout() |
135 | end | 135 | end |
136 | return true | 136 | return true |
137 | end | 137 | end |
diff --git a/src/luarocks/tools/tar.lua b/src/luarocks/tools/tar.lua index 0a3e07a4..e47172fa 100644 --- a/src/luarocks/tools/tar.lua +++ b/src/luarocks/tools/tar.lua | |||
@@ -3,6 +3,7 @@ module("luarocks.tools.tar", package.seeall) | |||
3 | 3 | ||
4 | local fs = require("luarocks.fs") | 4 | local fs = require("luarocks.fs") |
5 | local dir = require("luarocks.dir") | 5 | local dir = require("luarocks.dir") |
6 | local util = require("luarocks.util") | ||
6 | 7 | ||
7 | local blocksize = 512 | 8 | local blocksize = 512 |
8 | 9 | ||
@@ -96,7 +97,7 @@ function untar(filename, destdir) | |||
96 | if not block then break end | 97 | if not block then break end |
97 | local header, err = read_header_block(block) | 98 | local header, err = read_header_block(block) |
98 | if not header then | 99 | if not header then |
99 | print(err) | 100 | util.printerr(err) |
100 | end | 101 | end |
101 | 102 | ||
102 | local file_data = tar_handle:read(math.ceil(header.size / blocksize) * blocksize):sub(1,header.size) | 103 | local file_data = tar_handle:read(math.ceil(header.size / blocksize) * blocksize):sub(1,header.size) |
@@ -131,12 +132,11 @@ function untar(filename, destdir) | |||
131 | fs.chmod(pathname, header.mode) | 132 | fs.chmod(pathname, header.mode) |
132 | end | 133 | end |
133 | end | 134 | end |
134 | print(pathname) | ||
135 | --[[ | 135 | --[[ |
136 | for k,v in pairs(header) do | 136 | for k,v in pairs(header) do |
137 | print("[\""..tostring(k).."\"] = "..(type(v)=="number" and v or "\""..v:gsub("%z", "\\0").."\"")) | 137 | util.printout("[\""..tostring(k).."\"] = "..(type(v)=="number" and v or "\""..v:gsub("%z", "\\0").."\"")) |
138 | end | 138 | end |
139 | print() | 139 | util.printout() |
140 | --]] | 140 | --]] |
141 | end | 141 | end |
142 | return true | 142 | return true |
diff --git a/src/luarocks/tools/zip.lua b/src/luarocks/tools/zip.lua index 36adc7e2..19f6af85 100644 --- a/src/luarocks/tools/zip.lua +++ b/src/luarocks/tools/zip.lua | |||
@@ -116,11 +116,13 @@ local function zipwriter_add(self, file) | |||
116 | if ok then | 116 | if ok then |
117 | local buf = fin:read("*a") | 117 | local buf = fin:read("*a") |
118 | if not buf then | 118 | if not buf then |
119 | break | 119 | err = "error reading "..file |
120 | end | 120 | ok = false |
121 | ok = self:write_file_in_zip(buf) | 121 | else |
122 | if not ok then | 122 | ok = self:write_file_in_zip(buf) |
123 | err = "error in writing "..file.." in the zipfile" | 123 | if not ok then |
124 | err = "error in writing "..file.." in the zipfile" | ||
125 | end | ||
124 | end | 126 | end |
125 | end | 127 | end |
126 | if fin then | 128 | if fin then |
diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua index c73264d0..dacafa31 100644 --- a/src/luarocks/unpack.lua +++ b/src/luarocks/unpack.lua | |||
@@ -116,10 +116,10 @@ local function run_unpacker(file) | |||
116 | return nil, "Failed copying unpacked rockspec into unpacked source directory." | 116 | return nil, "Failed copying unpacked rockspec into unpacked source directory." |
117 | end | 117 | end |
118 | end | 118 | end |
119 | print() | 119 | util.printout() |
120 | print("Done. You may now enter directory ") | 120 | util.printout("Done. You may now enter directory ") |
121 | print(dir.path(dir_name, rockspec.source.dir)) | 121 | util.printout(dir.path(dir_name, rockspec.source.dir)) |
122 | print("and type 'luarocks make' to build.") | 122 | util.printout("and type 'luarocks make' to build.") |
123 | end | 123 | end |
124 | util.remove_scheduled_function(rollback) | 124 | util.remove_scheduled_function(rollback) |
125 | return true | 125 | return true |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index e0c01421..0ff36f3e 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -124,12 +124,6 @@ end | |||
124 | 124 | ||
125 | local var_format_pattern = "%$%((%a[%a%d_]+)%)" | 125 | local var_format_pattern = "%$%((%a[%a%d_]+)%)" |
126 | 126 | ||
127 | --- Display a warning message. | ||
128 | -- @param msg string: the warning message | ||
129 | function warning(msg) | ||
130 | print("Warning: "..msg) | ||
131 | end | ||
132 | |||
133 | --- Create a new shallow copy of a table: a new table with | 127 | --- Create a new shallow copy of a table: a new table with |
134 | -- the same keys and values. Keys point to the same objects as | 128 | -- the same keys and values. Keys point to the same objects as |
135 | -- the original table (ie, does not copy recursively). | 129 | -- the original table (ie, does not copy recursively). |
@@ -257,6 +251,24 @@ function starts_with(s, prefix) | |||
257 | return s:sub(1,#prefix) == prefix | 251 | return s:sub(1,#prefix) == prefix |
258 | end | 252 | end |
259 | 253 | ||
254 | --- Print a line to standard output | ||
255 | function printout(...) | ||
256 | io.stdout:write(table.concat({...},"\t")) | ||
257 | io.stdout:write("\n") | ||
258 | end | ||
259 | |||
260 | --- Print a line to standard error | ||
261 | function printerr(...) | ||
262 | io.stdout:write(table.concat({...},"\t")) | ||
263 | io.stderr:write("\n") | ||
264 | end | ||
265 | |||
266 | --- Display a warning message. | ||
267 | -- @param msg string: the warning message | ||
268 | function warning(msg) | ||
269 | printerr("Warning: "..msg) | ||
270 | end | ||
271 | |||
260 | -- from http://lua-users.org/wiki/SplitJoin | 272 | -- from http://lua-users.org/wiki/SplitJoin |
261 | -- by PhilippeLhoste | 273 | -- by PhilippeLhoste |
262 | function split_string(str, delim, maxNb) | 274 | function split_string(str, delim, maxNb) |
@@ -302,7 +314,7 @@ which logically are exactly not equivalent to the original code. | |||
302 | This routine can serve for pretty formating tables with | 314 | This routine can serve for pretty formating tables with |
303 | proper indentations, apart from printing them: | 315 | proper indentations, apart from printing them: |
304 | 316 | ||
305 | print(table.show(t, "t")) -- a typical use | 317 | io.write(table.show(t, "t")) -- a typical use |
306 | 318 | ||
307 | Heavily based on "Saving tables with cycles", PIL2, p. 113. | 319 | Heavily based on "Saving tables with cycles", PIL2, p. 113. |
308 | 320 | ||
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua index ef402988..fbffadc7 100644 --- a/src/luarocks/validate.lua +++ b/src/luarocks/validate.lua | |||
@@ -51,7 +51,7 @@ end | |||
51 | local function validate_rockspec(file) | 51 | local function validate_rockspec(file) |
52 | local ok, err, errcode = build.build_rockspec(file, true) | 52 | local ok, err, errcode = build.build_rockspec(file, true) |
53 | if not ok then | 53 | if not ok then |
54 | print(err) | 54 | util.printerr(err) |
55 | end | 55 | end |
56 | return ok, err, errcode | 56 | return ok, err, errcode |
57 | end | 57 | end |
@@ -59,7 +59,7 @@ end | |||
59 | local function validate_src_rock(file) | 59 | local function validate_src_rock(file) |
60 | local ok, err, errcode = build.build_rock(file, false) | 60 | local ok, err, errcode = build.build_rock(file, false) |
61 | if not ok then | 61 | if not ok then |
62 | print(err) | 62 | util.printerr(err) |
63 | end | 63 | end |
64 | return ok, err, errcode | 64 | return ok, err, errcode |
65 | end | 65 | end |
@@ -67,7 +67,7 @@ end | |||
67 | local function validate_rock(file) | 67 | local function validate_rock(file) |
68 | local ok, err, errcode = install.install_binary_rock(file) | 68 | local ok, err, errcode = install.install_binary_rock(file) |
69 | if not ok then | 69 | if not ok then |
70 | print(err) | 70 | util.printerr(err) |
71 | end | 71 | end |
72 | return ok, err, errcode | 72 | return ok, err, errcode |
73 | end | 73 | end |
@@ -93,8 +93,8 @@ local function validate(repo, flags) | |||
93 | sandbox = prepare_sandbox(file) | 93 | sandbox = prepare_sandbox(file) |
94 | end | 94 | end |
95 | local ok, err, errcode | 95 | local ok, err, errcode |
96 | print() | 96 | util.printout() |
97 | print("Verifying "..pathname) | 97 | util.printout("Verifying "..pathname) |
98 | if file:match("%.rockspec$") then | 98 | if file:match("%.rockspec$") then |
99 | ok, err, errcode = validate_rockspec(pathname) | 99 | ok, err, errcode = validate_rockspec(pathname) |
100 | elseif file:match("%.src%.rock$") then | 100 | elseif file:match("%.src%.rock$") then |
@@ -123,32 +123,32 @@ local function validate(repo, flags) | |||
123 | fs.delete(sandbox) | 123 | fs.delete(sandbox) |
124 | end | 124 | end |
125 | restore_settings(settings) | 125 | restore_settings(settings) |
126 | print() | 126 | util.printout() |
127 | print("Results:") | 127 | util.printout("Results:") |
128 | print("--------") | 128 | util.printout("--------") |
129 | print("OK: "..tostring(#results.ok)) | 129 | util.printout("OK: "..tostring(#results.ok)) |
130 | for _, entry in ipairs(results.ok) do | 130 | for _, entry in ipairs(results.ok) do |
131 | print(entry.file) | 131 | util.printout(entry.file) |
132 | end | 132 | end |
133 | for errcode, errors in pairs(results) do | 133 | for errcode, errors in pairs(results) do |
134 | if errcode ~= "ok" then | 134 | if errcode ~= "ok" then |
135 | print() | 135 | util.printout() |
136 | print(errcode.." errors: "..tostring(#errors)) | 136 | util.printout(errcode.." errors: "..tostring(#errors)) |
137 | for _, entry in ipairs(errors) do | 137 | for _, entry in ipairs(errors) do |
138 | print(entry.file, entry.err) | 138 | util.printout(entry.file, entry.err) |
139 | end | 139 | end |
140 | end | 140 | end |
141 | end | 141 | end |
142 | 142 | ||
143 | print() | 143 | util.printout() |
144 | print("Summary:") | 144 | util.printout("Summary:") |
145 | print("--------") | 145 | util.printout("--------") |
146 | local total = 0 | 146 | local total = 0 |
147 | for errcode, errors in pairs(results) do | 147 | for errcode, errors in pairs(results) do |
148 | print(errcode..": "..tostring(#errors)) | 148 | util.printout(errcode..": "..tostring(#errors)) |
149 | total = total + #errors | 149 | total = total + #errors |
150 | end | 150 | end |
151 | print("Total: "..total) | 151 | util.printout("Total: "..total) |
152 | return true | 152 | return true |
153 | end | 153 | end |
154 | 154 | ||
@@ -156,7 +156,7 @@ function run(...) | |||
156 | local flags, repo = util.parse_flags(...) | 156 | local flags, repo = util.parse_flags(...) |
157 | repo = repo or cfg.rocks_dir | 157 | repo = repo or cfg.rocks_dir |
158 | 158 | ||
159 | print("Verifying contents of "..repo) | 159 | util.printout("Verifying contents of "..repo) |
160 | 160 | ||
161 | return validate(repo, flags) | 161 | return validate(repo, flags) |
162 | end | 162 | end |