From 4f9f675e59b98edfe9f41c7bad51591acb919634 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 2 Nov 2010 20:45:36 -0200 Subject: use absolute paths with fs.delete --- src/luarocks/fetch/git.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 6305d781..a3b763d6 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua @@ -47,8 +47,8 @@ function get_sources(rockspec, extract, dest_dir) return nil, "Failed checking out tag/branch from git repository." end end - fs.delete(".git") - fs.delete(".gitignore") + fs.delete(dir.path(store_dir, module, ".git")) + fs.delete(dir.path(store_dir, module, ".gitignore")) fs.pop_dir() fs.pop_dir() return module, store_dir -- cgit v1.2.3-55-g6feb From 04d2aa2f9d81cb48875267437858bdf22eec759b Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 2 Nov 2010 20:46:16 -0200 Subject: display external dependencies in index.html page --- src/luarocks/index.lua | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/luarocks/index.lua b/src/luarocks/index.lua index 18afd797..570db431 100644 --- a/src/luarocks/index.lua +++ b/src/luarocks/index.lua @@ -64,6 +64,7 @@ local index_package_start = [[

$package - $summary

$detailed
+$externaldependencies latest sources $homepage | License: $license

@@ -83,6 +84,34 @@ local index_footer = [[ ]] +function format_external_dependencies(rockspec) + if rockspec.external_dependencies then + local deplist = {} + local listed_set = {} + local plats = nil + for name, desc in util.sortedpairs(rockspec.external_dependencies) do + if name ~= "platforms" then + table.insert(deplist, name:lower()) + listed_set[name] = true + else + plats = desc + end + end + if plats then + for plat, entries in util.sortedpairs(plats) do + for name, desc in util.sortedpairs(entries) do + if not listed_set[name] then + table.insert(deplist, name:lower() .. " (on "..plat..")") + end + end + end + end + return '

External dependencies: ' .. table.concat(deplist, ', ').. '

' + else + return "" + end +end + function make_index(repo) if not fs.is_dir(repo) then return nil, "Cannot access repository at "..repo @@ -96,9 +125,8 @@ function make_index(repo) local output = index_package_start for version, data in util.sortedpairs(version_list, deps.compare_versions) do local versions = {} - local versions_order = {} output = output..version..': ' - + table.sort(data, function(a,b) return a.arch < b.arch end) for _, item in ipairs(data) do local link = ''..item.arch..'' if item.arch == 'rockspec' then @@ -108,14 +136,9 @@ function make_index(repo) else link = link:gsub("$url", ("%s-%s.%s.rock"):format(package, version, item.arch)) end - versions[item.arch] = link - table.insert(versions_order, item.arch) - end - table.sort(versions_order) - for i, arch in ipairs(versions_order) do - versions_order[i] = versions[versions_order[i]] + table.insert(versions, link) end - output = output .. table.concat(versions_order, ', ') .. '
' + output = output .. table.concat(versions, ', ') .. '
' end output = output .. index_package_end if latest_rockspec then @@ -127,7 +150,8 @@ function make_index(repo) summary = rockspec.description.summary or "", detailed = rockspec.description.detailed or "", license = rockspec.description.license or "N/A", - homepage = rockspec.description.homepage and ("| project homepage") or "" + homepage = rockspec.description.homepage and ("| project homepage") or "", + externaldependencies = format_external_dependencies(rockspec) } vars.detailed = vars.detailed:gsub("\n\n", "

"):gsub("%s+", " ") output = output:gsub("$(%w+)", vars) -- cgit v1.2.3-55-g6feb From e0e5c21e5b374927cb3b015eaad34e2c804eb091 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 2 Nov 2010 20:46:33 -0200 Subject: fix for 'show' version selection by Steve Donovan --- src/luarocks/show.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 82568d13..34837c19 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua @@ -83,7 +83,7 @@ function run(...) --question: what do we do about multiple versions? This should --give us the latest version on the last repo (which is usually the global one) for vs, repos in util.sortedpairs(versions, deps.compare_versions) do - version = vs + if not version then version = vs end for _, rp in ipairs(repos) do repo_url = rp.repo end end -- cgit v1.2.3-55-g6feb From 7f79d5a020d2345704193aeb3cb17aee99c87b4a Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 18 Nov 2010 22:23:47 -0200 Subject: Fix usage of cfg.root_dir, which can now be either a string or a table. Thanks to Fabio Mascarenhas for the heads-up. --- src/luarocks/build.lua | 9 ++++----- src/luarocks/fs/lua.lua | 15 +++++++++++++++ src/luarocks/install.lua | 9 ++++----- src/luarocks/make.lua | 6 ++---- src/luarocks/util.lua | 1 - 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 6eca0c3e..e6afde54 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -235,8 +235,9 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) license = ("(license: "..rockspec.description.license..")") end + local root_dir = path.root_dir(cfg.rocks_dir) print() - print(name.." "..version.." is now built and installed in "..cfg.root_dir.." "..license) + print(name.." "..version.." is now built and installed in "..root_dir.." "..license) util.remove_scheduled_function(rollback) return true @@ -278,10 +279,8 @@ function run(...) end assert(type(version) == "string" or not version) - if not flags["local"] and (fs.exists(cfg.root_dir) and not fs.is_writable(cfg.root_dir)) then - return nil, "Your user does not have write permissions in " .. cfg.root_dir .. - " \n-- you may want to run as a privileged user or use your local tree with --local." - end + local ok, err = fs.check_command_permissions(flags) + if not ok then return nil, err end if name:match("%.rockspec$") then return build_rockspec(name, true) diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 70df65be..5b3efd94 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -8,6 +8,7 @@ local fs = require("luarocks.fs") local cfg = require("luarocks.cfg") local dir = require("luarocks.dir") local util = require("luarocks.util") +local path = require("luarocks.path") local socket_ok, http = pcall(require, "socket.http") local _, ftp = pcall(require, "socket.ftp") @@ -615,3 +616,17 @@ function move(src, dest) end return true end + +--- Check if user has write permissions for the command. +-- Assumes the configuration variables under cfg have been previously set up. +-- @param flags table: the flags table passed to run() drivers. +-- @return boolean or (boolean, string): true on success, false on failure, +-- plus an error message. +function check_command_permissions(flags) + local root_dir = path.root_dir(cfg.rocks_dir) + if not flags["local"] and not fs.is_writable(root_dir) then + return nil, "Your user does not have write permissions in " .. root_dir .. + " \n-- you may want to run as a privileged user or use your local tree with --local." + end + return true +end diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index f9f27ccf..016e73bb 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua @@ -84,8 +84,9 @@ function install_binary_rock(rock_file) license = ("(license: "..rockspec.description.license..")") end + local root_dir = path.root_dir(cfg.rocks_dir) print() - print(name.." "..version.." is now installed in "..cfg.root_dir.." "..license) + print(name.." "..version.." is now installed in "..root_dir.." "..license) util.remove_scheduled_function(rollback) return true @@ -107,10 +108,8 @@ function run(...) return nil, "Argument missing, see help." end - if not flags["local"] and (fs.exists(cfg.root_dir) and not fs.is_writable(cfg.root_dir)) then - return nil, "Your user does not have write permissions in " .. cfg.root_dir .. - " \n-- you may want to run as a privileged user or use your local tree with --local." - end + local ok, err = fs.check_command_permissions(flags) + if not ok then return nil, err end if name:match("%.rockspec$") or name:match("%.src%.rock$") then local build = require("luarocks.build") diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua index ec3772ac..4af5a16c 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua @@ -32,10 +32,8 @@ function run(...) local flags, rockspec = util.parse_flags(...) assert(type(rockspec) == "string" or not rockspec) - if not flags["local"] and not fs.is_writable(cfg.root_dir) then - return nil, "Your user does not have write permissions in " .. cfg.root_dir .. - " \n-- you may want to run as a privileged user or use your local tree with --local." - end + local ok, err = fs.check_command_permissions(flags) + if not ok then return nil, err end if not rockspec then local files = fs.list_dir(fs.current_dir()) diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index ed70b2ba..10fc1e36 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -362,4 +362,3 @@ function show_table(t, name, indent) addtocart(t, name, indent) return cart .. autoref end - -- cgit v1.2.3-55-g6feb From 6d7b31ad8d340ec237b07664070ef325ea6314a4 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 18 Nov 2010 22:46:05 -0200 Subject: Remove newline from string when reading from md5 or openssl. Closes #4. --- src/luarocks/fs/unix/tools.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index a67dca49..bb7e48db 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -302,14 +302,14 @@ function get_md5(file, md5sum) end elseif cfg.md5checker == "openssl" then local pipe = io.popen("openssl md5 "..file) - computed = pipe:read("*a") + computed = pipe:read("*l") pipe:close() if computed then computed = computed:sub(-32) end elseif cfg.md5checker == "md5" then local pipe = io.popen("md5 "..file) - computed = pipe:read("*a") + computed = pipe:read("*l") pipe:close() if computed then computed = computed:sub(-32) -- cgit v1.2.3-55-g6feb From abf7a9d408ed279a98287dad020afee88dcc68cc Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 22 Nov 2010 19:54:35 -0500 Subject: Add OpenBSD support --- src/luarocks/cfg.lua | 9 +++++++++ src/luarocks/fs/unix/tools.lua | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index d141bdee..2385d665 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -64,6 +64,10 @@ if system == "FreeBSD" then detected.unix = true detected.freebsd = true detected.bsd = true +elseif system == "OpenBSD" then + detected.unix = true + detected.openbsd = true + detected.bsd = true elseif system == "Darwin" then detected.unix = true detected.macosx = true @@ -289,6 +293,11 @@ if detected.freebsd then defaults.variables.LIBFLAG = "-shared" end +if detected.openbsd then + defaults.arch = "openbsd-"..proc + defaults.platforms = {"unix", "bsd", "openbsd"} +end + -- Expose some more values detected by LuaRocks for use by rockspec authors. defaults.variables.LUA = defaults.lua_interpreter defaults.variables.LIB_EXTENSION = defaults.lib_extension diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index bb7e48db..c805fb48 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua @@ -350,7 +350,18 @@ end function get_permissions(filename) local ret - local flag = cfg.is_platform("bsd") and "-f '%A'" or "-c '%a'" + + local flag + if cfg.is_platform("bsd") then + if cfg.is_platform("openbsd") then + flag = "-f '%Op'" + else + flag = "-f '%A'" + end + else + flag = "-c '%a'" + end + local pipe = io.popen("stat "..flag.." "..fs.Q(filename)) ret = pipe:read("*l") pipe:close() -- cgit v1.2.3-55-g6feb From 98ead176473c0fbd02b147adbcb089df8a56095e Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 23 Nov 2010 00:03:07 -0200 Subject: Getting ready for LuaRocks 2.0.4 --- Makefile | 3 ++- rockspec | 2 +- src/luarocks/cfg.lua | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 97ccefa5..1aac0350 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,8 @@ build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \ fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua path.lua \ remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ -help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua +help.lua util.lua index.lua cache.lua add.lua refresh_cache.lua loader.lua \ +admin_remove.lua CONFIG_FILE = $(SYSCONFDIR)/config.lua diff --git a/rockspec b/rockspec index 5c054e2f..a1ff04d8 100644 --- a/rockspec +++ b/rockspec @@ -1,5 +1,5 @@ package = "LuaRocks" -local VER = "2.0.3" +local VER = "2.0.4" local REV = "1" version = VER.."-"..REV diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 2385d665..d1735ff0 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -24,7 +24,7 @@ end _M.config = config -program_version = "2.0.3" +program_version = "2.0.4" user_agent = "LuaRocks/"..program_version local persist = require("luarocks.persist") -- cgit v1.2.3-55-g6feb