diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2017-09-29 17:48:51 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-09-29 17:48:51 -0300 |
| commit | c98e167122252dad9e304259bb653e5d0402f1fc (patch) | |
| tree | d778f97842d6fb5640a3f6996f07ea85ad218a3c | |
| parent | 2991e1d85e728d288f2397531336c513b3add596 (diff) | |
| download | luarocks-c98e167122252dad9e304259bb653e5d0402f1fc.tar.gz luarocks-c98e167122252dad9e304259bb653e5d0402f1fc.tar.bz2 luarocks-c98e167122252dad9e304259bb653e5d0402f1fc.zip | |
Be stricter when autodetecting `source.dir`
Only assume directory is the location when the tarball contains
only a single directory at the top level.
| -rw-r--r-- | src/luarocks/fetch.lua | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 2cad3df2..6f8dfc0b 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
| @@ -363,19 +363,18 @@ function fetch.get_sources(rockspec, extract, dest_dir) | |||
| 363 | -- we're looking for. | 363 | -- we're looking for. |
| 364 | -- We only do this if the rockspec source.dir was not set, and only | 364 | -- We only do this if the rockspec source.dir was not set, and only |
| 365 | -- with rockspecs newer than 3.0. | 365 | -- with rockspecs newer than 3.0. |
| 366 | local dir_count, found_dir = 0 | 366 | local file_count, found_dir = 0 |
| 367 | 367 | ||
| 368 | if not rockspec.source.dir_set and rockspec:format_is_at_least("3.0") then | 368 | if not rockspec.source.dir_set and rockspec:format_is_at_least("3.0") then |
| 369 | local files = fs.list_dir() | 369 | for file in fs.dir() do |
| 370 | for _, f in ipairs(files) do | 370 | file_count = file_count + 1 |
| 371 | if fs.is_dir(f) then | 371 | if fs.is_dir(file) then |
| 372 | dir_count = dir_count + 1 | 372 | found_dir = file |
| 373 | found_dir = f | ||
| 374 | end | 373 | end |
| 375 | end | 374 | end |
| 376 | end | 375 | end |
| 377 | 376 | ||
| 378 | if dir_count == 1 then | 377 | if file_count == 1 and found_dir then |
| 379 | rockspec.source.dir = found_dir | 378 | rockspec.source.dir = found_dir |
| 380 | else | 379 | else |
| 381 | return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir | 380 | return nil, "Directory "..rockspec.source.dir.." not found inside archive "..rockspec.source.file, "source.dir", source_file, store_dir |
