aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2016-05-03 21:21:55 -0300
committerHisham Muhammad <hisham@gobolinux.org>2016-05-03 21:21:55 -0300
commit0bed8bc1cf789ec3539469ed7d6ec437446b1b95 (patch)
tree24942be930e9b64c95bf0e4ac742a9d81debff3d /src
parent9b2b548f8a5e349993355288ef6849207fe25eb1 (diff)
parent6164f6f5c80320a0f250bbf187071b4feb668518 (diff)
downloadluarocks-0bed8bc1cf789ec3539469ed7d6ec437446b1b95.tar.gz
luarocks-0bed8bc1cf789ec3539469ed7d6ec437446b1b95.tar.bz2
luarocks-0bed8bc1cf789ec3539469ed7d6ec437446b1b95.zip
Merge pull request #472 from geoffleyland/luarocks-3
If an archive contains one top level directory, assume it's the one we're looking for.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/fetch.lua25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index d8fc84cc..1ba26663 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -245,6 +245,7 @@ function fetch.load_local_rockspec(filename, quick)
245 rockspec.local_filename = filename 245 rockspec.local_filename = filename
246 local filebase = rockspec.source.file or rockspec.source.url 246 local filebase = rockspec.source.file or rockspec.source.url
247 local base = fetch.url_to_base_dir(filebase) 247 local base = fetch.url_to_base_dir(filebase)
248 rockspec.source.dir_set = rockspec.source.dir ~= nil
248 rockspec.source.dir = rockspec.source.dir 249 rockspec.source.dir = rockspec.source.dir
249 or rockspec.source.module 250 or rockspec.source.module
250 or ( (filebase:match("%.lua$") or filebase:match("%.c$")) 251 or ( (filebase:match("%.lua$") or filebase:match("%.c$"))
@@ -355,7 +356,29 @@ function fetch.get_sources(rockspec, extract, dest_dir)
355 if not ok then return nil, err end 356 if not ok then return nil, err end
356 fs.unpack_archive(rockspec.source.file) 357 fs.unpack_archive(rockspec.source.file)
357 if not fs.exists(rockspec.source.dir) then 358 if not fs.exists(rockspec.source.dir) then
358 return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir 359
360 -- If rockspec.source.dir can't be found, see if we only have one
361 -- directory in store_dir. If that's the case, assume it's what
362 -- we're looking for.
363 -- We only do this if the rockspec source.dir was not set, and only
364 -- with rockspecs newer than 3.0.
365 local dir_count, found_dir = 0
366
367 if not rockspec.source.dir_set and deps.format_is_at_least(rockspec, "3.0") then
368 local files = fs.list_dir()
369 for _, f in ipairs(files) do
370 if fs.is_dir(f) then
371 dir_count = dir_count + 1
372 found_dir = f
373 end
374 end
375 end
376
377 if dir_count == 1 then
378 rockspec.source.dir = found_dir
379 else
380 return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir
381 end
359 end 382 end
360 fs.pop_dir() 383 fs.pop_dir()
361 end 384 end