diff options
author | Xpol Wan <xpolife@gmail.com> | 2015-03-18 15:38:52 +0800 |
---|---|---|
committer | Xpol Wan <xpolife@gmail.com> | 2015-03-18 15:38:52 +0800 |
commit | 90586f6616b2b1c7cea67eaa64a8c79e1591a921 (patch) | |
tree | 342022bcd96c1400e171fb5171ff55f2a3332b60 | |
parent | bdf218bfa94abf353d662ee92674ca22a33f8f25 (diff) | |
parent | 88a903a50bd0e581b8886004402d41f44d2255e1 (diff) | |
download | luarocks-90586f6616b2b1c7cea67eaa64a8c79e1591a921.tar.gz luarocks-90586f6616b2b1c7cea67eaa64a8c79e1591a921.tar.bz2 luarocks-90586f6616b2b1c7cea67eaa64a8c79e1591a921.zip |
Merge branch 'master' of https://github.com/keplerproject/luarocks
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 40 | ||||
-rw-r--r-- | Makefile.install.inc | 22 | ||||
-rw-r--r-- | Makefile.luarocks | 15 | ||||
-rw-r--r-- | Makefile.setup.inc | 19 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rwxr-xr-x | makedist | 6 | ||||
-rw-r--r-- | rockspec | 15 | ||||
-rw-r--r-- | src/luarocks/upload/api.lua | 17 | ||||
-rw-r--r-- | test/testfiles/not_a_zipfile-1.0-1.src.rock | 1 | ||||
-rw-r--r-- | test/testfiles/type_mismatch_string-1.0-1.rockspec | 4 | ||||
-rw-r--r-- | test/testfiles/type_mismatch_table-1.0-1.rockspec | 5 | ||||
-rw-r--r-- | test/testfiles/type_mismatch_version-1.0-1.rockspec | 4 |
14 files changed, 99 insertions, 56 deletions
@@ -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.* | ||
@@ -1,32 +1,16 @@ | |||
1 | 1 | ||
2 | include config.unix | 2 | include config.unix |
3 | include Makefile.setup.inc | ||
4 | include 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 | ||
8 | DESTDIR = | ||
9 | PREFIX ?= /usr/local | ||
10 | ROCKS_TREE ?= $(PREFIX) | 9 | ROCKS_TREE ?= $(PREFIX) |
11 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks | 10 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks |
12 | BINDIR ?= $(PREFIX)/bin | ||
13 | LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)/ | ||
14 | LUA_DIR ?= /usr/local | 11 | LUA_DIR ?= /usr/local |
15 | LUA_BINDIR ?= $(LUA_DIR)/bin | 12 | LUA_BINDIR ?= $(LUA_DIR)/bin |
16 | 13 | ||
17 | BIN_FILES = luarocks luarocks-admin | ||
18 | LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \ | ||
19 | fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \ | ||
20 | command_line.lua install.lua build/command.lua build/cmake.lua build/make.lua \ | ||
21 | build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \ | ||
22 | fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua \ | ||
23 | remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ | ||
24 | manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ | ||
25 | help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ | ||
26 | admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ | ||
27 | purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ | ||
28 | upload/api.lua upload/multipart.lua fetch/git_http.lua | ||
29 | |||
30 | CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua | 14 | CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua |
31 | 15 | ||
32 | SAFEPWD=`echo "$$PWD" | sed -e 's/\([][]\)\1/]]..'\''\1\1'\''..[[/g'` | 16 | SAFEPWD=`echo "$$PWD" | sed -e 's/\([][]\)\1/]]..'\''\1\1'\''..[[/g'` |
@@ -139,23 +123,6 @@ cleanup_bins: | |||
139 | clean: cleanup_bins | 123 | clean: cleanup_bins |
140 | rm -f src/luarocks/site_config.lua | 124 | rm -f src/luarocks/site_config.lua |
141 | 125 | ||
142 | install_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 | |||
150 | install_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 | |||
159 | install_site_config: src/luarocks/site_config.lua | 126 | install_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 | ||
182 | install_rock: install_bins install_luas | 149 | install_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 | |||
4 | install_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 | |||
14 | install_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 | |||
2 | include Makefile.setup.inc | ||
3 | include Makefile.install.inc | ||
4 | |||
5 | .PHONY: all install copy_site_config | ||
6 | |||
7 | all: | ||
8 | @echo This Makefile is used by the LuaRocks rockspec for upgrading itself. | ||
9 | |||
10 | install: install_bins install_luas copy_site_config | ||
11 | |||
12 | copy_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 | |||
2 | DESTDIR = | ||
3 | PREFIX ?= /usr/local | ||
4 | BINDIR ?= $(PREFIX)/bin | ||
5 | LUADIR ?= $(PREFIX)/share/lua/$(LUA_VERSION)/ | ||
6 | |||
7 | BIN_FILES = luarocks luarocks-admin | ||
8 | LUAROCKS_FILES = fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua \ | ||
9 | fs/lua.lua persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua \ | ||
10 | command_line.lua install.lua build/command.lua build/cmake.lua build/make.lua \ | ||
11 | build/builtin.lua fetch/cvs.lua fetch/git.lua fetch/sscm.lua tools/patch.lua \ | ||
12 | fetch/svn.lua tools/zip.lua tools/tar.lua pack.lua type_check.lua make.lua \ | ||
13 | remove.lua fs.lua manif.lua add.lua deps.lua build.lua search.lua show.lua \ | ||
14 | manif_core.lua fetch.lua unpack.lua validate.lua cfg.lua download.lua \ | ||
15 | help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \ | ||
16 | admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ | ||
17 | purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ | ||
18 | upload/api.lua upload/multipart.lua fetch/git_http.lua | ||
19 | |||
@@ -1,5 +1,4 @@ | |||
1 | LuaRocks | 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 | ||
4 | A package manager for Lua modules. | 3 | A package manager for Lua modules. |
5 | 4 | ||
@@ -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 |
@@ -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 .. | |||
68 | rm -rf "release-unix" | 68 | rm -rf "release-unix" |
69 | 69 | ||
70 | cd "release-windows/$out-win32" | 70 | cd "release-windows/$out-win32" |
71 | rm -rf makedist Makefile configure lfw .travis.yml .gitignore | 71 | rm -rf makedist Makefile* configure lfw .travis.yml .gitignore test |
72 | cd .. | 72 | cd .. |
73 | zip -r ../"$out-win32.zip" "$out-win32" | 73 | zip -r ../"$out-win32.zip" "$out-win32" |
74 | cd .. | 74 | cd .. |
@@ -1,7 +1,9 @@ | |||
1 | package = "LuaRocks" | 1 | package = "LuaRocks" |
2 | local VER = "2.2.0" | 2 | local VER = "scm-1" |
3 | local REV = "1" | 3 | |
4 | version = VER.."-"..REV | 4 | source = { |
5 | url = "--this rockspec is used by `make bootstrap` only--", | ||
6 | } | ||
5 | 7 | ||
6 | description = { | 8 | description = { |
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 | ||
26 | source = { | ||
27 | url = "http://luarocks.org/releases/luarocks-"..VER..".tar.gz", | ||
28 | } | ||
29 | |||
30 | build = { | 28 | build = { |
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 | |||
119 | local ltn12_ok, ltn12 = pcall(require, "ltn12") | 119 | local ltn12_ok, ltn12 = pcall(require, "ltn12") |
120 | if not ltn12_ok then -- If not using LuaSocket and/or LuaSec... | 120 | if not ltn12_ok then -- If not using LuaSocket and/or LuaSec... |
121 | 121 | ||
122 | local function redact_api_url(url) | ||
123 | url = tostring(url) | ||
124 | return (url:gsub(".*/api/[^/]+/[^/]+", "")) or "" | ||
125 | end | ||
126 | |||
122 | function Api:request(url, params, post_params) | 127 | function 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)) |
249 | end | 254 | end |
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 | |||
2 | package="type_mismatch_version" | ||
3 | version=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 | |||
2 | package="type_mismatch_table" | ||
3 | version="1.0-1" | ||
4 | |||
5 | source = "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 | |||
2 | package="type_mismatch_version" | ||
3 | version="1.0" | ||
4 | |||