diff options
-rw-r--r-- | src/luarocks/fetch.lua | 6 | ||||
-rw-r--r-- | src/luarocks/write_rockspec.lua | 26 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 111d229a..3ba90647 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
@@ -274,7 +274,7 @@ function get_sources(rockspec, extract, dest_dir) | |||
274 | local source_file, store_dir, err, errcode | 274 | local source_file, store_dir, err, errcode |
275 | if dest_dir then | 275 | if dest_dir then |
276 | local ok, err = fs.change_dir(dest_dir) | 276 | local ok, err = fs.change_dir(dest_dir) |
277 | if not ok then return nil, err end | 277 | if not ok then return nil, err, "dest_dir" end |
278 | source_file, err, errcode = fetch_url(url, filename) | 278 | source_file, err, errcode = fetch_url(url, filename) |
279 | fs.pop_dir() | 279 | fs.pop_dir() |
280 | store_dir = dest_dir | 280 | store_dir = dest_dir |
@@ -286,7 +286,7 @@ function get_sources(rockspec, extract, dest_dir) | |||
286 | end | 286 | end |
287 | if rockspec.source.md5 then | 287 | if rockspec.source.md5 then |
288 | if not fs.check_md5(source_file, rockspec.source.md5) then | 288 | if not fs.check_md5(source_file, rockspec.source.md5) then |
289 | return nil, "MD5 check for "..filename.." has failed." | 289 | return nil, "MD5 check for "..filename.." has failed.", "md5" |
290 | end | 290 | end |
291 | end | 291 | end |
292 | if extract then | 292 | if extract then |
@@ -294,7 +294,7 @@ function get_sources(rockspec, extract, dest_dir) | |||
294 | if not ok then return nil, err end | 294 | if not ok then return nil, err end |
295 | fs.unpack_archive(rockspec.source.file) | 295 | fs.unpack_archive(rockspec.source.file) |
296 | if not fs.exists(rockspec.source.dir) then | 296 | if not fs.exists(rockspec.source.dir) then |
297 | return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file | 297 | return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir |
298 | end | 298 | end |
299 | fs.pop_dir() | 299 | fs.pop_dir() |
300 | end | 300 | end |
diff --git a/src/luarocks/write_rockspec.lua b/src/luarocks/write_rockspec.lua index 9c20a054..6bfa4f1c 100644 --- a/src/luarocks/write_rockspec.lua +++ b/src/luarocks/write_rockspec.lua | |||
@@ -36,8 +36,10 @@ rockspec, and is not guaranteed to be complete or correct. | |||
36 | 36 | ||
37 | local function get_url(rockspec) | 37 | local function get_url(rockspec) |
38 | local url = rockspec.source.url | 38 | local url = rockspec.source.url |
39 | local file, temp_dir = fetch.fetch_sources(rockspec, true) | 39 | local file, temp_dir, err_code, err_file, err_temp_dir = fetch.fetch_sources(rockspec, true) |
40 | if not file then | 40 | if err_code == "source.dir" then |
41 | file, temp_dir = err_file, err_temp_dir | ||
42 | elseif not file then | ||
41 | util.warning("Could not fetch sources - "..temp_dir) | 43 | util.warning("Could not fetch sources - "..temp_dir) |
42 | return false | 44 | return false |
43 | end | 45 | end |
@@ -96,6 +98,17 @@ local function detect_description(rockspec) | |||
96 | end | 98 | end |
97 | end | 99 | end |
98 | 100 | ||
101 | local function show_license(rockspec) | ||
102 | local fd = io.open("COPYING", "r") | ||
103 | if not fd then fd = io.open("LICENSE", "r") end | ||
104 | if not fd then return end | ||
105 | local data = fd:read("*a") | ||
106 | fd:close() | ||
107 | util.title("License for "..rockspec.package..":") | ||
108 | util.printout(data) | ||
109 | util.printout() | ||
110 | end | ||
111 | |||
99 | local function get_cmod_name(file) | 112 | local function get_cmod_name(file) |
100 | local fd = io.open(file, "r") | 113 | local fd = io.open(file, "r") |
101 | if not fd then return nil end | 114 | if not fd then return nil end |
@@ -183,6 +196,11 @@ function run(...) | |||
183 | local_dir = name | 196 | local_dir = name |
184 | version = "scm" | 197 | version = "scm" |
185 | name = dir.base_name(name):gsub("%.[^.]+$", "") | 198 | name = dir.base_name(name):gsub("%.[^.]+$", "") |
199 | elseif protocol ~= "file" then | ||
200 | local_dir = name | ||
201 | local filename = dir.base_name(name) | ||
202 | name, version = filename:match("(.*)-([^-]+)") | ||
203 | version = version:gsub(".[a-z]+$", ""):gsub(".tar$", "") | ||
186 | else | 204 | else |
187 | return nil, "Missing name and version arguments. "..util.see_help("write_rockspec") | 205 | return nil, "Missing name and version arguments. "..util.see_help("write_rockspec") |
188 | end | 206 | end |
@@ -223,6 +241,8 @@ function run(...) | |||
223 | 241 | ||
224 | if local_dir:match("://") then | 242 | if local_dir:match("://") then |
225 | rockspec.source.url = local_dir | 243 | rockspec.source.url = local_dir |
244 | rockspec.source.file = dir.base_name(local_dir) | ||
245 | rockspec.source.dir = "dummy" | ||
226 | if not fetch.is_basic_protocol(rockspec.source.protocol) then | 246 | if not fetch.is_basic_protocol(rockspec.source.protocol) then |
227 | if version ~= "scm" then | 247 | if version ~= "scm" then |
228 | rockspec.source.tag = "v" .. version | 248 | rockspec.source.tag = "v" .. version |
@@ -261,6 +281,8 @@ function run(...) | |||
261 | if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end | 281 | if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end |
262 | 282 | ||
263 | detect_description(rockspec) | 283 | detect_description(rockspec) |
284 | |||
285 | show_license(rockspec) | ||
264 | 286 | ||
265 | fill_as_builtin(rockspec, libs) | 287 | fill_as_builtin(rockspec, libs) |
266 | 288 | ||