diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-01 15:21:16 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-01 22:54:07 -0300 |
| commit | 98d1f1da856ab59cf8355c1e2e11e3c0eb954fb2 (patch) | |
| tree | aeb6d9e6f45423cf5698930aea2bc55a8d721fa9 | |
| parent | cc4c9f6321ebaaf71f8c9c26bd30967e93bd2cbb (diff) | |
| download | luarocks-98d1f1da856ab59cf8355c1e2e11e3c0eb954fb2.tar.gz luarocks-98d1f1da856ab59cf8355c1e2e11e3c0eb954fb2.tar.bz2 luarocks-98d1f1da856ab59cf8355c1e2e11e3c0eb954fb2.zip | |
Unix: new build system
* Reworked configure script
* Now passes shellcheck
* New Makefile for Unix
* Simplified `make` and `make install` targets
* Simplified `make bootstrap` target
* New targets `make binary` and `make install-binary`
build and install an all-in-one binary of LuaRocks
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .travis.yml | 3 | ||||
| -rw-r--r-- | Makefile | 246 | ||||
| -rw-r--r-- | Makefile.install.inc | 23 | ||||
| -rw-r--r-- | Makefile.luarocks | 16 | ||||
| -rw-r--r-- | Makefile.setup.inc | 27 | ||||
| -rwxr-xr-x | binary/all_in_one | 442 | ||||
| -rw-r--r-- | binary/luaposix-34.0.4-1.rockspec | 55 | ||||
| -rw-r--r-- | binary/luasec-0.7alpha-2.rockspec | 119 | ||||
| -rwxr-xr-x | binary/static-gcc | 158 | ||||
| -rwxr-xr-x | configure | 633 | ||||
| -rw-r--r-- | luarocks-dev-1.rockspec (renamed from rockspec) | 40 | ||||
| -rwxr-xr-x | makedist | 45 |
13 files changed, 1213 insertions, 596 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | /test/testing_* | 3 | /test/testing_* |
| 4 | /test/luacov.* | 4 | /test/luacov.* |
| 5 | # Stuff that pops up during development but shouldn't be in the repo (helps clean up `git status`) | 5 | # Stuff that pops up during development but shouldn't be in the repo (helps clean up `git status`) |
| 6 | /*.rockspec | 6 | /build-binary |
| 7 | /*.rock | 7 | /*.rock |
| 8 | /*.tar.gz | 8 | /*.tar.gz |
| 9 | /*.zip | 9 | /*.zip |
diff --git a/.travis.yml b/.travis.yml index dab724b2..64d3347a 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -18,8 +18,9 @@ unit_script: &unit_script | |||
| 18 | 18 | ||
| 19 | integration_script: &integration_script | 19 | integration_script: &integration_script |
| 20 | - lua -v | 20 | - lua -v |
| 21 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then shellcheck ./configure; fi | ||
| 21 | - ./configure --with-lua=lua_install | 22 | - ./configure --with-lua=lua_install |
| 22 | - ./makedist scm | 23 | - ./makedist dev |
| 23 | - busted -o gtest --exclude-tags=git,unit --verbose -Xhelper "lua_dir=$PWD/lua_install,travis" | 24 | - busted -o gtest --exclude-tags=git,unit --verbose -Xhelper "lua_dir=$PWD/lua_install,travis" |
| 24 | - busted -o gtest --exclude-tags=git,unit --verbose -Xhelper "lua_dir=$PWD/lua_install,travis,env=full" | 25 | - busted -o gtest --exclude-tags=git,unit --verbose -Xhelper "lua_dir=$PWD/lua_install,travis,env=full" |
| 25 | 26 | ||
| @@ -1,150 +1,108 @@ | |||
| 1 | 1 | ||
| 2 | include config.unix | 2 | -include config.unix |
| 3 | 3 | ||
| 4 | .PHONY: all build dev build_bins luadoc check_makefile cleanup_bins clean \ | 4 | all: ./luarocks ./luarocks-admin |
| 5 | install_site_config write_sysconfig install bootstrap install_rock \ | ||
| 6 | run_luarocks | ||
| 7 | 5 | ||
| 8 | ROCKS_TREE ?= $(PREFIX) | 6 | # ---------------------------------------- |
| 9 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks | 7 | # Base build |
| 10 | LUA_DIR ?= /usr/local | 8 | # ---------------------------------------- |
| 11 | LUA_BINDIR ?= $(LUA_DIR)/bin | ||
| 12 | 9 | ||
| 13 | CONFIG_FILE = $(SYSCONFDIR)/config-$(LUA_VERSION).lua | 10 | build: all |
| 14 | 11 | ||
| 15 | SAFEPWD=`echo "$$PWD" | sed -e 's/\([][]\)\1/]]..'\''\1\1'\''..[[/g'` | 12 | config.unix: |
| 16 | 13 | @echo Please run the "./configure" script before building. | |
| 17 | all: | ||
| 18 | @echo "- Type 'make build' and 'make install':" | ||
| 19 | @echo " to install to $(PREFIX) as usual." | ||
| 20 | @echo "- Type 'make bootstrap':" | ||
| 21 | @echo " to install LuaRocks in $(PREFIX) as a rock." | ||
| 22 | @echo | ||
| 23 | |||
| 24 | include Makefile.setup.inc | ||
| 25 | include Makefile.install.inc | ||
| 26 | |||
| 27 | build: $(SITE_CONFIG) build_bins | ||
| 28 | @echo | ||
| 29 | @echo "Done. Type 'make install' to install into $(PREFIX)." | ||
| 30 | @echo | 14 | @echo |
| 31 | 15 | @exit 1 | |
| 32 | $(SITE_CONFIG): config.unix | 16 | |
| 33 | rm -f $(SITE_CONFIG) | 17 | config-$(LUA_VERSION).lua.in: config.unix |
| 34 | echo 'local site_config = {}' >> $(SITE_CONFIG) | 18 | |
| 35 | if [ -n "$(PREFIX)" ] ;\ | 19 | ./luarocks: config.unix config-$(LUA_VERSION).lua.in |
| 36 | then \ | 20 | rm -f src/luarocks/core/hardcoded.lua |
| 37 | echo "site_config.LUAROCKS_PREFIX=[[$(PREFIX)]]" >> $(SITE_CONFIG) ;\ | 21 | echo "#!/bin/sh" > luarocks |
| 38 | fi | 22 | echo "unset LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4" >> luarocks |
| 39 | if [ -n "$(LUA_INCDIR)" ] ;\ | 23 | echo 'LUAROCKS_SYSCONFDIR="$(SYSCONFDIR)" LUA_PATH="$(PWD)/src/?.lua;;" exec "$(LUA_BINDIR)/$(LUA_INTERPRETER)" "src/bin/luarocks" --project-tree="$(PWD)/lua_modules" "$$@"' >> luarocks |
| 40 | then \ | 24 | chmod +rx ./luarocks |
| 41 | echo "site_config.LUA_INCDIR=[[$(LUA_INCDIR)]]" >> $(SITE_CONFIG) ;\ | 25 | ./luarocks init |
| 42 | fi | 26 | cp config-$(LUA_VERSION).lua.in .luarocks/config-$(LUA_VERSION).lua |
| 43 | if [ -n "$(LUA_LIBDIR)" ] ;\ | 27 | |
| 44 | then \ | 28 | luarocks-admin: config.unix |
| 45 | echo "site_config.LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> $(SITE_CONFIG) ;\ | 29 | rm -f src/luarocks/core/hardcoded.lua |
| 46 | fi | 30 | echo "#!/bin/sh" > luarocks-admin |
| 47 | if [ -n "$(LUA_BINDIR)" ] ;\ | 31 | echo "unset LUA_PATH LUA_PATH_5_2 LUA_PATH_5_3 LUA_PATH_5_4" >> luarocks-admin |
| 48 | then \ | 32 | echo 'LUAROCKS_SYSCONFDIR="$(SYSCONFDIR)" LUA_PATH="$(PWD)/src/?.lua;;" exec "$(LUA_BINDIR)/$(LUA_INTERPRETER)" "src/bin/luarocks-admin" --project-tree="$(PWD)/lua_modules" "$$@"' >> luarocks-admin |
| 49 | echo "site_config.LUA_BINDIR=[[$(LUA_BINDIR)]]" >> $(SITE_CONFIG) ;\ | 33 | chmod +rx ./luarocks-admin |
| 50 | fi | 34 | |
| 51 | if [ -n "$(LUA_SUFFIX)" ] ;\ | 35 | # ---------------------------------------- |
| 52 | then \ | 36 | # Regular install |
| 53 | echo "site_config.LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> $(SITE_CONFIG) ;\ | 37 | # ---------------------------------------- |
| 54 | fi | 38 | |
| 55 | if [ -n "$(SYSCONFDIR)" ] ;\ | 39 | install: all $(PREFIX)/bin/luarocks $(PREFIX)/bin/luarocks-admin $(SYSCONFDIR)/config-$(LUA_VERSION).lua |
| 56 | then \ | 40 | mkdir -p "$(PREFIX)/share/lua/$(LUA_VERSION)/luarocks" |
| 57 | echo "site_config.LUAROCKS_SYSCONFDIR=[[$(SYSCONFDIR)]]" >> $(SITE_CONFIG) ;\ | 41 | cp -a src/luarocks/* "$(PREFIX)/share/lua/$(LUA_VERSION)/luarocks" |
| 58 | fi | 42 | |
| 59 | if [ -n "$(ROCKS_TREE)" ] ;\ | 43 | $(PREFIX)/bin/luarocks: src/bin/luarocks config.unix |
| 60 | then \ | 44 | mkdir -p "$(PREFIX)/bin" |
| 61 | echo "site_config.LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> $(SITE_CONFIG) ;\ | 45 | echo "#!$(LUA_BINDIR)/$(LUA_INTERPRETER)" > $@ |
| 62 | fi | 46 | echo "package.loaded['luarocks.core.hardcoded'] = { SYSCONFDIR = [[$(SYSCONFDIR)]] }" >> $@ |
| 63 | if [ -n "$(FORCE_CONFIG)" ] ;\ | 47 | echo "package.path=[[$(PREFIX)/share/lua/$(LUA_VERSION)/?.lua;]] .. package.path" >> $@ |
| 64 | then \ | 48 | tail -n +2 src/bin/luarocks >> $@ |
| 65 | echo "site_config.LUAROCKS_FORCE_CONFIG=true" >> $(SITE_CONFIG) ;\ | 49 | chmod +rx $@ |
| 66 | fi | 50 | |
| 67 | if [ "$(LUA_DIR_SET)" = "yes" ] ;\ | 51 | $(PREFIX)/bin/luarocks-admin: src/bin/luarocks-admin config.unix |
| 68 | then \ | 52 | mkdir -p "$(PREFIX)/bin" |
| 69 | echo "site_config.LUA_DIR_SET=true" >> $(SITE_CONFIG) ;\ | 53 | echo "#!$(LUA_BINDIR)/$(LUA_INTERPRETER)" > $@ |
| 70 | fi | 54 | echo "package.loaded['luarocks.core.hardcoded'] = { SYSCONFDIR = [[$(SYSCONFDIR)]] }" >> $@ |
| 71 | echo "site_config.LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> $(SITE_CONFIG) | 55 | echo "package.path=[[$(PREFIX)/share/lua/$(LUA_VERSION)/?.lua;]] .. package.path" >> $@ |
| 72 | echo "site_config.LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> $(SITE_CONFIG) | 56 | tail -n +2 src/bin/luarocks-admin >> $@ |
| 73 | echo "site_config.LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> $(SITE_CONFIG) | 57 | chmod +rx $@ |
| 74 | echo "site_config.LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> $(SITE_CONFIG) | 58 | |
| 75 | if [ -n "$(MULTIARCH_SUBDIR)" ] ;\ | 59 | $(SYSCONFDIR)/config-$(LUA_VERSION).lua: config-$(LUA_VERSION).lua.in |
| 76 | then \ | 60 | mkdir -p "$(SYSCONFDIR)" |
| 77 | echo 'site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> $(SITE_CONFIG) ;\ | 61 | cp config-$(LUA_VERSION).lua.in "$(SYSCONFDIR)/config-$(LUA_VERSION).lua" |
| 78 | echo 'site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> $(SITE_CONFIG) ;\ | 62 | |
| 79 | fi | 63 | # ---------------------------------------- |
| 80 | echo "return site_config" >> $(SITE_CONFIG) | 64 | # Binary build |
| 81 | 65 | # ---------------------------------------- | |
| 82 | dev: | 66 | |
| 83 | $(MAKE) build_bins LUADIR=$(PWD)/src | 67 | binary: build-binary/luarocks.exe build-binary/luarocks-admin.exe |
| 84 | 68 | ||
| 85 | build_bins: cleanup_bins | 69 | build-binary/luarocks.exe: ./luarocks |
| 86 | for f in $(BIN_FILES) ;\ | 70 | LUA_PATH="$(PWD)/src/?.lua;;" "$(LUA_BINDIR)/$(LUA_INTERPRETER)" ./all_in_one "src/bin/luarocks" "$(LUA_DIR)" "^src/luarocks/admin/" "$(SYSCONFDIR)" "build-binary" |
| 87 | do \ | 71 | |
| 88 | sed "1d" src/bin/$$f > src/bin/$$f.bak ;\ | 72 | build-binary/luarocks-admin.exe: ./luarocks |
| 89 | echo "#!$(LUA_BINDIR)/lua$(LUA_SUFFIX)" > src/bin/$$f ;\ | 73 | LUA_PATH="$(PWD)/src/?.lua;;" "$(LUA_BINDIR)/$(LUA_INTERPRETER)" ./all_in_one "src/bin/luarocks-admin" "$(LUA_DIR)" "^src/luarocks/cmd/" "$(SYSCONFDIR)" "build-binary" |
| 90 | echo "package.path = [[$(LUADIR)/?.lua;]]..package.path" | sed "s,//,/,g" >> src/bin/$$f ;\ | 74 | |
| 91 | cat src/bin/$$f.bak >> src/bin/$$f ;\ | 75 | # ---------------------------------------- |
| 92 | chmod +rx src/bin/$$f ;\ | 76 | # Binary install |
| 93 | rm -f src/bin/$$f.bak ;\ | 77 | # ---------------------------------------- |
| 94 | done | 78 | |
| 95 | 79 | install-binary: build-binary/luarocks.exe build-binary/luarocks-admin.exe | |
| 96 | luadoc: | 80 | mkdir -p "$(PREFIX)/bin" |
| 97 | rm -rf doc/luadoc | 81 | cp build-binary/luarocks.exe "$(PREFIX)/bin/luarocks" |
| 98 | mkdir -p doc/luadoc | 82 | chmod +rx "$(PREFIX)/bin/luarocks" |
| 99 | cd src && luadoc -d ../doc/luadoc --nofiles luarocks/*.lua | 83 | cp build-binary/luarocks-admin.exe "$(PREFIX)/bin/luarocks-admin" |
| 100 | 84 | chmod +rx "$(PREFIX)/bin/luarocks-admin" | |
| 101 | check_makefile: clean | 85 | mkdir -p "$(PREFIX)/share/lua/$(LUA_VERSION)/luarocks/core" |
| 102 | echo $(BIN_FILES) | tr " " "\n" | sort > makefile_list.txt | 86 | cp -a src/luarocks/core/* "$(PREFIX)/share/lua/$(LUA_VERSION)/luarocks/core" |
| 103 | ( cd src/bin && ls -d * ) | sort > luarocks_dir.txt | 87 | cp -a src/luarocks/loader.lua "$(PREFIX)/share/lua/$(LUA_VERSION)/luarocks/" |
| 104 | echo $(LUAROCKS_FILES) | tr " " "\n" | sort >> makefile_list.txt | 88 | |
| 105 | ( cd src/luarocks && find * -name "*.lua" ) | sort >> luarocks_dir.txt | 89 | # ---------------------------------------- |
| 106 | diff makefile_list.txt luarocks_dir.txt | 90 | # Bootstrap install |
| 107 | rm -f makefile_list.txt luarocks_dir.txt | 91 | # ---------------------------------------- |
| 108 | @echo | 92 | |
| 109 | @echo "Makefile is sane." | 93 | bootstrap: ./luarocks $(SYSCONFDIR)/config-$(LUA_VERSION).lua |
| 110 | @echo | 94 | ./luarocks make --tree="$(ROCKS_TREE)" |
| 111 | 95 | ||
| 112 | cleanup_bins: | 96 | # ---------------------------------------- |
| 113 | for f in $(BIN_FILES) ;\ | 97 | # Clean |
| 114 | do \ | 98 | # ---------------------------------------- |
| 115 | mv src/bin/$$f src/bin/$$f.bak ;\ | 99 | |
| 116 | sed "s,^#!.*lua.*,#!/usr/bin/env lua,;/^package.path/d" < src/bin/$$f.bak > src/bin/$$f ;\ | 100 | clean: |
| 117 | chmod +rx src/bin/$$f ;\ | 101 | rm -f ./config.unix |
| 118 | rm -f src/bin/$$f.bak ;\ | 102 | rm -f ./luarocks |
| 119 | done | 103 | rm -f ./luarocks-admin |
| 120 | 104 | rm -rf build-binary | |
| 121 | clean: cleanup_bins | 105 | rm -rf ./.luarocks |
| 122 | rm -f $(SITE_CONFIG) | 106 | rm -rf ./lua_modules |
| 123 | 107 | ||
| 124 | run_luarocks: | 108 | .PHONY: all build install binary install-binary bootstrap clean |
| 125 | '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$(SAFEPWD)/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)" | ||
| 126 | |||
| 127 | install_site_config: $(SITE_CONFIG) | ||
| 128 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks/core" | ||
| 129 | cp $(SITE_CONFIG) "$(DESTDIR)$(LUADIR)/luarocks/core" | ||
| 130 | |||
| 131 | write_sysconfig: | ||
| 132 | mkdir -p "$(DESTDIR)$(ROCKS_TREE)" | ||
| 133 | if [ ! -f "$(DESTDIR)$(CONFIG_FILE)" ] ;\ | ||
| 134 | then \ | ||
| 135 | mkdir -p `dirname "$(DESTDIR)$(CONFIG_FILE)"` ;\ | ||
| 136 | echo 'rocks_trees = {' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
| 137 | if [ ! -n "$(FORCE_CONFIG)" ] ;\ | ||
| 138 | then \ | ||
| 139 | echo ' { name = [[user]], root = home..[[/.luarocks]] },' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
| 140 | fi ;\ | ||
| 141 | echo ' { name = [[system]], root = [[$(ROCKS_TREE)]] }' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
| 142 | echo '}' >> "$(DESTDIR)$(CONFIG_FILE)" ;\ | ||
| 143 | fi | ||
| 144 | |||
| 145 | install: build install_bins install_luas install_site_config write_sysconfig | ||
| 146 | |||
| 147 | bootstrap: $(SITE_CONFIG) run_luarocks install_site_config write_sysconfig cleanup_bins | ||
| 148 | |||
| 149 | install_rock: install_bins install_luas | ||
| 150 | |||
diff --git a/Makefile.install.inc b/Makefile.install.inc deleted file mode 100644 index 621d7cb2..00000000 --- a/Makefile.install.inc +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 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 | chmod +rx "$(DESTDIR)$(BINDIR)/$$f-$$luaver"; \ | ||
| 12 | ln -nfs "$$f-$$luaver" "$(DESTDIR)$(BINDIR)/$$f"; \ | ||
| 13 | done | ||
| 14 | |||
| 15 | install_luas: | ||
| 16 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" | ||
| 17 | cd src/luarocks && for f in $(LUAROCKS_FILES); \ | ||
| 18 | do \ | ||
| 19 | d="$(DESTDIR)$(LUADIR)/luarocks"/`dirname "$$f"` && \ | ||
| 20 | mkdir -p "$$d" && \ | ||
| 21 | cp "$$f" "$$d" || exit 1; \ | ||
| 22 | done | ||
| 23 | |||
diff --git a/Makefile.luarocks b/Makefile.luarocks deleted file mode 100644 index f0652891..00000000 --- a/Makefile.luarocks +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 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 | site_config="site_config_$(echo "$luaver" | sed 's,\.,_,').lua" | ||
| 16 | lprefix=$(echo "$(LUADIR)" | sed 's,/lib/luarocks/.*,,'); sed "s,LUAROCKS_PREFIX=.*,LUAROCKS_PREFIX=[[$$lprefix]],g" "$(LUAROCKS_PREFIX)/share/lua/$$luaver/luarocks/core/$$site_config" > "$(DESTDIR)$(LUADIR)/luarocks/core/$$site_config" | ||
diff --git a/Makefile.setup.inc b/Makefile.setup.inc deleted file mode 100644 index f53686d0..00000000 --- a/Makefile.setup.inc +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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.lua dir.lua repos.lua cmd.lua upload/api.lua upload/multipart.lua \ | ||
| 9 | admin/index.lua build.lua search.lua fs/win32.lua fs/win32/tools.lua fs/win32/pe-parser.lua \ | ||
| 10 | fs/unix/tools.lua fs/lua.lua fs/tools.lua fs/unix.lua loader.lua cmd/help.lua \ | ||
| 11 | cmd/unpack.lua cmd/upload.lua cmd/lint.lua cmd/purge.lua cmd/install.lua \ | ||
| 12 | cmd/config.lua cmd/write_rockspec.lua cmd/build.lua cmd/search.lua cmd/test.lua \ | ||
| 13 | cmd/make.lua cmd/list.lua cmd/show.lua cmd/path.lua cmd/new_version.lua \ | ||
| 14 | cmd/pack.lua cmd/download.lua cmd/doc.lua cmd/remove.lua tools/patch.lua \ | ||
| 15 | tools/zip.lua tools/tar.lua manif/writer.lua build/cmake.lua build/make.lua \ | ||
| 16 | build/command.lua build/builtin.lua fetch.lua path.lua util.lua deps.lua \ | ||
| 17 | pack.lua download.lua core/dir.lua core/path.lua core/util.lua \ | ||
| 18 | core/cfg.lua core/persist.lua core/manif.lua \ | ||
| 19 | type_check.lua persist.lua require.lua manif.lua admin/cache.lua \ | ||
| 20 | admin/cmd/make_manifest.lua admin/cmd/add.lua admin/cmd/remove.lua \ | ||
| 21 | admin/cmd/refresh_cache.lua remove.lua fetch/git_file.lua fetch/sscm.lua \ | ||
| 22 | fetch/cvs.lua fetch/git_https.lua fetch/git_ssh.lua fetch/hg_http.lua \ | ||
| 23 | fetch/git_http.lua fetch/svn.lua fetch/git.lua fetch/hg_ssh.lua \ | ||
| 24 | fetch/hg_https.lua fetch/hg.lua core/vers.lua cmd/which.lua \ | ||
| 25 | fun.lua type/manifest.lua type/rockspec.lua queries.lua results.lua \ | ||
| 26 | test/busted.lua test/command.lua cmd/init.lua rockspecs.lua | ||
| 27 | |||
diff --git a/binary/all_in_one b/binary/all_in_one new file mode 100755 index 00000000..de545d04 --- /dev/null +++ b/binary/all_in_one | |||
| @@ -0,0 +1,442 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | --[[ | ||
| 3 | |||
| 4 | All-in-one packager for LuaRocks | ||
| 5 | * by Hisham Muhammad <hisham@gobolinux.org> | ||
| 6 | * licensed under the same terms as Lua (MIT license). | ||
| 7 | |||
| 8 | Based on: | ||
| 9 | |||
| 10 | * srlua.c - Lua interpreter for self-running programs | ||
| 11 | * by Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> | ||
| 12 | * 03 Nov 2014 15:31:43 | ||
| 13 | * srlua.c is placed in the public domain. | ||
| 14 | * bin2c.lua - converts a binary to a C string that can be embedded | ||
| 15 | * by Mark Edgar | ||
| 16 | * http://lua-users.org/wiki/BinTwoCee | ||
| 17 | * bin2c.lua is licensed under the same terms as Lua (MIT license). | ||
| 18 | * lua.c - Lua stand-alone interpreter | ||
| 19 | * by Luiz Henrique de Figueiredo, Waldemar Celes, Roberto Ierusalimschy | ||
| 20 | * lua.c is licensed under the same terms as Lua (MIT license). | ||
| 21 | * luastatic - builds a standalone executable from a Lua program | ||
| 22 | * by Eric R. Schulz | ||
| 23 | * https://github.com/ers35/luastatic | ||
| 24 | * luastatic is licensed under the CC0 1.0 Universal license | ||
| 25 | |||
| 26 | ]] | ||
| 27 | |||
| 28 | local MAIN_PROGRAM = arg[1] or "src/bin/luarocks" | ||
| 29 | local LUA_DIR = arg[2] or "/usr" | ||
| 30 | local EXCLUDE = arg[3] or "^src/luarocks/admin/" | ||
| 31 | local SYSCONFDIR = arg[4] or "/etc/luarocks" | ||
| 32 | local TARGET = arg[5] or "binary-build" | ||
| 33 | |||
| 34 | local LUA_MODULES = TARGET .. "/lua_modules" | ||
| 35 | local CONFIG_DIR = TARGET .. "/.luarocks" | ||
| 36 | |||
| 37 | package.path = "./src/?.lua;" .. package.path | ||
| 38 | |||
| 39 | local fs = require("luarocks.fs") | ||
| 40 | local cfg = require("luarocks.core.cfg") | ||
| 41 | local cmd = require("luarocks.cmd") | ||
| 42 | local deps = require("luarocks.deps") | ||
| 43 | local util = require("luarocks.util") | ||
| 44 | local path = require("luarocks.path") | ||
| 45 | local manif = require("luarocks.manif") | ||
| 46 | local queries = require("luarocks.queries") | ||
| 47 | local persist = require("luarocks.persist") | ||
| 48 | |||
| 49 | -------------------------------------------------------------------------------- | ||
| 50 | |||
| 51 | local function reindent_c(input) | ||
| 52 | local out = {} | ||
| 53 | local indent = 0 | ||
| 54 | local previous_is_blank = true | ||
| 55 | for line in input:gmatch("([^\n]*)") do | ||
| 56 | line = line:match("^[ \t]*(.-)[ \t]*$") | ||
| 57 | |||
| 58 | local is_blank = (#line == 0) | ||
| 59 | local do_print = | ||
| 60 | (not is_blank) or | ||
| 61 | (not previous_is_blank and indent == 0) | ||
| 62 | |||
| 63 | if line:match("^[})]") then | ||
| 64 | indent = indent - 1 | ||
| 65 | if indent < 0 then indent = 0 end | ||
| 66 | end | ||
| 67 | if do_print then | ||
| 68 | table.insert(out, string.rep(" ", indent)) | ||
| 69 | table.insert(out, line) | ||
| 70 | table.insert(out, "\n") | ||
| 71 | end | ||
| 72 | if line:match("[{(]$") then | ||
| 73 | indent = indent + 1 | ||
| 74 | end | ||
| 75 | |||
| 76 | previous_is_blank = is_blank | ||
| 77 | end | ||
| 78 | return table.concat(out) | ||
| 79 | end | ||
| 80 | |||
| 81 | local hexdump | ||
| 82 | do | ||
| 83 | local numtab = {} | ||
| 84 | for i = 0, 255 do | ||
| 85 | numtab[string.char(i)] = ("%-3d,"):format(i) | ||
| 86 | end | ||
| 87 | function hexdump(str) | ||
| 88 | return (str:gsub(".", numtab):gsub(("."):rep(80), "%0\n")) | ||
| 89 | end | ||
| 90 | end | ||
| 91 | |||
| 92 | local c_preamble = [[ | ||
| 93 | |||
| 94 | #include <lua.h> | ||
| 95 | #include <lualib.h> | ||
| 96 | #include <lauxlib.h> | ||
| 97 | #include <errno.h> | ||
| 98 | #include <stdio.h> | ||
| 99 | #include <stdlib.h> | ||
| 100 | |||
| 101 | /* portable alerts, from srlua */ | ||
| 102 | #ifdef _WIN32 | ||
| 103 | #include <windows.h> | ||
| 104 | #define alert(message) MessageBox(NULL, message, progname, MB_ICONERROR | MB_OK) | ||
| 105 | #define getprogname() char name[MAX_PATH]; argv[0]= GetModuleFileName(NULL,name,sizeof(name)) ? name : NULL; | ||
| 106 | #else | ||
| 107 | #define alert(message) fprintf(stderr,"%s: %s\n", progname, message) | ||
| 108 | #define getprogname() | ||
| 109 | #endif | ||
| 110 | |||
| 111 | static int registry_key; | ||
| 112 | |||
| 113 | ]] | ||
| 114 | |||
| 115 | local function bin2c_file(out, filename) | ||
| 116 | local content = string.dump(assert(loadfile(filename))) | ||
| 117 | table.insert(out, ("static const unsigned char code[] = {")) | ||
| 118 | table.insert(out, hexdump(content)) | ||
| 119 | table.insert(out, ("};")) | ||
| 120 | end | ||
| 121 | |||
| 122 | local function write_hardcoded_module(dir) | ||
| 123 | |||
| 124 | local system = util.popen_read("uname -s") | ||
| 125 | local processor = util.popen_read("uname -m") | ||
| 126 | |||
| 127 | if processor:match("i[%d]86") then | ||
| 128 | processor = "x86" | ||
| 129 | elseif processor:match("amd64") or processor:match("x86_64") then | ||
| 130 | processor = "x86_64" | ||
| 131 | elseif processor:match("Power Macintosh") then | ||
| 132 | processor = "powerpc" | ||
| 133 | end | ||
| 134 | |||
| 135 | local hardcoded = { | ||
| 136 | SYSTEM = system, | ||
| 137 | PROCESSOR = processor, | ||
| 138 | SYSCONFDIR = SYSCONFDIR, | ||
| 139 | LUA_DIR = cfg.variables.LUA_DIR, | ||
| 140 | LUA_BINDIR = cfg.variables.LUA_BINDIR, | ||
| 141 | LUA_INTERPRETER = cfg.lua_interpreter, | ||
| 142 | } | ||
| 143 | |||
| 144 | local name = dir .. "/luarocks/core/hardcoded.lua" | ||
| 145 | persist.save_as_module(name, hardcoded) | ||
| 146 | return name | ||
| 147 | end | ||
| 148 | |||
| 149 | local function declare_modules(out, dirs, skip) | ||
| 150 | skip = skip or {} | ||
| 151 | table.insert(out, [[ | ||
| 152 | static void declare_modules(lua_State* L) { | ||
| 153 | lua_settop(L, 0); /* */ | ||
| 154 | lua_newtable(L); /* modules */ | ||
| 155 | lua_pushlightuserdata(L, (void*) ®istry_key); /* modules registry_key */ | ||
| 156 | lua_pushvalue(L, 1); /* modules registry_key modules */ | ||
| 157 | lua_rawset(L, LUA_REGISTRYINDEX); /* modules */ | ||
| 158 | ]]) | ||
| 159 | for _, dir in ipairs(dirs) do | ||
| 160 | for _, name in ipairs(fs.find(dir)) do | ||
| 161 | local run = true | ||
| 162 | for _, pat in ipairs(skip) do | ||
| 163 | if name:match(pat) then | ||
| 164 | run = false | ||
| 165 | break | ||
| 166 | end | ||
| 167 | end | ||
| 168 | if run then | ||
| 169 | local filename = dir .. "/" .. name | ||
| 170 | if fs.is_file(filename) then | ||
| 171 | print(name) | ||
| 172 | local modname = name:gsub("%.lua$", ""):gsub("/", ".") | ||
| 173 | table.insert(out, ("/* %s */"):format(modname)) | ||
| 174 | table.insert(out, ("{")) | ||
| 175 | bin2c_file(out, filename) | ||
| 176 | table.insert(out, ("luaL_loadbuffer(L, code, sizeof(code), %q);"):format(filename)) | ||
| 177 | table.insert(out, ("lua_setfield(L, 1, %q);"):format(modname)) | ||
| 178 | table.insert(out, ("}")) | ||
| 179 | end | ||
| 180 | end | ||
| 181 | end | ||
| 182 | end | ||
| 183 | table.insert(out, [[ | ||
| 184 | lua_settop(L, 0); /* */ | ||
| 185 | } | ||
| 186 | ]]) | ||
| 187 | end | ||
| 188 | |||
| 189 | local function nm(filename) | ||
| 190 | local pd = io.popen("nm " .. filename) | ||
| 191 | local out = pd:read("*a") | ||
| 192 | pd:close() | ||
| 193 | return out | ||
| 194 | end | ||
| 195 | |||
| 196 | local function declare_libraries(out, dir) | ||
| 197 | local a_files = {} | ||
| 198 | local externs = {} | ||
| 199 | local fn = {} | ||
| 200 | table.insert(fn, [[ | ||
| 201 | static void declare_libraries(lua_State* L) { | ||
| 202 | lua_getglobal(L, "package"); /* package */ | ||
| 203 | lua_getfield(L, -1, "preload"); /* package package.preload */ | ||
| 204 | ]]) | ||
| 205 | for _, name in ipairs(fs.find(dir)) do | ||
| 206 | local filename = dir .. "/" .. name | ||
| 207 | if name:match("%.a$") then | ||
| 208 | table.insert(a_files, filename) | ||
| 209 | local nmout = nm(filename) | ||
| 210 | for luaopen in nmout:gmatch("[^dD] _?(luaopen_[%a%p%d]+)") do | ||
| 211 | |||
| 212 | -- FIXME what about module names with underscores? | ||
| 213 | local modname = luaopen:gsub("^_?luaopen_", ""):gsub("_", ".") | ||
| 214 | |||
| 215 | table.insert(externs, "extern int " .. luaopen .. "(lua_State* L);") | ||
| 216 | table.insert(fn, "lua_pushcfunction(L, " .. luaopen .. ");") | ||
| 217 | table.insert(fn, "lua_setfield(L, -2, \"" .. modname .. "\");") | ||
| 218 | end | ||
| 219 | end | ||
| 220 | end | ||
| 221 | local pd = io.popen("find " .. dir .. " -name '*.a'", "r") | ||
| 222 | for line in pd:lines() do | ||
| 223 | table.insert(a_files, line) | ||
| 224 | end | ||
| 225 | pd:close() | ||
| 226 | table.insert(fn, [[ | ||
| 227 | lua_settop(L, 0); /* */ | ||
| 228 | } | ||
| 229 | ]]) | ||
| 230 | |||
| 231 | table.insert(out, "\n") | ||
| 232 | for _, line in ipairs(externs) do | ||
| 233 | table.insert(out, line) | ||
| 234 | end | ||
| 235 | table.insert(out, "\n") | ||
| 236 | for _, line in ipairs(fn) do | ||
| 237 | table.insert(out, line) | ||
| 238 | end | ||
| 239 | table.insert(out, "\n") | ||
| 240 | |||
| 241 | return a_files | ||
| 242 | end | ||
| 243 | |||
| 244 | local function load_main(out, main_program, program_name) | ||
| 245 | table.insert(out, [[static void load_main(lua_State* L) {]]) | ||
| 246 | bin2c_file(out, main_program) | ||
| 247 | table.insert(out, ("luaL_loadbuffer(L, code, sizeof(code), %q);"):format(program_name)) | ||
| 248 | table.insert(out, [[}]]) | ||
| 249 | table.insert(out, [[]]) | ||
| 250 | end | ||
| 251 | |||
| 252 | local c_main = [[ | ||
| 253 | |||
| 254 | /* custom package loader */ | ||
| 255 | static int pkg_loader(lua_State* L) { | ||
| 256 | lua_pushlightuserdata(L, (void*) ®istry_key); /* modname ? registry_key */ | ||
| 257 | lua_rawget(L, LUA_REGISTRYINDEX); /* modname ? modules */ | ||
| 258 | lua_pushvalue(L, -1); /* modname ? modules modules */ | ||
| 259 | lua_pushvalue(L, 1); /* modname ? modules modules modname */ | ||
| 260 | lua_gettable(L, -2); /* modname ? modules mod */ | ||
| 261 | if (lua_type(L, -1) == LUA_TNIL) { | ||
| 262 | lua_pop(L, 1); /* modname ? modules */ | ||
| 263 | lua_pushvalue(L, 1); /* modname ? modules modname */ | ||
| 264 | lua_pushliteral(L, ".init"); /* modname ? modules modname ".init" */ | ||
| 265 | lua_concat(L, 2); /* modname ? modules modname .. ".init" */ | ||
| 266 | lua_gettable(L, -2); /* modname ? mod */ | ||
| 267 | } | ||
| 268 | return 1; | ||
| 269 | } | ||
| 270 | |||
| 271 | static void install_pkg_loader(lua_State* L) { | ||
| 272 | lua_settop(L, 0); /* */ | ||
| 273 | lua_getglobal(L, "table"); /* table */ | ||
| 274 | lua_getfield(L, -1, "insert"); /* table table.insert */ | ||
| 275 | lua_getglobal(L, "package"); /* table table.insert package */ | ||
| 276 | lua_getfield(L, -1, "searchers"); /* table table.insert package package.searchers */ | ||
| 277 | if (lua_type(L, -1) == LUA_TNIL) { | ||
| 278 | lua_pop(L, 1); | ||
| 279 | lua_getfield(L, -1, "loaders"); /* table table.insert package package.loaders */ | ||
| 280 | } | ||
| 281 | lua_copy(L, 4, 3); /* table table.insert package.searchers */ | ||
| 282 | lua_settop(L, 3); /* table table.insert package.searchers */ | ||
| 283 | lua_pushnumber(L, 1); /* table table.insert package.searchers 1 */ | ||
| 284 | lua_pushcfunction(L, pkg_loader); /* table table.insert package.searchers 1 pkg_loader */ | ||
| 285 | lua_call(L, 3, 0); /* table */ | ||
| 286 | lua_settop(L, 0); /* */ | ||
| 287 | } | ||
| 288 | |||
| 289 | /* main script launcher, from srlua */ | ||
| 290 | static int pmain(lua_State *L) { | ||
| 291 | int argc = lua_tointeger(L, 1); | ||
| 292 | char** argv = lua_touserdata(L, 2); | ||
| 293 | int i; | ||
| 294 | load_main(L); | ||
| 295 | lua_createtable(L, argc, 0); | ||
| 296 | for (i = 0; i < argc; i++) { | ||
| 297 | lua_pushstring(L, argv[i]); | ||
| 298 | lua_rawseti(L, -2, i); | ||
| 299 | } | ||
| 300 | lua_setglobal(L, "arg"); | ||
| 301 | luaL_checkstack(L, argc - 1, "too many arguments to script"); | ||
| 302 | for (i = 1; i < argc; i++) { | ||
| 303 | lua_pushstring(L, argv[i]); | ||
| 304 | } | ||
| 305 | lua_call(L, argc - 1, 0); | ||
| 306 | return 0; | ||
| 307 | } | ||
| 308 | |||
| 309 | /* fatal error, from srlua */ | ||
| 310 | static void fatal(const char* message) { | ||
| 311 | alert(message); | ||
| 312 | exit(EXIT_FAILURE); | ||
| 313 | } | ||
| 314 | |||
| 315 | /* error handler, from luac */ | ||
| 316 | static int msghandler (lua_State *L) { | ||
| 317 | /* is error object not a string? */ | ||
| 318 | const char *msg = lua_tostring(L, 1); | ||
| 319 | if (msg == NULL) { | ||
| 320 | /* does it have a metamethod that produces a string */ | ||
| 321 | if (luaL_callmeta(L, 1, "__tostring") && lua_type(L, -1) == LUA_TSTRING) { | ||
| 322 | /* then that is the message */ | ||
| 323 | return 1; | ||
| 324 | } else { | ||
| 325 | msg = lua_pushfstring(L, "(error object is a %s value)", luaL_typename(L, 1)); | ||
| 326 | } | ||
| 327 | } | ||
| 328 | /* append a standard traceback */ | ||
| 329 | luaL_traceback(L, L, msg, 1); | ||
| 330 | return 1; | ||
| 331 | } | ||
| 332 | |||
| 333 | /* main function, from srlua */ | ||
| 334 | int main(int argc, char** argv) { | ||
| 335 | lua_State* L; | ||
| 336 | getprogname(); | ||
| 337 | if (argv[0] == NULL) { | ||
| 338 | fatal("cannot locate this executable"); | ||
| 339 | } | ||
| 340 | L = luaL_newstate(); | ||
| 341 | if (L == NULL) { | ||
| 342 | fatal("not enough memory for state"); | ||
| 343 | } | ||
| 344 | luaL_openlibs(L); | ||
| 345 | install_pkg_loader(L); | ||
| 346 | declare_libraries(L); | ||
| 347 | declare_modules(L); | ||
| 348 | lua_pushcfunction(L, &msghandler); | ||
| 349 | lua_pushcfunction(L, &pmain); | ||
| 350 | lua_pushinteger(L, argc); | ||
| 351 | lua_pushlightuserdata(L, argv); | ||
| 352 | if (lua_pcall(L, 2, 0, -4) != 0) { | ||
| 353 | fatal(lua_tostring(L, -1)); | ||
| 354 | } | ||
| 355 | lua_close(L); | ||
| 356 | return EXIT_SUCCESS; | ||
| 357 | } | ||
| 358 | |||
| 359 | ]] | ||
| 360 | |||
| 361 | local function generate(main_program, dir, skip) | ||
| 362 | local program_name = main_program:gsub(".*/", "") | ||
| 363 | |||
| 364 | local hardcoded = write_hardcoded_module(dir) | ||
| 365 | |||
| 366 | local out = {} | ||
| 367 | table.insert(out, c_preamble) | ||
| 368 | table.insert(out, ([[static const char* progname = %q;]]):format(program_name)) | ||
| 369 | load_main(out, main_program, program_name) | ||
| 370 | local lua_modules = LUA_MODULES .. "/share/lua/" .. cfg.lua_version | ||
| 371 | declare_modules(out, { dir, lua_modules }, skip) | ||
| 372 | local a_files = declare_libraries(out, LUA_MODULES .. "/lib/lua/" .. cfg.lua_version) | ||
| 373 | table.insert(out, c_main) | ||
| 374 | |||
| 375 | os.remove(hardcoded) | ||
| 376 | |||
| 377 | local c_filename = TARGET .. "/" .. program_name .. ".exe.c" | ||
| 378 | local fd = io.open(c_filename, "w") | ||
| 379 | fd:write(reindent_c(table.concat(out, "\n"))) | ||
| 380 | fd:close() | ||
| 381 | |||
| 382 | cmd = table.concat({ | ||
| 383 | "gcc", "-o", TARGET .. "/" .. program_name .. ".exe", | ||
| 384 | "-I", cfg.variables.LUA_INCDIR, | ||
| 385 | "-rdynamic", | ||
| 386 | "-Os", | ||
| 387 | c_filename, | ||
| 388 | "-L", cfg.variables.LUA_LIBDIR, | ||
| 389 | table.concat(a_files, " "), | ||
| 390 | cfg.variables.LUA_LIBDIR .. "/" .. cfg.variables.LUALIB:gsub("%.so.*$", ".a"), | ||
| 391 | "-ldl", "-lm"}, " ") | ||
| 392 | print(cmd) | ||
| 393 | os.execute(cmd) | ||
| 394 | end | ||
| 395 | |||
| 396 | -------------------------------------------------------------------------------- | ||
| 397 | |||
| 398 | local function main() | ||
| 399 | |||
| 400 | cfg.init(cmd.find_lua(LUA_DIR)) | ||
| 401 | fs.init() | ||
| 402 | deps.check_lua(cfg.variables) | ||
| 403 | path.use_tree("./" .. LUA_MODULES) | ||
| 404 | |||
| 405 | local CONFIG_FILE = CONFIG_DIR .. "/config-" .. cfg.lua_version .. ".lua" | ||
| 406 | |||
| 407 | fs.make_dir(CONFIG_DIR) | ||
| 408 | local fd = io.open(CONFIG_FILE, "w") | ||
| 409 | fd:write([[ | ||
| 410 | lib_extension = "a" | ||
| 411 | external_lib_extension = "a" | ||
| 412 | variables = { | ||
| 413 | CC = "]] .. fs.current_dir() .. [[/static-gcc", | ||
| 414 | LD = "]] .. fs.current_dir() .. [[/static-gcc", | ||
| 415 | LIB_EXTENSION = "a", | ||
| 416 | LIBFLAG = "-static", | ||
| 417 | } | ||
| 418 | ]]) | ||
| 419 | fd:close() | ||
| 420 | |||
| 421 | local dependencies = { | ||
| 422 | md5 = "md5", | ||
| 423 | luazip = "luazip", | ||
| 424 | luasec = "./luasec-0.7alpha-2.rockspec", | ||
| 425 | luaposix = "./luaposix-34.0.4-1.rockspec", | ||
| 426 | luasocket = "luasocket", | ||
| 427 | ["lua-zlib"] = "lua-zlib", | ||
| 428 | luafilesystem = "luafilesystem", | ||
| 429 | } | ||
| 430 | |||
| 431 | fs.make_dir(LUA_MODULES) | ||
| 432 | for name, arg in pairs(dependencies) do | ||
| 433 | local vers = manif.get_versions(queries.from_dep_string(name), "one") | ||
| 434 | if not next(vers) then | ||
| 435 | os.execute("LUAROCKS_CONFIG='" .. CONFIG_FILE .. "' ./luarocks install '--tree=" .. LUA_MODULES .. "' " .. arg) | ||
| 436 | end | ||
| 437 | end | ||
| 438 | |||
| 439 | generate(MAIN_PROGRAM, "src", { EXCLUDE, "^bin/?" }) | ||
| 440 | end | ||
| 441 | |||
| 442 | main() | ||
diff --git a/binary/luaposix-34.0.4-1.rockspec b/binary/luaposix-34.0.4-1.rockspec new file mode 100644 index 00000000..490715d5 --- /dev/null +++ b/binary/luaposix-34.0.4-1.rockspec | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | local _MODREV, _SPECREV = '34.0.4', '-1' | ||
| 2 | |||
| 3 | package = 'luaposix' | ||
| 4 | version = _MODREV .. _SPECREV | ||
| 5 | |||
| 6 | description = { | ||
| 7 | summary = 'Lua bindings for POSIX', | ||
| 8 | detailed = [[ | ||
| 9 | A library binding various POSIX APIs. POSIX is the IEEE Portable | ||
| 10 | Operating System Interface standard. luaposix is based on lposix. | ||
| 11 | ]], | ||
| 12 | homepage = 'http://github.com/luaposix/luaposix/', | ||
| 13 | license = 'MIT/X11', | ||
| 14 | } | ||
| 15 | |||
| 16 | dependencies = { | ||
| 17 | 'bit32', | ||
| 18 | 'lua >= 5.1, < 5.4', | ||
| 19 | 'std.normalize', | ||
| 20 | } | ||
| 21 | |||
| 22 | source = { | ||
| 23 | url = 'http://github.com/luaposix/luaposix/archive/v' .. _MODREV .. '.zip', | ||
| 24 | dir = 'luaposix-' .. _MODREV, | ||
| 25 | } | ||
| 26 | |||
| 27 | build = { | ||
| 28 | type = 'command', | ||
| 29 | build_command = '$(LUA) build-aux/luke' | ||
| 30 | .. ' package="' .. package .. '"' | ||
| 31 | .. ' version="' .. _MODREV .. '"' | ||
| 32 | .. ' PREFIX="$(PREFIX)"' | ||
| 33 | .. ' LUA="$(LUA)"' | ||
| 34 | .. ' LUA_INCDIR="$(LUA_INCDIR)"' | ||
| 35 | .. ' CFLAGS="$(CFLAGS)"' | ||
| 36 | .. ' LIBFLAG="$(LIBFLAG)"' | ||
| 37 | .. ' LIB_EXTENSION="$(LIB_EXTENSION)"' | ||
| 38 | .. ' OBJ_EXTENSION="$(OBJ_EXTENSION)"' | ||
| 39 | .. ' INST_LIBDIR="$(LIBDIR)"' | ||
| 40 | .. ' INST_LUADIR="$(LUADIR)"' | ||
| 41 | , | ||
| 42 | install_command = '$(LUA) build-aux/luke install --quiet' | ||
| 43 | .. ' INST_LIBDIR="$(LIBDIR)"' | ||
| 44 | .. ' LIB_EXTENSION="$(LIB_EXTENSION)"' | ||
| 45 | .. ' INST_LUADIR="$(LUADIR)"' | ||
| 46 | , | ||
| 47 | } | ||
| 48 | |||
| 49 | if _MODREV == 'git' then | ||
| 50 | dependencies[#dependencies + 1] = 'ldoc' | ||
| 51 | |||
| 52 | source = { | ||
| 53 | url = 'git://github.com/luaposix/luaposix.git', | ||
| 54 | } | ||
| 55 | end | ||
diff --git a/binary/luasec-0.7alpha-2.rockspec b/binary/luasec-0.7alpha-2.rockspec new file mode 100644 index 00000000..2736ca15 --- /dev/null +++ b/binary/luasec-0.7alpha-2.rockspec | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | package = "LuaSec" | ||
| 2 | version = "0.7alpha-2" | ||
| 3 | source = { | ||
| 4 | url = "https://github.com/brunoos/luasec/archive/luasec-0.7alpha.tar.gz", | ||
| 5 | dir = "luasec-luasec-0.7alpha" | ||
| 6 | } | ||
| 7 | description = { | ||
| 8 | summary = "A binding for OpenSSL library to provide TLS/SSL communication over LuaSocket.", | ||
| 9 | detailed = "This version delegates to LuaSocket the TCP connection establishment between the client and server. Then LuaSec uses this connection to start a secure TLS/SSL session.", | ||
| 10 | homepage = "https://github.com/brunoos/luasec/wiki", | ||
| 11 | license = "MIT" | ||
| 12 | } | ||
| 13 | dependencies = { | ||
| 14 | "lua >= 5.1", "luasocket" | ||
| 15 | } | ||
| 16 | external_dependencies = { | ||
| 17 | platforms = { | ||
| 18 | unix = { | ||
| 19 | OPENSSL = { | ||
| 20 | header = "openssl/ssl.h", | ||
| 21 | library = "ssl" | ||
| 22 | } | ||
| 23 | }, | ||
| 24 | windows = { | ||
| 25 | OPENSSL = { | ||
| 26 | header = "openssl/ssl.h", | ||
| 27 | } | ||
| 28 | }, | ||
| 29 | } | ||
| 30 | } | ||
| 31 | build = { | ||
| 32 | type = "builtin", | ||
| 33 | copy_directories = { | ||
| 34 | "samples" | ||
| 35 | }, | ||
| 36 | platforms = { | ||
| 37 | unix = { | ||
| 38 | modules = { | ||
| 39 | ['ssl.https'] = "src/https.lua", | ||
| 40 | ['ssl.init'] = "src/ssl.lua", | ||
| 41 | ssl = { | ||
| 42 | defines = { | ||
| 43 | "WITH_LUASOCKET", "LUASOCKET_DEBUG", | ||
| 44 | }, | ||
| 45 | incdirs = { | ||
| 46 | "$(OPENSSL_INCDIR)", "src/", "src/luasocket", | ||
| 47 | }, | ||
| 48 | libdirs = { | ||
| 49 | "$(OPENSSL_LIBDIR)" | ||
| 50 | }, | ||
| 51 | libraries = { | ||
| 52 | "ssl", "crypto" | ||
| 53 | }, | ||
| 54 | sources = { | ||
| 55 | "src/config.c", "src/ec.c", | ||
| 56 | "src/x509.c", "src/context.c", "src/ssl.c", | ||
| 57 | "src/luasocket/buffer.c", "src/luasocket/io.c", | ||
| 58 | "src/luasocket/timeout.c", "src/luasocket/usocket.c" | ||
| 59 | } | ||
| 60 | } | ||
| 61 | } | ||
| 62 | }, | ||
| 63 | mingw = { | ||
| 64 | modules = { | ||
| 65 | ssl = { | ||
| 66 | libraries = { | ||
| 67 | "ssl", "crypto", | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | }, | ||
| 72 | windows = { | ||
| 73 | modules = { | ||
| 74 | ['ssl.https'] = "src/https.lua", | ||
| 75 | ['ssl.init'] = "src/ssl.lua", | ||
| 76 | ssl = { | ||
| 77 | defines = { | ||
| 78 | "WIN32", "NDEBUG", "_WINDOWS", "_USRDLL", "LSEC_EXPORTS", "BUFFER_DEBUG", "LSEC_API=__declspec(dllexport)", | ||
| 79 | "WITH_LUASOCKET", "LUASOCKET_DEBUG", | ||
| 80 | "LUASEC_INET_NTOP", "WINVER=0x0501", "_WIN32_WINNT=0x0501", "NTDDI_VERSION=0x05010300" | ||
| 81 | }, | ||
| 82 | libdirs = { | ||
| 83 | "$(OPENSSL_LIBDIR)", | ||
| 84 | "$(OPENSSL_BINDIR)", | ||
| 85 | }, | ||
| 86 | libraries = { | ||
| 87 | "libssl32MD", "libcrypto32MD", "ws2_32" | ||
| 88 | }, | ||
| 89 | incdirs = { | ||
| 90 | "$(OPENSSL_INCDIR)", "src/", "src/luasocket" | ||
| 91 | }, | ||
| 92 | sources = { | ||
| 93 | "src/config.c", "src/ec.c", | ||
| 94 | "src/x509.c", "src/context.c", "src/ssl.c", | ||
| 95 | "src/luasocket/buffer.c", "src/luasocket/io.c", | ||
| 96 | "src/luasocket/timeout.c", "src/luasocket/wsocket.c" | ||
| 97 | } | ||
| 98 | } | ||
| 99 | }, | ||
| 100 | patches = { | ||
| 101 | ["lowercase-winsock-h.diff"] = [[ | ||
| 102 | diff --git a/src/ssl.c b/src/ssl.c | ||
| 103 | index 95109c4..e5defa8 100644 | ||
| 104 | --- a/src/ssl.c | ||
| 105 | +++ b/src/ssl.c | ||
| 106 | @@ -11,7 +11,7 @@ | ||
| 107 | #include <string.h> | ||
| 108 | |||
| 109 | #if defined(WIN32) | ||
| 110 | -#include <Winsock2.h> | ||
| 111 | +#include <winsock2.h> | ||
| 112 | #endif | ||
| 113 | |||
| 114 | #include <openssl/ssl.h> | ||
| 115 | ]] | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
diff --git a/binary/static-gcc b/binary/static-gcc new file mode 100755 index 00000000..a4d865d5 --- /dev/null +++ b/binary/static-gcc | |||
| @@ -0,0 +1,158 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
| 4 | |||
| 5 | function log() { echo -- "$@" >> $DIR/log.txt; } | ||
| 6 | |||
| 7 | function runlog() { log "$@"; "$@"; } | ||
| 8 | |||
| 9 | log "---------------------------" | ||
| 10 | log INP "$@" | ||
| 11 | |||
| 12 | allargs=() | ||
| 13 | sources=() | ||
| 14 | objects=() | ||
| 15 | etc=() | ||
| 16 | libdirs=("/usr/lib") | ||
| 17 | incdirs=() | ||
| 18 | |||
| 19 | linking=0 | ||
| 20 | |||
| 21 | while [ "$1" ] | ||
| 22 | do | ||
| 23 | allargs+=("$1") | ||
| 24 | if [ "$next_libdir" = "1" ] | ||
| 25 | then | ||
| 26 | libdirs+=("$1") | ||
| 27 | next_libdir=0 | ||
| 28 | elif [ "$next_incdir" = "1" ] | ||
| 29 | then | ||
| 30 | incdirs+=("-I$1") | ||
| 31 | next_incdir=0 | ||
| 32 | elif [ "$next_lib" = "1" ] | ||
| 33 | then | ||
| 34 | libs+=("$1") | ||
| 35 | next_lib=0 | ||
| 36 | elif [ "$next_output" = "1" ] | ||
| 37 | then | ||
| 38 | output="$1" | ||
| 39 | next_output=0 | ||
| 40 | else | ||
| 41 | case "$1" in | ||
| 42 | -*) | ||
| 43 | case "$1" in | ||
| 44 | -shared) | ||
| 45 | linking=1 | ||
| 46 | ;; | ||
| 47 | -static) | ||
| 48 | linking=1 | ||
| 49 | ;; | ||
| 50 | -o) | ||
| 51 | next_output=1 | ||
| 52 | ;; | ||
| 53 | -c) | ||
| 54 | object=1 | ||
| 55 | etc+=("$1") | ||
| 56 | ;; | ||
| 57 | -L) | ||
| 58 | next_libdir=1 | ||
| 59 | ;; | ||
| 60 | -L*) | ||
| 61 | libdirs+=("${1:2}") | ||
| 62 | ;; | ||
| 63 | -I) | ||
| 64 | next_incdir=1 | ||
| 65 | ;; | ||
| 66 | -I*) | ||
| 67 | incdirs+=("$1") | ||
| 68 | ;; | ||
| 69 | -l) | ||
| 70 | next_lib=1 | ||
| 71 | ;; | ||
| 72 | -l*) | ||
| 73 | libs+=("${1:2}") | ||
| 74 | ;; | ||
| 75 | *) | ||
| 76 | etc+=("$1") | ||
| 77 | ;; | ||
| 78 | esac | ||
| 79 | ;; | ||
| 80 | *.c) | ||
| 81 | sources+=("$1") | ||
| 82 | ;; | ||
| 83 | *.o) | ||
| 84 | objects+=("$1") | ||
| 85 | ;; | ||
| 86 | *) | ||
| 87 | etc+=("$1") | ||
| 88 | ;; | ||
| 89 | esac | ||
| 90 | fi | ||
| 91 | shift | ||
| 92 | done | ||
| 93 | |||
| 94 | staticlibs=() | ||
| 95 | for lib in "${libs[@]}" | ||
| 96 | do | ||
| 97 | for libdir in "${libdirs[@]}" | ||
| 98 | do | ||
| 99 | staticlib="$libdir/lib$lib.a" | ||
| 100 | if [ -e "$staticlib" ] | ||
| 101 | then | ||
| 102 | staticlibs+=("$staticlib") | ||
| 103 | break | ||
| 104 | fi | ||
| 105 | done | ||
| 106 | done | ||
| 107 | |||
| 108 | oflag=() | ||
| 109 | if [ "$output" != "" ] | ||
| 110 | then | ||
| 111 | oflag=("-o" "$output") | ||
| 112 | fi | ||
| 113 | |||
| 114 | if [ "$linking" = "1" ] | ||
| 115 | then | ||
| 116 | log LINK | ||
| 117 | if [ "${#sources[@]}" -gt 0 ] | ||
| 118 | then | ||
| 119 | for source in "${sources[@]}" | ||
| 120 | do | ||
| 121 | object="${source%.c}.o" | ||
| 122 | runlog gcc "${incdirs[@]}" "${etc[@]}" -c -o "$object" "$source" | ||
| 123 | [ "$?" = 0 ] || runlog exit $? | ||
| 124 | objects+=("$object") | ||
| 125 | done | ||
| 126 | fi | ||
| 127 | |||
| 128 | # runlog ar rcu "${oflag[@]}" "${objects[@]}" "${staticlibs[@]}" | ||
| 129 | echo "CREATE $output" > ar.script | ||
| 130 | for o in "${objects[@]}" | ||
| 131 | do | ||
| 132 | echo "ADDMOD $o" >> ar.script | ||
| 133 | done | ||
| 134 | for o in "${staticlibs[@]}" | ||
| 135 | do | ||
| 136 | echo "ADDLIB $o" >> ar.script | ||
| 137 | done | ||
| 138 | echo "SAVE" >> ar.script | ||
| 139 | echo "END" >> ar.script | ||
| 140 | cat ar.script | ar -M | ||
| 141 | [ "$?" = 0 ] || runlog exit $? | ||
| 142 | |||
| 143 | [ -e "$output" ] || { | ||
| 144 | exit 1 | ||
| 145 | } | ||
| 146 | |||
| 147 | runlog ranlib "$output" | ||
| 148 | runlog exit $? | ||
| 149 | elif [ "$object" = 1 ] | ||
| 150 | then | ||
| 151 | log OBJECT | ||
| 152 | runlog gcc "${oflag[@]}" "${incdirs[@]}" "${etc[@]}" "${sources[@]}" | ||
| 153 | runlog exit $? | ||
| 154 | else | ||
| 155 | log EXECUTABLE | ||
| 156 | runlog gcc "${allargs[@]}" | ||
| 157 | runlog exit $? | ||
| 158 | fi | ||
| @@ -1,74 +1,44 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # A basic configure script for LuaRocks. | ||
| 4 | # Not doing any fancy shell stuff here to keep good compatibility. | ||
| 5 | |||
| 6 | # Defaults | 3 | # Defaults |
| 7 | 4 | ||
| 8 | PREFIX="/usr/local" | 5 | PREFIX="/usr/local" |
| 9 | SYSCONFDIR="$PREFIX/etc/luarocks" | 6 | SYSCONFDIR="$PREFIX/etc/luarocks" |
| 10 | ROCKS_TREE="$PREFIX" | 7 | ROCKS_TREE="$PREFIX" |
| 11 | LUA_SUFFIX="" | ||
| 12 | LUA_DIR="/usr" | ||
| 13 | LUA_BINDIR="/usr/bin" | ||
| 14 | LUA_INCDIR="/usr/include" | ||
| 15 | LUA_LIBDIR="/usr/lib" | ||
| 16 | LUA_VERSION="5.1" | ||
| 17 | MULTIARCH_SUBDIR="" | ||
| 18 | 8 | ||
| 19 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 20 | # FUNCTION DEFINITIONS | 10 | # FUNCTION DEFINITIONS |
| 21 | # ---------------------------------------------------------------------------- | 11 | # ---------------------------------------------------------------------------- |
| 22 | 12 | ||
| 23 | # Help | 13 | # Utility functions |
| 14 | # ----------------- | ||
| 24 | 15 | ||
| 25 | show_help() { | 16 | # Resolves a full path |
| 26 | cat <<EOF | 17 | # - alternative to "readlink -f", which is not available on solaris |
| 27 | Configure LuaRocks. | 18 | # based on https://stackoverflow.com/a/6554854/1793220 |
| 28 | 19 | canonicalpath() { | |
| 29 | --help This help. | 20 | oldpwd="$PWD" |
| 30 | --prefix=DIR Prefix where LuaRocks should be installed. | 21 | if [ -d "$1" ] |
| 31 | Default is $PREFIX | 22 | then |
| 32 | --sysconfdir=DIR Location where the config file should be installed. | 23 | if cd "$1" >/dev/null 2>&1 |
| 33 | Default is \$PREFIX/etc/luarocks | 24 | then |
| 34 | 25 | echo "$PWD" | |
| 35 | Where to install files installed by rocks, to make the accessible to Lua and | 26 | else |
| 36 | your \$PATH. Beware of clashes between files installed by LuaRocks and by your | 27 | echo "$1" |
| 37 | system's package manager. | 28 | fi |
| 38 | 29 | else | |
| 39 | --rocks-tree=DIR Root of the local tree of installed rocks. | 30 | if cd "$(dirname "$1")" >/dev/null 2>&1 |
| 40 | Default is \$PREFIX | 31 | then |
| 41 | 32 | echo "$PWD/$(basename "$1")" | |
| 42 | --lua-version=VERSION Use specific Lua version: 5.1, 5.2, 5.3, or 5.4 | 33 | else |
| 43 | Default is auto-detected. | 34 | echo "$1" |
| 44 | --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. | 35 | fi |
| 45 | Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) | 36 | fi |
| 46 | --with-lua=PREFIX Use Lua from given prefix. | 37 | cd "$oldpwd" >/dev/null 2>&1 || return |
| 47 | Default is auto-detected (the parent directory of \$LUA_BINDIR). | ||
| 48 | --with-lua-bin=DIR You can also specify Lua's bin dir. | ||
| 49 | Default is the directory of the auto-detected Lua interpreter, | ||
| 50 | or \$LUA_DIR/bin if --with-lua is used. | ||
| 51 | --with-lua-include=DIR You can also specify Lua's includes dir. | ||
| 52 | Default is \$LUA_DIR/include | ||
| 53 | --with-lua-lib=DIR You can also specify Lua's libraries dir. | ||
| 54 | Default is \$LUA_DIR/lib | ||
| 55 | --with-downloader=TOOL Which tool to use as a downloader. | ||
| 56 | Valid options are: curl, wget. | ||
| 57 | Default is to auto-detect. | ||
| 58 | --with-md5-checker=TOOL Which tool to use as a downloader. | ||
| 59 | Valid options are: md5sum, openssl | ||
| 60 | Default is to auto-detect. | ||
| 61 | --force-config Use a single config location. Do not use the | ||
| 62 | \$LUAROCKS_CONFIG variable or the user's home | ||
| 63 | directory. Useful to avoid conflicts when LuaRocks | ||
| 64 | is embedded within an application. | ||
| 65 | EOF | ||
| 66 | } | 38 | } |
| 67 | 39 | ||
| 68 | # Helper functions | ||
| 69 | |||
| 70 | find_program() { | 40 | find_program() { |
| 71 | prog=`command -v "$1" 2>/dev/null` | 41 | prog=$(command -v "$1" 2>/dev/null) |
| 72 | if [ -n "$prog" ] | 42 | if [ -n "$prog" ] |
| 73 | then | 43 | then |
| 74 | dirname "$prog" | 44 | dirname "$prog" |
| @@ -78,37 +48,154 @@ find_program() { | |||
| 78 | die() { | 48 | die() { |
| 79 | echo "$*" | 49 | echo "$*" |
| 80 | echo | 50 | echo |
| 81 | echo "configure failed." | 51 | RED "configure failed." |
| 52 | echo | ||
| 82 | echo | 53 | echo |
| 83 | exit 1 | 54 | exit 1 |
| 84 | } | 55 | } |
| 85 | 56 | ||
| 86 | find_helper() { | 57 | echo_n() { |
| 87 | explanation="$1" | 58 | printf "%s" "$*" |
| 88 | shift | 59 | } |
| 89 | tried="$*" | 60 | |
| 90 | while [ -n "$1" ] | 61 | bold='\033[1m' |
| 91 | do | 62 | red='\033[1;31m' |
| 92 | found=`find_program "$1"` | 63 | green='\033[1;32m' |
| 93 | if [ -n "$found" ] | 64 | blue='\033[1;36m' |
| 65 | reset='\033[0m' | ||
| 66 | |||
| 67 | BOLD() { | ||
| 68 | printf "$bold%s$reset" "$*" | ||
| 69 | } | ||
| 70 | |||
| 71 | RED() { | ||
| 72 | printf "$red%s$reset" "$*" | ||
| 73 | } | ||
| 74 | |||
| 75 | GREEN() { | ||
| 76 | printf "$green%s$reset" "$*" | ||
| 77 | } | ||
| 78 | |||
| 79 | BLUE() { | ||
| 80 | printf "$blue%s$reset" "$*" | ||
| 81 | } | ||
| 82 | |||
| 83 | # Help | ||
| 84 | # ---- | ||
| 85 | |||
| 86 | show_help() { | ||
| 87 | cat <<EOF | ||
| 88 | |||
| 89 | Configure the build process of LuaRocks. | ||
| 90 | |||
| 91 | --help This help. | ||
| 92 | |||
| 93 | Where to install LuaRocks: | ||
| 94 | -------------------------- | ||
| 95 | |||
| 96 | --prefix=PREFIX Directory where LuaRocks should be installed. | ||
| 97 | - Default is $PREFIX | ||
| 98 | --sysconfdir=SYSCONFDIR Where the config file should be installed. | ||
| 99 | - Default is $SYSCONFDIR | ||
| 100 | (PREFIX/etc/luarocks) | ||
| 101 | |||
| 102 | Where to install files provided by rocks: | ||
| 103 | ----------------------------------------- | ||
| 104 | |||
| 105 | --rocks-tree=ROCKS_DIR Root of the local tree of installed rocks. | ||
| 106 | To make files installed in this location | ||
| 107 | accessible to Lua and your \$PATH, see | ||
| 108 | "luarocks path --help" after installation. | ||
| 109 | Avoid using paths controlled by your | ||
| 110 | system's package manager, such as /usr. | ||
| 111 | - Default is $PREFIX | ||
| 112 | (PREFIX) | ||
| 113 | |||
| 114 | Where is your Lua interpreter: | ||
| 115 | ------------------------------ | ||
| 116 | |||
| 117 | --lua-version=VERSION) Use specific Lua version: 5.1, 5.2, 5.3, or 5.4 | ||
| 118 | - Default is auto-detected. | ||
| 119 | --with-lua=LUA_DIR) Use Lua from given directory. | ||
| 120 | - Default is auto-detected from your \$PATH | ||
| 121 | (or the parent directory of LUA_BINDIR | ||
| 122 | if --with-lua-bin is used). | ||
| 123 | --with-lua-bin=LUA_BINDIR) You can also specify Lua's bin dir. | ||
| 124 | - Default is the directory of the | ||
| 125 | auto-detected Lua interpreter, | ||
| 126 | (or LUA_DIR/bin if --with-lua is used) | ||
| 127 | --with-lua-include=LUA_INCDIR) Lua's includes dir. | ||
| 128 | - Default is LUA_DIR/include | ||
| 129 | --with-lua-lib=LUA_LIBDIR) Lua's libraries dir. | ||
| 130 | - Default is LUA_DIR/lib | ||
| 131 | |||
| 132 | For specialized uses of LuaRocks: | ||
| 133 | --------------------------------- | ||
| 134 | |||
| 135 | --force-config) Force using a single config location. | ||
| 136 | Do not honor the \$LUAROCKS_CONFIG_5_x | ||
| 137 | or \$LUAROCKS_CONFIG environment | ||
| 138 | variable or the user's local config. | ||
| 139 | Useful to avoid conflicts when LuaRocks | ||
| 140 | is embedded within an application. | ||
| 141 | |||
| 142 | EOF | ||
| 143 | } | ||
| 144 | |||
| 145 | # Lua detection | ||
| 146 | # ------------- | ||
| 147 | |||
| 148 | detect_lua_version() { | ||
| 149 | detected_lua=$($1 -e 'print(_VERSION:match(" (5%.[1234])$"))' 2> /dev/null) | ||
| 150 | if [ "$detected_lua" != "nil" ] | ||
| 151 | then | ||
| 152 | if [ "$LUA_VERSION_SET" != "yes" ] | ||
| 94 | then | 153 | then |
| 95 | echo "$1 found at $found" | 154 | echo "Lua version detected: $(GREEN "$detected_lua")" |
| 96 | HELPER=$1 | 155 | LUA_VERSION=$detected_lua |
| 97 | return | 156 | return 0 |
| 157 | elif [ "$LUA_VERSION" = "$detected_lua" ] | ||
| 158 | then | ||
| 159 | return 0 | ||
| 98 | fi | 160 | fi |
| 99 | shift | 161 | fi |
| 100 | done | 162 | return 1 |
| 101 | echo "Could not find $explanation. Tried: $tried." | ||
| 102 | die "Make sure one of them is installed and available in your PATH." | ||
| 103 | } | 163 | } |
| 104 | 164 | ||
| 105 | case `echo -n x` in | 165 | search_interpreter() { |
| 106 | -n*) echo_n_flag='';; | 166 | suffix="$1" |
| 107 | *) echo_n_flag='-n';; | 167 | lua_at="" |
| 108 | esac | 168 | if [ "$LUA_BINDIR_SET" = "yes" ] |
| 109 | 169 | then | |
| 110 | echo_n() { | 170 | lua_at="$LUA_BINDIR" |
| 111 | echo $echo_n_flag "$*" | 171 | elif [ "$LUA_DIR_SET" = "yes" ] |
| 172 | then | ||
| 173 | LUA_BINDIR="$LUA_DIR/bin" | ||
| 174 | if [ -f "$LUA_BINDIR/lua$suffix" ] | ||
| 175 | then | ||
| 176 | lua_at="$LUA_BINDIR" | ||
| 177 | fi | ||
| 178 | else | ||
| 179 | lua_at=$(find_program "lua$suffix") | ||
| 180 | fi | ||
| 181 | if [ -n "$lua_at" ] && [ -x "$lua_at/lua$suffix" ] | ||
| 182 | then | ||
| 183 | if detect_lua_version "$lua_at/lua$suffix" | ||
| 184 | then | ||
| 185 | echo "Lua interpreter found: $(GREEN "$lua_at/lua$suffix")" | ||
| 186 | if [ "$LUA_BINDIR_SET" != "yes" ] | ||
| 187 | then | ||
| 188 | LUA_BINDIR="$lua_at" | ||
| 189 | fi | ||
| 190 | if [ "$LUA_DIR_SET" != "yes" ] | ||
| 191 | then | ||
| 192 | LUA_DIR=$(dirname "$lua_at") | ||
| 193 | fi | ||
| 194 | LUA_INTERPRETER="lua$suffix" | ||
| 195 | return 0 | ||
| 196 | fi | ||
| 197 | fi | ||
| 198 | return 1 | ||
| 112 | } | 199 | } |
| 113 | 200 | ||
| 114 | # ---------------------------------------------------------------------------- | 201 | # ---------------------------------------------------------------------------- |
| @@ -119,89 +206,97 @@ echo_n() { | |||
| 119 | 206 | ||
| 120 | while [ -n "$1" ] | 207 | while [ -n "$1" ] |
| 121 | do | 208 | do |
| 122 | value="`echo $1 | sed 's/[^=]*.\(.*\)/\1/'`" | 209 | value="$(echo "$1" | sed 's/[^=]*.\(.*\)/\1/')" |
| 123 | key="`echo $1 | sed 's/=.*//'`" | 210 | key="$(echo "$1" | sed 's/=.*//')" |
| 124 | if `echo "$value" | grep "~" >/dev/null 2>/dev/null` | 211 | if echo "$value" | grep "~" >/dev/null 2>/dev/null |
| 125 | then | 212 | then |
| 126 | echo | 213 | echo |
| 127 | echo '*WARNING*: the "~" sign is not expanded in flags.' | 214 | echo "$(RED WARNING:) the '~' sign is not expanded in flags." |
| 128 | echo 'If you mean the home directory, use $HOME instead.' | 215 | echo "If you mean the home directory, use \$HOME instead." |
| 129 | echo | 216 | echo |
| 130 | fi | 217 | fi |
| 131 | case "$key" in | 218 | case "$key" in |
| 219 | |||
| 220 | # Help | ||
| 221 | # ---- | ||
| 132 | --help) | 222 | --help) |
| 133 | show_help | 223 | show_help |
| 134 | exit 0 | 224 | exit 0 |
| 135 | ;; | 225 | ;; |
| 226 | |||
| 227 | # Where to install LuaRocks: | ||
| 228 | # -------------------------- | ||
| 136 | --prefix) | 229 | --prefix) |
| 137 | [ -n "$value" ] || die "Missing value in flag $key." | 230 | [ -n "$value" ] || die "Missing value in flag $key." |
| 138 | PREFIX="$value" | 231 | PREFIX="$(canonicalpath "$value")" |
| 139 | PREFIX_SET=yes | 232 | PREFIX_SET=yes |
| 140 | ;; | 233 | ;; |
| 141 | --sysconfdir) | 234 | --sysconfdir) |
| 142 | [ -n "$value" ] || die "Missing value in flag $key." | 235 | [ -n "$value" ] || die "Missing value in flag $key." |
| 143 | SYSCONFDIR="$value" | 236 | SYSCONFDIR="$(canonicalpath "$value")" |
| 144 | SYSCONFDIR_SET=yes | 237 | SYSCONFDIR_SET=yes |
| 145 | ;; | 238 | ;; |
| 239 | |||
| 240 | |||
| 241 | # Where to install files provided by rocks: | ||
| 242 | # ----------------------------------------- | ||
| 146 | --rocks-tree) | 243 | --rocks-tree) |
| 147 | [ -n "$value" ] || die "Missing value in flag $key." | 244 | [ -n "$value" ] || die "Missing value in flag $key." |
| 148 | ROCKS_TREE="$value" | 245 | ROCKS_TREE="$(canonicalpath "$value")" |
| 149 | ROCKS_TREE_SET=yes | 246 | ROCKS_TREE_SET=yes |
| 150 | ;; | 247 | ;; |
| 151 | --force-config) | 248 | |
| 152 | FORCE_CONFIG=yes | 249 | # Where is your Lua interpreter: |
| 153 | ;; | 250 | # ------------------------------ |
| 154 | --versioned-rocks-dir) | ||
| 155 | echo "--versioned-rocks-dir is no longer necessary." | ||
| 156 | echo "The rocks tree in LuaRocks 3.0 is always versioned." | ||
| 157 | ;; | ||
| 158 | --lua-suffix) | ||
| 159 | [ -n "$value" ] || die "Missing value in flag $key." | ||
| 160 | LUA_SUFFIX="$value" | ||
| 161 | LUA_SUFFIX_SET=yes | ||
| 162 | ;; | ||
| 163 | --lua-version|--with-lua-version) | 251 | --lua-version|--with-lua-version) |
| 164 | [ -n "$value" ] || die "Missing value in flag $key." | 252 | [ -n "$value" ] || die "Missing value in flag $key." |
| 165 | LUA_VERSION="$value" | 253 | LUA_VERSION="$value" |
| 166 | [ "$LUA_VERSION" = "5.1" -o "$LUA_VERSION" = "5.2" -o "$LUA_VERSION" = "5.3" -o "$LUA_VERSION" = "5.4" ] || die "Invalid Lua version in flag $key." | 254 | case "$LUA_VERSION" in |
| 255 | 5.1|5.2|5.3|5.4) ;; | ||
| 256 | *) die "Invalid Lua version in flag $key." | ||
| 257 | esac | ||
| 167 | LUA_VERSION_SET=yes | 258 | LUA_VERSION_SET=yes |
| 168 | ;; | 259 | ;; |
| 169 | --with-lua) | 260 | --with-lua) |
| 170 | [ -n "$value" ] || die "Missing value in flag $key." | 261 | [ -n "$value" ] || die "Missing value in flag $key." |
| 171 | LUA_DIR="$value" | 262 | LUA_DIR="$(canonicalpath "$value")" |
| 263 | [ -d "$LUA_DIR" ] || die "Bad value for --with-lua: $LUA_DIR is not a valid directory." | ||
| 172 | LUA_DIR_SET=yes | 264 | LUA_DIR_SET=yes |
| 173 | ;; | 265 | ;; |
| 174 | --with-lua-bin) | 266 | --with-lua-bin) |
| 175 | [ -n "$value" ] || die "Missing value in flag $key." | 267 | [ -n "$value" ] || die "Missing value in flag $key." |
| 176 | LUA_BINDIR="$value" | 268 | LUA_BINDIR="$(canonicalpath "$value")" |
| 269 | [ -d "$LUA_BINDIR" ] || die "Bad value for --with-lua-bin: $LUA_BINDIR is not a valid directory." | ||
| 177 | LUA_BINDIR_SET=yes | 270 | LUA_BINDIR_SET=yes |
| 178 | ;; | 271 | ;; |
| 179 | --with-lua-include) | 272 | --with-lua-include) |
| 180 | [ -n "$value" ] || die "Missing value in flag $key." | 273 | [ -n "$value" ] || die "Missing value in flag $key." |
| 181 | LUA_INCDIR="$value" | 274 | LUA_INCDIR="$(canonicalpath "$value")" |
| 182 | LUA_INCDIR_SET=yes | 275 | [ -d "$LUA_INCDIR" ] || die "Bad value for --with-lua-include: $LUA_INCDIR is not a valid directory." |
| 183 | ;; | 276 | ;; |
| 184 | --with-lua-lib) | 277 | --with-lua-lib) |
| 185 | [ -n "$value" ] || die "Missing value in flag $key." | 278 | [ -n "$value" ] || die "Missing value in flag $key." |
| 186 | LUA_LIBDIR="$value" | 279 | LUA_LIBDIR="$(canonicalpath "$value")" |
| 187 | LUA_LIBDIR_SET=yes | 280 | [ -d "$LUA_LIBDIR" ] || die "Bad value for --with-lua-lib: $LUA_LIBDIR is not a valid directory." |
| 188 | ;; | 281 | ;; |
| 189 | --with-downloader) | 282 | |
| 190 | [ -n "$value" ] || die "Missing value in flag $key." | 283 | # For specialized uses of LuaRocks: |
| 191 | case "$value" in | 284 | # --------------------------------- |
| 192 | wget|curl) LUAROCKS_DOWNLOADER="$value" ;; | 285 | --force-config) |
| 193 | *) die "Invalid option: $value. See --help." ;; | 286 | FORCE_CONFIG=yes |
| 194 | esac | ||
| 195 | LUAROCKS_DOWNLOADER_SET=yes | ||
| 196 | ;; | 287 | ;; |
| 197 | --with-md5-checker) | 288 | |
| 198 | [ -n "$value" ] || die "Missing value in flag $key." | 289 | # Old options that no longer apply |
| 199 | case "$value" in | 290 | # -------------------------------- |
| 200 | md5sum|openssl|md5) LUAROCKS_MD5CHECKER="$value" ;; | 291 | --versioned-rocks-dir) |
| 201 | *) die "Invalid option: $value. See --help." ;; | 292 | echo "--versioned-rocks-dir is no longer necessary." |
| 202 | esac | 293 | echo "The rocks tree in LuaRocks 3.0 is always versioned." |
| 203 | LUAROCKS_MD5CHECKER_SET=yes | ||
| 204 | ;; | 294 | ;; |
| 295 | --lua-suffix) | ||
| 296 | echo "--lua-suffix is no longer necessary." | ||
| 297 | echo "The suffix is automatically detected." | ||
| 298 | ;; | ||
| 299 | |||
| 205 | *) | 300 | *) |
| 206 | die "Error: Unknown flag: $1" | 301 | die "Error: Unknown flag: $1" |
| 207 | ;; | 302 | ;; |
| @@ -209,7 +304,16 @@ do | |||
| 209 | shift | 304 | shift |
| 210 | done | 305 | done |
| 211 | 306 | ||
| 212 | if [ "$PREFIX_SET" = "yes" -a ! "$SYSCONFDIR_SET" = "yes" ] | 307 | echo |
| 308 | BLUE "Configuring LuaRocks..." | ||
| 309 | echo | ||
| 310 | echo | ||
| 311 | |||
| 312 | # ---------------------------------------- | ||
| 313 | # Derive options from the ones given | ||
| 314 | # ---------------------------------------- | ||
| 315 | |||
| 316 | if [ "$PREFIX_SET" = "yes" ] && [ ! "$SYSCONFDIR_SET" = "yes" ] | ||
| 213 | then | 317 | then |
| 214 | if [ "$PREFIX" = "/usr" ] | 318 | if [ "$PREFIX" = "/usr" ] |
| 215 | then SYSCONFDIR=/etc/luarocks | 319 | then SYSCONFDIR=/etc/luarocks |
| @@ -217,260 +321,129 @@ then | |||
| 217 | fi | 321 | fi |
| 218 | fi | 322 | fi |
| 219 | 323 | ||
| 220 | 324 | if [ "$PREFIX_SET" = "yes" ] && [ ! "$ROCKS_TREE_SET" = "yes" ] | |
| 221 | if [ "$PREFIX_SET" = "yes" -a ! "$ROCKS_TREE_SET" = "yes" ] | ||
| 222 | then | 325 | then |
| 223 | ROCKS_TREE=$PREFIX | 326 | ROCKS_TREE=$PREFIX |
| 224 | fi | 327 | fi |
| 225 | 328 | ||
| 226 | detect_lua_version() { | 329 | # ---------------------------------------- |
| 227 | detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[1234])$"))' 2> /dev/null` | 330 | # Search for Lua |
| 228 | if [ "$detected_lua" != "nil" ] | 331 | # ---------------------------------------- |
| 229 | then | ||
| 230 | if [ "$LUA_VERSION_SET" != "yes" ] | ||
| 231 | then | ||
| 232 | echo "Lua version detected: $detected_lua" | ||
| 233 | LUA_VERSION=$detected_lua | ||
| 234 | return 0 | ||
| 235 | elif [ "$LUA_VERSION" = "$detected_lua" ] | ||
| 236 | then | ||
| 237 | return 0 | ||
| 238 | fi | ||
| 239 | fi | ||
| 240 | return 1 | ||
| 241 | } | ||
| 242 | |||
| 243 | search_interpreter() { | ||
| 244 | suffix="$1" | ||
| 245 | if [ "$LUA_BINDIR_SET" = "yes" ] | ||
| 246 | then | ||
| 247 | find_lua="$LUA_BINDIR" | ||
| 248 | elif [ "$LUA_DIR_SET" = "yes" ] | ||
| 249 | then | ||
| 250 | LUA_BINDIR="$LUA_DIR/bin" | ||
| 251 | if [ -f "$LUA_BINDIR/lua$suffix" ] | ||
| 252 | then | ||
| 253 | find_lua="$LUA_BINDIR" | ||
| 254 | fi | ||
| 255 | else | ||
| 256 | find_lua=`find_program lua$suffix` | ||
| 257 | fi | ||
| 258 | if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ] | ||
| 259 | then | ||
| 260 | if detect_lua_version "$find_lua/lua$suffix" | ||
| 261 | then | ||
| 262 | echo "Lua interpreter found: $find_lua/lua$suffix..." | ||
| 263 | if [ "$LUA_BINDIR_SET" != "yes" ] | ||
| 264 | then | ||
| 265 | LUA_BINDIR="$find_lua" | ||
| 266 | fi | ||
| 267 | if [ "$LUA_DIR_SET" != "yes" ] | ||
| 268 | then | ||
| 269 | LUA_DIR=`dirname "$find_lua"` | ||
| 270 | fi | ||
| 271 | LUA_SUFFIX="$suffix" | ||
| 272 | return 0 | ||
| 273 | fi | ||
| 274 | fi | ||
| 275 | return 1 | ||
| 276 | } | ||
| 277 | 332 | ||
| 278 | lua_interp_found=no | 333 | lua_interp_found=no |
| 279 | if [ "$LUA_SUFFIX_SET" != "yes" ] | 334 | |
| 280 | then | 335 | case "$LUA_VERSION" in |
| 281 | if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ] | 336 | 5.1) |
| 282 | then | 337 | suffixes="5.1 51 -5.1 -51 jit" |
| 283 | suffixes="5.1 51 -5.1 -51" | 338 | ;; |
| 284 | elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.2" ] | 339 | 5.2) |
| 285 | then | 340 | suffixes="5.2 52 -5.2 -52" |
| 286 | suffixes="5.2 52 -5.2 -52" | 341 | ;; |
| 287 | elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.3" ] | 342 | 5.3) |
| 288 | then | 343 | suffixes="5.3 53 -5.3 -53" |
| 289 | suffixes="5.4 54 -5.4 -54" | 344 | ;; |
| 290 | elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.4" ] | 345 | 5.4) |
| 291 | then | 346 | suffixes="5.4 54 -5.4 -54" |
| 292 | suffixes="5.3 53 -5.3 -53" | 347 | ;; |
| 293 | else | 348 | *) |
| 294 | suffixes="5.4 54 -5.4 -54 5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51" | 349 | suffixes="5.4 54 -5.4 -54 5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51 jit" |
| 295 | fi | 350 | ;; |
| 296 | for suffix in `echo $suffixes` "" | 351 | esac |
| 297 | do | 352 | |
| 298 | search_interpreter "$suffix" && { | 353 | for suffix in $suffixes "" |
| 299 | lua_interp_found=yes | 354 | do |
| 300 | break | 355 | search_interpreter "$suffix" && { |
| 301 | } | ||
| 302 | done | ||
| 303 | else | ||
| 304 | search_interpreter "$LUA_SUFFIX" && { | ||
| 305 | lua_interp_found=yes | 356 | lua_interp_found=yes |
| 357 | break | ||
| 306 | } | 358 | } |
| 307 | fi | 359 | done |
| 308 | 360 | ||
| 309 | if [ "$lua_interp_found" != "yes" ] | 361 | if [ "$lua_interp_found" != "yes" ] |
| 310 | then | 362 | then |
| 311 | [ "$LUA_VERSION_SET" ] && { interp="Lua $LUA_VERSION" ;} || { interp="Lua" ;} | 363 | if [ "$LUA_VERSION_SET" ] |
| 312 | [ "$LUA_DIR_SET" -o "$LUA_BINDIR_SET" ] && { where="$LUA_BINDIR" ;} || { where="\$PATH" ;} | ||
| 313 | echo "$interp interpreter not found in $where" | ||
| 314 | die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help." | ||
| 315 | fi | ||
| 316 | |||
| 317 | if [ "$LUA_VERSION_SET" = "yes" ] | ||
| 318 | then | ||
| 319 | echo_n "Checking if $LUA_BINDIR/lua$LUA_SUFFIX is Lua version $LUA_VERSION... " | ||
| 320 | if detect_lua_version "$LUA_BINDIR/lua$LUA_SUFFIX" | ||
| 321 | then | 364 | then |
| 322 | echo "yes" | 365 | interp="Lua $LUA_VERSION" |
| 323 | else | 366 | else |
| 324 | echo "no" | 367 | interp="Lua" |
| 325 | die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help." | ||
| 326 | fi | 368 | fi |
| 327 | fi | 369 | if [ "$LUA_DIR_SET" ] || [ "$LUA_BINDIR_SET" ] |
| 328 | |||
| 329 | if [ "$LUA_INCDIR_SET" != "yes" ] | ||
| 330 | then | ||
| 331 | LUA_INCDIR="$LUA_DIR/include" | ||
| 332 | fi | ||
| 333 | |||
| 334 | if [ "$LUA_LIBDIR_SET" != "yes" ] | ||
| 335 | then | ||
| 336 | LUA_LIBDIR="$LUA_DIR/lib" | ||
| 337 | fi | ||
| 338 | |||
| 339 | echo_n "Checking Lua includes... " | ||
| 340 | lua_h="$LUA_INCDIR/lua.h" | ||
| 341 | if [ -f "$lua_h" ] | ||
| 342 | then | ||
| 343 | echo "lua.h found in $lua_h" | ||
| 344 | else | ||
| 345 | v_dir="$LUA_INCDIR/lua/$LUA_VERSION" | ||
| 346 | lua_h="$v_dir/lua.h" | ||
| 347 | if [ -f "$lua_h" ] | ||
| 348 | then | 370 | then |
| 349 | echo "lua.h found in $lua_h" | 371 | where="$LUA_BINDIR" |
| 350 | LUA_INCDIR="$v_dir" | ||
| 351 | else | 372 | else |
| 352 | d_dir="$LUA_INCDIR/lua$LUA_VERSION" | 373 | where="\$PATH" |
| 353 | lua_h="$d_dir/lua.h" | ||
| 354 | if [ -f "$lua_h" ] | ||
| 355 | then | ||
| 356 | echo "lua.h found in $lua_h (Debian/Ubuntu)" | ||
| 357 | LUA_INCDIR="$d_dir" | ||
| 358 | else | ||
| 359 | echo "lua.h not found (looked in $LUA_INCDIR, $v_dir, $d_dir)" | ||
| 360 | die "You may want to use the flag --with-lua or --with-lua-include. See --help." | ||
| 361 | fi | ||
| 362 | fi | 374 | fi |
| 375 | echo "$(RED $interp interpreter not found) in $where" | ||
| 376 | echo "You may want to use the flags $(BOLD --with-lua), $(BOLD --with-lua-bin) and/or $(BOLD --lua-version)" | ||
| 377 | die "Run $(BOLD ./configure --help) for details." | ||
| 363 | fi | 378 | fi |
| 364 | 379 | ||
| 365 | echo_n "Checking if Lua header version matches that of the interpreter... " | 380 | if [ "$LUA_VERSION_SET" = "yes" ] |
| 366 | header_version=$(sed -n 's/.*LUA_VERSION_NUM.*5.\(.\).*/5.\1/p' "$lua_h") | ||
| 367 | if [ "$header_version" = "$LUA_VERSION" ] | ||
| 368 | then | ||
| 369 | echo "yes" | ||
| 370 | else | ||
| 371 | echo "no" | ||
| 372 | echo "lua.h version mismatch (interpreter: $LUA_VERSION; lua.h: $header_version)." | ||
| 373 | die "You may want to use the flag --with-lua or --with-lua-include. See --help." | ||
| 374 | fi | ||
| 375 | |||
| 376 | |||
| 377 | if [ "$LUAROCKS_DOWNLOADER_SET" != "yes" ] | ||
| 378 | then | ||
| 379 | find_helper "a downloader helper program" curl wget fetch | ||
| 380 | LUAROCKS_DOWNLOADER=$HELPER | ||
| 381 | fi | ||
| 382 | |||
| 383 | if [ "$LUAROCKS_MD5CHECKER_SET" != "yes" ] | ||
| 384 | then | ||
| 385 | find_helper "a MD5 checksum calculator" md5sum openssl md5 | ||
| 386 | LUAROCKS_MD5CHECKER=$HELPER | ||
| 387 | fi | ||
| 388 | |||
| 389 | find_helper "an 'unzip' program" unzip | ||
| 390 | |||
| 391 | echo_n "Configuring for system... " | ||
| 392 | if uname -s | ||
| 393 | then | ||
| 394 | LUAROCKS_UNAME_S=`uname -s` | ||
| 395 | else | ||
| 396 | die "Could not determine operating system. 'uname -s' failed." | ||
| 397 | fi | ||
| 398 | echo_n "Configuring for architecture... " | ||
| 399 | if uname -m | ||
| 400 | then | ||
| 401 | LUAROCKS_UNAME_M=`uname -m` | ||
| 402 | else | ||
| 403 | die "Could not determine processor architecture. 'uname -m' failed." | ||
| 404 | fi | ||
| 405 | |||
| 406 | for v in 5.1 5.2 5.3 5.4; do | ||
| 407 | if [ "$v" != "$LUA_VERSION" ]; then | ||
| 408 | if [ -e "$PREFIX/share/lua/$v/luarocks/site_config.lua" ]; then | ||
| 409 | LUA_OTHER_VERSION="$v" | ||
| 410 | break | ||
| 411 | fi | ||
| 412 | fi | ||
| 413 | done | ||
| 414 | |||
| 415 | if [ "$LUAROCKS_UNAME_S" = Linux ] | ||
| 416 | then | 381 | then |
| 417 | GCC_ARCH=`gcc -print-multiarch 2>/dev/null` | 382 | echo_n "Checking if $LUA_BINDIR/$LUA_INTERPRETER is Lua version $LUA_VERSION... " |
| 418 | if [ -n "$GCC_ARCH" -a -d "/usr/lib/$GCC_ARCH" ] | 383 | if detect_lua_version "$LUA_BINDIR/$LUA_INTERPRETER" |
| 419 | then | ||
| 420 | MULTIARCH_SUBDIR="lib/$GCC_ARCH" | ||
| 421 | elif [ -d "/usr/lib64" ] | ||
| 422 | then | 384 | then |
| 423 | # Useful for Fedora systems | 385 | echo "yes" |
| 424 | MULTIARCH_SUBDIR="lib64" | 386 | else |
| 387 | echo "no" | ||
| 388 | die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-version. See --help." | ||
| 425 | fi | 389 | fi |
| 426 | fi | 390 | fi |
| 427 | 391 | ||
| 428 | if [ -f config.unix ]; then | 392 | unzip_found=$(find_program "unzip") |
| 429 | rm -f config.unix | 393 | if [ -n "$unzip_found" ] |
| 394 | then | ||
| 395 | echo "unzip found in PATH: $(GREEN "$unzip_found")" | ||
| 396 | else | ||
| 397 | RED "Could not find 'unzip'." | ||
| 398 | die "Make sure it is installed and available in your PATH." | ||
| 430 | fi | 399 | fi |
| 431 | 400 | ||
| 432 | SITE_CONFIG=src/luarocks/core/site_config_$(echo "$LUA_VERSION" | sed 's,\.,_,').lua | ||
| 433 | |||
| 434 | # Write config | 401 | # Write config |
| 435 | 402 | ||
| 436 | echo "Writing configuration..." | 403 | make clean > /dev/null 2> /dev/null |
| 437 | echo | ||
| 438 | 404 | ||
| 439 | rm -f built | 405 | rm -f built |
| 440 | cat <<EOF > config.unix | 406 | cat <<EOF > config.unix |
| 441 | # This file was automatically generated by the configure script. | 407 | # This file was automatically generated by the configure script. |
| 442 | # Run "./configure --help" for details. | 408 | # Run "./configure --help" for details. |
| 443 | 409 | ||
| 444 | LUA_VERSION=$LUA_VERSION | ||
| 445 | SITE_CONFIG=$SITE_CONFIG | ||
| 446 | PREFIX=$PREFIX | 410 | PREFIX=$PREFIX |
| 447 | SYSCONFDIR=$SYSCONFDIR | 411 | SYSCONFDIR=$SYSCONFDIR |
| 448 | ROCKS_TREE=$ROCKS_TREE | 412 | ROCKS_TREE=$ROCKS_TREE |
| 449 | LUA_SUFFIX=$LUA_SUFFIX | 413 | LUA_VERSION=$LUA_VERSION |
| 414 | LUA_INTERPRETER=$LUA_INTERPRETER | ||
| 450 | LUA_DIR=$LUA_DIR | 415 | LUA_DIR=$LUA_DIR |
| 451 | LUA_DIR_SET=$LUA_DIR_SET | 416 | LUA_BINDIR=$LUA_BINDIR |
| 452 | LUA_INCDIR=$LUA_INCDIR | 417 | LUA_INCDIR=$LUA_INCDIR |
| 453 | LUA_LIBDIR=$LUA_LIBDIR | 418 | LUA_LIBDIR=$LUA_LIBDIR |
| 454 | LUA_BINDIR=$LUA_BINDIR | ||
| 455 | FORCE_CONFIG=$FORCE_CONFIG | 419 | FORCE_CONFIG=$FORCE_CONFIG |
| 456 | LUAROCKS_UNAME_M=$LUAROCKS_UNAME_M | ||
| 457 | LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S | ||
| 458 | LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER | ||
| 459 | LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER | ||
| 460 | MULTIARCH_SUBDIR=$MULTIARCH_SUBDIR | ||
| 461 | |||
| 462 | EOF | 420 | EOF |
| 463 | 421 | ||
| 464 | echo "Installation prefix: $PREFIX" | 422 | { |
| 465 | echo "LuaRocks configuration directory: $SYSCONFDIR" | 423 | echo '-- LuaRocks configuration' |
| 466 | echo "Using Lua from: $LUA_DIR" | 424 | echo |
| 467 | 425 | echo 'rocks_trees = {' | |
| 468 | make clean > /dev/null 2> /dev/null | 426 | echo ' { name = "user", root = home .. "/.luarocks" },' |
| 427 | echo ' { name = "system", root = "'"$ROCKS_TREE"'" },' | ||
| 428 | echo '}' | ||
| 429 | if [ -n "$LUA_INTERPRETER" ]; then echo 'lua_interpreter = "'"$LUA_INTERPRETER"'"' ; fi | ||
| 430 | if [ -n "$LUA_DIR" ]; then echo 'variables.LUA_DIR = "'"$LUA_DIR"'"' ; fi | ||
| 431 | if [ -n "$LUA_INCDIR" ]; then echo 'variables.LUA_INCDIR = "'"$LUA_INCDIR"'"' ; fi | ||
| 432 | if [ -n "$LUA_BINDIR" ]; then echo 'variables.LUA_BINDIR = "'"$LUA_BINDIR"'"' ; fi | ||
| 433 | if [ -n "$LUA_LIBDIR" ]; then echo 'variables.LUA_LIBDIR = "'"$LUA_LIBDIR"'"' ; fi | ||
| 434 | } > "config-$LUA_VERSION.lua.in" | ||
| 469 | 435 | ||
| 470 | echo | 436 | echo |
| 471 | echo "Done configuring." | 437 | BLUE "Done configuring." |
| 472 | echo "- Type 'make build' and 'make install':" | 438 | echo |
| 439 | echo | ||
| 440 | echo "LuaRocks will be installed at......: $(GREEN "$PREFIX")" | ||
| 441 | echo "LuaRocks will install rocks at.....: $(GREEN "$ROCKS_TREE")" | ||
| 442 | echo "LuaRocks configuration directory...: $(GREEN "$SYSCONFDIR")" | ||
| 443 | echo "Using Lua from.....................: $(GREEN "$LUA_DIR")" | ||
| 444 | echo | ||
| 445 | echo "* Type $(BOLD make build) and $(BOLD make install):" | ||
| 473 | echo " to install to $PREFIX as usual." | 446 | echo " to install to $PREFIX as usual." |
| 474 | echo "- Type 'make bootstrap':" | 447 | echo "* Type $(BOLD make bootstrap):" |
| 475 | echo " to install LuaRocks in $PREFIX as a rock." | 448 | echo " to install LuaRocks into $ROCKS_TREE as a rock." |
| 476 | echo | 449 | echo |
diff --git a/rockspec b/luarocks-dev-1.rockspec index bb7645f9..bc19e3ff 100644 --- a/rockspec +++ b/luarocks-dev-1.rockspec | |||
| @@ -1,13 +1,11 @@ | |||
| 1 | package = "LuaRocks" | 1 | rockspec_format = "3.0" |
| 2 | local VER = "scm" | 2 | package = "luarocks" |
| 3 | version = VER .. "-1" | 3 | version = "dev-1" |
| 4 | |||
| 5 | source = { | 4 | source = { |
| 6 | url = "--this rockspec is used by `make bootstrap` only--", | 5 | url = "git+https://github.com/luarocks/luarocks" |
| 7 | } | 6 | } |
| 8 | |||
| 9 | description = { | 7 | description = { |
| 10 | summary = "A deployment and management system for Lua modules.", | 8 | summary = "A package manager for Lua modules.", |
| 11 | detailed = [[ | 9 | detailed = [[ |
| 12 | LuaRocks allows you to install Lua modules as self-contained | 10 | LuaRocks allows you to install Lua modules as self-contained |
| 13 | packages called "rocks", which also contain version dependency | 11 | packages called "rocks", which also contain version dependency |
| @@ -17,22 +15,22 @@ description = { | |||
| 17 | required, the correct version is loaded. LuaRocks supports both | 15 | required, the correct version is loaded. LuaRocks supports both |
| 18 | local and remote repositories, and multiple local rocks trees. | 16 | local and remote repositories, and multiple local rocks trees. |
| 19 | ]], | 17 | ]], |
| 20 | license = "MIT/X11", | ||
| 21 | homepage = "http://www.luarocks.org", | 18 | homepage = "http://www.luarocks.org", |
| 22 | maintainer = "Hisham Muhammad" | 19 | issues_url = "https://github.com/luarocks/luarocks/issues", |
| 20 | maintainer = "Hisham Muhammad", | ||
| 21 | license = "MIT", | ||
| 23 | } | 22 | } |
| 24 | 23 | test_dependencies = { | |
| 25 | dependencies = { | 24 | "luacov", |
| 26 | "lua >= 5.1" | ||
| 27 | } | 25 | } |
| 28 | 26 | test = { | |
| 29 | build = { | 27 | type = "busted", |
| 30 | type = "make", | 28 | platforms = { |
| 31 | install_target = "install_rock", | 29 | windows = { |
| 32 | build_pass=false, | 30 | flags = { "--exclude-tags=ssh,git,unix" } |
| 33 | install_variables = { | 31 | }, |
| 34 | BINDIR="$(BINDIR)", | 32 | unix = { |
| 35 | LUADIR="$(LUADIR)", | 33 | flags = { "--exclude-tags=ssh,git" } |
| 36 | LUA="$(LUA)", | 34 | } |
| 37 | } | 35 | } |
| 38 | } | 36 | } |
| @@ -8,16 +8,23 @@ fi | |||
| 8 | 8 | ||
| 9 | if ! [ -d ".git" ] | 9 | if ! [ -d ".git" ] |
| 10 | then | 10 | then |
| 11 | echo "Should be run inside a git repo dir." | 11 | echo "Should be run from the LuaRocks git repo dir." |
| 12 | exit 1 | 12 | exit 1 |
| 13 | fi | 13 | fi |
| 14 | 14 | ||
| 15 | make clean || exit 1 | 15 | make clean || exit 1 |
| 16 | 16 | ||
| 17 | if [ "$1" != "scm" ] | 17 | if [ "$1" != "dev" ] |
| 18 | then | 18 | then |
| 19 | 19 | ||
| 20 | grep -q "\"$1\"" rockspec || { | 20 | ROCKSPEC="luarocks-$1-1.rockspec" |
| 21 | |||
| 22 | [ -e "$ROCKSPEC" ] || { | ||
| 23 | echo | ||
| 24 | echo "$ROCKSPEC is missing. Please check rockspec version is correct." | ||
| 25 | } | ||
| 26 | |||
| 27 | grep -q "\"$1-1\"" "$ROCKSPEC" || { | ||
| 21 | echo | 28 | echo |
| 22 | echo "version in rockspec is incorrect. Please fix it." | 29 | echo "version in rockspec is incorrect. Please fix it." |
| 23 | exit 1 | 30 | exit 1 |
| @@ -61,7 +68,7 @@ fi | |||
| 61 | out="luarocks-$1" | 68 | out="luarocks-$1" |
| 62 | rm -rf "$out" | 69 | rm -rf "$out" |
| 63 | mkdir "$out" | 70 | mkdir "$out" |
| 64 | rm -f "missing_ref" | 71 | |
| 65 | git ls-files | while read i | 72 | git ls-files | while read i |
| 66 | do | 73 | do |
| 67 | if [ -f "$i" ] | 74 | if [ -f "$i" ] |
| @@ -69,36 +76,8 @@ do | |||
| 69 | dir=`dirname $i` | 76 | dir=`dirname $i` |
| 70 | mkdir -p "$out/$dir" | 77 | mkdir -p "$out/$dir" |
| 71 | cp "$i" "$out/$dir" | 78 | cp "$i" "$out/$dir" |
| 72 | if echo "$i" | grep -v "/bin/" | grep -q "^src/" | ||
| 73 | then | ||
| 74 | grep -qw `basename "$i"` Makefile.setup.inc || { | ||
| 75 | echo "Missing ref in Makefile.setup.inc: $i" | ||
| 76 | touch "missing_ref" | ||
| 77 | exit 1 | ||
| 78 | } | ||
| 79 | fi | ||
| 80 | fi | ||
| 81 | done | ||
| 82 | if [ -e "missing_ref" ] | ||
| 83 | then | ||
| 84 | rm -f "missing_ref" | ||
| 85 | exit 1 | ||
| 86 | fi | ||
| 87 | |||
| 88 | cat Makefile.setup.inc | tr ' \\' '\n\n' | grep 'lua$' | while read i | ||
| 89 | do | ||
| 90 | if [ ! -e src/luarocks/$i ] | ||
| 91 | then | ||
| 92 | echo "Ref in Makefile.setup.inc for file that no longer exists: $i" | ||
| 93 | touch "outdated_ref" | ||
| 94 | exit 1 | ||
| 95 | fi | 79 | fi |
| 96 | done | 80 | done |
| 97 | if [ -e "outdated_ref" ] | ||
| 98 | then | ||
| 99 | rm -f "outdated_ref" | ||
| 100 | exit 1 | ||
| 101 | fi | ||
| 102 | 81 | ||
| 103 | rm -rf "release-unix" "release-windows" "$out.tar.gz" "$out-win32.zip" | 82 | rm -rf "release-unix" "release-windows" "$out.tar.gz" "$out-win32.zip" |
| 104 | 83 | ||
| @@ -115,7 +94,7 @@ cd .. | |||
| 115 | rm -rf "release-unix" | 94 | rm -rf "release-unix" |
| 116 | 95 | ||
| 117 | cd "release-windows/$out-win32" | 96 | cd "release-windows/$out-win32" |
| 118 | rm -rf makedist Makefile* configure .travis.yml .gitignore test appveyor* .appveyor | 97 | rm -rf makedist Makefile configure .travis.yml .gitignore test appveyor* .appveyor |
| 119 | cd .. | 98 | cd .. |
| 120 | zip -r ../"$out-win32.zip" "$out-win32" | 99 | zip -r ../"$out-win32.zip" "$out-win32" |
| 121 | cd .. | 100 | cd .. |
