diff options
| author | ruki <[email protected]> | 2019-03-14 23:57:38 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-14 17:45:49 +0800 |
| commit | 9036abe2d5d282bd19c9f6bdd2acee9ac03051fc (patch) | |
| tree | 9de2c370b841128b754bd2590e4d0a82173bbe7f /xmake/actions/require | |
| parent | 1885d14af400ea5658dc89431fc1353184e40643 (diff) | |
fix uninstall and remove unlink for package
Diffstat (limited to 'xmake/actions/require')
| -rw-r--r-- | xmake/actions/require/impl/action/install.lua | 24 | ||||
| -rw-r--r-- | xmake/actions/require/impl/package.lua | 36 | ||||
| -rw-r--r-- | xmake/actions/require/main.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/require/unlink.lua | 77 | ||||
| -rw-r--r-- | xmake/actions/require/xmake.lua | 1 |
5 files changed, 15 insertions, 129 deletions
diff --git a/xmake/actions/require/impl/action/install.lua b/xmake/actions/require/impl/action/install.lua index a032dd7aa..f55d8afd1 100644 --- a/xmake/actions/require/impl/action/install.lua +++ b/xmake/actions/require/impl/action/install.lua @@ -79,6 +79,7 @@ function main(package) local installtask = function () -- install the third-party package directly, e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable + local need_test = false if package:is3rd() then local script = package:script("install") if script ~= nil then @@ -102,11 +103,21 @@ function main(package) -- save the package info to the manifest file package:manifest_save() - - -- test it - test(package) + need_test = true end end + + -- fetch package and force to flush the cache + local fetchinfo = package:fetch({force = true}) + if option.get("verbose") or option.get("diagnosis") then + print(fetchinfo) + end + assert(fetchinfo, "fetch %s failed!", tipname) + + -- test it + if need_test then + test(package) + end end -- install package @@ -116,13 +127,6 @@ function main(package) process.asyncrun(installtask) end - -- fetch package and force to flush the cache - local fetchinfo = package:fetch({force = true}) - if option.get("verbose") or option.get("diagnosis") then - print(fetchinfo) - end - assert(fetchinfo, "fetch %s failed!", tipname) - -- trace cprint("${color.success}${text.success}") end, diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua index dbed2aee8..06fa89a1e 100644 --- a/xmake/actions/require/impl/package.lua +++ b/xmake/actions/require/impl/package.lua @@ -601,48 +601,14 @@ function uninstall_packages(requires, opt) -- remove all packages local packages = {} for _, instance in ipairs(load_packages(requires, opt)) do - if os.isfile(instance:prefixfile()) then - - -- uninstall package from the prefix directory - action.prefix.uninstall(instance) - - -- remove ok + if os.isfile(instance:manifest_file()) then table.insert(packages, instance) end - - -- remove the installed files os.tryrm(instance:installdir()) end return packages end --- only unlink packages from the prefix directory -function unlink_packages(requires, opt) - - -- init options - opt = opt or {} - - -- do not remove dependent packages - opt.nodeps = true - - -- clear the detect cache - detectcache.clear() - - -- unlink all packages - local packages = {} - for _, instance in ipairs(load_packages(requires, opt)) do - if os.isfile(instance:prefixfile()) then - - -- uninstall package from the prefix directory - action.prefix.uninstall(instance) - - -- remove ok - table.insert(packages, instance) - end - end - return packages -end - -- search packages function search_packages(names) diff --git a/xmake/actions/require/main.lua b/xmake/actions/require/main.lua index 5e5ccd830..ed42efcd5 100644 --- a/xmake/actions/require/main.lua +++ b/xmake/actions/require/main.lua @@ -34,7 +34,6 @@ import("clear") import("search") import("install") import("uninstall") -import("unlink") -- -- the default repositories: @@ -89,11 +88,6 @@ function main() uninstall(option.get("requires")) - -- unlink the installed packages - elseif option.get("unlink") then - - unlink(option.get("requires")) - -- show the given package info elseif option.get("info") then diff --git a/xmake/actions/require/unlink.lua b/xmake/actions/require/unlink.lua deleted file mode 100644 index de1cd5f99..000000000 --- a/xmake/actions/require/unlink.lua +++ /dev/null @@ -1,77 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015 - 2019, TBOOX Open Source Group. --- --- @author ruki --- @file unlink.lua --- - --- imports -import("core.base.task") -import("core.base.option") -import("core.project.project") -import("impl.package") -import("impl.repository") -import("impl.environment") - --- unlink the given packages -function main(package_names) - - -- no package names? - if not package_names then - return - end - - -- enter environment - environment.enter() - - -- pull all repositories first if not exists - if not repository.pulled() then - task.run("repo", {update = true}) - end - - -- get project requires - local project_requires, requires_extra = project.requires_str() - if not project_requires then - raise("requires(%s) not found in project!", table.concat(requires, " ")) - end - - -- find required package in project - local requires = {} - for _, name in ipairs(package_names) do - for _, require_str in ipairs(project_requires) do - if require_str:split(' ')[1]:lower():find(name:lower()) then - table.insert(requires, require_str) - end - end - end - if #requires == 0 then - raise("%s not found in project!", table.concat(package_names, " ")) - end - - -- unlink packages - local packages = package.unlink_packages(requires, {requires_extra = requires_extra}) - for _, instance in ipairs(packages) do - print("unlink: %s%s ok!", instance:name(), instance:version_str() and ("-" .. instance:version_str()) or "") - end - - -- leave environment - environment.leave() -end - diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua index 35d6e0853..c9cf9452f 100644 --- a/xmake/actions/require/xmake.lua +++ b/xmake/actions/require/xmake.lua @@ -51,7 +51,6 @@ task("require") , { } , {nil, "info", "k", nil, "Show the given package info." } , {'s', "search", "k", nil, "Search for the given packages from repositories." } - , {nil, "unlink", "k", nil, "Only unlink the installed packages." } , {nil, "uninstall", "k", nil, "Uninstall the installed packages." } , {nil, "extra", "kv", nil, "Set the extra info of packages." } , { } |
