aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/fetch.lua8
-rw-r--r--src/luarocks/new_version.lua18
2 files changed, 24 insertions, 2 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua
index b835b20e..3bb0cdc0 100644
--- a/src/luarocks/fetch.lua
+++ b/src/luarocks/fetch.lua
@@ -120,6 +120,11 @@ function fetch_and_unpack_rock(rock_file, dest)
120 return unpack_dir 120 return unpack_dir
121end 121end
122 122
123function url_to_base_dir(url)
124 local base = dir.base_name(url)
125 return base:gsub("%.[^.]*$", ""):gsub("%.tar$", "")
126end
127
123--- Back-end function that actually loads the local rockspec. 128--- Back-end function that actually loads the local rockspec.
124-- Performs some validation and postprocessing of the rockspec contents. 129-- Performs some validation and postprocessing of the rockspec contents.
125-- @param filename string: The local filename of the rockspec file. 130-- @param filename string: The local filename of the rockspec file.
@@ -177,8 +182,7 @@ function load_local_rockspec(filename)
177 182
178 rockspec.local_filename = filename 183 rockspec.local_filename = filename
179 local filebase = rockspec.source.file or rockspec.source.url 184 local filebase = rockspec.source.file or rockspec.source.url
180 local base = dir.base_name(filebase) 185 local base = url_to_base_dir(filebase)
181 base = base:gsub("%.[^.]*$", ""):gsub("%.tar$", "")
182 rockspec.source.dir = rockspec.source.dir 186 rockspec.source.dir = rockspec.source.dir
183 or rockspec.source.module 187 or rockspec.source.module
184 or ((filebase:match(".lua$") or filebase:match(".c$")) and ".") 188 or ((filebase:match(".lua$") or filebase:match(".c$")) and ".")
diff --git a/src/luarocks/new_version.lua b/src/luarocks/new_version.lua
index e1e3f80f..66802f0b 100644
--- a/src/luarocks/new_version.lua
+++ b/src/luarocks/new_version.lua
@@ -60,6 +60,18 @@ local function check_url_and_update_md5(out_rs, out_name)
60 if file then 60 if file then
61 util.printout("File successfully downloaded. Updating MD5 checksum...") 61 util.printout("File successfully downloaded. Updating MD5 checksum...")
62 out_rs.source.md5 = fs.get_md5(file) 62 out_rs.source.md5 = fs.get_md5(file)
63 fs.change_dir(temp_dir)
64 fs.unpack_archive(file)
65 local base_dir = out_rs.source.dir or fetch.url_to_base_dir(out_rs.source.url)
66 if not fs.exists(base_dir) then
67 util.printerr("Directory "..base_dir.." not found")
68 local files = fs.list_dir()
69 if files[1] and fs.is_dir(files[1]) then
70 util.printerr("Found "..files[1])
71 out_rs.source.dir = files[1]
72 end
73 end
74 fs.pop_dir()
63 else 75 else
64 util.printerr("Warning: invalid URL - "..temp_dir) 76 util.printerr("Warning: invalid URL - "..temp_dir)
65 end 77 end
@@ -110,6 +122,12 @@ function run(...)
110 check_url_and_update_md5(out_rs, out_name) 122 check_url_and_update_md5(out_rs, out_name)
111 else 123 else
112 if new_ver ~= old_ver then 124 if new_ver ~= old_ver then
125 if out_rs.source and out_rs.source.dir then
126 try_replace(out_rs.source, "dir", old_ver, new_ver)
127 end
128 if out_rs.source and out_rs.source.file then
129 try_replace(out_rs.source, "file", old_ver, new_ver)
130 end
113 local ok = try_replace(out_rs.source, "url", old_ver, new_ver) 131 local ok = try_replace(out_rs.source, "url", old_ver, new_ver)
114 if ok then 132 if ok then
115 check_url_and_update_md5(out_rs, out_name) 133 check_url_and_update_md5(out_rs, out_name)