Bug 202302 - [MAINTAINER] www/lighttpd: convert to options macros and add Lua 5.2+ compatibility
Summary: [MAINTAINER] www/lighttpd: convert to options macros and add Lua 5.2+ compati...
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Philip M. Gollucci
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-13 18:08 UTC by Piotr Kubaj
Modified: 2016-07-16 22:42 UTC (History)
1 user (show)

See Also:


Attachments
www/lighttpd/Makefile update (4.72 KB, patch)
2015-08-13 18:08 UTC, Piotr Kubaj
no flags Details | Diff
remove Lua 5.2+ support (2.12 KB, patch)
2015-09-29 10:11 UTC, Piotr Kubaj
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer freebsd_triage 2015-08-13 18:08:20 UTC
Created attachment 159838 [details]
www/lighttpd/Makefile update

I changed options to new the use macros (except for those that don't have new macros yet). To make it work, I had to move setting options out of ".if !defined(_BUILDING_LIGHTTPD_MODULE)" (only those that were converted to the new schema). When it was in .if, setting them didn't work. I've checked that it configures lighttpd, so there's no regressions. I've also build-tested www/lighttpd-*, so there's no reggressions.


The other change is that I've created patches for compatibility with Lua 5.2+. I've also build and run-tested them with Lua 5.2.
Comment 1 Philip M. Gollucci freebsd_committer freebsd_triage 2015-08-18 22:03:25 UTC
Take.
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-08-19 01:27:09 UTC
A commit references this bug:

Author: pgollucci
Date: Wed Aug 19 01:26:40 UTC 2015
New revision: 394667
URL: https://svnweb.freebsd.org/changeset/ports/394667

Log:
  www/lighttpd: modernize, support lua 5.2+

  - Use USE OPTIONs helpers
  - add support for lua 5.2+

  PR:                  202302
  Submitted by:        pkubaj@riseup.net (maintainer)

Changes:
  head/www/lighttpd/Makefile
  head/www/lighttpd/files/patch-src_mod__cml__lua.c
  head/www/lighttpd/files/patch-src_mod__magnet.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-09-01 07:49:37 UTC
A commit references this bug:

Author: madpilot
Date: Tue Sep  1 07:48:37 UTC 2015
New revision: 395750
URL: https://svnweb.freebsd.org/changeset/ports/395750

Log:
  MFH: r394667

  www/lighttpd: modernize, support lua 5.2+

  - Use USE OPTIONs helpers
  - add support for lua 5.2+

  PR:                  202302
  Submitted by:        pkubaj@riseup.net (maintainer)

  Needed to complete merge done in r395736.

  Approved by:	ports-secteam (delphij)

Changes:
_U  branches/2015Q3/
  branches/2015Q3/www/lighttpd/Makefile
  branches/2015Q3/www/lighttpd/files/patch-src_mod__cml__lua.c
  branches/2015Q3/www/lighttpd/files/patch-src_mod__magnet.c
Comment 4 Daniel Gerzo freebsd_committer freebsd_triage 2015-09-24 11:39:32 UTC
Hello, I don't know if this is related, but with recent update I am getting the following error upon lighttpd startup:

/usr/local/lib/lighttpd/mod_magnet.so: Undefined symbol "lua_getfenv" 
2015-09-24 11:42:51: (server.c.679) loading plugins finally failed 
./lighttpd: WARNING: failed to start lighttpd

Can you guys look at this please?
Comment 5 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-24 12:06:59 UTC
(In reply to Daniel Gerzo from comment #4)
Please post your FreeBSD version, architecture and port options.
Comment 6 Daniel Gerzo freebsd_committer freebsd_triage 2015-09-24 15:23:37 UTC
FreeBSD 10.1-STABLE #5 r284256M: Thu Jun 11 11:09:59 CEST 2015 amd64

root@[fw2-os /home/danger]# poudriere options -s -j 10x64 www/lighttpd
[00:00:00] ====>> Appending to make.conf: /usr/local/etc/poudriere.d/make.conf
[00:00:00] ====>> Appending to make.conf: /usr/local/etc/poudriere.d/10x64-make.conf
===> The following configuration options are available for lighttpd-1.4.37:
     BZIP2=off: bzip2 support (mod_compress)
     DOCS=on: Build and/or install documentation
     FAM=off: File Alteration Monitor support
     GDBM=off: gdbm storage (mod_trigger_b4_dl)
     IPV6=on: IPv6 protocol support
     LDAP=off: LDAP authentication
     LIBEV=off: High-performance events support via libev
     LUA=on: lua support (mod_cml, mod_magnet)
     MEMCACHE=off: memcached storage (mod_trigger_b4_dl)
     MYSQL=off: MySQL support (mod_mysql_vhost)
     MYSQLAUTH=off: MySQL authentication (requires WITH_MYSQL)
     NODELAY=on: Set TCP_NODELAY on listening sockets
     OPENSSL=on: SSL/TLS support via OpenSSL
     SPAWNFCGI=off: Depend on spawn-fcgi utility
     VALGRIND=off: valgrind support
     WEBDAV=off: WebDAV support
===> Use 'make config' to modify these settings
===> The following configuration options are available for lighttpd-1.4.37 and dependencies
===> The following configuration options are available for lighttpd-1.4.37:
     BZIP2=off: bzip2 support (mod_compress)
     DOCS=on: Build and/or install documentation
     FAM=off: File Alteration Monitor support
     GDBM=off: gdbm storage (mod_trigger_b4_dl)
     IPV6=on: IPv6 protocol support
     LDAP=off: LDAP authentication
     LIBEV=off: High-performance events support via libev
     LUA=on: lua support (mod_cml, mod_magnet)
     MEMCACHE=off: memcached storage (mod_trigger_b4_dl)
     MYSQL=off: MySQL support (mod_mysql_vhost)
     MYSQLAUTH=off: MySQL authentication (requires WITH_MYSQL)
     NODELAY=on: Set TCP_NODELAY on listening sockets
     OPENSSL=on: SSL/TLS support via OpenSSL
     SPAWNFCGI=off: Depend on spawn-fcgi utility
     VALGRIND=off: valgrind support
     WEBDAV=off: WebDAV support
===> Use 'make config' to modify these settings
===> The following configuration options are available for m4-1.4.17_1,1:
     EXAMPLES=on: Build and/or install examples
     LIBSIGSEGV=off: Use alternative page fault handler (GNU libsigsegv)
===> Use 'make config' to modify these settings
===> The following configuration options are available for help2man-1.43.3_1:
     NLS=on: Native Language Support
===> Use 'make config' to modify these settings
===> The following configuration options are available for gettext-tools-0.19.5.1:
     DOCS=on: Build and/or install documentation
     THREADS=on: Threading support
===> Use 'make config' to modify these settings
===> The following configuration options are available for libiconv-1.14_8:
     DOCS=on: Build and/or install documentation
     ENCODINGS=on: Include extra character sets
     PATCHES=on: Apply patches to fix CP932, add EUCJP-MS
===> Use 'make config' to modify these settings
===> The following configuration options are available for perl5-5.20.3_8:
     DEBUG=off: Build with debugging support
     GDBM=off: GDBM_File extension
     MULTIPLICITY=on: Use multiplicity
     PERL_64BITINT=on: Use 64 bit integers (on i386)
     PTHREAD=on: Build with -lpthread
     SITECUSTOMIZE=off: Run-time customization of @INC
====> Exclusive OPTIONS: you can only select none or one of them
     THREADS=on: Build threaded perl
     PERL_MALLOC=off: Use Perl malloc
===> Use 'make config' to modify these settings
===> The following configuration options are available for gmake-4.1_2:
     NLS=on: Native Language Support
===> Use 'make config' to modify these settings
===> The following configuration options are available for pcre-8.37_4:
     DOCS=on: Build and/or install documentation
     LIBEDIT=off: Command line editing via libedit
     READLINE=off: Command line editing via libreadline
     STACK_RECURSION=on: Use the stack for recursion during matching
===> Use 'make config' to modify these settings
Comment 7 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-24 15:28:03 UTC
(In reply to Daniel Gerzo from comment #6)
I forgot to ask before, but do you use Lua 5.1 or 5.2? I'd like to know whether I'll have to correct my patch for Lua 5.2 (or maybe return to supporting only 5.1) or this is something with breaking compatibility with 5.1 (in which case I'll contact Lighttpd developers).
Comment 8 Daniel Gerzo freebsd_committer freebsd_triage 2015-09-25 09:16:41 UTC
root@[web1-os /usr/local/etc]# pkg info -d lighttpd
lighttpd-1.4.37:
        lua52-5.2.4
        pcre-8.37_4
Comment 9 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-28 11:31:52 UTC
(In reply to Daniel Gerzo from comment #8)
I can't reproduce this error when starting lighttpd. I've built it in poudriere with LUA on (it uses 5.2). It starts and runs correctly. Can you reproduce it when building in poudriere?
Comment 10 Daniel Gerzo freebsd_committer freebsd_triage 2015-09-28 12:16:16 UTC
I am actually building my packages using poudriere. Do you have mod_magned enabled?
Comment 11 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-28 12:25:07 UTC
(In reply to Daniel Gerzo from comment #10)
Yes, please take a look at:
█▓▒░root@xxx█▓▒░ Mon Sep 28 02:21:16P 
~/ pkg options lighttpd
lighttpd - BZIP2: on
lighttpd - DOCS: off
lighttpd - FAM: off
lighttpd - GDBM: off
lighttpd - IPV6: on
lighttpd - LDAP: off
lighttpd - LIBEV: off
lighttpd - LUA: on
lighttpd - MEMCACHE: off
lighttpd - MYSQL: off
lighttpd - MYSQLAUTH: off
lighttpd - NODELAY: off
lighttpd - OPENSSL: on
lighttpd - SPAWNFCGI: on
lighttpd - VALGRIND: off
lighttpd - WEBDAV: off
█▓▒░root@xxx█▓▒░ Mon Sep 28 02:21:22P 
~/ /usr/local/sbin/lighttpd -f /usr/local/etc/lighttpd/lighttpd.conf
2015-09-28 14:21:36: (network.c.283) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes 
█▓▒░root@xxx█▓▒░ Mon Sep 28 02:21:36P 
~/ sockstat -4 -l | grep www
www      lighttpd   86276 5  tcp4   *:80                  *:*




uname -a:
FreeBSD xxx 10.2-RELEASE FreeBSD 10.2-RELEASE #13 r286769: Mon Aug 17 16:59:15 CEST 2015     toor@xxx:/usr/obj/usr/src/sys/xxx  amd64
Comment 12 Daniel Gerzo freebsd_committer freebsd_triage 2015-09-28 12:48:37 UTC
so I don't know what's going on....do you also have it enabled in lighttpd.conf or modules.conf (mod_magnet is not enabled by default)?

root@[web1-os /usr/local/etc]# lighttpd -V
lighttpd/1.4.37 (ssl) - a light and fast webserver
Build-Date: Sep 24 2015 09:34:32

Event Handlers:

        + select (generic)
        + poll (Unix)
        - rt-signals (Linux 2.4+)
        - epoll (Linux 2.6)
        - /dev/poll (Solaris)
        - eventports (Solaris)
        + kqueue (FreeBSD)
        - libev (generic)

Network handler:

        - linux-sendfile
        + freebsd-sendfile
        - solaris-sendfilev
        + writev
        + write
        - mmap support

Features:

        + IPv6 support
        + zlib support
        - bzip2 support
        - crypt support
        + SSL Support
        + PCRE support
        - mySQL support
        - LDAP support
        - memcached support
        - FAM support
        + LUA support
        - xml support
        - SQLite support
        - GDBM support


root@[web1-os /usr/local/etc]# ldd /usr/local/lib/lighttpd/mod_magnet.so
/usr/local/lib/lighttpd/mod_magnet.so:
        liblua-5.2.so => /usr/local/lib/liblua-5.2.so (0x801606000)
        libm.so.5 => /lib/libm.so.5 (0x801839000)
        libc.so.7 => /lib/libc.so.7 (0x80081f000)
        libthr.so.3 => /lib/libthr.so.3 (0x801a61000)
Comment 13 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-28 13:15:22 UTC
(In reply to Daniel Gerzo from comment #12)
You were right, mod_magnet was off. I have checked the 5.2 manual, and modfied src/mod_magned.c patch. Could you try this patch? For me it compiles and runs fine.
Index: files/patch-src_mod__magnet.c
===================================================================
--- files/patch-src_mod__magnet.c	(revision 398075)
+++ files/patch-src_mod__magnet.c	(working copy)
@@ -11,3 +11,31 @@
  /* plugin config for all request/connections */
  
  static jmp_buf exceptionjmp;
+@@ -688,7 +688,7 @@
+ 	 * get the environment of the function
+ 	 */
+ 
+-	lua_getfenv(L, -1); /* -1 is the function */
++	lua_getuservalue(L, -1); /* -1 is the function */
+ 
+ 	/* lighty.header */
+ 
+@@ -738,7 +738,7 @@
+ 	 */
+ 
+ 	force_assert(lua_isfunction(L, -1));
+-	lua_getfenv(L, -1); /* -1 is the function */
++	lua_getuservalue(L, -1); /* -1 is the function */
+ 
+ 	lua_getfield(L, -1, "lighty"); /* lighty.* from the env  */
+ 	force_assert(lua_istable(L, -1));
+@@ -988,7 +988,7 @@
+ 	lua_setmetatable(L, -2); /* setmetatable({}, {__index = _G}) (sp -= 1) */
+ 
+ 
+-	lua_setfenv(L, -2); /* on the stack should be a modified env (sp -= 1) */
++	lua_setuservalue(L, -2); /* on the stack should be a modified env (sp -= 1) */
+ 
+ 	errfunc = push_traceback(L, 0);
+ 	if (lua_pcall(L, 0, 1, errfunc)) {
+
Comment 14 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-28 13:16:52 UTC
(In reply to pkubaj from comment #13)
If it works for you, I guess it can be committed, although PORTREVISION will need to be bumped.
Comment 15 Daniel Gerzo freebsd_committer freebsd_triage 2015-09-29 09:11:36 UTC
OK, so with this patch lighttpd compiles fine and starts up fine as well, however the functionality of mod_magnet does not work. If we enable mod_magnet but do not set magnet.attract-physical-path-to, the server starts up and works fine, but when  we set setting magnet.attract-physical-path-to = ( "/path/script.lua" ) and script.lua is non-empty the server returns 503.
Comment 16 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-29 10:10:36 UTC
(In reply to Daniel Gerzo from comment #15)
I've opened the lighttpd bug based on what I got on IRC:
http://redmine.lighttpd.net/issues/2674

In the following patch I remove the support for 5.2, set the port as 5.1-only. Since LUA is off by default, I didn't bump the PORTREVISION.
Comment 17 Piotr Kubaj freebsd_committer freebsd_triage 2015-09-29 10:11:37 UTC
Created attachment 161523 [details]
remove Lua 5.2+ support
Comment 18 Piotr Kubaj freebsd_committer freebsd_triage 2015-10-20 10:21:51 UTC
Anyone using Lighttpd with Lua should try this patch (against master branch of Lighttpd):
https://review.lighttpd.net/file/data/f7e2grz4jjiegmii5sjg/PHID-FILE-2xmht3cuvlx52rulqoe4/D4.diff

You could also try lighttpd-1.4.x-stbuehler branch, which contains this patch.
Comment 19 Piotr Kubaj freebsd_committer freebsd_triage 2016-01-03 14:52:11 UTC
It seems like Lighttpd 1.4.40 will support Lua 5.1+. If anyone wishes, I can backports this patch to 1.4.39:
http://redmine.lighttpd.net/projects/lighttpd/repository/revisions/3070/diff
Comment 20 Piotr Kubaj freebsd_committer freebsd_triage 2016-07-16 22:42:02 UTC
Version 1.4.40 supports Lua 5.2+. I've submitted the patch to 1.4.40 at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211163 so this PR can be closed.