lighttpd: improve recipe to make it work out-of-the-box.

Use autoconf and patch configure.ac instead of configure.
Declare the recipe as also tested on x86 and x86_64.
Install default configuration (in settings/lighttpd/) with SSI enabled.
Declare data/lighttpd/www/htdocs as the document root.
Install a default index.shtml page that works if SSI is enabled.
Install a default index.lighttpd.html page that is used if SSI is disabled.
Group all modules (mod_*.so) in lib/lighttpd/ instead of installing them in lib.
Make var/log/lighttpd/ the default directory for access.log and error.log.
Remove all lib-related stuff from the devel package and, instead, add all .h files that could be required to build third-party modules in separate recipes. That lists consists of all .h files in src except these: configparser.h network.h proc_open.h request.h
Add --with-{zlib,bzip2} to configure args to enable {zlib,bzip2} support for mod_compress.
Add --with-pcre to configure args to make lighttpd understand regexps in the server configuration.
Add --with-webdav-props to configure args (as well as the required dependencies on libsqlite3 and libxml2) to enable some features of the WebDAV module.

With these changes lighttpd runs out of the box on Haiku.
Launch lighttpd with:
lighttpd -f /system/settings/lighttpd/lighttpd.conf
Monitor the access log with:
tail -f /var/log/lighttpd/access.log
Monitor the error log with:
tail -f /var/log/lighttpd/error.log
Stop lighttpd with:
kill $(cat /var/lighttpd.pid)

Notes:
To have alternate pages served instead of the default page, comment-out the active "var.server_root" line in /system/settings/lighttpd/lighttpd.conf and uncomment the inactive one at the next line, then place the alternate content in /var/www/htdocs/ and restart lighttpd.

Further changes that could be nice to make:

* Find a better way to patch configure.ac for the detection of libnetwork to make it compatible with all other platforms and then send it to upstream.
* Check if USER_SETTINGS_FILES and GLOBAL_WRITABLE_FILES could be improved. In particular, see how "template" works and provide both read-only template config files and user-modifiable "keep-old" copies.
* Check if there is a more appropriate directory for the customized default index.(s)html.
* Suggest a default location for cgi-bin scripts/runtimes.
* Add start/stop scripts and some glue to make lighttpd available as service on Haiku.
* Add glue to auto-rotate logs.
This commit is contained in:
fbrosson
2016-03-04 13:36:06 +00:00
parent 323486349d
commit cf8807bd7f
4 changed files with 192 additions and 66 deletions

View File

@@ -0,0 +1,13 @@
#!/bin/sh
mkdir -p var/www/htdocs
if [ ! -e var/www/htdocs/index.shtml ]; then
ln -s /system/data/lighttpd/www/htdocs/index.shtml var/www/htdocs
fi
if [ ! -e var/www/htdocs/index.lighttpd.html ]; then
ln -s /system/data/lighttpd/www/htdocs/index.lighttpd.html var/www/htdocs
fi
mkdir -p var/log/lighttpd var/lib/lighttpd var/cache/lighttpd

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Webserver testpage for lighttpd on Haiku</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div>This is only a test page for <a href="https://www.lighttpd.net/">lighttpd</a> on <a href="https://www.haiku-os.org/">Haiku</a>.
Haiku is not responsible for the contents of this server or domain.
<table>
<tr><th>Operating system:</th><td>@SYSTEM@</td></tr>
<tr><th>Architecture:</th><td>@GETARCH@</td></tr>
<tr><th>Host:</th><td>@HOSTNAME@</td></tr>
<tr><th>Webserver version:</th><td>@LIGHTTPD_VERSION@</td></tr>
</table>
</div>
</body>
</html>

View File

@@ -9,12 +9,16 @@ solution for every server that is suffering load problems."
HOMEPAGE="https://www.lighttpd.net/"
COPYRIGHT="2003-2016 Jan Kneschke"
LICENSE="BSD (3-clause)"
REVISION="1"
REVISION="2"
SOURCE_URI="https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-$portVersion.tar.gz"
CHECKSUM_SHA256="bc5f910f78b8cbae3e8fe1a1d8558259f09dbe50dd3907db771404bfab27bb2e"
PATCHES="lighttpd-$portVersion.patch"
ADDITIONAL_FILES="
create_directories.sh
index.template
"
ARCHITECTURES="x86_gcc2 ?x86 ?x86_64 ?arm ?ppc"
ARCHITECTURES="x86_gcc2 x86 x86_64 ?arm ?ppc"
PROVIDES="
lighttpd = $portVersion
@@ -58,44 +62,14 @@ REQUIRES="
lib:libbz2
lib:libcrypto
lib:libpcre
lib:libsqlite3
lib:libssl
lib:libxml2
lib:libz
"
PROVIDES_devel="
lighttpd_devel = $portVersion
devel:mod_access
devel:mod_accesslog
devel:mod_alias
devel:mod_auth
devel:mod_cgi
devel:mod_cml
devel:mod_compress
devel:mod_dirlisting
devel:mod_evasive
devel:mod_evhost
devel:mod_expire
devel:mod_extforward
devel:mod_fastcgi
devel:mod_flv_streaming
devel:mod_indexfile
devel:mod_magnet
devel:mod_mysql_vhost
devel:mod_proxy
devel:mod_redirect
devel:mod_rewrite
devel:mod_rrdtool
devel:mod_scgi
devel:mod_secdownload
devel:mod_setenv
devel:mod_simple_vhost
devel:mod_ssi
devel:mod_staticfile
devel:mod_status
devel:mod_trigger_b4_dl
devel:mod_userdir
devel:mod_usertrack
devel:mod_webdav
"
REQUIRES_devel="
lighttpd == $portVersion base
@@ -105,41 +79,172 @@ BUILD_REQUIRES="
haiku_devel
devel:libbz2
devel:libpcre
devel:libsqlite3
devel:libssl
devel:libxml2
devel:libz
"
BUILD_PREREQUIRES="
cmd:aclocal
cmd:autoconf
cmd:autom4te
cmd:automake
cmd:awk
cmd:gcc
cmd:git
cmd:make
cmd:perl
cmd:pkg_config
cmd:sed
cmd:uname
cmd:which
"
GLOBAL_WRITABLE_FILES="
settings/lighttpd/lighttpd.conf keep-old
settings/lighttpd/modules.conf keep-old
settings/lighttpd/conf.d/access_log.conf keep-old
settings/lighttpd/conf.d/auth.conf keep-old
settings/lighttpd/conf.d/cgi.conf keep-old
settings/lighttpd/conf.d/cml.conf keep-old
settings/lighttpd/conf.d/compress.conf keep-old
settings/lighttpd/conf.d/debug.conf keep-old
settings/lighttpd/conf.d/dirlisting.conf keep-old
settings/lighttpd/conf.d/evhost.conf keep-old
settings/lighttpd/conf.d/expire.conf keep-old
settings/lighttpd/conf.d/fastcgi.conf keep-old
settings/lighttpd/conf.d/geoip.conf keep-old
settings/lighttpd/conf.d/magnet.conf keep-old
settings/lighttpd/conf.d/mime.conf keep-old
settings/lighttpd/conf.d/mysql_vhost.conf keep-old
settings/lighttpd/conf.d/proxy.conf keep-old
settings/lighttpd/conf.d/rrdtool.conf keep-old
settings/lighttpd/conf.d/scgi.conf keep-old
settings/lighttpd/conf.d/secdownload.conf keep-old
settings/lighttpd/conf.d/simple_vhost.conf keep-old
settings/lighttpd/conf.d/ssi.conf keep-old
settings/lighttpd/conf.d/status.conf keep-old
settings/lighttpd/conf.d/trigger_b4_dl.conf keep-old
settings/lighttpd/conf.d/userdir.conf keep-old
settings/lighttpd/conf.d/webdav.conf keep-old
"
USER_SETTINGS_FILES="
settings/lighttpd directory
settings/lighttpd/conf.d directory
"
POST_INSTALL_SCRIPTS="
$relativePostInstallDir/create_directories.sh
"
BUILD()
{
aclocal
autoconf
automake
runConfigure ./configure --with-openssl
runConfigure --omit-dirs libDir ./configure --libdir=$libDir/lighttpd \
--with-openssl --with-zlib --with-bzip2 --with-pcre \
--with-webdav-props
make $jobArgs
}
INSTALL()
{
make install
mkdir -p $postInstallDir
cp -f $portDir/additional-files/create_directories.sh $postInstallDir
rm $libDir/lighttpd/mod_*.la
mkdir -p \
$localStateDir/cache/lighttpd \
$localStateDir/lib/lighttpd \
$localStateDir/log/lighttpd \
$localStateDir/www/htdocs \
$settingsDir/lighttpd/conf.d
prepareInstalledDevelLibs mod_access mod_accesslog mod_alias mod_auth \
mod_cgi mod_cml mod_compress mod_dirlisting mod_evasive mod_evhost \
mod_expire mod_extforward mod_fastcgi mod_flv_streaming mod_indexfile \
mod_magnet mod_mysql_vhost mod_proxy mod_redirect mod_rewrite \
mod_rrdtool mod_scgi mod_secdownload mod_setenv mod_simple_vhost \
mod_ssi mod_staticfile mod_status mod_trigger_b4_dl mod_userdir \
mod_usertrack mod_webdav
# Tweak lighttpd.conf to have a working config with mod_ssi enabled.
# Tweak ssi.conf to add index.shtml as index-file.names for mod_indexfile.
# Tweak modules.conf to also add index.lighttpd.html as index-file.names.
# This ensures a default main page will still be available if the user later
# choses to disable SSI.
cp doc/config/lighttpd.conf $settingsDir/lighttpd
sed \
-e "/^var\.log_root/ \
s|\"/var\(/log/lighttpd\"\)|\"$localStateDir\1|" \
-e "/^var\.server_root/ \
s|\"/srv/www\"|\"$dataDir/lighttpd/www\"|" \
-e "/^var\.server_root/ \
a #var.server_root = \"/$relativeSharedStateDir/www\"" \
-e "/^var\.state_dir/ s|\"/var/run\"|\"$localStateDir\"|" \
-e "/^var\.home_dir/ \
s|\"/var/lib/lighttpd\"|\"$localStateDir/lib/lighttpd\"|" \
-e "/^var\.conf_dir/ \
s|\"/etc\(/lighttpd\"\)|\"/system/$relativeSettingsDir\1|" \
-e "/^var\.cache_dir/ \
s|\"/var\(/cache/lighttpd\"\)|\"$localStateDir\1|" \
-e "/^server\.use-ipv6 / s|\"enable\"|\"disable\"|" \
-e "s|^server\.username |#&|" \
-e "s|^server\.groupname |#&|" \
-e "s|^server\.max-fds |#&|" \
-e "s|^server\.max-connections |#&|" \
-e "s|^server\.network-backend |#&|" \
-e "/^server\.event-handler/ \
s|\"linux-sysepoll\"|\"select\"|" \
-e "/^server\.upload-dirs/ \
s|\"/var/tmp\"|\"$localStateDir/tmp\"|" \
-e "/^#ssl\.pemfile/ \
s|\"/etc/ssl\(/private/lighttpd.pem\"\)|\"$dataDir\1|" \
-e "/^include \"modules\.conf\"/ \
a index-file.names += ( \"index.lighttpd.html\" )" \
-i $settingsDir/lighttpd/lighttpd.conf
cp doc/config/modules.conf $settingsDir/lighttpd
sed \
-e "s|^#\(include \"conf\.d/ssi\.conf\"\)|\1|" \
-i $settingsDir/lighttpd/modules.conf
cp doc/config/conf.d/*.conf $settingsDir/lighttpd/conf.d
sed \
-e "/^ssi\.extension/ \
a index-file.names += ( \"index.shtml\" )" \
-i $settingsDir/lighttpd/conf.d/ssi.conf
mkdir -p $dataDir/lighttpd/www/htdocs
# Create and install a static index.lighttpd.html test page from the template.
cp $portDir/additional-files/index.template \
$dataDir/lighttpd/www/htdocs/index.lighttpd.html
sed \
-e "s|@SYSTEM@|`uname -a`|" \
-e "s|@GETARCH@|`getarch`|" \
-e "s|@HOSTNAME@|`uname -n`|" \
-e "s|@LIGHTTPD_VERSION@|lighttpd/$portVersion|" \
-i $dataDir/lighttpd/www/htdocs/index.lighttpd.html
# Create and install the SSI index.shtml test page from the template.
cp $portDir/additional-files/index.template \
$dataDir/lighttpd/www/htdocs/index.shtml
sed \
-e "s|@SYSTEM@|<!--#exec cmd=\"/bin/uname -a\"-->|" \
-e "s|@GETARCH@|<!--#exec cmd=\"/bin/getarch\"-->|" \
-e "s|@HOSTNAME@|<!--#echo var=\"HTTP_HOST\"-->|" \
-e "s|@LIGHTTPD_VERSION@|<!--#echo var=\"SERVER_SOFTWARE\"-->|" \
-i $dataDir/lighttpd/www/htdocs/index.shtml
# Install headers in develop/headers/lighttpd/ for building third-party modules.
mkdir -p $developDir/headers/lighttpd
cp -p src/*.h $developDir/headers/lighttpd
# Remove those headers that won't ever be needed for building a module.
for i in \
configparser.h \
network.h \
proc_open.h \
request.h
do
rm -f $developDir/headers/lighttpd/$i
done
packageEntries devel $developDir
}

View File

@@ -1,6 +1,17 @@
diff -upr lighttpd-1.4.39/configure.ac lighttpd-1.4.39-haiku/configure.ac
--- lighttpd-1.4.39/configure.ac 2015-12-05 14:17:22.000000000 +0000
+++ lighttpd-1.4.39-haiku/configure.ac
@@ -690,7 +690,7 @@ AM_CONDITIONAL(CHECK_WITH_FASTCGI, test
@@ -279,6 +279,9 @@ AC_SEARCH_LIBS(socket,socket)
AC_SEARCH_LIBS(gethostbyname,nsl socket)
AC_SEARCH_LIBS(hstrerror,resolv)
+dnl On Haiku the accept function is in libnetwork
+AC_SEARCH_LIBS(accept,network)
+
save_LIBS=$LIBS
AC_SEARCH_LIBS(dlopen,dl,[
AC_CHECK_HEADERS([dlfcn.h],[
@@ -690,7 +693,7 @@ AM_CONDITIONAL(CHECK_WITH_FASTCGI, test
dnl check for extra compiler options (warning options)
if test "${GCC}" = "yes"; then
TRY_CFLAGS([-Wall -W -Wshadow -pedantic])
@@ -9,25 +20,3 @@
fi
AC_ARG_ENABLE(extra-warnings,
--- lighttpd-1.4.39/configure 2016-01-02 11:47:11.000000000 +0000
+++ lighttpd-1.4.39-haiku/configure
@@ -16726,8 +16726,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLA
ac_compiler_gnu=$ac_cv_c_compiler_gnu
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -std=gnu99" >&5
-$as_echo_n "checking if $CC supports -std=gnu99... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -std=gnu9x" >&5
+$as_echo_n "checking if $CC supports -std=gnu9x... " >&6; }
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -16735,7 +16735,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLA
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_try_cflags_saved_cflags="${CFLAGS}"
- CFLAGS="${CFLAGS} -std=gnu99"
+ CFLAGS="${CFLAGS} -std=gnu9x"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */