diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-11-19 11:55:44 +0100 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-11-19 11:55:44 +0100 |
commit | 7f11f5fa1a08aef38ac6e8ede0e10e583619fa25 (patch) | |
tree | a585454e62c6f7dc81b9b7be406e59ce6a5adf33 /src | |
parent | 722c03ae8b059cba8039e8066dd1a82e7c3ddcb3 (diff) | |
parent | 827bdfd16adf324f118f843cb4d1eea94e887480 (diff) | |
download | luarocks-7f11f5fa1a08aef38ac6e8ede0e10e583619fa25.tar.gz luarocks-7f11f5fa1a08aef38ac6e8ede0e10e583619fa25.tar.bz2 luarocks-7f11f5fa1a08aef38ac6e8ede0e10e583619fa25.zip |
Merge branch 'master' of https://github.com/keplerproject/luarocks into command_quoting
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 2 | ||||
-rw-r--r-- | src/luarocks/manif.lua | 4 | ||||
-rw-r--r-- | src/luarocks/path.lua | 12 | ||||
-rw-r--r-- | src/luarocks/unpack.lua | 19 |
4 files changed, 26 insertions, 11 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index e3d924fb..f66ad1d9 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -322,7 +322,7 @@ if detected.windows then | |||
322 | local localappdata = os.getenv("LOCALAPPDATA") | 322 | local localappdata = os.getenv("LOCALAPPDATA") |
323 | if not localappdata then | 323 | if not localappdata then |
324 | -- for Windows versions below Vista | 324 | -- for Windows versions below Vista |
325 | localappdata = os.getenv("USER_PROFILE").."/Local Settings/Application Data" | 325 | localappdata = os.getenv("USERPROFILE").."/Local Settings/Application Data" |
326 | end | 326 | end |
327 | defaults.local_cache = localappdata.."/LuaRocks/Cache" | 327 | defaults.local_cache = localappdata.."/LuaRocks/Cache" |
328 | end | 328 | end |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 9feb35ce..1c7707a9 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
@@ -139,9 +139,11 @@ function load_manifest(repo_url) | |||
139 | if pathname:match(".*%.zip$") then | 139 | if pathname:match(".*%.zip$") then |
140 | local dir = dir.dir_name(pathname) | 140 | local dir = dir.dir_name(pathname) |
141 | fs.change_dir(dir) | 141 | fs.change_dir(dir) |
142 | local nozip = pathname:match("(.*)%.zip$") | ||
143 | fs.delete(nozip) | ||
142 | fs.unzip(pathname) | 144 | fs.unzip(pathname) |
143 | fs.pop_dir() | 145 | fs.pop_dir() |
144 | pathname = pathname:match("(.*)%.zip$") | 146 | pathname = nozip |
145 | end | 147 | end |
146 | return manif_core.manifest_loader(pathname, repo_url) | 148 | return manif_core.manifest_loader(pathname, repo_url) |
147 | end | 149 | end |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index f8ae15c0..d7273095 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -410,9 +410,17 @@ function run(...) | |||
410 | util.printout(util.remove_path_dupes(lr_bin, ';')) | 410 | util.printout(util.remove_path_dupes(lr_bin, ';')) |
411 | return true | 411 | return true |
412 | end | 412 | end |
413 | |||
414 | if flags["append"] then | ||
415 | lr_path = package.path .. ";" .. lr_path | ||
416 | lr_cpath = package.cpath .. ";" .. lr_cpath | ||
417 | else | ||
418 | lr_path = lr_path.. ";" .. package.path | ||
419 | lr_cpath = lr_cpath .. ";" .. package.cpath | ||
420 | end | ||
413 | 421 | ||
414 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) | 422 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) |
415 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) | 423 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) |
416 | if flags["bin"] then | 424 | if flags["bin"] then |
417 | table.insert(bin_dirs, 1, os.getenv("PATH")) | 425 | table.insert(bin_dirs, 1, os.getenv("PATH")) |
418 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) | 426 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) |
diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua index 70c116fd..95762a2c 100644 --- a/src/luarocks/unpack.lua +++ b/src/luarocks/unpack.lua | |||
@@ -10,11 +10,13 @@ local build = require("luarocks.build") | |||
10 | local dir = require("luarocks.dir") | 10 | local dir = require("luarocks.dir") |
11 | 11 | ||
12 | help_summary = "Unpack the contents of a rock." | 12 | help_summary = "Unpack the contents of a rock." |
13 | help_arguments = "{<rock>|<name> [<version>]}" | 13 | help_arguments = "[--force] {<rock>|<name> [<version>]}" |
14 | help = [[ | 14 | help = [[ |
15 | Unpacks the contents of a rock in a newly created directory. | 15 | Unpacks the contents of a rock in a newly created directory. |
16 | Argument may be a rock file, or the name of a rock in a rocks server. | 16 | Argument may be a rock file, or the name of a rock in a rocks server. |
17 | In the latter case, the app version may be given as a second argument. | 17 | In the latter case, the app version may be given as a second argument. |
18 | |||
19 | --force Unpack files even if the output directory already exists. | ||
18 | ]] | 20 | ]] |
19 | 21 | ||
20 | --- Load a rockspec file to the given directory, fetches the source | 22 | --- Load a rockspec file to the given directory, fetches the source |
@@ -88,7 +90,7 @@ end | |||
88 | -- @param file string: A rockspec or .rock URL. | 90 | -- @param file string: A rockspec or .rock URL. |
89 | -- @return boolean or (nil, string): true if successful or nil followed | 91 | -- @return boolean or (nil, string): true if successful or nil followed |
90 | -- by an error message. | 92 | -- by an error message. |
91 | local function run_unpacker(file) | 93 | local function run_unpacker(file, force) |
92 | assert(type(file) == "string") | 94 | assert(type(file) == "string") |
93 | 95 | ||
94 | local base_name = dir.base_name(file) | 96 | local base_name = dir.base_name(file) |
@@ -100,12 +102,15 @@ local function run_unpacker(file) | |||
100 | if not extension then | 102 | if not extension then |
101 | return nil, file.." does not seem to be a valid filename." | 103 | return nil, file.." does not seem to be a valid filename." |
102 | end | 104 | end |
103 | 105 | ||
104 | if (fs.exists(dir_name)) then | 106 | local exists = fs.exists(dir_name) |
107 | if exists and not force then | ||
105 | return nil, "Directory "..dir_name.." already exists." | 108 | return nil, "Directory "..dir_name.." already exists." |
106 | end | 109 | end |
107 | local ok, err = fs.make_dir(dir_name) | 110 | if not exists then |
108 | if not ok then return nil, err end | 111 | local ok, err = fs.make_dir(dir_name) |
112 | if not ok then return nil, err end | ||
113 | end | ||
109 | local rollback = util.schedule_function(fs.delete, fs.absolute_name(dir_name)) | 114 | local rollback = util.schedule_function(fs.delete, fs.absolute_name(dir_name)) |
110 | 115 | ||
111 | local rockspec, err | 116 | local rockspec, err |
@@ -149,7 +154,7 @@ function run(...) | |||
149 | end | 154 | end |
150 | 155 | ||
151 | if name:match(".*%.rock") or name:match(".*%.rockspec") then | 156 | if name:match(".*%.rock") or name:match(".*%.rockspec") then |
152 | return run_unpacker(name) | 157 | return run_unpacker(name, flags["force"]) |
153 | else | 158 | else |
154 | local search = require("luarocks.search") | 159 | local search = require("luarocks.search") |
155 | return search.act_on_src_or_rockspec(run_unpacker, name, version) | 160 | return search.act_on_src_or_rockspec(run_unpacker, name, version) |