aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/fetch.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index e1cad11b..ef478658 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -355,7 +355,32 @@ function fetch.get_sources(rockspec, extract, dest_dir)
355 if not ok then return nil, err end 355 if not ok then return nil, err end
356 fs.unpack_archive(rockspec.source.file) 356 fs.unpack_archive(rockspec.source.file)
357 if not fs.exists(rockspec.source.dir) then 357 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 358
359 -- if rockspec.source.dir can't be found, see if we only have one
360 -- directory in store_dir. If that's the case, assume it's what
361 -- we're looking for.
362 -- Ideally, we'd only do this if rockspec.source.dir was not
363 -- defined in the rockspec, but load_local_repository already
364 -- set it to an inferred value if it wasn't set there, so we
365 -- can't tell its status in the rockspec.
366 -- In any case, we only do this with rockspecs newer than 3.0.
367 local dir_count, found_dir = 0
368
369 if deps.format_is_at_least(rockspec, "3.0") then
370 local files = fs.list_dir()
371 for _, f in ipairs(files) do
372 if fs.is_dir(f) then
373 dir_count = dir_count + 1
374 found_dir = f
375 end
376 end
377 end
378
379 if dir_count == 1 then
380 rockspec.source.dir = found_dir
381 else
382 return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir
383 end
359 end 384 end
360 fs.pop_dir() 385 fs.pop_dir()
361 end 386 end