diff options
author | Hisham <hisham@gobolinux.org> | 2016-10-29 17:47:04 -0200 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-10-29 17:47:04 -0200 |
commit | 5b8d37cdbdd93e0cbd4e78d564dd0018972b3a44 (patch) | |
tree | c45d92d856a333f5e51485791e08c688a68bd6d6 /src | |
parent | 825e722029fbc93976c2d882dd21f444f9bffda0 (diff) | |
parent | d9437bb79499c25751c304ee684c5de8fbfa1d73 (diff) | |
download | luarocks-5b8d37cdbdd93e0cbd4e78d564dd0018972b3a44.tar.gz luarocks-5b8d37cdbdd93e0cbd4e78d564dd0018972b3a44.tar.bz2 luarocks-5b8d37cdbdd93e0cbd4e78d564dd0018972b3a44.zip |
Merge branch 'master' into luarocks-3
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/core/manif.lua | 21 | ||||
-rw-r--r-- | src/luarocks/fs/win32.lua | 39 |
2 files changed, 41 insertions, 19 deletions
diff --git a/src/luarocks/core/manif.lua b/src/luarocks/core/manif.lua index f0912bfd..49619e7f 100644 --- a/src/luarocks/core/manif.lua +++ b/src/luarocks/core/manif.lua | |||
@@ -88,20 +88,19 @@ end | |||
88 | function manif.get_versions(name, deps_mode) | 88 | function manif.get_versions(name, deps_mode) |
89 | assert(type(name) == "string") | 89 | assert(type(name) == "string") |
90 | assert(type(deps_mode) == "string") | 90 | assert(type(deps_mode) == "string") |
91 | 91 | ||
92 | local manifest = {} | 92 | local version_set = {} |
93 | path.map_trees(deps_mode, function(tree) | 93 | path.map_trees(deps_mode, function(tree) |
94 | local loaded = manif.load_local_manifest(path.rocks_dir(tree)) | 94 | local manifest = manif.load_local_manifest(path.rocks_dir(tree)) |
95 | if loaded then | 95 | |
96 | util.deep_merge(manifest, loaded) | 96 | if manifest and manifest.repository[name] then |
97 | for version in pairs(manifest.repository[name]) do | ||
98 | version_set[version] = true | ||
99 | end | ||
97 | end | 100 | end |
98 | end) | 101 | end) |
99 | 102 | ||
100 | local item = next(manifest) and manifest.repository[name] | 103 | return util.keys(version_set) |
101 | if item then | ||
102 | return util.keys(item) | ||
103 | end | ||
104 | return {} | ||
105 | end | 104 | end |
106 | 105 | ||
107 | return manif | 106 | return manif |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 2216d2fa..789913a7 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
@@ -33,7 +33,24 @@ function win32.quiet_stderr(cmd) | |||
33 | return cmd.." 2> NUL" | 33 | return cmd.." 2> NUL" |
34 | end | 34 | end |
35 | 35 | ||
36 | local drive_letter = "[%.a-zA-Z]?:?[\\/]" | 36 | -- Split path into root and the rest. |
37 | -- Root part consists of an optional drive letter (e.g. "C:") | ||
38 | -- and an optional directory separator. | ||
39 | local function split_root(path) | ||
40 | local root = "" | ||
41 | |||
42 | if path:match("^.:") then | ||
43 | root = path:sub(1, 2) | ||
44 | path = path:sub(3) | ||
45 | end | ||
46 | |||
47 | if path:match("^[\\/]") then | ||
48 | root = path:sub(1, 1) | ||
49 | path = path:sub(2) | ||
50 | end | ||
51 | |||
52 | return root, path | ||
53 | end | ||
37 | 54 | ||
38 | --- Quote argument for shell processing. Fixes paths on Windows. | 55 | --- Quote argument for shell processing. Fixes paths on Windows. |
39 | -- Adds double quotes and escapes. | 56 | -- Adds double quotes and escapes. |
@@ -41,8 +58,9 @@ local drive_letter = "[%.a-zA-Z]?:?[\\/]" | |||
41 | -- @return string: Quoted argument. | 58 | -- @return string: Quoted argument. |
42 | function win32.Q(arg) | 59 | function win32.Q(arg) |
43 | assert(type(arg) == "string") | 60 | assert(type(arg) == "string") |
44 | -- Quote DIR for Windows | 61 | -- Use Windows-specific directory separator for paths. |
45 | if arg:match("^"..drive_letter) then | 62 | -- Paths should be converted to absolute by now. |
63 | if split_root(arg) ~= "" then | ||
46 | arg = arg:gsub("/", "\\") | 64 | arg = arg:gsub("/", "\\") |
47 | end | 65 | end |
48 | if arg == "\\" then | 66 | if arg == "\\" then |
@@ -62,8 +80,9 @@ end | |||
62 | -- @return string: Quoted argument. | 80 | -- @return string: Quoted argument. |
63 | function win32.Qb(arg) | 81 | function win32.Qb(arg) |
64 | assert(type(arg) == "string") | 82 | assert(type(arg) == "string") |
65 | -- Quote DIR for Windows | 83 | -- Use Windows-specific directory separator for paths. |
66 | if arg:match("^"..drive_letter) then | 84 | -- Paths should be converted to absolute by now. |
85 | if split_root(arg) ~= "" then | ||
67 | arg = arg:gsub("/", "\\") | 86 | arg = arg:gsub("/", "\\") |
68 | end | 87 | end |
69 | if arg == "\\" then | 88 | if arg == "\\" then |
@@ -88,10 +107,14 @@ function win32.absolute_name(pathname, relative_to) | |||
88 | assert(type(relative_to) == "string" or not relative_to) | 107 | assert(type(relative_to) == "string" or not relative_to) |
89 | 108 | ||
90 | relative_to = relative_to or fs.current_dir() | 109 | relative_to = relative_to or fs.current_dir() |
91 | if pathname:match("^"..drive_letter) then | 110 | local root, rest = split_root(pathname) |
111 | if root:match("[\\/]$") then | ||
112 | -- It's an absolute path already. | ||
92 | return pathname | 113 | return pathname |
93 | else | 114 | else |
94 | return relative_to .. "/" .. pathname | 115 | -- It's a relative path, join it with base path. |
116 | -- This drops drive letter from paths like "C:foo". | ||
117 | return relative_to .. "/" .. rest | ||
95 | end | 118 | end |
96 | end | 119 | end |
97 | 120 | ||
@@ -100,7 +123,7 @@ end | |||
100 | -- @param pathname string: pathname to use. | 123 | -- @param pathname string: pathname to use. |
101 | -- @return string: The root of the given pathname. | 124 | -- @return string: The root of the given pathname. |
102 | function win32.root_of(pathname) | 125 | function win32.root_of(pathname) |
103 | return (fs.absolute_name(pathname):match("^("..drive_letter..")")) | 126 | return (split_root(fs.absolute_name(pathname))) |
104 | end | 127 | end |
105 | 128 | ||
106 | --- Create a wrapper to make a script executable from the command-line. | 129 | --- Create a wrapper to make a script executable from the command-line. |