Sunday, January 15, 2023

Re: UPDATE net/luasocket 3.0rc1p1 -> 3.1.0

On 2023/01/15 09:39:11 +0100, Robert Nagy <robert@openbsd.org> wrote:
> On 14/01/23 14:39 -0700, Ashlen wrote:
> > On 23/01/07 00:20, Ashlen wrote:
> > > As for the renaming thing, I realized I didn't actually provide any links
> > > showing why I kept this in. I looked at the commits and it appears their
> > > rationale is that anyone that writes a Lua script and imports luasocket as well
> > > as another module that happens to have an identical buffer_* will have a
> > > headache due to name collisions. Though if that's the case, it makes me wonder
> > > why FreeBSD backed out the patch in the commit op@ mentioned.
> > >
> > > https://cvsweb.openbsd.org/ports/net/luasocket/patches/patch-src_buffer_c?rev=1.2&content-type=text/x-cvsweb-markup
> > > https://marc.info/?l=freebsd-ports-bugs&m=125089202109336&w=2
> > > https://marc.info/?l=freebsd-ports&m=125097467421558&w=2
> >
> > Hey Robert, I CC'ed you because I need to ask you something. You were originally
> > the person who made patches renaming 'buffer_*' to 'ls_buffer_*' in
> > net/luasocket due to them creating a namespace clash with other ports. I know
> > this was all the way back in 2009, but can you let me know if changing those is
> > still necessary? I'm guessing the answer is yes, but I wanted to double check to
> > make sure since there was some discussion about it earlier.
> >
> > I meant to test it myself and therefore avoid bothering you, but it's been a
> > week and I'm realizing I'm not going to get to it in a timely manner (I don't
> > know how to write in Lua yet).
> >
> > (Side note for the other people in the thread: testing against those two other
> > ports is on my TODO list. Life has just been crazy lately and it's been a
> > struggle to get organized again... sorry for the delay on that)
>
> I haven't used this for a long time using that module, but it might not be
> the case anymore. It has to be tested I guess,

I haven't noticed before, sorry, but this shouldn't cause issues
anymore. luasocket doesn't export the buffer_* symbols:

% nm /usr/local/lib/lua/5.1/{mime,socket}/*so | grep buffer
U luaL_prepbuffer
00000000 F buffer.c
000077a0 t buffer_init
000080c0 t buffer_isempty
000077f0 t buffer_meth_getstats
00007bc0 t buffer_meth_receive
00007980 t buffer_meth_send
00007890 t buffer_meth_setstats
00007770 t buffer_open
U luaL_prepbuffer
00000000 F buffer.c
000047d0 t buffer_init
000050f0 t buffer_isempty
00004820 t buffer_meth_getstats
00004bf0 t buffer_meth_receive
000049b0 t buffer_meth_send
000048c0 t buffer_meth_setstats
000047a0 t buffer_open
U luaL_prepbuffer
00000000 F buffer.c
00005650 t buffer_init
00005f70 t buffer_isempty
000056a0 t buffer_meth_getstats
00005a70 t buffer_meth_receive
00005830 t buffer_meth_send
00005740 t buffer_meth_setstats
00005620 t buffer_open
U luaL_prepbuffer

(this is luasocket built with patch below)

The lowercase 't' should mean those symbols are private, right? if
so, I think we can go on with the update. I'm reattaching Ashlen'
patch without the sed to rename the symbols and with my previous
tweaks included.

ok?

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/net/luasocket/Makefile,v
retrieving revision 1.37
diff -u -p -r1.37 Makefile
--- Makefile 11 Mar 2022 19:46:18 -0000 1.37
+++ Makefile 9 Jan 2023 09:46:07 -0000
@@ -1,49 +1,42 @@
COMMENT= network support for the lua language
-V= 3.0-rc1
-GH_ACCOUNT= diegonehab
+
+V= 3.1.0
+GH_ACCOUNT= lunarmodules
GH_PROJECT= luasocket
GH_TAGNAME= v$V
-REVISION= 1
-PKGNAME= ${DISTNAME:S/-rc/rc/}
+
CATEGORIES= net

-HOMEPAGE= http://w3.impa.br/~diego/software/luasocket/
+HOMEPAGE= https://lunarmodules.github.io/luasocket/index.html

# MIT
PERMIT_PACKAGE= Yes

MODULES= lang/lua

-FLAVORS= lua52 lua53
+FLAVORS= lua52 lua53 lua54
FLAVOR?=

-NO_TEST= Yes
-
-USE_GMAKE= Yes
-
MAKE_FILE= makefile

+CFLAGS+= -fPIC -DPIC -I${MODLUA_INCL_DIR}
+CFLAGS+= -DUNIX_HAS_SUN_LEN -DLUA_COMPAT_APIINTCASTS
MAKE_FLAGS= CC_linux=${CC} \
LD_linux=${CC} \
- CFLAGS_linux="${CFLAGS} -I${MODLUA_INCL_DIR} -fPIC \
- -DPIC -DUNIX_HAS_SUN_LEN \
- -DLUA_COMPAT_APIINTCASTS" \
- LDFLAGS_linux="${LDFLAGS} -shared -fPIC -o "
-
-do-install:
- ${INSTALL_DATA_DIR} ${MODLUA_DATADIR}/socket ${MODLUA_DATADIR}/mime
- ${INSTALL_DATA_DIR} ${MODLUA_LIBDIR}/socket ${MODLUA_LIBDIR}/mime
+ CFLAGS_linux="${CFLAGS}" \
+ LDFLAGS_linux="${LDFLAGS} -shared -fPIC -o " \
+ LUAV=${MODLUA_VERSION}
+
+INSTALL_TARGET= install-unix
+
+TEST_DEPENDS= ${PKGPATH},${FLAVOR}=$V
+
+post-install:
${INSTALL_DATA_DIR} ${MODLUA_DOCDIR} ${MODLUA_EXAMPLEDIR}
- ${INSTALL_DATA} ${WRKSRC}/src/socket.so ${MODLUA_LIBDIR}/socket/core.so
- ${INSTALL_DATA} ${WRKSRC}/src/unix.so ${MODLUA_LIBDIR}/socket/unix.so
- ${INSTALL_DATA} ${WRKSRC}/src/mime.so ${MODLUA_LIBDIR}/mime/core.so
-.for l in ltn12 socket mime
- ${INSTALL_DATA} ${WRKSRC}/src/$l.lua ${MODLUA_DATADIR}
-.endfor
-.for l in http url tp ftp headers smtp
- ${INSTALL_DATA} ${WRKSRC}/src/$l.lua ${MODLUA_DATADIR}/socket
-.endfor
- ${INSTALL_DATA} ${WRKSRC}/doc/* ${MODLUA_DOCDIR}
+ ${INSTALL_DATA} ${WRKSRC}/docs/* ${MODLUA_DOCDIR}
${INSTALL_DATA} ${WRKSRC}/samples/* ${MODLUA_EXAMPLEDIR}
+
+pre-test:
+ ln -sf ${MODLUA_BIN} ${WRKDIR}/bin/lua

.include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /home/cvs/ports/net/luasocket/distinfo,v
retrieving revision 1.9
diff -u -p -r1.9 distinfo
--- distinfo 25 Nov 2013 15:27:56 -0000 1.9
+++ distinfo 5 Jan 2023 10:40:51 -0000
@@ -1,2 +1,2 @@
-SHA256 (luasocket-3.0-rc1.tar.gz) = i2fZtbVF4baUdT2re9bNvCTCkPKyG6HhTHezKBfqEkk=
-SIZE (luasocket-3.0-rc1.tar.gz) = 328598
+SHA256 (luasocket-3.1.0.tar.gz) = vwM6655ivKqNAH32jBGclmQY6Mnvfk8tfpa93sqcym4=
+SIZE (luasocket-3.1.0.tar.gz) = 336542
Index: patches/patch-docs_installation_html
===================================================================
RCS file: patches/patch-docs_installation_html
diff -N patches/patch-docs_installation_html
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-docs_installation_html 5 Jan 2023 10:40:51 -0000
@@ -0,0 +1,12 @@
+Index: docs/installation.html
+--- docs/installation.html.orig
++++ docs/installation.html
+@@ -89,7 +89,7 @@ it should be easy to use LuaSocket. Just fire the inte
+ Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
+ &gt; socket = require("socket")
+ &gt; print(socket._VERSION)
+---&gt; LuaSocket 3.0.0
++--&gt; LuaSocket 3.1.0
+ </pre>
+
+ <p> Each module loads their dependencies automatically, so you only need to
Index: patches/patch-makefile_dist
===================================================================
RCS file: patches/patch-makefile_dist
diff -N patches/patch-makefile_dist
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-makefile_dist 5 Jan 2023 10:40:51 -0000
@@ -0,0 +1,12 @@
+Index: makefile.dist
+--- makefile.dist.orig
++++ makefile.dist
+@@ -1,7 +1,7 @@
+ #--------------------------------------------------------------------------
+ # Distribution makefile
+ #--------------------------------------------------------------------------
+-DIST = luasocket-3.0.0
++DIST = luasocket-3.1.0
+
+ TEST = \
+ test/README \
Index: patches/patch-src_buffer_c
===================================================================
RCS file: patches/patch-src_buffer_c
diff -N patches/patch-src_buffer_c
--- patches/patch-src_buffer_c 11 Mar 2022 19:46:18 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
---- src/buffer.c.orig Fri Nov 15 10:51:53 2013
-+++ src/buffer.c Fri Nov 15 10:54:02 2013
-@@ -31,7 +31,7 @@ static int sendraw(p_buffer buf, const char *data, siz
- /*-------------------------------------------------------------------------*\
- * Initializes module
- \*-------------------------------------------------------------------------*/
--int buffer_open(lua_State *L) {
-+int ls_buffer_open(lua_State *L) {
- (void) L;
- return 0;
- }
-@@ -39,7 +39,7 @@ int buffer_open(lua_State *L) {
- /*-------------------------------------------------------------------------*\
- * Initializes C structure
- \*-------------------------------------------------------------------------*/
--void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
-+void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm) {
- buf->first = buf->last = 0;
- buf->io = io;
- buf->tm = tm;
-@@ -50,7 +50,7 @@ void buffer_init(p_buffer buf, p_io io, p_timeout tm)
- /*-------------------------------------------------------------------------*\
- * object:getstats() interface
- \*-------------------------------------------------------------------------*/
--int buffer_meth_getstats(lua_State *L, p_buffer buf) {
-+int ls_buffer_meth_getstats(lua_State *L, p_buffer buf) {
- lua_pushnumber(L, (lua_Number) buf->received);
- lua_pushnumber(L, (lua_Number) buf->sent);
- lua_pushnumber(L, timeout_gettime() - buf->birthday);
-@@ -60,7 +60,7 @@ int buffer_meth_getstats(lua_State *L, p_buffer buf) {
- /*-------------------------------------------------------------------------*\
- * object:setstats() interface
- \*-------------------------------------------------------------------------*/
--int buffer_meth_setstats(lua_State *L, p_buffer buf) {
-+int ls_buffer_meth_setstats(lua_State *L, p_buffer buf) {
- buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received);
- buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent);
- if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4);
-@@ -71,7 +71,7 @@ int buffer_meth_setstats(lua_State *L, p_buffer buf) {
- /*-------------------------------------------------------------------------*\
- * object:send() interface
- \*-------------------------------------------------------------------------*/
--int buffer_meth_send(lua_State *L, p_buffer buf) {
-+int ls_buffer_meth_send(lua_State *L, p_buffer buf) {
- int top = lua_gettop(L);
- int err = IO_DONE;
- size_t size = 0, sent = 0;
-@@ -106,7 +106,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
- /*-------------------------------------------------------------------------*\
- * object:receive() interface
- \*-------------------------------------------------------------------------*/
--int buffer_meth_receive(lua_State *L, p_buffer buf) {
-+int ls_buffer_meth_receive(lua_State *L, p_buffer buf) {
- int err = IO_DONE, top = lua_gettop(L);
- luaL_Buffer b;
- size_t size;
-@@ -157,7 +157,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
- /*-------------------------------------------------------------------------*\
- * Determines if there is any data in the read buffer
- \*-------------------------------------------------------------------------*/
--int buffer_isempty(p_buffer buf) {
-+int ls_buffer_isempty(p_buffer buf) {
- return buf->first >= buf->last;
- }
-
-@@ -252,7 +252,7 @@ static int recvline(p_buffer buf, luaL_Buffer *b) {
- static void buffer_skip(p_buffer buf, size_t count) {
- buf->received += count;
- buf->first += count;
-- if (buffer_isempty(buf))
-+ if (ls_buffer_isempty(buf))
- buf->first = buf->last = 0;
- }
-
-@@ -264,7 +264,7 @@ static int buffer_get(p_buffer buf, const char **data,
- int err = IO_DONE;
- p_io io = buf->io;
- p_timeout tm = buf->tm;
-- if (buffer_isempty(buf)) {
-+ if (ls_buffer_isempty(buf)) {
- size_t got;
- err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, tm);
- buf->first = 0;
Index: patches/patch-src_buffer_h
===================================================================
RCS file: patches/patch-src_buffer_h
diff -N patches/patch-src_buffer_h
--- patches/patch-src_buffer_h 11 Mar 2022 19:46:18 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,22 +0,0 @@
---- src/buffer.h.orig Fri Jun 14 13:27:32 2013
-+++ src/buffer.h Fri Nov 15 10:48:31 2013
-@@ -34,12 +34,12 @@ typedef struct t_buffer_ {
- } t_buffer;
- typedef t_buffer *p_buffer;
-
--int buffer_open(lua_State *L);
--void buffer_init(p_buffer buf, p_io io, p_timeout tm);
--int buffer_meth_send(lua_State *L, p_buffer buf);
--int buffer_meth_receive(lua_State *L, p_buffer buf);
--int buffer_meth_getstats(lua_State *L, p_buffer buf);
--int buffer_meth_setstats(lua_State *L, p_buffer buf);
--int buffer_isempty(p_buffer buf);
-+int ls_buffer_open(lua_State *L);
-+void ls_buffer_init(p_buffer buf, p_io io, p_timeout tm);
-+int ls_buffer_meth_send(lua_State *L, p_buffer buf);
-+int ls_buffer_meth_receive(lua_State *L, p_buffer buf);
-+int ls_buffer_meth_getstats(lua_State *L, p_buffer buf);
-+int ls_buffer_meth_setstats(lua_State *L, p_buffer buf);
-+int ls_buffer_isempty(p_buffer buf);
-
-

No comments:

Post a Comment