summaryrefslogtreecommitdiff
path: root/xmake/modules/private
diff options
context:
space:
mode:
authorruki <[email protected]>2022-03-13 16:49:46 +0800
committerruki <[email protected]>2022-03-13 16:49:46 +0800
commitfd3212860f087849cd59c0435f66da2aac52f32a (patch)
tree902699a1d4d4a1ef7eb71f5d4c0e9e8da1fef9f5 /xmake/modules/private
parent321b13a3b93168eb840d3cb395300b5e43288307 (diff)
improve to pull repo
Diffstat (limited to 'xmake/modules/private')
-rw-r--r--xmake/modules/private/action/require/check.lua18
-rw-r--r--xmake/modules/private/action/require/impl/repository.lua20
-rw-r--r--xmake/modules/private/action/require/install.lua2
3 files changed, 29 insertions, 11 deletions
diff --git a/xmake/modules/private/action/require/check.lua b/xmake/modules/private/action/require/check.lua
index 6b37eeb8b..943e6aad4 100644
--- a/xmake/modules/private/action/require/check.lua
+++ b/xmake/modules/private/action/require/check.lua
@@ -20,8 +20,12 @@
-- imports
import("core.base.option")
+import("core.base.task")
+import("lib.detect.find_tool")
import("private.async.runjobs")
import("private.action.require.impl.package")
+import("private.action.require.impl.repository")
+import("private.action.require.impl.environment")
import("private.action.require.impl.register_packages")
import("private.action.require.impl.utils.get_requires")
@@ -35,6 +39,20 @@ function main(requires_raw)
return
end
+ -- find git
+ environment.enter()
+ local git = find_tool("git")
+ environment.leave()
+
+ -- pull all repositories first if not exists
+ --
+ -- attempt to install git from the builtin-packages first if git not found
+ --
+ if git and (not repository.pulled() or option.get("upgrade")) then
+ print("repo update")
+ task.run("repo", {update = true})
+ end
+
-- install packages
local packages = package.load_packages(requires, {requires_extra = requires_extra})
if packages then
diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua
index 6fb4fccdc..f6ad1b777 100644
--- a/xmake/modules/private/action/require/impl/repository.lua
+++ b/xmake/modules/private/action/require/impl/repository.lua
@@ -115,16 +115,18 @@ end
function pulled()
if global.get("network") ~= "private" then
for _, repo in ipairs(repositories()) do
- -- repository not found? or xmake has been re-installed
- local repodir = repo:directory()
- local updatefile = path.join(repodir, "updated")
- if not os.isfile(updatefile) or (os.isfile(updatefile) and os.mtime(os.programfile()) > os.mtime(updatefile)) then
- -- fix broken empty directory
- -- @see https://github.com/xmake-io/xmake/issues/2159
- if os.isdir(repodir) and os.emptydir(repodir) then
- os.tryrm(repodir)
+ if not os.isdir(repo:url()) then
+ -- repository not found? or xmake has been re-installed
+ local repodir = repo:directory()
+ local updatefile = path.join(repodir, "updated")
+ if not os.isfile(updatefile) or (os.isfile(updatefile) and os.mtime(os.programfile()) > os.mtime(updatefile)) then
+ -- fix broken empty directory
+ -- @see https://github.com/xmake-io/xmake/issues/2159
+ if os.isdir(repodir) and os.emptydir(repodir) then
+ os.tryrm(repodir)
+ end
+ return false
end
- return false
end
end
end
diff --git a/xmake/modules/private/action/require/install.lua b/xmake/modules/private/action/require/install.lua
index e27e627cb..c75df8a35 100644
--- a/xmake/modules/private/action/require/install.lua
+++ b/xmake/modules/private/action/require/install.lua
@@ -84,8 +84,6 @@ function main(requires_raw)
environment.enter()
local packages = install_packages(requires, {requires_extra = requires_extra})
if packages then
-
- -- check missing packages
_check_missing_packages(packages)
end
environment.leave()