From 39c2585daadc4fddc42ca26c0419696c38f34a82 Mon Sep 17 00:00:00 2001 From: luau-project Date: Mon, 17 Jun 2024 12:59:41 -0300 Subject: [PATCH 1/2] [new-package] luafilesystem --- .../001-makefile-for-mingw.patch | 43 +++++ mingw-w64-luafilesystem/PKGBUILD | 163 ++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 mingw-w64-luafilesystem/001-makefile-for-mingw.patch create mode 100644 mingw-w64-luafilesystem/PKGBUILD diff --git a/mingw-w64-luafilesystem/001-makefile-for-mingw.patch b/mingw-w64-luafilesystem/001-makefile-for-mingw.patch new file mode 100644 index 0000000000000..f03f03e6cde22 --- /dev/null +++ b/mingw-w64-luafilesystem/001-makefile-for-mingw.patch @@ -0,0 +1,43 @@ +diff -Naur a/Makefile.mingw b/Makefile.mingw +--- a/Makefile.mingw 1969-12-31 21:00:00.000000000 -0300 ++++ b/Makefile.mingw 2024-06-17 12:37:55.857370395 -0300 +@@ -0,0 +1,38 @@ ++LUA_VERSION=5.1 ++LUA_VERSION_SHORT=51 ++ ++PREFIX=/usr/local ++LUA_BIN=$(PREFIX)/bin ++LUA_INC=$(PREFIX)/include/lua$(LUA_VERSION) ++LUA_CMODULE_DIR=$(PREFIX)/lib/lua/$(LUA_VERSION) ++LUA_EXE_NAME=lua$(LUA_VERSION) ++DLL_EXT=.dll ++LUA_DLL=$(LUA_BIN)/lua$(LUA_VERSION_SHORT)$(DLL_EXT) ++ ++SRC_FILES= src/lfs.c ++DEF_FILE= src/lfs.def ++OBJ_FILES= src/lfs.o ++TEST_FILE= tests/test.lua ++OUT_FILE= lfs.dll ++ ++MKDIR_P= mkdir -p ++RM= rm -f ++INSTALL= install -p ++INSTALL_EXEC= $(INSTALL) -m 0755 ++INSTALL_DATA= $(INSTALL) -m 0644 ++ ++all: $(OUT_FILE) ++ ++$(OBJ_FILES): $(SRC_FILES) ++ $(CC) -c "-I$(LUA_INC)" $(CFLAGS) -o $@ $< ++ ++$(OUT_FILE): $(OBJ_FILES) $(DEF_FILE) ++ $(CC) -shared $(LDFLAGS) -o $@ "$(LUA_DLL)" $< ++ ++install: $(OUT_FILE) ++ $(MKDIR_P) $(DESTDIR)$(LUA_CMODULE_DIR) ++ $(RM) $(DESTDIR)$(LUA_CMODULE_DIR)/$(OUT_FILE) ++ $(INSTALL_EXEC) $(OUT_FILE) $(DESTDIR)$(LUA_CMODULE_DIR)/$(OUT_FILE) ++ ++check: ++ "$(LUA_BIN)/$(LUA_EXE_NAME)" $(TEST_FILE) +\ No newline at end of file diff --git a/mingw-w64-luafilesystem/PKGBUILD b/mingw-w64-luafilesystem/PKGBUILD new file mode 100644 index 0000000000000..ce37f61614e72 --- /dev/null +++ b/mingw-w64-luafilesystem/PKGBUILD @@ -0,0 +1,163 @@ +# Maintainer: luau-project + +_realname=luafilesystem +pkgbase=mingw-w64-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-lua-${_realname}" + "${MINGW_PACKAGE_PREFIX}-lua51-${_realname}" + "${MINGW_PACKAGE_PREFIX}-lua53-${_realname}") +_tagver=1_8_0 +pkgver=1.8.0 +pkgrel=1 +arch=('any') +mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') +url='https://github.com/lunarmodules/luafilesystem' +license=('spdx:MIT') +makedepends=("${MINGW_PACKAGE_PREFIX}-cc" + "${MINGW_PACKAGE_PREFIX}-lua" + "${MINGW_PACKAGE_PREFIX}-lua51" + "${MINGW_PACKAGE_PREFIX}-lua53" + "${MINGW_PACKAGE_PREFIX}-pkgconf") +source=("${url}/archive/refs/tags/v${_tagver}.tar.gz" + "001-makefile-for-mingw.patch") +sha256sums=('16d17c788b8093f2047325343f5e9b74cccb1ea96001e45914a58bbae8932495' + '4eacf6828e8a4e1fedf48c704a5df5fb4d09e6357c0d72a265704a76cc33507f') + +prepare() { + cd "${srcdir}/${_realname}-${_tagver}" + patch -Np1 -i ${srcdir}/001-makefile-for-mingw.patch + + cd ${srcdir} + + cp -r "${srcdir}/${_realname}-${_tagver}" "${srcdir}/${_realname}-${_tagver}-51" + cp -r "${srcdir}/${_realname}-${_tagver}" "${srcdir}/${_realname}-${_tagver}-53" + + # current Lua + _lua_ver=$(pkgconf --variable=V lua) + _lua_ver_short=$(echo $_lua_ver | sed -En "s/\.//p") + + _options=("--file=Makefile.mingw" + "PREFIX=${MINGW_PREFIX}" + "LUA_VERSION=${_lua_ver}" + "LUA_VERSION_SHORT=${_lua_ver_short}" + "LUA_EXE_NAME=lua" + "LUA_INC=${MINGW_PREFIX}/include" + "") + + sed -e "s/\#\!\/usr\/bin\/env lua5\.1/\#\!\/usr\/bin\/env lua/" \ + -i "${srcdir}/${_realname}-${_tagver}"/tests/test.lua + + # Lua 5.1 + _lua_ver51=$(pkgconf --variable=V lua5.1) + _lua_ver_short51=$(echo $_lua_ver51 | sed -En "s/\.//p") + + _options51=("--file=Makefile.mingw" + "PREFIX=${MINGW_PREFIX}" + "LUA_VERSION=${_lua_ver51}" + "LUA_VERSION_SHORT=${_lua_ver_short51}" + "") + + # Lua 5.3 + _lua_ver53=$(pkgconf --variable=V lua5.3) + _lua_ver_short53=$(echo $_lua_ver53 | sed -En "s/\.//p") + + _options53=("--file=Makefile.mingw" + "PREFIX=${MINGW_PREFIX}" + "LUA_VERSION=${_lua_ver53}" + "LUA_VERSION_SHORT=${_lua_ver_short53}" + "") + + sed -e "s/\#\!\/usr\/bin\/env lua5\.1/\#\!\/usr\/bin\/env lua5.3/" \ + -i "${srcdir}/${_realname}-${_tagver}-53"/tests/test.lua +} + +build() { + # current Lua + cd "${srcdir}/${_realname}-${_tagver}" + + make \ + "${_options[@]}" \ + all + + # Lua 5.1 + cd "${srcdir}/${_realname}-${_tagver}-51" + + make \ + "${_options51[@]}" \ + all + + # Lua 5.3 + cd "${srcdir}/${_realname}-${_tagver}-53" + + make \ + "${_options53[@]}" \ + all +} + +check() { + # current Lua + cd "${srcdir}/${_realname}-${_tagver}" + + make \ + "${_options[@]}" \ + check + + # Lua 5.1 + cd "${srcdir}/${_realname}-${_tagver}-51" + + make \ + "${_options51[@]}" \ + check + + # Lua 5.3 + cd "${srcdir}/${_realname}-${_tagver}-53" + + make \ + "${_options53[@]}" \ + check +} + +package_lua-luafilesystem() { + pkgdesc="File System Library for the Lua Programming Language (mingw-w64)" + depends=("${MINGW_PACKAGE_PREFIX}-lua") + + cd "${srcdir}/${_realname}-${_tagver}" + + DESTDIR="${pkgdir}" make \ + "${_options[@]}" \ + install + + install -Dm644 "${srcdir}/${_realname}-${_tagver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/lua${_lua_ver_short}-${_realname}/LICENSE" +} + +package_lua51-luafilesystem() { + pkgdesc="File System Library for the Lua ${_lua_ver51} Programming Language (mingw-w64)" + depends=("${MINGW_PACKAGE_PREFIX}-lua51") + + cd "${srcdir}/${_realname}-${_tagver}-51" + + DESTDIR="${pkgdir}" make \ + "${_options51[@]}" \ + install + + install -Dm644 "${srcdir}/${_realname}-${_tagver}-51/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/lua${_lua_ver_short51}-${_realname}/LICENSE" +} + +package_lua53-luafilesystem() { + pkgdesc="File System Library for the Lua ${_lua_ver53} Programming Language (mingw-w64)" + depends=("${MINGW_PACKAGE_PREFIX}-lua53") + + cd "${srcdir}/${_realname}-${_tagver}-53" + + DESTDIR="${pkgdir}" make \ + "${_options53[@]}" \ + install + + install -Dm644 "${srcdir}/${_realname}-${_tagver}-53/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/lua${_lua_ver_short53}-${_realname}/LICENSE" +} + +# generate wrappers +for _name in "${pkgname[@]}"; do + _short="package_${_name#${MINGW_PACKAGE_PREFIX}-}" + _func="$(declare -f "${_short}")" + eval "${_func/#${_short}/package_${_name}}" +done \ No newline at end of file From f98bd26a65b186c72a2cb980c14354b660cf0ddb Mon Sep 17 00:00:00 2001 From: luau-project Date: Mon, 17 Jun 2024 13:26:08 -0300 Subject: [PATCH 2/2] fix: version variable on 5.3 shebang replacement. --- mingw-w64-luafilesystem/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-luafilesystem/PKGBUILD b/mingw-w64-luafilesystem/PKGBUILD index ce37f61614e72..34204167919a2 100644 --- a/mingw-w64-luafilesystem/PKGBUILD +++ b/mingw-w64-luafilesystem/PKGBUILD @@ -66,7 +66,7 @@ prepare() { "LUA_VERSION_SHORT=${_lua_ver_short53}" "") - sed -e "s/\#\!\/usr\/bin\/env lua5\.1/\#\!\/usr\/bin\/env lua5.3/" \ + sed -e "s/\#\!\/usr\/bin\/env lua5\.1/\#\!\/usr\/bin\/env lua${_lua_ver53}/" \ -i "${srcdir}/${_realname}-${_tagver}-53"/tests/test.lua }