From 162bfd9f0f7994aa40dbc3fc40e8704c3e9ef6a7 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Sat, 23 Dec 2023 07:55:23 +0100 Subject: [PATCH] website-build: make the lighttpd port configurable Signed-off-by: Denis 'GNUtoo' Carikli Acked-by: Adrien 'neox' Bourmault --- website-build/Makefile.am | 6 +++--- website-build/README | 4 +++- website-build/configure.ac | 11 +++++++++++ website-build/lighttpd.conf.tmpl | 2 +- website-build/serve.sh | 12 +++++++++--- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/website-build/Makefile.am b/website-build/Makefile.am index d33683d..5c3e15c 100644 --- a/website-build/Makefile.am +++ b/website-build/Makefile.am @@ -70,7 +70,7 @@ help: @printf "%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n" \ "Available commands:" \ "help # Print this help" \ - "test # run lighttpd on localhost:8080" \ + "test # run lighttpd on localhost:$(LIGHTTPD_PORT)" \ "check # Run automatic tests" \ "deploy # Deploy the website to https://gnu.org/software/gnuboot" \ "website.tar.gz # Create a tarball of the website" @@ -88,11 +88,11 @@ test: website.tar.gz sed \ tar \ -- \ - ./serve.sh website.tar.gz + ./serve.sh website.tar.gz $(LIGHTTPD_PORT) else if WANT_LIGHTTPD test: website.tar.gz - ./serve.sh website.tar.gz + ./serve.sh website.tar.gz $(LIGHTTPD_PORT) else test: @printf "%s %s\n" \ diff --git a/website-build/README b/website-build/README index 4613f56..fdff5d4 100644 --- a/website-build/README +++ b/website-build/README @@ -13,7 +13,9 @@ $ ./autogen.sh $ ./configure $ make test -Then you can point a browser to http://localhost:8080/software/gnuboot/web/ +Then you can point a browser to http://localhost:8080/software/gnuboot/web/ or +to http://localhost:PORT/software/gnuboot/web/ if you changed the port through +./configure options. == Deployment on https://gnu.org/software/gnuboot/ == diff --git a/website-build/configure.ac b/website-build/configure.ac index 6d6bd27..1aea32b 100644 --- a/website-build/configure.ac +++ b/website-build/configure.ac @@ -17,6 +17,7 @@ AC_INIT([gnuboot],[0.1],[gnuboot@gnu.org]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_FILES([Makefile]) +AC_SUBST([LIGHTTPD_PORT], []) AC_SUBST([RSYNC_DESTINATION], []) AC_SUBST([UNTITLED_PATH], []) AC_SUBST([UNTITLED_GIT_FOUND], []) @@ -36,6 +37,14 @@ AC_ARG_ENABLE(lighttpd, [lighttpd="yes"]) AM_CONDITIONAL( [WANT_LIGHTTPD], [test x"$lighttpd" = x"yes"]) +# --with-lighttpd-port +AC_ARG_WITH([lighttpd-port], + [AS_HELP_STRING([--with-lighttpd-port=PORT], + [Use a custom TCP port for lighttpd tests instead of the + default one (8080).])], + [LIGHTTPD_PORT=$withval], + [LIGHTTPD_PORT=8080]) + # --with-rsync-destination AC_ARG_WITH([rsync-destination], [AS_HELP_STRING([--with-rsync-destination=DESTINATION], @@ -156,6 +165,8 @@ AS_IF([test x"$guix" = x"yes"], AC_OUTPUT AS_ECHO(["Configuration options:"]) +AS_ECHO([" LIGHTTPD_PORT: $LIGHTTPD_PORT"]) + AS_ECHO([" RSYNC_DESTINATION: $RSYNC_DESTINATION"]) AS_IF([test x"$UNTITLED_PATH" != x""], diff --git a/website-build/lighttpd.conf.tmpl b/website-build/lighttpd.conf.tmpl index 4013ec6..ef0e98d 100644 --- a/website-build/lighttpd.conf.tmpl +++ b/website-build/lighttpd.conf.tmpl @@ -14,7 +14,7 @@ # along with this program. If not, see . server.bind = "localhost" -server.port = 8080 +server.port = LIGHTTPD_PORT server.document-root = "TMPDIR" dir-listing.activate = "enable" index-file.names = ( "index.html" ) diff --git a/website-build/serve.sh b/website-build/serve.sh index 35f1d51..35c8761 100755 --- a/website-build/serve.sh +++ b/website-build/serve.sh @@ -18,11 +18,11 @@ set -e usage() { - echo "$0 " + echo "$0 [PORT]" exit 1 } -if [ $# -ne 1 ] ; then +if [ $# -ne 1 ] && [ $# -ne 2 ] ; then usage fi @@ -30,12 +30,18 @@ basedir="$(dirname $(realpath $0))" tarball="$1" +lighttpd_port=8080 +if [ $# -eq 2 ] ; then + lighttpd_port="$2" +fi + tmpdir="$(mktemp -d)" mkdir -p "${tmpdir}/software/gnuboot/" tar xf "${tarball}" -C "${tmpdir}/software/gnuboot/" -sed "s#TMPDIR#${tmpdir}#g" \ +sed -e "s#TMPDIR#${tmpdir}#g" \ + -e "s#LIGHTTPD_PORT#${lighttpd_port}#g" \ "${basedir}/lighttpd.conf.tmpl" > \ "${basedir}/lighttpd.conf"