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(-) (limited to 'src') 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