From 574897fb8a878e0abf56d7f3f5ed2a6459dbfba8 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Wed, 19 Oct 2016 11:55:51 +0300 Subject: Run manif.update_manifest in repos.deploy_files Similarly to repos.delete_version, it's a good idea to update manifest immediately after altering what's deployed, even though in this case manifest was always updated by the caller. Also added more doc comments for repos functions. --- src/luarocks/build.lua | 5 +---- src/luarocks/install.lua | 7 ++----- src/luarocks/repos.lua | 27 +++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index f2784a3a..b306b050 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -320,7 +320,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m ok, err = manif.make_rock_manifest(name, version) if err then return nil, err end - ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec)) + ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode) if err then return nil, err end util.remove_scheduled_function(rollback) @@ -331,9 +331,6 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m ok, err = repos.run_hook(rockspec, "post_install") if err then return nil, err end - ok, err = manif.update_manifest(name, version, nil, deps_mode) - if err then return nil, err end - util.announce_install(rockspec) util.remove_scheduled_function(rollback) return name, version diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index daebfc70..b5128430 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua @@ -84,7 +84,7 @@ function install.install_binary_rock(rock_file, deps_mode) if err then return nil, err, errcode end end - ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec)) + ok, err = repos.deploy_files(name, version, repos.should_wrap_bin_scripts(rockspec), deps_mode) if err then return nil, err end util.remove_scheduled_function(rollback) @@ -94,10 +94,7 @@ function install.install_binary_rock(rock_file, deps_mode) ok, err = repos.run_hook(rockspec, "post_install") if err then return nil, err end - - ok, err = manif.update_manifest(name, version, nil, deps_mode) - if err then return nil, err end - + util.announce_install(rockspec) util.remove_scheduled_function(rollback) return name, version diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 4e8a9a13..a1cf2bb4 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua @@ -190,7 +190,18 @@ function repos.should_wrap_bin_scripts(rockspec) return true end -function repos.deploy_files(name, version, wrap_bin_scripts) +--- Deploy a package from the rocks subdirectory. +-- It is maintained that for each file the one that is provided +-- by the newest version of the lexicographically smallest package +-- is installed using unversioned name, and other versions of the file +-- use versioned names. +-- @param name string: name of package +-- @param version string: exact package version in string format +-- @param wrap_bin_scripts bool: whether commands written in Lua should be wrapped. +-- @param deps_mode: string: Which trees to check dependencies for: +-- "one" for the current default tree, "all" for all trees, +-- "order" for all trees with priority >= the current default, "none" for no trees. +function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) assert(type(name) == "string") assert(type(version) == "string") assert(type(wrap_bin_scripts) == "boolean") @@ -245,7 +256,12 @@ function repos.deploy_files(name, version, wrap_bin_scripts) if ok and rock_manifest.lib then ok, err = deploy_file_tree(rock_manifest.lib, path.lib_dir, cfg.deploy_lib_dir, make_mover(cfg.perm_exec)) end - return ok, err + + if not ok then + return nil, err + end + + return manif.update_manifest(name, version, nil, deps_mode) end local function delete_suffixed(filename, suffix) @@ -264,9 +280,12 @@ local function delete_suffixed(filename, suffix) end --- Delete a package from the local repository. --- Version numbers are compared as exact string comparison. +-- It is maintained that for each file the one that is provided +-- by the newest version of the lexicographically smallest package +-- is installed using unversioned name, and other versions of the file +-- use versioned names. -- @param name string: name of package --- @param version string: package version in string format +-- @param version string: exact package version in string format -- @param deps_mode: string: Which trees to check dependencies for: -- "one" for the current default tree, "all" for all trees, -- "order" for all trees with priority >= the current default, "none" for no trees. -- cgit v1.2.3-55-g6feb From 66390224e272b0cbda12e50042209dafd1222dc0 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Wed, 19 Oct 2016 17:46:28 +0300 Subject: Remove some useless code in build.builtin If `basename` is equal to `baseinfo` then, as `filename` is `baseinfo` plus ".lua", assignment `filename = basename..".lua"` has no effect and the if statement can be removed. Then `baseinfo` can be removed as unused. --- src/luarocks/build/builtin.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index b6f53271..c8b1b84d 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -209,10 +209,7 @@ function builtin.run(rockspec) moddir = path.module_to_path(name..".init") else local basename = name:match("([^.]+)$") - local baseinfo = filename:gsub("%.lua$", "") - if basename ~= baseinfo then - filename = basename..".lua" - end + filename = basename..".lua" end local dest = dir.path(luadir, moddir, filename) lua_modules[info] = dest -- cgit v1.2.3-55-g6feb From 2bfcd954d1b7c94983ea3e25ac1cf44f304d9505 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Wed, 19 Oct 2016 17:59:36 +0300 Subject: Fix installation of modules from files ending with "init.lua" In builtin backend, when figuring out where to install a module and checking for special "init.lua" logic, trigger it only when the whole basename is "init.lua", not when it merely ends with it. Fixes incorrect installation when build.modules contains pairs like `["kainit"] = "kainit.lua"` - the module used to go to `kainit/kainit.lua` instead of just `kainit.lua`. --- src/luarocks/build/builtin.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index c8b1b84d..6719be81 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -205,7 +205,7 @@ function builtin.run(rockspec) local ext = info:match("%.([^.]+)$") if ext == "lua" then local filename = dir.base_name(info) - if info:match("init%.lua$") and not name:match("%.init$") then + if filename == "init.lua" and not name:match("%.init$") then moddir = path.module_to_path(name..".init") else local basename = name:match("([^.]+)$") -- cgit v1.2.3-55-g6feb From 5c6eb8604fe5aee3088096ef808399f847fb24a0 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Wed, 19 Oct 2016 18:10:18 +0300 Subject: Fix tests on Windows with Lua 5.3 Don't install luafilesystem 1.6.1 on Windows with Lua 5.3, it fails. --- spec/install_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 45b3e2f9..2bbf4221 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -20,7 +20,7 @@ local extra_rocks = { "/say-1.0-1.src.rock", "/wsapi-1.6-1.src.rock", "/luafilesystem-1.6.3-2.src.rock", - "/luafilesystem-1.6.1-1.src.rock", + "/luafilesystem-1.6.3-1.src.rock", } describe("LuaRocks install tests #blackbox #b_install", function() @@ -87,12 +87,12 @@ describe("LuaRocks install tests #blackbox #b_install", function() it('LuaRocks install - handle versioned modules when installing another version with --keep #268', function() assert.is_true(run.luarocks_bool("install luafilesystem")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) - assert.is_true(run.luarocks_bool("install luafilesystem 1.6.1 --keep")) + assert.is_true(run.luarocks_bool("install luafilesystem 1.6.3-1 --keep")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_1_1-lfs."..test_env.lib_extension)) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) assert.is_true(run.luarocks_bool("install luafilesystem")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_1_1-lfs."..test_env.lib_extension)) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) end) it("LuaRocks install only-deps of luasocket packed rock", function() -- cgit v1.2.3-55-g6feb