@@ -34,7 +34,7 @@ local FORCE_CONFIG = (arg[6] == "yes")
3434local MY_PLATFORM = arg [7 ] or " unix"
3535local CC = arg [8 ] or " gcc"
3636local 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"
3838local TRIPLET = arg [11 ] or CROSSCOMPILER_SYSROOT :gsub (" .*/" , " " )
3939local PROCESSOR = arg [12 ] or TRIPLET :gsub (" %-.*" , " " )
4040if PROCESSOR == " i686" then
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+
438459local 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
0 commit comments