Skip to content

Commit 1cd2987

Browse files
committed
MacroQuest Customizations for luarocks 3.92
- Set version to 3.9.2-mq - Added --skip-config-warning to skip the lua interpreter warning - Added --cache for specifying cache - Added -e for excuting lua directly using the built-in interpreter - Updated lua-bz2 dep for windows and adjusted for https for easier retrieval - Fixed issue with downloading ZLIB for windows builds - Updated paths for mingw for compiling on WSL with mingw - Hacked in a fix for forcing the all_in_one CONFIG_FILE to retain the LUA_INCDIR - Hacked in a fix for luasocket building on WSL with mingw
1 parent 89daf1f commit 1cd2987

8 files changed

Lines changed: 85 additions & 18 deletions

File tree

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
version: 3.0.0.{build}-test
1+
version: 3.9.2-mq.
22

33
shallow_clone: true
44

55
matrix:
66
fast_finish: true
77

88
environment:
9-
LUAROCKS_VER: 3.0.0
9+
LUAROCKS_VER: 3.9.2-mq
1010

1111
matrix:
1212
# Lua 5.4 tests

binary/Makefile.windows

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
# "i686-w64-mingw32" or "x86_64-w64-mingw32"
3-
MINGW_PREFIX?=i686-w64-mingw32
3+
MINGW_PREFIX?=x86_64-w64-mingw32
44
# sysroot of your mingw-w64 installation
5-
MINGW_SYSROOT=/usr/lib/mingw-w64-sysroot/$(MINGW_PREFIX)
5+
MINGW_SYSROOT=/usr/$(MINGW_PREFIX)
66
# "mingw" or "mingw64"
77
OPENSSL_PLATFORM=mingw
88
# Versions of dependencies
99
LIBLUA_VERSION=5.4.3
1010
OPENSSL_VERSION=1.0.2o
11-
ZLIB_VERSION=1.2.12
11+
ZLIB_VERSION=1.3
1212
BZIP2_VERSION=1.0.6
1313

1414
WINDOWS_DEPS_DIR=windows-deps-$(MINGW_PREFIX)
@@ -24,7 +24,7 @@ windows-binary: $(WINDOWS_DEPS_DIR)/lib/liblua.a $(WINDOWS_DEPS_DIR)/lib/libssl.
2424

2525
$(BUILD_WINDOWS_DEPS_DIR)/lua-$(LIBLUA_VERSION).tar.gz:
2626
mkdir -p $(@D)
27-
cd $(BUILD_WINDOWS_DEPS_DIR) && curl -OL https://www.lua.org/ftp/lua-$(LIBLUA_VERSION).tar.gz
27+
cd $(BUILD_WINDOWS_DEPS_DIR) && wget https://www.lua.org/ftp/lua-$(LIBLUA_VERSION).tar.gz
2828
$(BUILD_WINDOWS_DEPS_DIR)/lua-$(LIBLUA_VERSION): $(BUILD_WINDOWS_DEPS_DIR)/lua-$(LIBLUA_VERSION).tar.gz
2929
cd $(BUILD_WINDOWS_DEPS_DIR) && tar zxvpf lua-$(LIBLUA_VERSION).tar.gz
3030
$(WINDOWS_DEPS_DIR)/lib/liblua.a: $(BUILD_WINDOWS_DEPS_DIR)/lua-$(LIBLUA_VERSION)
@@ -36,7 +36,7 @@ $(WINDOWS_DEPS_DIR)/lib/liblua.a: $(BUILD_WINDOWS_DEPS_DIR)/lua-$(LIBLUA_VERSION
3636

3737
$(BUILD_WINDOWS_DEPS_DIR)/openssl-$(OPENSSL_VERSION).tar.gz:
3838
mkdir -p $(@D)
39-
cd $(BUILD_WINDOWS_DEPS_DIR) && curl -OL https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
39+
cd $(BUILD_WINDOWS_DEPS_DIR) && wget https://www.openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz
4040
$(BUILD_WINDOWS_DEPS_DIR)/openssl-$(OPENSSL_VERSION): $(BUILD_WINDOWS_DEPS_DIR)/openssl-$(OPENSSL_VERSION).tar.gz
4141
cd $(BUILD_WINDOWS_DEPS_DIR) && tar zxvpf openssl-$(OPENSSL_VERSION).tar.gz
4242
$(WINDOWS_DEPS_DIR)/lib/libssl.a: $(BUILD_WINDOWS_DEPS_DIR)/openssl-$(OPENSSL_VERSION)
@@ -46,7 +46,7 @@ $(WINDOWS_DEPS_DIR)/lib/libssl.a: $(BUILD_WINDOWS_DEPS_DIR)/openssl-$(OPENSSL_VE
4646

4747
$(BUILD_WINDOWS_DEPS_DIR)/zlib-$(ZLIB_VERSION).tar.gz:
4848
mkdir -p $(@D)
49-
cd $(BUILD_WINDOWS_DEPS_DIR) && curl -OL https://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
49+
cd $(BUILD_WINDOWS_DEPS_DIR) && wget https://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
5050
$(BUILD_WINDOWS_DEPS_DIR)/zlib-$(ZLIB_VERSION): $(BUILD_WINDOWS_DEPS_DIR)/zlib-$(ZLIB_VERSION).tar.gz
5151
cd $(BUILD_WINDOWS_DEPS_DIR) && tar zxvpf zlib-$(ZLIB_VERSION).tar.gz
5252
$(WINDOWS_DEPS_DIR)/lib/libz.a: $(BUILD_WINDOWS_DEPS_DIR)/zlib-$(ZLIB_VERSION)
@@ -61,7 +61,7 @@ $(WINDOWS_DEPS_DIR)/lib/libz.a: $(BUILD_WINDOWS_DEPS_DIR)/zlib-$(ZLIB_VERSION)
6161

6262
$(BUILD_WINDOWS_DEPS_DIR)/bzip2-$(BZIP2_VERSION).tar.gz:
6363
mkdir -p $(@D)
64-
cd $(BUILD_WINDOWS_DEPS_DIR) && curl -OL http://downloads.sourceforge.net/project/bzip2/bzip2-$(BZIP2_VERSION).tar.gz
64+
cd $(BUILD_WINDOWS_DEPS_DIR) && wget http://downloads.sourceforge.net/project/bzip2/bzip2-$(BZIP2_VERSION).tar.gz
6565
$(BUILD_WINDOWS_DEPS_DIR)/bzip2-$(BZIP2_VERSION): $(BUILD_WINDOWS_DEPS_DIR)/bzip2-$(BZIP2_VERSION).tar.gz
6666
cd $(BUILD_WINDOWS_DEPS_DIR) && tar zxvpf bzip2-$(BZIP2_VERSION).tar.gz
6767
$(WINDOWS_DEPS_DIR)/lib/libbz2.a: $(BUILD_WINDOWS_DEPS_DIR)/bzip2-$(BZIP2_VERSION)

binary/all_in_one

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ local FORCE_CONFIG = (arg[6] == "yes")
3434
local MY_PLATFORM = arg[7] or "unix"
3535
local CC = arg[8] or "gcc"
3636
local NM = arg[9] or "nm"
37-
local CROSSCOMPILER_SYSROOT = arg[10] or "/usr/lib/mingw-w64-sysroot/i686-w64-mingw32"
37+
local CROSSCOMPILER_SYSROOT = arg[10] or "/usr/x86_64-w64-mingw32"
3838
local TRIPLET = arg[11] or CROSSCOMPILER_SYSROOT:gsub(".*/", "")
3939
local PROCESSOR = arg[12] or TRIPLET:gsub("%-.*", "")
4040
if PROCESSOR == "i686" then
@@ -435,6 +435,27 @@ end
435435

436436
--------------------------------------------------------------------------------
437437

438+
local function readFile(path)
439+
local file = io.open(path, "r")
440+
if not file then return nil end
441+
local content = file:read("*a")
442+
file:close()
443+
return content
444+
end
445+
446+
-- Function to write contents to a file
447+
local function writeFile(path, content)
448+
local file = io.open(path, "w")
449+
if not file then return false end
450+
file:write(content)
451+
file:close()
452+
return true
453+
end
454+
455+
---------------------------------------------------------------------------------
456+
457+
458+
438459
local function main()
439460

440461
os.remove("src/luarocks/core/hardcoded.lua")
@@ -466,11 +487,11 @@ local function main()
466487

467488
local dependencies = {
468489
md5 = "md5",
469-
luasec = "./binary/luasec-1.0.2-1.rockspec",
470490
["lua-zlib"] = "./binary/lua-zlib-1.2-0.rockspec",
471491
["lua-bz2"] = "./binary/lua-bz2-0.2.1-1.rockspec",
472492
luaposix = if_platform("unix", "./binary/luaposix-35.1-1.rockspec"),
473493
luasocket = "luasocket",
494+
luasec = "./binary/luasec-1.0.2-1.rockspec",
474495
luafilesystem = "luafilesystem",
475496
dkjson = "dkjson",
476497
}
@@ -482,7 +503,30 @@ local function main()
482503
print("----------------------------------------------------------------")
483504
local vers = manif.get_versions(queries.from_dep_string(name), "one")
484505
if not next(vers) then
485-
local ok = os.execute("LUAROCKS_CONFIG='" .. CONFIG_FILE .. "' ./luarocks install --no-project '--tree=" .. LUA_MODULES .. "' " .. arg)
506+
-- Knightly Edit to force config update
507+
local content = readFile(CONFIG_FILE)
508+
if not content then
509+
error("Failed to read the config file at "..CONFIG_FILE)
510+
end
511+
-- Add or update the LUA_INCDIR line
512+
local luaIncDirLine = ' LUA_INCDIR = "/usr/include/lua5.4",\n'
513+
if not content:find("LUA_INCDIR") then
514+
-- Add new line
515+
content = content:gsub("(variables%s*=%s*{)", "%1\n" .. luaIncDirLine)
516+
-- Write the updated content back to the config file
517+
if not writeFile(CONFIG_FILE, content) then
518+
error("Failed to write to the config file at "..CONFIG_FILE)
519+
end
520+
end
521+
522+
local ok = 1
523+
if name == 'luasocket' and string.find(CONFIG_FILE, 'mingw') then
524+
print("LUAROCKS_CONFIG='" .. CONFIG_FILE .. "' ./luarocks install --only-server https://raw.githubusercontent.com/macroquest/moonrocks/luarocks_build/ --no-project '--tree=" .. LUA_MODULES .. "' " .. arg)
525+
ok = os.execute("LUAROCKS_CONFIG='" .. CONFIG_FILE .. "' ./luarocks install --only-server https://raw.githubusercontent.com/macroquest/moonrocks/luarocks_build/ --no-project '--tree=" .. LUA_MODULES .. "' " .. arg)
526+
else
527+
print("LUAROCKS_CONFIG='" .. CONFIG_FILE .. "' ./luarocks install --no-project '--tree=" .. LUA_MODULES .. "' " .. arg)
528+
ok = os.execute("LUAROCKS_CONFIG='" .. CONFIG_FILE .. "' ./luarocks install --no-project '--tree=" .. LUA_MODULES .. "' " .. arg)
529+
end
486530
if ok ~= 0 and ok ~= true then
487531
error("Failed building dependency: " .. name)
488532
end

binary/lua-bz2-0.2.1-1.rockspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package = "lua-bz2"
22
version = "0.2.1-1"
33
source = {
4-
url = "git+ssh://git@github.com/hishamhm/lua-bz2.git",
5-
tag = "0.2.1",
4+
url = "git+https://github.com/hishamhm/lua-bz2.git",
5+
tag = "0.2.1.1",
66
}
77
description = {
88
summary = "A Lua binding to Julian Seward's libbzip2",

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ do
320320
done
321321

322322
echo
323-
BLUE "Configuring LuaRocks version dev..."
323+
BLUE "Configuring LuaRocks version 3.9.2-mq..."
324324
echo
325325
echo
326326

install.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local vars = {}
66

77

88
vars.PREFIX = nil
9-
vars.VERSION = "3.0"
9+
vars.VERSION = "3.9"
1010
vars.SYSCONFDIR = nil
1111
vars.CONFBACKUPDIR = nil
1212
vars.SYSCONFFILENAME = nil

src/luarocks/cmd.lua

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ Enabling completion for Fish:
486486
tostring(cfg.connection_timeout)..".")
487487
:argname("<seconds>")
488488
:convert(tonumber)
489+
parser:option("--cache", "Folder to use for caching rockspecs")
490+
:argname("<cache>")
491+
parser:flag("--skip-config-warning", "Skip the warning for missing configuration")
492+
parser:option("-e", "Execute lua script and exit")
493+
:argname("<quoted_script>")
489494

490495
-- Used internally to force the use of a particular project tree
491496
parser:option("--project-tree"):hidden(true)
@@ -578,6 +583,20 @@ function cmd.run_command(description, commands, external_namespace, ...)
578583
local parser = get_parser(description, cmd_modules)
579584
args = parser:parse(args)
580585

586+
-- Execute lua script and exit
587+
if args.e then
588+
local func, err = load(args.e)
589+
if func then
590+
local success, runtimeError = pcall(func)
591+
if not success then
592+
die(runtimeError)
593+
end
594+
os.exit(cmd.errorcodes.OK)
595+
else
596+
die(err)
597+
end
598+
end
599+
581600
-- Compatibility for old flag
582601
if args.nodeps then
583602
args.deps_mode = "none"
@@ -617,7 +636,7 @@ function cmd.run_command(description, commands, external_namespace, ...)
617636
end
618637
end
619638

620-
if not lua_found and args.command ~= "config" and args.command ~= "help" then
639+
if not lua_found and args.command ~= "config" and args.command ~= "help" and not args.skip_config_warning then
621640
util.warning(tried ..
622641
"\nModules may not install with the correct configurations. " ..
623642
"You may want to configure the path prefix to your build " ..
@@ -662,6 +681,10 @@ function cmd.run_command(description, commands, external_namespace, ...)
662681
cfg.local_cache = dir.path(fs.system_cache_dir(), "luarocks")
663682
end
664683

684+
if args.cache then
685+
cfg.local_cache = args.cache
686+
end
687+
665688
if args.no_manifest then
666689
cfg.no_manifest = true
667690
end

src/luarocks/core/cfg.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ local vers = require("luarocks.core.vers")
2020

2121
--------------------------------------------------------------------------------
2222

23-
local program_version = "dev"
23+
local program_version = "3.9.2-mq"
2424

2525
local is_windows = package.config:sub(1,1) == "\\"
2626

0 commit comments

Comments
 (0)