aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXpol Wan <xpolife@gmail.com>2015-03-18 15:38:52 +0800
committerXpol Wan <xpolife@gmail.com>2015-03-18 15:38:52 +0800
commit90586f6616b2b1c7cea67eaa64a8c79e1591a921 (patch)
tree342022bcd96c1400e171fb5171ff55f2a3332b60
parentbdf218bfa94abf353d662ee92674ca22a33f8f25 (diff)
parent88a903a50bd0e581b8886004402d41f44d2255e1 (diff)
downloadluarocks-90586f6616b2b1c7cea67eaa64a8c79e1591a921.tar.gz
luarocks-90586f6616b2b1c7cea67eaa64a8c79e1591a921.tar.bz2
luarocks-90586f6616b2b1c7cea67eaa64a8c79e1591a921.zip
Merge branch 'master' of https://github.com/keplerproject/luarocks
-rw-r--r--.gitignore2
-rw-r--r--Makefile40
-rw-r--r--Makefile.install.inc22
-rw-r--r--Makefile.luarocks15
-rw-r--r--Makefile.setup.inc19
-rw-r--r--README.md3
-rwxr-xr-xconfigure2
-rwxr-xr-xmakedist6
-rw-r--r--rockspec15
-rw-r--r--src/luarocks/upload/api.lua17
-rw-r--r--test/testfiles/not_a_zipfile-1.0-1.src.rock1
-rw-r--r--test/testfiles/type_mismatch_string-1.0-1.rockspec4
-rw-r--r--test/testfiles/type_mismatch_table-1.0-1.rockspec5
-rw-r--r--test/testfiles/type_mismatch_version-1.0-1.rockspec4
14 files changed, 99 insertions, 56 deletions
diff --git a/.gitignore b/.gitignore
index 13a07720..f74b9549 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
1/config.* 1/config.*
2/src/luarocks/site_config.lua 2/src/luarocks/site_config.lua
3/test/testing_*
4/test/luacov.*
diff --git a/Makefile b/Makefile
index 1f9d0e2d..5f983534 100644
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,16 @@
1 1
2include config.unix 2include config.unix
3include Makefile.setup.inc
4include Makefile.install.inc
3 5
4.PHONY: all build dev build_bins luadoc check_makefile cleanup_bins clean \ 6.PHONY: all build dev build_bins luadoc check_makefile cleanup_bins clean \
5 install_bins install_luas install_site_config write_sysconfig \ 7 install_site_config write_sysconfig install bootstrap install_rock
6 install bootstrap install_rock
7 8
8DESTDIR =
9PREFIX ?= /usr/local
10ROCKS_TREE ?= $(PREFIX) 9ROCKS_TREE ?= $(PREFIX)
11SYSCONFDIR ?= $(PREFIX)/etc/luarocks 10SYSCONFDIR ?= $(PREFIX)/etc/luarocks
12BINDIR ?= $(PREFIX)/bin
13LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)/
14LUA_DIR ?= /usr/local 11LUA_DIR ?= /usr/local
15LUA_BINDIR ?= $(LUA_DIR)/bin 12LUA_BINDIR ?= $(LUA_DIR)/bin
16 13
17BIN_FILES = luarocks luarocks-admin
18LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \
19fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \
20command_line.lua install.lua build/command.lua build/cmake.lua build/make.lua \
21build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \
22fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua \
23remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \
24manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \
25help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \
26admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \
27purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \
28upload/api.lua upload/multipart.lua fetch/git_http.lua
29
30CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua 14CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua
31 15
32SAFEPWD=`echo "$$PWD" | sed -e 's/\([][]\)\1/]]..'\''\1\1'\''..[[/g'` 16SAFEPWD=`echo "$$PWD" | sed -e 's/\([][]\)\1/]]..'\''\1\1'\''..[[/g'`
@@ -139,23 +123,6 @@ cleanup_bins:
139clean: cleanup_bins 123clean: cleanup_bins
140 rm -f src/luarocks/site_config.lua 124 rm -f src/luarocks/site_config.lua
141 125
142install_bins:
143 mkdir -p "$(DESTDIR)$(BINDIR)"
144 cd src/bin && for f in $(BIN_FILES); \
145 do \
146 cp "$$f" "$(DESTDIR)$(BINDIR)/$$f-$(LUA_VERSION)"; \
147 ln -nfs "$$f-$(LUA_VERSION)" "$(DESTDIR)$(BINDIR)/$$f"; \
148 done
149
150install_luas:
151 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
152 cd src/luarocks && for f in $(LUAROCKS_FILES); \
153 do \
154 d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"` && \
155 mkdir -p "$$d" && \
156 cp "$$f" "$$d" || exit 1; \
157 done
158
159install_site_config: src/luarocks/site_config.lua 126install_site_config: src/luarocks/site_config.lua
160 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" 127 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
161 cp src/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks" 128 cp src/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks"
@@ -180,3 +147,4 @@ bootstrap: src/luarocks/site_config.lua install_site_config write_sysconfig clea
180 '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$(SAFEPWD)/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)" 147 '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$(SAFEPWD)/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)"
181 148
182install_rock: install_bins install_luas 149install_rock: install_bins install_luas
150
diff --git a/Makefile.install.inc b/Makefile.install.inc
new file mode 100644
index 00000000..20d96a12
--- /dev/null
+++ b/Makefile.install.inc
@@ -0,0 +1,22 @@
1
2.PHONY: install_bins install_luas
3
4install_bins:
5 mkdir -p "$(DESTDIR)$(BINDIR)"
6 cd src/bin && \
7 luaver="$(LUA_VERSION)" && [ -n "$$luaver" ] || luaver=`$(LUA) -e 'print(_VERSION:sub(5))'`; \
8 for f in $(BIN_FILES); \
9 do \
10 cp "$$f" "$(DESTDIR)$(BINDIR)/$$f-$$luaver"; \
11 ln -nfs "$$f-$$luaver" "$(DESTDIR)$(BINDIR)/$$f"; \
12 done
13
14install_luas:
15 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"
16 cd src/luarocks && for f in $(LUAROCKS_FILES); \
17 do \
18 d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"` && \
19 mkdir -p "$$d" && \
20 cp "$$f" "$$d" || exit 1; \
21 done
22
diff --git a/Makefile.luarocks b/Makefile.luarocks
new file mode 100644
index 00000000..1eecfeae
--- /dev/null
+++ b/Makefile.luarocks
@@ -0,0 +1,15 @@
1
2include Makefile.setup.inc
3include Makefile.install.inc
4
5.PHONY: all install copy_site_config
6
7all:
8 @echo This Makefile is used by the LuaRocks rockspec for upgrading itself.
9
10install: install_bins install_luas copy_site_config
11
12copy_site_config:
13 luaver="$(LUA_VERSION)" && [ -n "$$luaver" ] || luaver=`$(LUA) -e 'print(_VERSION:sub(5))'`; \
14 mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"; \
15 cp $(LUAROCKS_PREFIX)/share/lua/$$luaver/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks"
diff --git a/Makefile.setup.inc b/Makefile.setup.inc
new file mode 100644
index 00000000..eb51ba5e
--- /dev/null
+++ b/Makefile.setup.inc
@@ -0,0 +1,19 @@
1
2DESTDIR =
3PREFIX ?= /usr/local
4BINDIR ?= $(PREFIX)/bin
5LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)/
6
7BIN_FILES = luarocks luarocks-admin
8LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \
9fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \
10command_line.lua install.lua build/command.lua build/cmake.lua build/make.lua \
11build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \
12fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua \
13remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \
14manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \
15help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \
16admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \
17purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \
18upload/api.lua upload/multipart.lua fetch/git_http.lua
19
diff --git a/README.md b/README.md
index d6494a5c..5fd44d22 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
1LuaRocks 1<p align="center"><a href="http://luarocks.org"><img border="0" src="http://keplerproject.github.io/luarocks/luarocks.png" alt="LuaRocks" width="500px"></a></p>
2========
3 2
4A package manager for Lua modules. 3A package manager for Lua modules.
5 4
diff --git a/configure b/configure
index e67337ab..e84f00bf 100755
--- a/configure
+++ b/configure
@@ -292,7 +292,7 @@ then
292 else 292 else
293 suffixes="5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51" 293 suffixes="5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51"
294 fi 294 fi
295 for suffix in `echo $suffixes` "" 295 for suffix in "" `echo $suffixes`
296 do 296 do
297 search_interpreter "$suffix" && break 297 search_interpreter "$suffix" && break
298 done 298 done
diff --git a/makedist b/makedist
index 141f6700..482c77f7 100755
--- a/makedist
+++ b/makedist
@@ -39,8 +39,8 @@ do
39 cp "$i" "$out/$dir" 39 cp "$i" "$out/$dir"
40 if echo "$i" | grep -v "/bin/" | grep -q "^src/" 40 if echo "$i" | grep -v "/bin/" | grep -q "^src/"
41 then 41 then
42 grep -qw `basename "$i"` Makefile || { 42 grep -qw `basename "$i"` Makefile.setup.inc || {
43 echo "Missing ref in makefile: $i" 43 echo "Missing ref in Makefile.setup.inc: $i"
44 touch "missing_ref" 44 touch "missing_ref"
45 exit 1 45 exit 1
46 } 46 }
@@ -68,7 +68,7 @@ cd ..
68rm -rf "release-unix" 68rm -rf "release-unix"
69 69
70cd "release-windows/$out-win32" 70cd "release-windows/$out-win32"
71rm -rf makedist Makefile configure lfw .travis.yml .gitignore 71rm -rf makedist Makefile* configure lfw .travis.yml .gitignore test
72cd .. 72cd ..
73zip -r ../"$out-win32.zip" "$out-win32" 73zip -r ../"$out-win32.zip" "$out-win32"
74cd .. 74cd ..
diff --git a/rockspec b/rockspec
index 69a85319..5b0ffc9c 100644
--- a/rockspec
+++ b/rockspec
@@ -1,7 +1,9 @@
1package = "LuaRocks" 1package = "LuaRocks"
2local VER = "2.2.0" 2local VER = "scm-1"
3local REV = "1" 3
4version = VER.."-"..REV 4source = {
5 url = "--this rockspec is used by `make bootstrap` only--",
6}
5 7
6description = { 8description = {
7 summary = "A deployment and management system for Lua modules.", 9 summary = "A deployment and management system for Lua modules.",
@@ -23,16 +25,13 @@ dependencies = {
23 "lua >= 5.1" 25 "lua >= 5.1"
24} 26}
25 27
26source = {
27 url = "http://luarocks.org/releases/luarocks-"..VER..".tar.gz",
28}
29
30build = { 28build = {
31 type = "make", 29 type = "make",
32 install_target = "install_rock", 30 install_target = "install_rock",
33 build_pass=false, 31 build_pass=false,
34 install_variables = { 32 install_variables = {
35 BINDIR="$(BINDIR)", 33 BINDIR="$(BINDIR)",
36 LUADIR="$(LUADIR)" 34 LUADIR="$(LUADIR)",
35 LUA="$(LUA)",
37 } 36 }
38} 37}
diff --git a/src/luarocks/upload/api.lua b/src/luarocks/upload/api.lua
index fd476968..6dfb98df 100644
--- a/src/luarocks/upload/api.lua
+++ b/src/luarocks/upload/api.lua
@@ -119,6 +119,11 @@ end
119local ltn12_ok, ltn12 = pcall(require, "ltn12") 119local ltn12_ok, ltn12 = pcall(require, "ltn12")
120if not ltn12_ok then -- If not using LuaSocket and/or LuaSec... 120if not ltn12_ok then -- If not using LuaSocket and/or LuaSec...
121 121
122local function redact_api_url(url)
123 url = tostring(url)
124 return (url:gsub(".*/api/[^/]+/[^/]+", "")) or ""
125end
126
122function Api:request(url, params, post_params) 127function Api:request(url, params, post_params)
123 local vars = cfg.variables 128 local vars = cfg.variables
124 local json_ok, json = require_json() 129 local json_ok, json = require_json()
@@ -157,26 +162,26 @@ function Api:request(url, params, post_params)
157 end 162 end
158 local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile)) 163 local ok = fs.execute_string(curl_cmd..fs.Q(url).." -o "..fs.Q(tmpfile))
159 if not ok then 164 if not ok then
160 return nil, "API failure: " .. tostring(url) 165 return nil, "API failure: " .. redact_api_url(url)
161 end 166 end
162 else 167 else
163 local ok, err = fs.download(url, tmpfile) 168 local ok, err = fs.download(url, tmpfile)
164 if not ok then 169 if not ok then
165 return nil, "API failure: " .. tostring(err) .. " - " .. tostring(url) 170 return nil, "API failure: " .. tostring(err) .. " - " .. redact_api_url(url)
166 end 171 end
167 end 172 end
168 173
169 local tmpfd = io.open(tmpfile) 174 local tmpfd = io.open(tmpfile)
170 if not tmpfd then 175 if not tmpfd then
171 os.remove(tmpfile) 176 os.remove(tmpfile)
172 return nil, "API failure reading temporary file - " .. tostring(url) 177 return nil, "API failure reading temporary file - " .. redact_api_url(url)
173 end 178 end
174 out = tmpfd:read("*a") 179 out = tmpfd:read("*a")
175 tmpfd:close() 180 tmpfd:close()
176 os.remove(tmpfile) 181 os.remove(tmpfile)
177 182
178 if self.debug then 183 if self.debug then
179 util.printout("[" .. tostring(method) .. " via curl] " .. tostring(url) .. " ... ") 184 util.printout("[" .. tostring(method) .. " via curl] " .. redact_api_url(url) .. " ... ")
180 end 185 end
181 186
182 return json.decode(out) 187 return json.decode(out)
@@ -229,7 +234,7 @@ function Api:request(url, params, post_params)
229 end 234 end
230 local method = post_params and "POST" or "GET" 235 local method = post_params and "POST" or "GET"
231 if self.debug then 236 if self.debug then
232 util.printout("[" .. tostring(method) .. " via "..via.."] " .. tostring(url) .. " ... ") 237 util.printout("[" .. tostring(method) .. " via "..via.."] " .. redact_api_url(url) .. " ... ")
233 end 238 end
234 local out = {} 239 local out = {}
235 local _, status = http.request({ 240 local _, status = http.request({
@@ -243,7 +248,7 @@ function Api:request(url, params, post_params)
243 util.printout(tostring(status)) 248 util.printout(tostring(status))
244 end 249 end
245 if status ~= 200 then 250 if status ~= 200 then
246 return nil, "API returned " .. tostring(status) .. " - " .. tostring(url) 251 return nil, "API returned " .. tostring(status) .. " - " .. redact_api_url(url)
247 end 252 end
248 return json.decode(table.concat(out)) 253 return json.decode(table.concat(out))
249end 254end
diff --git a/test/testfiles/not_a_zipfile-1.0-1.src.rock b/test/testfiles/not_a_zipfile-1.0-1.src.rock
new file mode 100644
index 00000000..e36f8bbe
--- /dev/null
+++ b/test/testfiles/not_a_zipfile-1.0-1.src.rock
@@ -0,0 +1 @@
I am not a .zip file!
diff --git a/test/testfiles/type_mismatch_string-1.0-1.rockspec b/test/testfiles/type_mismatch_string-1.0-1.rockspec
new file mode 100644
index 00000000..7a607cfd
--- /dev/null
+++ b/test/testfiles/type_mismatch_string-1.0-1.rockspec
@@ -0,0 +1,4 @@
1
2package="type_mismatch_version"
3version=1.0
4
diff --git a/test/testfiles/type_mismatch_table-1.0-1.rockspec b/test/testfiles/type_mismatch_table-1.0-1.rockspec
new file mode 100644
index 00000000..f348b798
--- /dev/null
+++ b/test/testfiles/type_mismatch_table-1.0-1.rockspec
@@ -0,0 +1,5 @@
1
2package="type_mismatch_table"
3version="1.0-1"
4
5source = "not a table"
diff --git a/test/testfiles/type_mismatch_version-1.0-1.rockspec b/test/testfiles/type_mismatch_version-1.0-1.rockspec
new file mode 100644
index 00000000..5e30dae6
--- /dev/null
+++ b/test/testfiles/type_mismatch_version-1.0-1.rockspec
@@ -0,0 +1,4 @@
1
2package="type_mismatch_version"
3version="1.0"
4