From 15d71214638c6f7f808b838cfc4215ece0a53101 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 4 Apr 2024 23:32:09 -0300 Subject: fix(build): ensure --force works for build --- spec/quick/build.q | 8 ++++++++ spec/quick/make.q | 37 +++++++++++++++++++++++++++++++++++++ src/luarocks/build.lua | 1 + src/luarocks/cmd/build.lua | 3 ++- src/luarocks/cmd/install.lua | 2 +- src/luarocks/cmd/make.lua | 1 + 6 files changed, 50 insertions(+), 2 deletions(-) diff --git a/spec/quick/build.q b/spec/quick/build.q index 4d0f6f9f..d0d6a890 100644 --- a/spec/quick/build.q +++ b/spec/quick/build.q @@ -214,6 +214,14 @@ Use --force to reinstall -------------------------------------------------------------------------------- +RUN: luarocks build a_rock-1.0-1.rockspec --force +NOT_STDOUT: +-------------------------------------------------------------------------------- +a_rock 1.0-1 is already installed +Use --force to reinstall +-------------------------------------------------------------------------------- + + ================================================================================ TEST: supports --pin #pinning diff --git a/spec/quick/make.q b/spec/quick/make.q index c77bb499..eb3472b6 100644 --- a/spec/quick/make.q +++ b/spec/quick/make.q @@ -49,3 +49,40 @@ return { } } -------------------------------------------------------------------------------- + + + +================================================================================ +TEST: running make twice builds twice + +FILE: test-2.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "2.0-1" +source = { + url = "file://%{path(tmpdir)}/test.lua" +} +build = { + type = "builtin", + modules = { + test = "test.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: test.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks make --only-server=%{fixtures_dir}/a_repo --pin --tree=lua_modules +STDOUT: +-------------------------------------------------------------------------------- +test 2.0-1 is now installed +-------------------------------------------------------------------------------- + +RUN: luarocks make --only-server=%{fixtures_dir}/a_repo --pin --tree=lua_modules +STDOUT: +-------------------------------------------------------------------------------- +test 2.0-1 is now installed +-------------------------------------------------------------------------------- diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 55242e60..c6b3388b 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -24,6 +24,7 @@ build.opts = util.opts_table("build.opts", { verify = "boolean", check_lua_versions = "boolean", pin = "boolean", + rebuild = "boolean", no_install = "boolean" }) diff --git a/src/luarocks/cmd/build.lua b/src/luarocks/cmd/build.lua index ada6b7d2..32680411 100644 --- a/src/luarocks/cmd/build.lua +++ b/src/luarocks/cmd/build.lua @@ -95,7 +95,7 @@ local function do_build(name, namespace, version, opts) name, version = path.parse_name(url) if name and repos.is_installed(name, version) then - if (not opts.force) and (not opts.force_fast) then + if not opts.rebuild then util.printout(name .. " " .. version .. " is already installed in " .. path.root_dir(cfg.root_dir)) util.printout("Use --force to reinstall.") return name, version, "skip" @@ -138,6 +138,7 @@ function cmd_build.command(args) verify = not not args.verify, check_lua_versions = not not args.check_lua_versions, pin = not not args.pin, + rebuild = not not (args.force or args.force_fast), no_install = false }) diff --git a/src/luarocks/cmd/install.lua b/src/luarocks/cmd/install.lua index e71b6db8..9e705d12 100644 --- a/src/luarocks/cmd/install.lua +++ b/src/luarocks/cmd/install.lua @@ -84,7 +84,7 @@ function install.install_binary_rock(rock_file, opts) return nil, "Incompatible architecture "..arch, "arch" end if repos.is_installed(name, version) then - if (not opts.force) and (not opts.force_fast) then + if not (opts.force or opts.force_fast) then util.printout(name .. " " .. version .. " is already installed in " .. path.root_dir(cfg.root_dir)) util.printout("Use --force to reinstall.") return name, version diff --git a/src/luarocks/cmd/make.lua b/src/luarocks/cmd/make.lua index eaa4b899..0b3db27c 100644 --- a/src/luarocks/cmd/make.lua +++ b/src/luarocks/cmd/make.lua @@ -106,6 +106,7 @@ function make.command(args) verify = not not args.verify, check_lua_versions = not not args.check_lua_versions, pin = not not args.pin, + rebuild = true, no_install = not not args.no_install }) -- cgit v1.2.3-55-g6feb