diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-10-13 18:37:40 -0700 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-10-13 18:37:40 -0700 |
| commit | faf67404e4648715bc620017da263250d979e9e3 (patch) | |
| tree | 02c57daf60ea526c90f2248fc9543f84dc795372 | |
| parent | 57bde51526bcd9c022e29802f29ae432a3a03bef (diff) | |
| parent | 58c7d8dd682fb69f1c5344bc9bacd58776ea0ced (diff) | |
| download | luarocks-faf67404e4648715bc620017da263250d979e9e3.tar.gz luarocks-faf67404e4648715bc620017da263250d979e9e3.tar.bz2 luarocks-faf67404e4648715bc620017da263250d979e9e3.zip | |
Merge pull request #154 from siffiejoe/linux-multiarch
Detect native multiarch directory on linux
| -rw-r--r-- | Makefile | 12 | ||||
| -rwxr-xr-x | configure | 11 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 36 | ||||
| -rw-r--r-- | src/luarocks/fs/unix.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/fs/win32.lua | 9 |
6 files changed, 50 insertions, 28 deletions
| @@ -81,6 +81,11 @@ src/luarocks/site_config.lua: config.unix | |||
| 81 | echo "LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/site_config.lua | 81 | echo "LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/site_config.lua |
| 82 | echo "LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/site_config.lua | 82 | echo "LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/site_config.lua |
| 83 | echo "LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/site_config.lua | 83 | echo "LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/site_config.lua |
| 84 | if [ -n "$(MULTIARCH_SUBDIR)" ] ;\ | ||
| 85 | then \ | ||
| 86 | echo 'LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> src/luarocks/site_config.lua ;\ | ||
| 87 | echo 'LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> src/luarocks/site_config.lua ;\ | ||
| 88 | fi | ||
| 84 | 89 | ||
| 85 | dev: | 90 | dev: |
| 86 | $(MAKE) build_bins LUADIR=$(PWD)/src | 91 | $(MAKE) build_bins LUADIR=$(PWD)/src |
| @@ -169,11 +174,6 @@ write_sysconfig: built | |||
| 169 | install: install_bins install_luas install_site_config write_sysconfig | 174 | install: install_bins install_luas install_site_config write_sysconfig |
| 170 | 175 | ||
| 171 | bootstrap: src/luarocks/site_config.lua install_site_config write_sysconfig | 176 | bootstrap: src/luarocks/site_config.lua install_site_config write_sysconfig |
| 172 | if [ -n "$$LUA_PATH_5_2" ] ;\ | 177 | '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$$PWD/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)" |
| 173 | then \ | ||
| 174 | LUA_PATH="$$PWD/src/?.lua;$$LUA_PATH" LUA_PATH_5_2="$$PWD/src/?.lua;$$LUA_PATH_5_2" src/bin/luarocks make rockspec --tree="$(PREFIX)" ;\ | ||
| 175 | else \ | ||
| 176 | LUA_PATH="$$PWD/src/?.lua;$$LUA_PATH" src/bin/luarocks make rockspec --tree="$(PREFIX)" ;\ | ||
| 177 | fi | ||
| 178 | 178 | ||
| 179 | install_rock: install_bins install_luas | 179 | install_rock: install_bins install_luas |
| @@ -14,6 +14,7 @@ LUA_BINDIR="/usr/bin" | |||
| 14 | LUA_INCDIR="/usr/include" | 14 | LUA_INCDIR="/usr/include" |
| 15 | LUA_LIBDIR="/usr/lib" | 15 | LUA_LIBDIR="/usr/lib" |
| 16 | LUA_VERSION="5.1" | 16 | LUA_VERSION="5.1" |
| 17 | MULTIARCH_SUBDIR="" | ||
| 17 | 18 | ||
| 18 | # ---------------------------------------------------------------------------- | 19 | # ---------------------------------------------------------------------------- |
| 19 | # FUNCTION DEFINITIONS | 20 | # FUNCTION DEFINITIONS |
| @@ -396,6 +397,15 @@ else | |||
| 396 | echo "Using unversioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" | 397 | echo "Using unversioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" |
| 397 | fi | 398 | fi |
| 398 | 399 | ||
| 400 | if [ "$LUAROCKS_UNAME_S" = Linux ] | ||
| 401 | then | ||
| 402 | GCC_ARCH=`gcc -print-multiarch 2>/dev/null` | ||
| 403 | if [ -n "$GCC_ARCH" -a -d "/usr/lib/$GCC_ARCH" ] | ||
| 404 | then | ||
| 405 | MULTIARCH_SUBDIR="lib/$GCC_ARCH" | ||
| 406 | fi | ||
| 407 | fi | ||
| 408 | |||
| 399 | if [ -f config.unix ]; then | 409 | if [ -f config.unix ]; then |
| 400 | rm -f config.unix | 410 | rm -f config.unix |
| 401 | fi | 411 | fi |
| @@ -426,6 +436,7 @@ LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S | |||
| 426 | LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER | 436 | LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER |
| 427 | LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER | 437 | LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER |
| 428 | LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR | 438 | LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR |
| 439 | MULTIARCH_SUBDIR=$MULTIARCH_SUBDIR | ||
| 429 | 440 | ||
| 430 | EOF | 441 | EOF |
| 431 | 442 | ||
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 8e26bb46..94afe0a0 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -254,12 +254,12 @@ local defaults = { | |||
| 254 | STATFLAG = "-c '%a'", | 254 | STATFLAG = "-c '%a'", |
| 255 | }, | 255 | }, |
| 256 | 256 | ||
| 257 | external_deps_subdirs = { | 257 | external_deps_subdirs = site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS or { |
| 258 | bin = "bin", | 258 | bin = "bin", |
| 259 | lib = "lib", | 259 | lib = "lib", |
| 260 | include = "include" | 260 | include = "include" |
| 261 | }, | 261 | }, |
| 262 | runtime_external_deps_subdirs = { | 262 | runtime_external_deps_subdirs = site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS or { |
| 263 | bin = "bin", | 263 | bin = "bin", |
| 264 | lib = "lib", | 264 | lib = "lib", |
| 265 | include = "include" | 265 | include = "include" |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index f24dc507..7f3b44f2 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -583,7 +583,19 @@ function check_external_deps(rockspec, mode) | |||
| 583 | prefix = prefix.prefix | 583 | prefix = prefix.prefix |
| 584 | end | 584 | end |
| 585 | for dirname, dirdata in pairs(dirs) do | 585 | for dirname, dirdata in pairs(dirs) do |
| 586 | dirdata.dir = vars[name.."_"..dirname] or dir.path(prefix, dirdata.subdir) | 586 | local paths |
| 587 | local path_var_value = vars[name.."_"..dirname] | ||
| 588 | if path_var_value then | ||
| 589 | paths = { path_var_value } | ||
| 590 | elseif type(dirdata.subdir) == "table" then | ||
| 591 | paths = {} | ||
| 592 | for i,v in ipairs(dirdata.subdir) do | ||
| 593 | paths[i] = dir.path(prefix, v) | ||
| 594 | end | ||
| 595 | else | ||
| 596 | paths = { dir.path(prefix, dirdata.subdir) } | ||
| 597 | end | ||
| 598 | dirdata.dir = paths[1] | ||
| 587 | local file = files[dirdata.testfile] | 599 | local file = files[dirdata.testfile] |
| 588 | if file then | 600 | if file then |
| 589 | local files = {} | 601 | local files = {} |
| @@ -605,16 +617,22 @@ function check_external_deps(rockspec, mode) | |||
| 605 | if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then | 617 | if f:match("%.so$") or f:match("%.dylib$") or f:match("%.dll$") then |
| 606 | f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension) | 618 | f = f:gsub("%.[^.]+$", "."..cfg.external_lib_extension) |
| 607 | end | 619 | end |
| 608 | if f:match("%*") then | 620 | for _, d in ipairs(paths) do |
| 609 | local replaced = f:gsub("%.", "%%."):gsub("%*", ".*") | 621 | if f:match("%*") then |
| 610 | for _, entry in ipairs(fs.list_dir(dirdata.dir)) do | 622 | local replaced = f:gsub("%.", "%%."):gsub("%*", ".*") |
| 611 | if entry:match(replaced) then | 623 | for _, entry in ipairs(fs.list_dir(d)) do |
| 612 | found = true | 624 | if entry:match(replaced) then |
| 613 | break | 625 | found = true |
| 626 | break | ||
| 627 | end | ||
| 614 | end | 628 | end |
| 629 | else | ||
| 630 | found = fs.is_file(dir.path(d, f)) | ||
| 631 | end | ||
| 632 | if found then | ||
| 633 | dirdata.dir = d | ||
| 634 | break | ||
| 615 | end | 635 | end |
| 616 | else | ||
| 617 | found = fs.is_file(dir.path(dirdata.dir, f)) | ||
| 618 | end | 636 | end |
| 619 | if found then | 637 | if found then |
| 620 | break | 638 | break |
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index cccbbd33..5b9a11b5 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
| @@ -53,15 +53,13 @@ function wrap_script(file, dest, name, version) | |||
| 53 | 53 | ||
| 54 | local base = dir.base_name(file) | 54 | local base = dir.base_name(file) |
| 55 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest | 55 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest |
| 56 | local lpath, lcpath = cfg.package_paths() | ||
| 56 | local wrapper = io.open(wrapname, "w") | 57 | local wrapper = io.open(wrapname, "w") |
| 57 | if not wrapper then | 58 | if not wrapper then |
| 58 | return nil, "Could not open "..wrapname.." for writing." | 59 | return nil, "Could not open "..wrapname.." for writing." |
| 59 | end | 60 | end |
| 60 | wrapper:write("#!/bin/sh\n\n") | 61 | wrapper:write("#!/bin/sh\n\n") |
| 61 | wrapper:write('LUA_PATH="'..package.path..';$LUA_PATH"\n') | 62 | wrapper:write('exec "'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -e \'package.path=[['..lpath..';]]..package.path\' -e \'package.cpath=[['..lcpath..';]]..package.cpath\' -lluarocks.loader -e\'luarocks.loader.add_context([['..name..']],[['..version..']])\' "'..file..'" "$@"\n') |
| 62 | wrapper:write('LUA_CPATH="'..package.cpath..';$LUA_CPATH"\n') | ||
| 63 | wrapper:write('export LUA_PATH LUA_CPATH\n') | ||
| 64 | wrapper:write('exec "'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader -e\'luarocks.loader.add_context([['..name..']],[['..version..']])\' "'..file..'" "$@"\n') | ||
| 65 | wrapper:close() | 63 | wrapper:close() |
| 66 | if fs.chmod(wrapname, "0755") then | 64 | if fs.chmod(wrapname, "0755") then |
| 67 | return true | 65 | return true |
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua index 2bc595f6..8f14239d 100644 --- a/src/luarocks/fs/win32.lua +++ b/src/luarocks/fs/win32.lua | |||
| @@ -63,18 +63,13 @@ function wrap_script(file, dest, name, version) | |||
| 63 | local base = dir.base_name(file) | 63 | local base = dir.base_name(file) |
| 64 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest | 64 | local wrapname = fs.is_dir(dest) and dest.."/"..base or dest |
| 65 | wrapname = wrapname..".bat" | 65 | wrapname = wrapname..".bat" |
| 66 | local lpath, lcpath = cfg.package_paths() | ||
| 66 | local wrapper = io.open(wrapname, "w") | 67 | local wrapper = io.open(wrapname, "w") |
| 67 | if not wrapper then | 68 | if not wrapper then |
| 68 | return nil, "Could not open "..wrapname.." for writing." | 69 | return nil, "Could not open "..wrapname.." for writing." |
| 69 | end | 70 | end |
| 70 | wrapper:write("@echo off\n") | 71 | wrapper:write("@echo off\n") |
| 71 | wrapper:write("setlocal\n") | 72 | wrapper:write('"'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -e "package.path=[['..lpath..';]]..package.path" -e "package.cpath=[['..lcpath..';]]..package.cpath" -lluarocks.loader -e"luarocks.loader.add_context([['..name..']],[['..version..']])" "'..file..'" %*\n') |
| 72 | wrapper:write('set LUA_PATH='..package.path..";%LUA_PATH%\n") | ||
| 73 | wrapper:write('set LUA_CPATH='..package.cpath..";%LUA_CPATH%\n") | ||
| 74 | wrapper:write('if not "%LUA_PATH_5_2%"=="" set LUA_PATH_5_2='..package.path..";%LUA_PATH_5_2%\n") | ||
| 75 | wrapper:write('if not "%LUA_CPATH_5_2%"=="" set LUA_CPATH_5_2='..package.cpath..";%LUA_CPATH_5_2%\n") | ||
| 76 | wrapper:write('"'..dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)..'" -lluarocks.loader -e"luarocks.loader.add_context([['..name..']],[['..version..']])" "'..file..'" %*\n') | ||
| 77 | wrapper:write("endlocal\n") | ||
| 78 | wrapper:close() | 73 | wrapper:close() |
| 79 | return true | 74 | return true |
| 80 | end | 75 | end |
