From 1720740bdd7e08d957d0d7d39dba67703de7b0d7 Mon Sep 17 00:00:00 2001 From: fosslinux Date: Sat, 5 Dec 2020 10:20:10 +1100 Subject: [PATCH 1/5] Introduce new build system This build system is very different to the old build system, and is much more inuitive. It leverages a hand made configure script to generate the Makefile. The listener is no longer auto-detected, unless specifically specified, and no longer activated by default. That is not the place for a build system. Along with the focus of moving to distribution repositiories, this 'feature' is clearly unwanted by distributions. Multiple listeners are now also supported, primarily for distributions. Lastly, parallelism now works as well. --- .gitignore | 21 +- Makefile | 269 --------------- Makefile.in | 149 +++++++++ install-sh => build-aux/install-sh | 0 configure | 310 ++++++++++++++++++ init/.gitignore | 4 + ...phernicus.xinetd => gophernicus.xinetd.in} | 0 init/haiku_snippet.in | 7 + init/inetlin.in | 1 + ....plist => org.gophernicus.server.plist.in} | 0 10 files changed, 472 insertions(+), 289 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.in rename install-sh => build-aux/install-sh (100%) create mode 100755 configure create mode 100644 init/.gitignore rename init/{gophernicus.xinetd => gophernicus.xinetd.in} (100%) create mode 100644 init/haiku_snippet.in create mode 100644 init/inetlin.in rename init/{org.gophernicus.server.plist => org.gophernicus.server.plist.in} (100%) diff --git a/.gitignore b/.gitignore index c744658..0a62130 100644 --- a/.gitignore +++ b/.gitignore @@ -6,26 +6,7 @@ src/files.h src/filetypes.h src/bin2c src/gophernicus +Makefile README README.options - -# -# Test leftovers -# -test.output - -# -# Release files -# -*.gz - -# -# Debian packaging leftovers -# -build-stamp -debian/files -debian/gophernicus.debhelper.log -debian/gophernicus.postrm.debhelper -debian/gophernicus.substvars -debian/gophernicus/ diff --git a/Makefile b/Makefile deleted file mode 100644 index b1e2a46..0000000 --- a/Makefile +++ /dev/null @@ -1,269 +0,0 @@ -NAME = gophernicus -PACKAGE = $(NAME) -BINARY = $(NAME) -VERSION = 3.1 -CODENAME = Dungeon Edition - -SOURCES = src/$(NAME).c src/file.c src/menu.c src/string.c src/platform.c src/session.c src/options.c src/log.c -HEADERS = src/files.h src/filetypes.h -OBJECTS = $(SOURCES:.c=.o) -README = README.md - -DESTDIR = /usr -OSXDIR = /usr/local -SBINDIR = $(DESTDIR)/sbin -DOCDIR = $(DESTDIR)/share/doc/$(PACKAGE) -MANPAGE = gophernicus.1 -MANDEST = $(DESTDIR)/share/man/man1/gophernicus.1 - -INSTALL = PATH=$$PATH:/usr/sbin ./install-sh -o 0 -g 0 -ROOT = /var/gopher -OSXROOT = /Library/GopherServer -WRTROOT = /gopher -MAP = gophermap - -INETD = /etc/inetd.conf -XINETD = /etc/xinetd.d -# get OPTIONS line from gophernicus.env and use that also for inetd -INETOPT = $$(grep '^OPTIONS=' $(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//') -INETLIN = "gopher stream tcp nowait nobody $(SBINDIR)/$(BINARY) $(BINARY) $(INETOPT)" -INETPID = /var/run/inetd.pid -LAUNCHD = /Library/LaunchDaemons -PLIST = org.$(NAME).server.plist -NET_SRV = /boot/common/settings/network/services -SYSTEMD = /lib/systemd/system /usr/lib/systemd/system -HAS_STD = /run/systemd/system -SYSCONF = /etc/sysconfig -DEFAULT = /etc/default - -CC ?= cc -CFLAGS := -O2 -Wall $(CFLAGS) -LDFLAGS := $(LDFLAGS) - -IPCRM = /usr/bin/ipcrm - -all: - @case $$(uname) in \ - Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDIr)" src/$(BINARY); ;; \ - Haiku) $(MAKE) LDFLAGS="$(LDFLAGS) -lnetwork" src/$(BINARY); ;; \ - *) if [ -f "/usr/include/tcpd.h" ]; then $(MAKE) withwrap; else $(MAKE) src/$(BINARY); fi; ;; \ - esac - -withwrap: - $(MAKE) CFLAGS="$(CFLAGS) -DHAVE_LIBWRAP" LDFLAGS="$(LDFLAGS) -lwrap" src/$(BINARY) - -deb: - dpkg-buildpackage -rfakeroot -uc -us - -headers: $(HEADERS) - -src/$(NAME).c: headers src/$(NAME).h - -src/$(BINARY): $(OBJECTS) - $(CC) $(OBJECTS) $(CFLAGS) -o $@ $(LDFLAGS) - -.c.o: - $(CC) -c $(CFLAGS) -DVERSION="\"$(VERSION)\"" -DCODENAME="\"$(CODENAME)\"" -DDEFAULT_ROOT="\"$(ROOT)\"" $< -o $@ - -src/filetypes.h: src/filetypes.conf - sh src/filetypes.sh < src/filetypes.conf > $@ - -src/bin2c: src/bin2c.c - $(CC) src/bin2c.c -o $@ - -README: $(README) - cat $(README) > $@ - -src/files.h: src/bin2c README - sed -e '/^(end of option list)/,$$d' README > README.options - ./src/bin2c -0 -n README README.options > $@ - ./src/bin2c -0 LICENSE >> $@ - ./src/bin2c -n ERROR_GIF error.gif >> $@ - @echo - -# Clean cases - -clean: clean-build clean-deb - -clean-build: - rm -rf src/$(BINARY) $(OBJECTS) $(HEADERS) README.options README src/bin2c - -clean-deb: - if [ -d debian/$(PACKAGE) ]; then fakeroot debian/rules clean; fi - -clean-shm: - if [ -x $(IPCRM) ]; then $(IPCRM) -M $$(awk '/SHM_KEY/ { print $$3 }' src/$(NAME).h) || true; fi - -# Install cases - -install: clean-shm - @case $$(uname) in \ - Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDIR)" install-files install-docs install-root install-osx install-done; ;; \ - Haiku) $(MAKE) SBINDIR=/boot/common/bin DOCDIR=/boot/common/share/doc/$(PACKAGE) \ - install-files install-docs install-root install-haiku install-done; ;; \ - *) $(MAKE) install-files install-docs install-root; ;; \ - esac - @if [ -d "$(HAS_STD)" ]; then $(MAKE) install-systemd install-done; \ - elif [ -d "$(XINETD)" ]; then $(MAKE) install-xinetd install-done; \ - elif [ -f "$(INETD)" ]; then $(MAKE) install-inetd install-done; fi - -.PHONY: install - -install-done: - @echo - @echo "======================================================================" - @echo - @echo "If there were no errors shown above," - @echo "Gophernicus has now been succesfully installed. To try it out, launch" - @echo "your favorite gopher browser and navigate to your gopher root." - @echo - @echo "Gopher URL...: gopher://$$(hostname)/" - @for CONFFILE in /etc/sysconfig/gophernicus \ - /etc/default/gophernicus \ - /Library/LaunchDaemons/org.gophernicus.server.plist \ - /boot/common/settings/network/services \ - /lib/systemd/system/gophernicus\@.service \ - /etc/xinetd.d/gophernicus \ - /etc/inetd.conf; do \ - if [ -f $$CONFFILE ]; then echo "Configuration: $$CONFFILE"; break; fi; done; - @echo - @echo "======================================================================" - @echo - -install-files: src/$(BINARY) - mkdir -p $(SBINDIR) - $(INSTALL) -s -m 755 src/$(BINARY) $(SBINDIR) - @echo - -install-docs: - mkdir -p $(DOCDIR) - $(INSTALL) -m 644 $(MANPAGE) $(MANDEST) - @echo - -install-root: - if [ ! -d "$(ROOT)" -o ! -f "$(ROOT)/$(MAP)" ]; then \ - mkdir -p $(ROOT); \ - $(INSTALL) -m 644 $(MAP).sample $(ROOT); \ - ln -fs $(DOCDIR) $(ROOT)/docs; \ - fi - @echo - -install-inetd: install-files install-docs install-root - @if update-inetd --add $(INETLIN); then \ - echo update-inetd install worked ; \ - else if grep '^gopher' $(INETD) >/dev/null 2>&1 ; then \ - echo "::::: Gopher entry in $(INETD) already present -- please check! :::::"; \ - else echo "Trying to add gopher entry to $(INETD)" ; \ - echo "$(INETLIN)" >> $(INETD) ; \ - if [ -r $(INETPID) ] ; then kill -HUP $$(cat $(INETPID)) ; \ - else echo "::::: No PID for inetd found, not restarted -- please check! :::::" ; fi ; \ - fi ; \ - fi - @echo - -install-xinetd: install-files install-docs install-root - if [ -d "$(XINETD)" -a ! -f "$(XINETD)/$(NAME)" ]; then \ - sed -e "s/@HOSTNAME@/$$(hostname)/g" $(NAME).xinetd > $(XINETD)/$(NAME); \ - [ -x /sbin/service ] && /sbin/service xinetd reload; \ - fi - @echo - -install-osx: - if [ -d "$(LAUNCHD)" -a ! -f "$(LAUNCHD)/$(PLIST)" ]; then \ - sed -e "s/@HOSTNAME@/$$(hostname)/g" src/$(PLIST) > $(LAUNCHD)/$(PLIST); \ - launchctl load $(LAUNCHD)/$(PLIST); \ - fi - @echo - chown -h root:admin $(ROOT) $(ROOT)/* - chmod -h 0775 $(ROOT) $(ROOT)/docs - @echo - -install-haiku: - if [ -f "$(NET_SRV)" -a ! "$$(grep -m1 gopher $(NET_SRV))" ]; then \ - (echo ""; \ - echo "service gopher {"; \ - echo " family inet"; \ - echo " protocol tcp"; \ - echo " port 70"; \ - echo " launch $(BINARY) -h $$(hostname)"; \ - echo "}") >> $(NET_SRV); \ - fi - @echo - chown user:root $(DOCDIR)/* $(SBINDIR)/$(BINARY) $(ROOT)/$(MAP) - @echo - ps | grep net_server | grep -v grep | awk '{ print $$2 }' | xargs kill - nohup /boot/system/servers/net_server >/dev/null 2>/dev/null & - @echo - -install-systemd: install-files install-docs install-root - if [ -d "$(HAS_STD)" ]; then \ - if [ -d "$(SYSCONF)" -a ! -f "$(SYSCONF)/$(NAME)" ]; then \ - $(INSTALL) -m 644 init/$(NAME).env $(SYSCONF)/$(NAME); \ - fi; \ - if [ ! -d "$(SYSCONF)" -a -d "$(DEFAULT)" -a ! -f $(DEFAULT)/$(NAME) ]; then \ - $(INSTALL) -m 644 init/$(NAME).env $(DEFAULT)/$(NAME); \ - fi; \ - for DIR in $(SYSTEMD); do \ - if [ -d "$$DIR" ]; then \ - $(INSTALL) -m 644 init/$(NAME).socket init/$(NAME)\@.service $$DIR; \ - break; \ - fi; \ - done; \ - if pidof systemd ; then \ - systemctl daemon-reload; \ - systemctl enable $(NAME).socket; \ - systemctl start $(NAME).socket; \ - fi; \ - fi - @echo - -# Uninstall cases -uninstall: uninstall-xinetd uninstall-launchd uninstall-systemd uninstall-inetd - rm -f $(SBINDIR)/$(BINARY) - for DOC in $(DOCS); do rm -f $(DOCDIR)/$$DOC; done - rmdir -p $(SBINDIR) $(DOCDIR) 2>/dev/null || true - rm -rf $(MANDEST) - @echo - -uninstall-inetd: - @if [ -f "$(INETD)" ] && update-inetd --remove "^gopher.*gophernicus" ; then \ - echo update-inetd remove worked ; \ - else if grep '^gopher' $(INETD) >/dev/null 2>&1 && \ - sed -i .bak -e 's/^gopher/#gopher/' $(INETD) ; then \ - echo "commented out gopher entry in $(INETD), reloading inetd" ; \ - [ -r $(INETPID) ] && kill -HUP $$(cat $(INETPID)) ; \ - else echo "::::: could not find gopher entry in $(INETD) :::::" ; \ - fi ; \ - fi - @echo - -uninstall-xinetd: - if grep -q $(BINARY) "$(XINETD)/gopher" 2>/dev/null; then \ - rm -f $(XINETD)/gopher; \ - [ -x /sbin/service ] && service xinetd reload; \ - fi - @echo - -uninstall-launchd: - if [ -f $(LAUNCHD)/$(PLIST) ]; then \ - launchctl unload $(LAUNCHD)/$(PLIST); \ - rm -f $(LAUNCHD)/$(PLIST); \ - fi - if [ -L $(ROOT) ]; then \ - rm -f $(ROOT); \ - fi - @echo - -uninstall-systemd: - if [ -d "$(HAS_STD)" ]; then \ - for DIR in $(SYSTEMD); do \ - if [ -f "$$DIR/$(NAME).socket" ]; then \ - systemctl stop $(NAME).socket; \ - systemctl disable $(NAME).socket; \ - rm -f $$DIR/$(NAME).socket $$DIR/$(NAME)\@.service $(SYSCONF)/$(NAME) $(DEFAULT)/$(NAME); \ - systemctl daemon-reload; \ - break; \ - fi; \ - done; \ - fi - @echo diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..24ddacc --- /dev/null +++ b/Makefile.in @@ -0,0 +1,149 @@ +NAME = gophernicus +PACKAGE = $(NAME) +BINARY = $(NAME) +VERSION = 3.1 +CODENAME = Dungeon Edition + +SOURCES = src/$(NAME).c src/file.c src/menu.c src/string.c src/platform.c src/session.c src/options.c src/log.c +HEADERS = src/files.h src/filetypes.h +OBJECTS = $(SOURCES:.c=.o) +README = README.md +MANPAGE = $(DESTDIR)gophernicus.1 + +DESTDIR ?= / +PREFIX = @PREFIX@ +BINDIR = @BINDIR@ +SBINDIR = @SBINDIR@ +MANDIR = @MANDIR@ +MAN1DIR = @MAN1DIR@ + +INSTALL = @INSTALL@ +INSTALL_ARGS = -o 0 -g 0 +ROOT = @ROOT@ +OSXROOT = /Library/GopherServer + +INETD = @INETD_CONF@ +XINETD = @XINETD_CONF@ +# get OPTIONS line from gophernicus.env and use that also for inetd +INETOPT = $$(grep '^OPTIONS=' $(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//') +LAUNCHD = @LAUNCHD@ +PLIST = org.$(NAME).server.plist +HAIKU_SRV = @HAIKUSRV@ +DEFAULT = @DEFAULT@ +SYSCONF = @SYSCONF@ +HOSTNAME = @HOSTNAME@ + +CC ?= @CC@ +CFLAGS := -O2 -Wall @LIBWRAP@ $(CFLAGS) +LDFLAGS := $(LDFLAGS) + +IPCRM ?= @IPCRM@ +MAKE ?= @MAKE@ + +all: + $(MAKE) headers + $(MAKE) src/$(BINARY) + +headers: $(HEADERS) + +src/$(NAME).c: src/$(NAME).h + +src/$(BINARY): $(OBJECTS) + $(CC) $(OBJECTS) $(CFLAGS) -o $@ $(LDFLAGS) + +.c.o: + $(CC) -c $(CFLAGS) -DVERSION="\"$(VERSION)\"" -DCODENAME="\"$(CODENAME)\"" -DDEFAULT_ROOT="\"$(ROOT)\"" $< -o $@ + +src/filetypes.h: src/filetypes.conf + sh src/filetypes.sh < src/filetypes.conf > $@ + +src/bin2c: src/bin2c.c + $(CC) src/bin2c.c -o $@ + +src/files.h: src/bin2c + sed -e '/^(end of option list)/,$$d' README.md > README.options + ./src/bin2c -0 -n README README.options > $@ + ./src/bin2c -0 LICENSE >> $@ + ./src/bin2c -n ERROR_GIF error.gif >> $@ + +# Clean cases + +clean: @CLEAN_SHM@ + rm -rf src/$(BINARY) $(OBJECTS) $(HEADERS) README.options README src/bin2c + +clean-shm: + $(IPCRM) -M $$(awk '/SHM_KEY/ { print $$3 }' src/$(NAME).h) || true + +# Install cases + +install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INSTALL_HAIKU@ @INSTALL_SYSTEMD@ @INSTALL_XINETD@ @INSTALL_INETD_MANUAL@ @INSTALL_INETD_UPDATE@ install-done + $(INSTALL) -s -m 755 src/$(BINARY) $(DESTDIR)$(SBINDIR) +.PHONY: install + +install-done: + @echo + @echo "======================================================================" + @echo + @echo "If there were no errors shown above," + @echo "Gophernicus has now been succesfully installed. To try it out, launch" + @echo "your favorite gopher browser and navigate to your gopher root." + @echo + @echo "Gopher URL...: gopher://$$(hostname)/" + @echo + @echo "======================================================================" + @echo + +install-man: + $(INSTALL) -m 644 $(MANPAGE) $(DESTDIR)$(MANDEST) + +install-root: + $(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT) + +install-inetd-update: install-root + update-inetd --add $$(sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in) + +install-inetd-manual: install-root + sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in > $(DESTDIR)$(INETD) + +install-xinetd: install-root + sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" init/$(NAME).xinetd.in > $(DESTDIR)$(XINETD)/$(NAME) + +install-osx: install-root + sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" init/$(PLIST).in > $(DESTDIR)$(LAUNCHD)/$(PLIST) + chown -h root:admin $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/* + chmod -h 0775 $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/docs + +install-haiku: install-root + sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" -e "s/@BINARY@/$(BINARY)/g" init/haiku_snippet.in >> $(DESTDIR)$(HAIKU_SRV) + chown user:root $(DESTDIR)$(DOCDIR)/* $(DESTDIR)$(SBINDIR)/$(BINARY) $(DESTDIR)$(ROOT)/$(MAP) + +install-systemd: install-root + $(INSTALL) -m 644 init/$(NAME).env init/$(NAME).socket init/$(NAME)\@.service $(DESTDIR)$(SYSCONF)/$(NAME) + $(INSTALL) -m 644 init/$(NAME).env init/$(NAME).socket init/$(NAME)\@.service $(DESTDIR)$(DEFAULT)/$(NAME) + +uninstall: @UNINSTALL_INETD_UPDATE@ @UNINSTALL_INETD_MANUAL@ @UNINSTALL_XINETD@ @UNINSTALL_OSX@ @UNINSTALL_SYSTEMD@ + rm -f $(DESTDIR)$(SBINDIR)/$(BINARY) + rm -f $(DESTDIR)$(MANDEST)/$(MANPAGE) + +uninstall-inetd-update: + update-inetd --remove "^gopher.*gophernicus" + +uninstall-inetd-manual: + sed -i '/^gopher/d' $(DESTDIR)$(INETD) + +uninstall-xinetd: + rm -f $(DESTDIR)$(XINETD)/gopher + +uninstall-osx: + rm -f $(DESTDIR)$(LAUNCHD)/$(PLIST) + +uninstall-haiku: + rm -f $(DESTDIR)$(HAIKU_SRV) + +uninstall-systemd: + rm -f $(DESTDIR)$(SYSCONF)/$(NAME)/$(NAME).env + rm -f $(DESTDIR)$(SYSCONF)/$(NAME)/$(NAME).socket + rm -f $(DESTDIR)$(SYSCONF)/$(NAME)/$(NAME)\@.service + rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME).env + rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME).socket + rm -f $(DESTDIR)$(DEFAULT)/$(NAME)/$(NAME)\@.service diff --git a/install-sh b/build-aux/install-sh similarity index 100% rename from install-sh rename to build-aux/install-sh diff --git a/configure b/configure new file mode 100755 index 0000000..579a5db --- /dev/null +++ b/configure @@ -0,0 +1,310 @@ +#!/bin/sh + +# Is similar to an autoconf configure script, but is written by hand + +usage() { + printf "Usage: %s [options]\\n\\n" "$0" + printf " --prefix=/usr/local Prefix for all files\\n" + printf " --bindir=PREFIX/bin Prefix for binaries\\n" + printf " --sbindir=PREFIX/sbin Prefix for system binaries\\n" + printf " --mandir=PREFIX/share/man Prefix for manpages\\n" + printf " --man1dir=MANDIR/man1 Prefix for section 1 manpages\\n" + printf " --gopherroot=/var/gopher Path to gopher root\\n" + printf " --sysconfig=/etc/sysconfig Path to sysconfig directory\\n\\n" + printf " --default=/etc/default Path to 'default' configuration directory\\n\\n" + printf " --launchd=/Library/LaunchDaemons Path to launchd for MacOS\\n" + printf " --haikusrv=/boot/common/settings/network/services Path to services directory in Haiku\\n\\n" + printf " --os=autodetected Your target OS, one of linux, mac, haiku, netbsd, openbsd or freebsd\\n" + printf " --listener=autodetected Program to recieve and pass network requests; one or more of systemd, inetd, xinetd, comma-seperated, or autodetect, mac or haiku (parameter required, mac/haiku required on respective OSes)\\n" + printf " --hostname=autodetected Desired hostname for gophernicus to identify as\\n" +} + +# Set values for each option +while [ "$#" -gt 0 ] ; do + opt="${1%%=*}" + opt="${opt##--}" + value="${1##*=}" + case "${opt}" in + prefix) PREFIX="${value}"; shift ;; + bindir) BINDIR="${value}"; shift ;; + sbindir) SBINDIR="${value}"; shift ;; + docdir) DOCDIR="${value}"; shift ;; + mandir) MANDIR="${value}"; shift ;; + man1dir) MAN1DIR="${value}"; shift ;; + gopherroot) GOPHERROOT="${value}"; shift ;; + sysconfig) SYSCONFIG="${value}"; shift ;; + default) DEFAULTCONF="${value}"; shift ;; + os) OS="${value}"; shift ;; + launchd) LAUNCHD="${value}"; shift ;; + haikusrv) HAIKUSRV="${value}"; shift ;; + listener) LISTENER="${value}"; shift ;; + hostname) HOSTNAME="${value}"; shift ;; + help) usage; exit 0 ;; + *) usage; exit 2 ;; + esac +done + +# Set default values +: ${PREFIX:=/usr/local} +: ${BINDIR:=${PREFIX}/bin} +: ${SBINDIR:=${PREFIX}/sbin} +: ${DOCDIR:=${PREFIX}/share/doc} +: ${MANDIR:=${PREFIX}/share/man} +: ${MAN1DIR:=${MANDIR}/man1} +: ${GOPHERROOT:=/var/gopher} +: ${SYSCONFIG:=/etc/sysconfig} +: ${DEFAULTCONF:=/etc/default} +: ${LAUNCHD:=/Library/LaunchDaemons} +: ${HAIKUSRV:=/boot/common/settings/network/services} +: ${CC:=cc} +: ${CFLAGS:=-O2} +: ${HOSTNAME:=autodetect} + +# Check for a compiler that actually works +printf "checking for working compiler... " +cat > conftest.c < +int main() { return 0; } +EOF +if ! ${CC} -o conftest conftest.c; then + printf "no\\n" + exit 1 +else + printf "${CC}\\n" +fi + +# Autodetect the OS +if ! [ "${OS:=1}" ]; then + # If it can't find uname, it needs to be manually specified + printf "checking for uname... " + if ! UNAME="$(command -v uname)"; then + printf "please provide OS in options\\n" + exit 1 + else + printf "%s\\n" "${UNAME}" + fi + + # If it can, it presses on + printf "checking for OS... " + case "$(${UNAME})" in + Linux) OS=linux ;; + Haiku) OS=haiku + INSTALL_HAIKU="install-haiku" ;; + Darwin) OS=mac + INSTALL_OSX="install-osx" ;; + NetBSD) OS=netbsd ;; + OpenBSD) OS=openbsd ;; + FreeBSD) OS=freebsd ;; + *) printf "unknown, pressing on anyway\\n" ;; + esac + printf "%s\\n" "${OS}" +fi + +# Checks for an install command and falls back to install-sh +printf "checking for install... " +if ! INSTALL="$(command -v install)"; then + printf "install-sh" + INSTALL=build-aux/install-sh +else + printf "%s" "${INSTALL}" +fi +printf "\\n" + +# Check for listener validity and autodetect if required +# Checks that take place: +# mac OS = mac listener (both ways) +# haiku OS = haiku listener (both ways) +# systemd listener = linux OS +printf "checking for listener... " +if [ -z "${LISTENER}" ]; then + printf "not given\\n" + exit 1 +elif [ "${LISTENER}" = "mac" ] && [ "${OS}" != "mac" ]; then + printf "mac listener only valid with macos\\n" + exit 1 +elif [ "${LISTENER}" = "haiku" ] && [ "${OS}" != "haiku" ]; then + printf "haiku listener only valid with haiku\\n" + exit 1 +elif [ "${LISTENER}" = "systemd" ] && [ "${OS}" != "linux" ]; then + printf "systemd listener only valid with linux\\n" + exit 1 +elif [ "${LISTENER}" = "autodetect" ]; then + # OS-specific listeners + case "${OS}" in + mac) + LISTENER=mac + printf "mac\\n" + break ;; + haiku) + LISTENER=haiku + printf "haiku\\n" + break ;; + esac + + if [ -d "/lib/systemd/system" ] ; then + LISTENER=systemd + printf "systemd\\n" + break + fi + + printf "checking for inetd... " + if command -v update-inetd; then + LISTENER=inetd + printf "inetd\\n" + break + fi + + printf "checking for xinetd... " + if XINETD="$(command -v xinetd)"; then + LISTENER=xinetd + printf "xinetd\\n" + break + fi + + # Ensure we detected something + if [ "${LISTENER}" = "autodetect" ]; then + printf "unable to autodetect, please manually specify\\n" + exit 1 + fi +elif [ "${OS}" = "haiku" ] && [ "${LISTENER}" != "haiku" ]; then + printf "only haiku listener supported on haiku\\n" + exit 1 +elif [ "${OS}" = "mac" ] && [ "${LISTENER}" != "mac" ]; then + printf "only mac listener supported on mac\\n" + exit 1 +else + printf "%s\\n" "${LISTENER}" +fi + +# Act accordingly based on whichever listener we are given +case "${LISTENER}" in + systemd) + INSTALL_SYSTEMD="install-systemd" + UNINSTALL_SYSTEMD="uninstall-systemd" ;; + xinetd) + INSTALL_XINETD="install-xinetd" + UNINSTALL_XINETD="uninstall-xinetd" + XINETD_CONF="/etc/xinetd.d/gophernicus" ;; + inetd) + INSTALL_INETD="install-inetd" + INETD_CONF="/etc/inetd.conf" + printf "checking for update-inetd... " + if ! UPDATE_INETD="$(command -v update-inetd)"; then + printf "not found\\n" + INSTALL_INETD_MANUAL="install-inetd-manual" + UNINSTALL_INETD_UPDATE="uninstall-inetd-update" + else + printf "%s\\n" "${UPDATE_INETD}" + INSTALL_INETD_UPDATE="install-inetd-update" + UNINSTALL_INETD_UPDATE="uninstall-inetd-update" + fi + ;; + mac) INSTALL_OSX="install-osx" UNINSTALL_OSX="uninstall-osx" ;; + haiku) INSTALL_HAIKU="install-haiku" UNINSTALL_HAIKU="uninstall-haiku" ;; + *) printf "The listener %s is not offically supported; continuing anyway.\\n" "${LISTENER}" ;; +esac + +# Try to detect hostname +printf "getting hostname... " +if [ "${HOSTNAME}" = "autodetect" ]; then + HOSTNAME="$(hostname)" + # If no hostname then we couldn't autodetect + if [ $? != 0 ] || [ -z "${HOSTNAME}" ]; then + printf "unable to detect hostname\\n" + exit 1 + fi +fi +printf "%s\\n" "${HOSTNAME}" + +# Use libwrap when it is avaliable +printf "checking for libwrap... " +cat > conftest.c < +int main() {} +EOF +if ${CC} -o conftest -lwrap conftest.c 2>/dev/null; then + LIBWRAP="-DHAVE_LIBWRAP" + printf "yes" +else + LIBWRAP= + printf "no, but program will still work" +fi +printf "\\n" + +# Check and use SHM if avaliable +printf "checking for ipcrm (SHM management)... " +if ! IPCRM="$(command -v ipcrm)"; then + printf "not found" +else + printf "%s" "${IPCRM}" + CLEAN_SHM="clean-shm" +fi +printf "\\n" + +# Trying to autodetect make +printf "checking for make... " +if ! MAKE="$(command -v make)"; then + printf "not found, please pass MAKE=/path/to/make to make invocation" + MAKE="make" +else + printf "%s" "${MAKE}" +fi +printf "\\n" + +# Don't replace an existing root +printf "checking for existing gopher root... " +if [ -d "${GOPHERROOT}" ] || [ -f "${GOPHERROOT}/gophermap" ]; then + INSTALL_ROOT="install-root" + printf "yes" +else + printf "no" +fi +printf "\\n" + +# Sub in values +cp Makefile.in Makefile + +printf "creating Makefile... " +sed -i "s:@CC@:${CC}:" Makefile +sed -i "s:@LIBWRAP@:${LIBWRAP}:" Makefile +sed -i "s:@INSTALL@:${INSTALL}:" Makefile +sed -i "s:@MAKE@:${MAKE}:" Makefile + +sed -i "s:@PREFIX@:${PREFIX}:" Makefile +sed -i "s:@BINDIR@:${BINDIR}:" Makefile +sed -i "s:@SBINDIR@:${SBINDIR}:" Makefile +sed -i "s:@DOCDIR@:${DOCDIR}:" Makefile +sed -i "s:@MANDIR@:${MANDIR}:" Makefile +sed -i "s:@MAN1DIR@:${MAN1DIR}:" Makefile + +sed -i "s:@IPCRM@:${IPCRM}:" Makefile +sed -i "s:@CLEAN_SHM@:${CLEAN_SHM}:" Makefile + +sed -i "s:@SYSCONF@:${SYSCONFIG}:" Makefile +sed -i "s:@DEFAULT@:${DEFAULTCONF}:" Makefile +sed -i "s:@HOSTNAME@:${HOSTNAME}:" Makefile +sed -i "s:@ROOT@:${GOPHERROOT}:" Makefile + +sed -i "s:@HAIKUSRV@:${HAIKUSRV}:" Makefile +sed -i "s:@LAUNCHD@:${LAUNCHD}:" Makefile +sed -i "s:@INSTALL_ROOT@:${INSTALL_ROOT}:" Makefile + +sed -i "s:@INSTALL_OSX@:${INSTALL_OSX}:" Makefile +sed -i "s:@INSTALL_INETD_MANUAL@:${INSTALL_INETD_MANUAL}:" Makefile +sed -i "s:@INSTALL_INETD_UPDATE@:${INSTALL_INETD_UPDATE}:" Makefile +sed -i "s:@INSTALL_XINETD@:${INSTALL_XINETD}:" Makefile +sed -i "s:@INSTALL_SYSTEMD@:${INSTALL_SYSTEMD}:" Makefile +sed -i "s:@INSTALL_HAIKU@:${INSTALL_HAIKU}:" Makefile +sed -i "s:@UNINSTALL_OSX@:${UNINSTALL_OSX}:" Makefile +sed -i "s:@UNINSTALL_INETD_MANUAL@:${UNINSTALL_INETD_MANUAL}:" Makefile +sed -i "s:@UNINSTALL_INETD_UPDATE@:${UNINSTALL_INETD_UPDATE}:" Makefile +sed -i "s:@UNINSTALL_XINETD@:${UNINSTALL_XINETD}:" Makefile +sed -i "s:@UNINSTALL_SYSTEMD@:${UNINSTALL_SYSTEMD}:" Makefile +sed -i "s:@UNINSTALL_HAIKU@:${UNINSTALL_HAIKU}:" Makefile + +sed -i "s:@INETD_CONF@:${INETD_CONF}:" Makefile +sed -i "s:@XINETD_CONF@:${XINETD_CONF}:" Makefile +printf "done\\n" + +# Cleanup +rm -f conftest conftest.c diff --git a/init/.gitignore b/init/.gitignore new file mode 100644 index 0000000..882a402 --- /dev/null +++ b/init/.gitignore @@ -0,0 +1,4 @@ +haiku_snippet +org.gophernicus.server.plist +gophernicus.xinetd +inetlin diff --git a/init/gophernicus.xinetd b/init/gophernicus.xinetd.in similarity index 100% rename from init/gophernicus.xinetd rename to init/gophernicus.xinetd.in diff --git a/init/haiku_snippet.in b/init/haiku_snippet.in new file mode 100644 index 0000000..84da366 --- /dev/null +++ b/init/haiku_snippet.in @@ -0,0 +1,7 @@ + +service gopher { + family inet + protocol tcp + port 70 + launch @BINARY@ -h @HOSTNAME@ +} diff --git a/init/inetlin.in b/init/inetlin.in new file mode 100644 index 0000000..aa02d82 --- /dev/null +++ b/init/inetlin.in @@ -0,0 +1 @@ +gopher stream tcp nowait @BINARY_PATH@ @BINARY_NAME@ @OPTIONS@ diff --git a/init/org.gophernicus.server.plist b/init/org.gophernicus.server.plist.in similarity index 100% rename from init/org.gophernicus.server.plist rename to init/org.gophernicus.server.plist.in From c3ab769f8dc16373cabac8c4b89dd3fcc44d4257 Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Wed, 9 Dec 2020 10:15:15 -0500 Subject: [PATCH 2/5] Fix build system issues Also, move the gophernicus man page to its appropriate section (8) --- Makefile.in | 16 +++++++--------- configure | 10 +++++----- gophernicus.1 => gophernicus.8 | 0 3 files changed, 12 insertions(+), 14 deletions(-) rename gophernicus.1 => gophernicus.8 (100%) diff --git a/Makefile.in b/Makefile.in index 24ddacc..00b807b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -8,14 +8,15 @@ SOURCES = src/$(NAME).c src/file.c src/menu.c src/string.c src/platform.c src/se HEADERS = src/files.h src/filetypes.h OBJECTS = $(SOURCES:.c=.o) README = README.md -MANPAGE = $(DESTDIR)gophernicus.1 +MANPAGE = gophernicus.8 +MAP = gophermap DESTDIR ?= / PREFIX = @PREFIX@ BINDIR = @BINDIR@ SBINDIR = @SBINDIR@ MANDIR = @MANDIR@ -MAN1DIR = @MAN1DIR@ +MAN8DIR = @MAN8DIR@ INSTALL = @INSTALL@ INSTALL_ARGS = -o 0 -g 0 @@ -76,11 +77,8 @@ clean-shm: # Install cases -install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INSTALL_HAIKU@ @INSTALL_SYSTEMD@ @INSTALL_XINETD@ @INSTALL_INETD_MANUAL@ @INSTALL_INETD_UPDATE@ install-done - $(INSTALL) -s -m 755 src/$(BINARY) $(DESTDIR)$(SBINDIR) -.PHONY: install - -install-done: +install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INSTALL_HAIKU@ @INSTALL_SYSTEMD@ @INSTALL_XINETD@ @INSTALL_INETD_MANUAL@ @INSTALL_INETD_UPDATE@ + $(INSTALL) -s -m 755 -D -t $(DESTDIR)$(SBINDIR) src/$(BINARY) @echo @echo "======================================================================" @echo @@ -94,10 +92,10 @@ install-done: @echo install-man: - $(INSTALL) -m 644 $(MANPAGE) $(DESTDIR)$(MANDEST) + $(INSTALL) -m 644 -D -t $(DESTDIR)$(MAN8DIR) $(MANPAGE) install-root: - $(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT) + $(INSTALL) -m 644 -D $(MAP).sample $(DESTDIR)$(ROOT)/gophermap install-inetd-update: install-root update-inetd --add $$(sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in) diff --git a/configure b/configure index 579a5db..03a55ba 100755 --- a/configure +++ b/configure @@ -8,7 +8,7 @@ usage() { printf " --bindir=PREFIX/bin Prefix for binaries\\n" printf " --sbindir=PREFIX/sbin Prefix for system binaries\\n" printf " --mandir=PREFIX/share/man Prefix for manpages\\n" - printf " --man1dir=MANDIR/man1 Prefix for section 1 manpages\\n" + printf " --man8dir=MANDIR/man8 Prefix for section 8 manpages\\n" printf " --gopherroot=/var/gopher Path to gopher root\\n" printf " --sysconfig=/etc/sysconfig Path to sysconfig directory\\n\\n" printf " --default=/etc/default Path to 'default' configuration directory\\n\\n" @@ -30,7 +30,7 @@ while [ "$#" -gt 0 ] ; do sbindir) SBINDIR="${value}"; shift ;; docdir) DOCDIR="${value}"; shift ;; mandir) MANDIR="${value}"; shift ;; - man1dir) MAN1DIR="${value}"; shift ;; + man8dir) MAN8DIR="${value}"; shift ;; gopherroot) GOPHERROOT="${value}"; shift ;; sysconfig) SYSCONFIG="${value}"; shift ;; default) DEFAULTCONF="${value}"; shift ;; @@ -50,7 +50,7 @@ done : ${SBINDIR:=${PREFIX}/sbin} : ${DOCDIR:=${PREFIX}/share/doc} : ${MANDIR:=${PREFIX}/share/man} -: ${MAN1DIR:=${MANDIR}/man1} +: ${MAN8DIR:=${MANDIR}/man8} : ${GOPHERROOT:=/var/gopher} : ${SYSCONFIG:=/etc/sysconfig} : ${DEFAULTCONF:=/etc/default} @@ -223,7 +223,7 @@ cat > conftest.c </dev/null; then - LIBWRAP="-DHAVE_LIBWRAP" + LIBWRAP="-DHAVE_LIBWRAP -lwrap" printf "yes" else LIBWRAP= @@ -275,7 +275,7 @@ sed -i "s:@BINDIR@:${BINDIR}:" Makefile sed -i "s:@SBINDIR@:${SBINDIR}:" Makefile sed -i "s:@DOCDIR@:${DOCDIR}:" Makefile sed -i "s:@MANDIR@:${MANDIR}:" Makefile -sed -i "s:@MAN1DIR@:${MAN1DIR}:" Makefile +sed -i "s:@MAN8DIR@:${MAN8DIR}:" Makefile sed -i "s:@IPCRM@:${IPCRM}:" Makefile sed -i "s:@CLEAN_SHM@:${CLEAN_SHM}:" Makefile diff --git a/gophernicus.1 b/gophernicus.8 similarity index 100% rename from gophernicus.1 rename to gophernicus.8 From 44e50e2dabbcffe37aef95a7be68e8c86e98ef97 Mon Sep 17 00:00:00 2001 From: fosslinux Date: Wed, 23 Dec 2020 11:48:42 +1100 Subject: [PATCH 3/5] Further improvements, delete debian packaging --- INSTALL.md | 157 ++++++----------- Makefile.in | 18 +- configure | 201 ++++++++++++---------- debian/changelog | 89 ---------- debian/compat | 1 - debian/control | 16 -- debian/copyright | 23 --- debian/dirs | 5 - debian/docs | 4 - debian/gophernicus.config | 14 -- debian/gophernicus.default | 13 -- debian/gophernicus.logcheck.ignore.server | 4 - debian/gophernicus.logrotate | 7 - debian/gophernicus.templates | 4 - debian/postinst | 46 ----- debian/postrm | 11 -- debian/prerm | 12 -- debian/rules | 85 --------- debian/source/format | 1 - init/.gitignore | 1 + init/gophernicus.env | 2 +- init/gophernicus.env.in | 10 ++ 22 files changed, 179 insertions(+), 545 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/docs delete mode 100755 debian/gophernicus.config delete mode 100644 debian/gophernicus.default delete mode 100644 debian/gophernicus.logcheck.ignore.server delete mode 100644 debian/gophernicus.logrotate delete mode 100644 debian/gophernicus.templates delete mode 100644 debian/postinst delete mode 100644 debian/postrm delete mode 100644 debian/prerm delete mode 100755 debian/rules delete mode 100644 debian/source/format create mode 100644 init/gophernicus.env.in diff --git a/INSTALL.md b/INSTALL.md index f586343..6f11f09 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -13,121 +13,65 @@ To compile and install run: ``` $ git clone -b 3.0.1 https://github.com/gophernicus/gophernicus.git $ cd gophernicus +$ ./configure --listener=somelistener $ make $ sudo make install ``` -after having set the correct public hostname in the `gophernicus.env` -file. If this is wrong, selectors ("gopher links") won't work! +Important configure arguments include: -On \*nix systems, `hostname` might give you an idea, but please -note this might be completely wrong, especially on your personal -machine at home or on some cheap virtual server. If you know you -have a fixed numerical IP, you can also directly use that. -For testing, just keep the default value of `localhost` which will -result in selectors working only when you're connecting locally. +- `--listener`. This is the only required argument. You must + choose a listener that passes network requests to + gophernicus, as gophernicus dosen't do this by itself. The + options are: + - systemd, a common init system on many Linux distributions + that can do this without an external program. + - inetd, an older, well-known implementation that is very + simple. + - xinetd, a modern reimplementation of inetd using specific + config files. + - mac, to be used on Mac OSX machines. + - haiku, to be used on Haiku machines. + - autodetect, which looks at what you have avaliable + (unrecommended, please manually specify where possible). +- `--hostname`. This is by default attempted to be autodetected + by the configure script, using the command `hostname`. It is + expected to be the publicly-accessible address of the server. + However, this might be completely wrong, especially on your + personal machine at home or on some cheap VPS. If you know you + have a fixed numerical IP, you can also directly use that. + For testing, just keep the default value of `localhost` which will + result in selectors working only when you're connecting locally. +- `--gopherroot`. The location in which your gopher server will + serve from. By default is `/var/gopher`. Also can be changed + later using the `-r ` parameter in configuration files. That's it - Gophernicus should now be installed, preconfigured and running under gopher:///. And more often than not, It Just Works(tm). -By default Gophernicus serves gopher documents from `/var/gopher` -although that can be changed by using the `-r ` parameter. -To enable virtual hosting create hostname directories under -the gopher root and make sure you have at least the primary -hostname (the one set with `-h `) directory available -(`mkdir /var/gopher/$HOSTNAME`). - - -## Dependencies - -These were obtained from a base docker installation. - -### Ubuntu 18.04, 16.04, Debian Sid, Buster, Stretch, Jessie -- build-essential -- git -- libwrap0-dev for tcp -- fakeroot - -### Centos 6, 7 -- the group 'Development Tools'. less is probably required, but - I know this works and couldn't be bothered to find out what was - actually required. - -### Fedora 29, 30, rawhide -- the group 'Development Tools'. less is probably required, but - I know this works and couldn't be bothered to find out what was - actually required. -- net-tools - -### OpenSuse Leap, Tumbleweed -- the pattern devel_C_C++ -- the pattern devel_basis -- git - -### archlinux -- base-devel -- git - -### Gentoo -- git - -### Alpine Linux -- alpine-sdk. once again, less is probably required.. blah blah. - - -### Other installation targets - -Suppose your server runs systemd, but you'd rather have Gophernicus -started with inetd or xinetd. To do that, do `make install-inetd` -or `make install-xinetd`. Likewise use `make uninstall-inetd` or -`make uninstall-xinetd` to uninstall Gophernicus. - - ## Compiling with TCP wrappers Gophernicus uses no extra libraries... well... except libwrap (TCP wrappers) if it is installed with headers in default Unix directories at the time of compiling. If you have the headers -installed and don't want wrapper support, run 'make generic' -instead of just 'make', and if you have wrappers installed in -non-standard place and want to force compile with wrappers -just run 'make withwrap'. +installed and don't want wrapper support, too bad (for now, see +issue #89). For configuring IP access lists with TCP wrappers, take a look at the files `/etc/hosts.allow` and `/etc/hosts.deny` (because the manual pages suck). Use the daemon name "gophernicus" to make your access lists. +## Distributions -## Running with traditional inetd superserver - -If you want to run Gophernicus under the traditional Unix inetd, the -below line should be added to your `/etc/inetd.conf` and the inetd -process restarted. - -``` -gopher stream tcp nowait nobody /usr/sbin/gophernicus gophernicus -h -``` - -The Makefile will automatically do this for you and remove it when -uninstalling. - - -## Compiling on Debian Linux (and Ubuntu) - -The above commands work on Debian just fine, but if you prefer -having everything installed as packages run `make deb` instead -of plain `make`. If all the dependencies were in place you'll -end up with an offical-looking deb package in the parent -directory (don't ask - that's just how it works). And instead -of `sudo make install` you should just install the deb with -`dpkg -i ../gophernicus_*.deb` after which It Should Just -Work(tm). - -If you need TCP wrappers support on Debian/Ubuntu, please -install libwrap0-dev before compiling. +### Debian (and -based) (including Ubuntu) distributions +We used to distribute a `debian/` directory for people to `make +deb` and then install a deb. However, thanks to the work of +Ryan Kavanagh, gophernicus will be distributed in the official +debian repositories in the next stable release! In the interim, +either keep using the old version or install without deb. ## Cross-compiling @@ -137,7 +81,9 @@ must point to a local arch compiler, and CC to the target arch one. ``` -$ make HOSTCC=gcc CC=target-arch-gcc +$ export HOSTCC=gcc CC=target-arch-gcc +$ ./configure .... +$ make ``` ## Shared memory issues @@ -157,7 +103,6 @@ let Gophernicus recreate it - no harm done: $ sudo make clean-shm ``` - ## Porting to different platforms If you need to port Gophernicus to a new platform, please take a look at @@ -168,17 +113,15 @@ the patches to so we can include them into the next release -- or even better, commit them to your fork on Github and make a pull request! -## Supported Platforms +## For packagers -| Platform | Versions | -| ------------ | ---------------------------- | -| Ubuntu | 18.04, 16.04 | -| Debian | Sid, Buster, Stretch, Jessie | -| Centos | 7, 6 | -| Fedora | 29, 30, Rawhide | -| Opensuse | Leap, Tumbleweed | -| Arch Linux | up to date | -| Gentoo | up to date | -| Alpine Linux | Edge, 3.9 | -| FreeBSD | 12.0 | -| Darwin (Mac) | OSX 10.7 | +Are you looking to package gophernicus for a Linux +distribution? Thanks! Please see issue #50 to help. Some tips: + +- Hostnames will need to be configured by users at runtime, the + installed gophernicus.env will need to be a config file. +- You probably want to support as many listeners as possible. + We allow this through the use of a comma seperated list to + `--listener`. +- The default gopher root is `/var/gopher`; many disributions + prefer `/srv`. diff --git a/Makefile.in b/Makefile.in index 00b807b..134f58e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -26,15 +26,15 @@ OSXROOT = /Library/GopherServer INETD = @INETD_CONF@ XINETD = @XINETD_CONF@ # get OPTIONS line from gophernicus.env and use that also for inetd -INETOPT = $$(grep '^OPTIONS=' $(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//') +INETOPT = $$(grep '^OPTIONS=' init/$(NAME).env | tail -n 1 | sed -e 's/OPTIONS="*//;s/"*$$//') LAUNCHD = @LAUNCHD@ PLIST = org.$(NAME).server.plist HAIKU_SRV = @HAIKUSRV@ DEFAULT = @DEFAULT@ SYSCONF = @SYSCONF@ -HOSTNAME = @HOSTNAME@ CC ?= @CC@ +HOSTCC ?= @HOSTCC@ CFLAGS := -O2 -Wall @LIBWRAP@ $(CFLAGS) LDFLAGS := $(LDFLAGS) @@ -59,7 +59,7 @@ src/filetypes.h: src/filetypes.conf sh src/filetypes.sh < src/filetypes.conf > $@ src/bin2c: src/bin2c.c - $(CC) src/bin2c.c -o $@ + $(HOSTCC) src/bin2c.c -o $@ src/files.h: src/bin2c sed -e '/^(end of option list)/,$$d' README.md > README.options @@ -101,18 +101,18 @@ install-inetd-update: install-root update-inetd --add $$(sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in) install-inetd-manual: install-root - sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in > $(DESTDIR)$(INETD) + sed -e "s:@BINARY_PATH@:$(DESTDIR)$(SBINDIR)/$(BINARY):g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in >> $(DESTDIR)$(INETD) install-xinetd: install-root - sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" init/$(NAME).xinetd.in > $(DESTDIR)$(XINETD)/$(NAME) + $(INSTALL) -T -m 644 init/$(NAME).xinetd $(DESTDIR)$(XINETD) install-osx: install-root - sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" init/$(PLIST).in > $(DESTDIR)$(LAUNCHD)/$(PLIST) + $(INSTALL) -m 644 init/$(PLIST) $(DESTDIR)$(LAUNCHD) chown -h root:admin $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/* chmod -h 0775 $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/docs install-haiku: install-root - sed -e "s/@HOSTNAME@/$(HOSTNAME)/g" -e "s/@BINARY@/$(BINARY)/g" init/haiku_snippet.in >> $(DESTDIR)$(HAIKU_SRV) + sed -e "s/@BINARY@/$(BINARY)/g" init/haiku_snippet.in >> $(DESTDIR)$(HAIKU_SRV) chown user:root $(DESTDIR)$(DOCDIR)/* $(DESTDIR)$(SBINDIR)/$(BINARY) $(DESTDIR)$(ROOT)/$(MAP) install-systemd: install-root @@ -121,7 +121,7 @@ install-systemd: install-root uninstall: @UNINSTALL_INETD_UPDATE@ @UNINSTALL_INETD_MANUAL@ @UNINSTALL_XINETD@ @UNINSTALL_OSX@ @UNINSTALL_SYSTEMD@ rm -f $(DESTDIR)$(SBINDIR)/$(BINARY) - rm -f $(DESTDIR)$(MANDEST)/$(MANPAGE) + rm -f $(DESTDIR)$(MAN8DIR)/$(MANPAGE) uninstall-inetd-update: update-inetd --remove "^gopher.*gophernicus" @@ -130,7 +130,7 @@ uninstall-inetd-manual: sed -i '/^gopher/d' $(DESTDIR)$(INETD) uninstall-xinetd: - rm -f $(DESTDIR)$(XINETD)/gopher + rm -f $(DESTDIR)$(XINETD) uninstall-osx: rm -f $(DESTDIR)$(LAUNCHD)/$(PLIST) diff --git a/configure b/configure index 03a55ba..21f29fb 100755 --- a/configure +++ b/configure @@ -15,7 +15,7 @@ usage() { printf " --launchd=/Library/LaunchDaemons Path to launchd for MacOS\\n" printf " --haikusrv=/boot/common/settings/network/services Path to services directory in Haiku\\n\\n" printf " --os=autodetected Your target OS, one of linux, mac, haiku, netbsd, openbsd or freebsd\\n" - printf " --listener=autodetected Program to recieve and pass network requests; one or more of systemd, inetd, xinetd, comma-seperated, or autodetect, mac or haiku (parameter required, mac/haiku required on respective OSes)\\n" + printf " --listener=somelistener Program to recieve and pass network requests; one or more of systemd, inetd, xinetd, comma-seperated, or autodetect, mac or haiku (parameter required, mac/haiku required on respective OSes)\\n" printf " --hostname=autodetected Desired hostname for gophernicus to identify as\\n" } @@ -57,6 +57,7 @@ done : ${LAUNCHD:=/Library/LaunchDaemons} : ${HAIKUSRV:=/boot/common/settings/network/services} : ${CC:=cc} +: ${HOSTCC:=${CC}} : ${CFLAGS:=-O2} : ${HOSTNAME:=autodetect} @@ -74,7 +75,7 @@ else fi # Autodetect the OS -if ! [ "${OS:=1}" ]; then +if [ -z "${OS}" ]; then # If it can't find uname, it needs to be manually specified printf "checking for uname... " if ! UNAME="$(command -v uname)"; then @@ -110,102 +111,105 @@ else fi printf "\\n" -# Check for listener validity and autodetect if required -# Checks that take place: -# mac OS = mac listener (both ways) -# haiku OS = haiku listener (both ways) -# systemd listener = linux OS -printf "checking for listener... " -if [ -z "${LISTENER}" ]; then - printf "not given\\n" - exit 1 -elif [ "${LISTENER}" = "mac" ] && [ "${OS}" != "mac" ]; then - printf "mac listener only valid with macos\\n" - exit 1 -elif [ "${LISTENER}" = "haiku" ] && [ "${OS}" != "haiku" ]; then - printf "haiku listener only valid with haiku\\n" - exit 1 -elif [ "${LISTENER}" = "systemd" ] && [ "${OS}" != "linux" ]; then - printf "systemd listener only valid with linux\\n" - exit 1 -elif [ "${LISTENER}" = "autodetect" ]; then - # OS-specific listeners - case "${OS}" in - mac) - LISTENER=mac - printf "mac\\n" - break ;; - haiku) - LISTENER=haiku - printf "haiku\\n" - break ;; - esac - - if [ -d "/lib/systemd/system" ] ; then - LISTENER=systemd - printf "systemd\\n" - break - fi - - printf "checking for inetd... " - if command -v update-inetd; then - LISTENER=inetd - printf "inetd\\n" - break - fi - - printf "checking for xinetd... " - if XINETD="$(command -v xinetd)"; then - LISTENER=xinetd - printf "xinetd\\n" - break - fi - - # Ensure we detected something - if [ "${LISTENER}" = "autodetect" ]; then - printf "unable to autodetect, please manually specify\\n" +listeners="$(echo ${LISTENER} | tr ',' ' ')" +for listener in ${listeners}; do + # Check for listener validity and autodetect if required + # Checks that take place: + # mac OS = mac listener (both ways) + # haiku OS = haiku listener (both ways) + # systemd listener = linux OS + printf "checking for listener... " + if [ -z "${listener}" ]; then + printf "not given\\n" exit 1 - fi -elif [ "${OS}" = "haiku" ] && [ "${LISTENER}" != "haiku" ]; then - printf "only haiku listener supported on haiku\\n" - exit 1 -elif [ "${OS}" = "mac" ] && [ "${LISTENER}" != "mac" ]; then - printf "only mac listener supported on mac\\n" - exit 1 -else - printf "%s\\n" "${LISTENER}" -fi + elif [ "${listener}" = "mac" ] && [ "${OS}" != "mac" ]; then + printf "mac listener only valid with macos\\n" + exit 1 + elif [ "${listener}" = "haiku" ] && [ "${OS}" != "haiku" ]; then + printf "haiku listener only valid with haiku\\n" + exit 1 + elif [ "${listener}" = "systemd" ] && [ "${OS}" != "linux" ]; then + printf "systemd listener only valid with linux\\n" + exit 1 + elif [ "${listener}" = "autodetect" ]; then + # OS-specific listeners + case "${OS}" in + mac) + LISTENER=mac + printf "mac\\n" + break ;; + haiku) + LISTENER=haiku + printf "haiku\\n" + break ;; + esac -# Act accordingly based on whichever listener we are given -case "${LISTENER}" in - systemd) - INSTALL_SYSTEMD="install-systemd" - UNINSTALL_SYSTEMD="uninstall-systemd" ;; - xinetd) - INSTALL_XINETD="install-xinetd" - UNINSTALL_XINETD="uninstall-xinetd" - XINETD_CONF="/etc/xinetd.d/gophernicus" ;; - inetd) - INSTALL_INETD="install-inetd" - INETD_CONF="/etc/inetd.conf" - printf "checking for update-inetd... " - if ! UPDATE_INETD="$(command -v update-inetd)"; then - printf "not found\\n" - INSTALL_INETD_MANUAL="install-inetd-manual" - UNINSTALL_INETD_UPDATE="uninstall-inetd-update" - else - printf "%s\\n" "${UPDATE_INETD}" - INSTALL_INETD_UPDATE="install-inetd-update" - UNINSTALL_INETD_UPDATE="uninstall-inetd-update" + if [ -d "/lib/systemd/system" ] ; then + LISTENER=systemd + printf "systemd\\n" + break fi - ;; - mac) INSTALL_OSX="install-osx" UNINSTALL_OSX="uninstall-osx" ;; - haiku) INSTALL_HAIKU="install-haiku" UNINSTALL_HAIKU="uninstall-haiku" ;; - *) printf "The listener %s is not offically supported; continuing anyway.\\n" "${LISTENER}" ;; -esac + + printf "checking for inetd... " + if command -v update-inetd; then + LISTENER=inetd + printf "inetd\\n" + break + fi + + printf "checking for xinetd... " + if XINETD="$(command -v xinetd)"; then + LISTENER=xinetd + printf "xinetd\\n" + break + fi + + # Ensure we detected something + if [ "${listener}" = "autodetect" ]; then + printf "unable to autodetect, please manually specify\\n" + exit 1 + fi + elif [ "${OS}" = "haiku" ] && [ "${listener}" != "haiku" ]; then + printf "only haiku listener supported on haiku\\n" + exit 1 + elif [ "${OS}" = "mac" ] && [ "${listener}" != "mac" ]; then + printf "only mac listener supported on mac\\n" + exit 1 + else + printf "%s\\n" "${listener}" + fi + + # Act accordingly based on whichever listener we are given + case "${listener}" in + systemd) + INSTALL_SYSTEMD="install-systemd" + UNINSTALL_SYSTEMD="uninstall-systemd" ;; + xinetd) + INSTALL_XINETD="install-xinetd" + UNINSTALL_XINETD="uninstall-xinetd" + XINETD_CONF="/etc/xinetd.d/gophernicus" ;; + inetd) + INSTALL_INETD="install-inetd" + INETD_CONF="/etc/inetd.conf" + printf "checking for update-inetd... " + if ! UPDATE_INETD="$(command -v update-inetd)"; then + printf "not found\\n" + INSTALL_INETD_MANUAL="install-inetd-manual" + UNINSTALL_INETD_UPDATE="uninstall-inetd-manual" + else + printf "%s\\n" "${UPDATE_INETD}" + INSTALL_INETD_UPDATE="install-inetd-update" + UNINSTALL_INETD_UPDATE="uninstall-inetd-update" + fi + ;; + mac) INSTALL_OSX="install-osx" UNINSTALL_OSX="uninstall-osx" ;; + haiku) INSTALL_HAIKU="install-haiku" UNINSTALL_HAIKU="uninstall-haiku" ;; + *) printf "The listener %s is not offically supported; continuing anyway.\\n" "${listener}" ;; + esac +done # Try to detect hostname -printf "getting hostname... " +printf "checking current hostname... " if [ "${HOSTNAME}" = "autodetect" ]; then HOSTNAME="$(hostname)" # If no hostname then we couldn't autodetect @@ -266,6 +270,7 @@ cp Makefile.in Makefile printf "creating Makefile... " sed -i "s:@CC@:${CC}:" Makefile +sed -i "s:@HOSTCC@:${HOSTCC}:" Makefile sed -i "s:@LIBWRAP@:${LIBWRAP}:" Makefile sed -i "s:@INSTALL@:${INSTALL}:" Makefile sed -i "s:@MAKE@:${MAKE}:" Makefile @@ -304,7 +309,17 @@ sed -i "s:@UNINSTALL_HAIKU@:${UNINSTALL_HAIKU}:" Makefile sed -i "s:@INETD_CONF@:${INETD_CONF}:" Makefile sed -i "s:@XINETD_CONF@:${XINETD_CONF}:" Makefile + printf "done\\n" +# Also sub in $HOSTNAME to the various init systems (whether or not we really +# use them, its just easier) +for f in gophernicus.env haiku_snippet org.gophernicus.server.plist \ + gophernicus.xinetd; do + printf "creating init/${f}... " + sed -e "s:@HOSTNAME@:${HOSTNAME}:" "init/${f}.in" > "init/${f}" + printf "done\\n" +done + # Cleanup rm -f conftest conftest.c diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index d46606c..0000000 --- a/debian/changelog +++ /dev/null @@ -1,89 +0,0 @@ -gophernicus (3.1-1) experimental; urgency=medium - - * .gitignore for restructure - * src/bin2c.c should not be executable - * corrected some typos in author's names (#55) - * Merge pull request #54 from emilengler/2020-01-make-force-symlink - * build: macOS travis fix - * build: Force create symlink - * Merge pull request #52 from emilengler/2020-01-new-travis - * ci: New Travis system for linux and macOS builds and installs - * Merge pull request #51 from emilengler/2020-01-refactor-hierarchy - * refactor: New hierarchy and refactored Makefile - * re-add travis - * use user-defined CC by default - * update development version to 3.1; next release will be 3.1 - * gophermap -> gophermap.sample debian - * Merge pull request #47 from tallship/patch-1 - * Update gophernicus.1.man - * gophermap -> gophermap.sample, be more descriptive with the name - * add manpage - * clean up Makefile - * add -b option to git clone instead of git checkout - * add fakeroot as dependency for dpkg - * changelog update, todo makefile fix - * Merge pull request #44 from tallship/patch-1 - * Update README.md - * remove TODO - * Merge pull request #17 from vext01/pledge-unveil - * Add OpenBSD pledge(2) and unveil(2) support. - * utf-8 default charset in readme.md - * update changelog - * Merge pull request #40 from fosslinux/utf8-charset - * change default charset to utf-8 - * change max-width to 67 (#39) - * change indentation from tabs to spaces - * fix copyright - * update copyright in README.md - * Update INSTALL.md - * No longer relevant - * remove <>, was screwing up email - * remove obselete .travis.yml - * Update LICENSE - * forgot to change makefile - * Merge pull request #36 from gophernicus/3.0.1 - - -- gophernicus developers Mon, 31 Dec 9999 11:59:59 +0000 - -gophernicus (3.0.1-1) unstable; urgency=medium - - * add installation notes to git checkout before installing - * fix typo in debian packaging (fixes `make deb`) - * update docs to reflect new changes - * fix indenting and typos in docs - - -- gophernicus developers Sun, 21 Jul 2019 18:36:08 +1000 - -gophernicus (3.0-1.1) unstable; urgency=medium - - * N.B. this version has two important changes that may make it - backwards-incompatible: - * binary changed from in.gophernicus to gophernicus - * virtual hosting NEVER WORKED and does not work in the way previously - described - * Other changes: - * prevent leak of executable gophermap contents - * make sure {x,}inetd works when systemd is on the system - * allow -j flag to work - * add h9bnks (yargo) and fosslinux into developer roles - * add -nx flag, blocks executable gophermaps - * add -nu flag, disable ~/public_gopher - * modify various documentation to markdown - * fix various formattings and typos - * allow inetd targets to work without update-inetd - * correct handling of inetd.conf - * remove list of supported platforms - * remove example gophermaps - * add dependencies for various distros to INSTALL.md - * fix query urls - * add travis ci - * add documentation about CI - * Upgrade guide: - * If you are running gophernicus on a **production** system, **do not** upgrade - to 3.0. Wait for 3.1. - * As a general guide, - * If you are running 101 and haven't upgraded to newer versions **because** of - instability worries, **wait for 3.1**. - * If you were running other rolling-release versions, **upgrade now**. - - -- gophernicus developers Sun, 16 Jun 2019 17:49:46 +0000 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/control b/debian/control deleted file mode 100644 index 84fce6c..0000000 --- a/debian/control +++ /dev/null @@ -1,16 +0,0 @@ -Source: gophernicus -Section: net -Priority: extra -Maintainer: gophernicus developers -Build-Depends: debhelper (>= 5), libwrap0-dev -Standards-Version: 3.7.3 -Homepage: https://github.com/gophernicus/gophernicus - -Package: gophernicus -Architecture: any -Depends: ${shlibs:Depends}, debconf, netbase, libwrap0, openbsd-inetd | inet-superserver | systemd -Recommends: lsb-release -Suggests: php5-cli -Description: Modern full-featured gopher server - Gophernicus is a modern full-featured (and hopefully) secure - gopher daemon. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 096df79..0000000 --- a/debian/copyright +++ /dev/null @@ -1,23 +0,0 @@ -Gophernicus - Copyright (c) 2009-2018 Kim Holviala - 2019 gophernicus developers -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index 6dc0f4e..0000000 --- a/debian/dirs +++ /dev/null @@ -1,5 +0,0 @@ -usr/sbin -var/gopher -var/log/gophernicus -usr/lib/gophernicus/filters -lib/systemd/system diff --git a/debian/docs b/debian/docs deleted file mode 100644 index a470771..0000000 --- a/debian/docs +++ /dev/null @@ -1,4 +0,0 @@ -gophernicus.1 -README.gophermap -changelog -gophertag diff --git a/debian/gophernicus.config b/debian/gophernicus.config deleted file mode 100755 index 1332353..0000000 --- a/debian/gophernicus.config +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Source debconf library -. /usr/share/debconf/confmodule - -# Ask for a hostname -db_input high gophernicus/fqdn || true -db_go - -# Clear old config on reconfigure -if [ "$1" = "reconfigure" -a -x /usr/sbin/update-inetd ]; then - /usr/sbin/update-inetd --remove "## gopher" -fi - diff --git a/debian/gophernicus.default b/debian/gophernicus.default deleted file mode 100644 index c06f426..0000000 --- a/debian/gophernicus.default +++ /dev/null @@ -1,13 +0,0 @@ -# Options for Gophernicus for use with systemd -# -# If you are using Gophernicus with inetd this configuration file -# is ignored and the real configuration is in /etc/inetd.conf -# -# See README or run "gophernicus -?" to see a full list of -# configuration options. -# -# Example: -# OPTIONS="-h full.hostname -D \"I find your lack of gopher disturbing.\"" -# -# Add your options here: -OPTIONS="-h __HOSTNAME__ -l __LOGDIR__/server.log -f /usr/lib/__PACKAGE__/filters" diff --git a/debian/gophernicus.logcheck.ignore.server b/debian/gophernicus.logcheck.ignore.server deleted file mode 100644 index 5675585..0000000 --- a/debian/gophernicus.logcheck.ignore.server +++ /dev/null @@ -1,4 +0,0 @@ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ gophernicus\[[0-9]+\]: request for "[^"]*" from [._[:alnum:]:-]+$ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ gophernicus\[[0-9]+\]: error "No such file or directory" for request "[^"]*" from [._[:alnum:]:-]+$ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ gophernicus\[[0-9]+\]: error "User not found" for request "/~[^"]*" from [._[:alnum:]:-]+$ -^\w{3} [ :0-9]{11} [._[:alnum:]-]+ systemd\[1\]: Start(ing|ed) Gophernicus gopher server \([^[:space:]]+\)\.+$ diff --git a/debian/gophernicus.logrotate b/debian/gophernicus.logrotate deleted file mode 100644 index d8bde2a..0000000 --- a/debian/gophernicus.logrotate +++ /dev/null @@ -1,7 +0,0 @@ -/var/log/gophernicus/server.log { - rotate 6 - weekly - compress - missingok - notifempty -} diff --git a/debian/gophernicus.templates b/debian/gophernicus.templates deleted file mode 100644 index 3a550ca..0000000 --- a/debian/gophernicus.templates +++ /dev/null @@ -1,4 +0,0 @@ -Template: gophernicus/fqdn -Type: string -Default: -Description: Fully-qualified hostname for the gopher server: diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index 3d83d23..0000000 --- a/debian/postinst +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -#DEBHELPER# - -# Source debconf library. -. /usr/share/debconf/confmodule - -# Configuration -HOSTNAME="$(hostname)" -ROOT=/var/gopher -PACKAGE=gophernicus -LOGDIR=/var/log/$PACKAGE -LIBDIR=/usr/lib/$PACKAGE -BINARY=gophernicus -DEFAULT=/etc/default/$PACKAGE -USER=nobody - -# Get hostname from debconf -db_get gophernicus/fqdn -if [ "$RET" ]; then - HOSTNAME="$(echo $RET | tr -cd 'A-Za-z0-9.-')" -fi - -# Configure gophernicus -if [ "$1" = "configure" ]; then - if [ ! -f "$ROOT/gophermap" ]; then - cp $LIBDIR/gophermap.sample $ROOT/gophermap - fi - - chown $USER.adm $LOGDIR - chmod 0750 $LOGDIR - - sed -i -e "s|-h [^ ]* |-h $HOSTNAME |" $DEFAULT - sed -i -e "s|__PACKAGE__|$PACKAGE|g" $DEFAULT - sed -i -e "s|__LOGDIR__|$LOGDIR|g" $DEFAULT - - if [ -x /usr/bin/deb-systemd-helper -a -d /run/systemd/system ]; then - /usr/bin/deb-systemd-helper enable gophernicus.socket - /usr/bin/deb-systemd-invoke start gophernicus.socket - else - if [ -f /etc/inetd.conf -a -x /usr/sbin/update-inetd ]; then - /usr/sbin/update-inetd --add "gopher\t\tstream\ttcp\tnowait\t$USER\t/usr/sbin/$BINARY\t$BINARY -h $HOSTNAME -l $LOGDIR/server.log -f /usr/lib/$PACKAGE/filters" - fi - fi -fi - diff --git a/debian/postrm b/debian/postrm deleted file mode 100644 index f6bfaa0..0000000 --- a/debian/postrm +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -if [ "$1" = "purge" -a -f /etc/inetd.conf -a -x /usr/sbin/update-inetd ]; then - /usr/sbin/update-inetd --remove "## gopher" -fi - -if [ -d /run/systemd/system ]; then - systemctl --system daemon-reload >/dev/null || true -fi - -#DEBHELPER# diff --git a/debian/prerm b/debian/prerm deleted file mode 100644 index 1035cd9..0000000 --- a/debian/prerm +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -if [ -f /etc/inetd.conf -a -x /usr/sbin/update-inetd ]; then - /usr/sbin/update-inetd --disable gopher -fi - -if [ -x /usr/bin/deb-systemd-helper ]; then - /usr/bin/deb-systemd-helper disable gophernicus.socket >/dev/null -fi - -#DEBHELPER# - diff --git a/debian/rules b/debian/rules deleted file mode 100755 index c71b1d9..0000000 --- a/debian/rules +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Gophernicus debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# Installation directory -DEST=$(CURDIR)/debian/gophernicus - -configure: - -build: build-stamp - -build-stamp: - dh_testdir - - $(MAKE) - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - $(MAKE) clean-build - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/gophernicus - $(MAKE) DESTDIR=$(DEST)/usr install-files - rm -rf $(DEST)/tmp - ln -s /usr/share/doc/gophernicus/ $(DEST)/var/gopher/docs - ln -s /usr/bin/php5 $(DEST)/usr/lib/gophernicus/filters/php - cp $(CURDIR)/gophermap.sample $(DEST)/usr/lib/gophernicus/gophermap - cp $(CURDIR)/init/gophernicus.socket $(CURDIR)/init/gophernicus@.service $(DEST)/lib/systemd/system/ - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs changelog - dh_installdocs -# dh_install -# dh_installmenu - dh_installdebconf - dh_installlogrotate - dh_installlogcheck -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python - dh_installinit -# dh_installcron -# dh_installinfo -# dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl -# dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index d3827e7..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/init/.gitignore b/init/.gitignore index 882a402..4fc3d36 100644 --- a/init/.gitignore +++ b/init/.gitignore @@ -2,3 +2,4 @@ haiku_snippet org.gophernicus.server.plist gophernicus.xinetd inetlin +gophernicus.env diff --git a/init/gophernicus.env b/init/gophernicus.env index 89aefd0..33c6b7d 100644 --- a/init/gophernicus.env +++ b/init/gophernicus.env @@ -7,4 +7,4 @@ # OPTIONS="-h full.hostname -D \"I find your lack of gopher disturbing.\"" # # modify and set your options here: -OPTIONS="-h localhost -nv" +OPTIONS="-h beast -nv" diff --git a/init/gophernicus.env.in b/init/gophernicus.env.in new file mode 100644 index 0000000..7fd4361 --- /dev/null +++ b/init/gophernicus.env.in @@ -0,0 +1,10 @@ +# Options for Gophernicus +# +# See README or run "gophernicus -?" to see a full list of +# configuration options. +# +# Example: +# OPTIONS="-h full.hostname -D \"I find your lack of gopher disturbing.\"" +# +# modify and set your options here: +OPTIONS="-h @HOSTNAME@ -nv" From 9573940c7c23f4117acb9d38bce72654163aa6fe Mon Sep 17 00:00:00 2001 From: fosslinux Date: Sun, 27 Dec 2020 09:07:23 +1100 Subject: [PATCH 4/5] Adapt travis for the new build system --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cbccdb3..c3a0dc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,8 @@ addons: - debhelper script: + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then ./configure --listener=systemd,inetd,xinetd --hostname=travis; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then ./configure --listener=mac --hostname=travis; fi - make - sudo make install - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then make deb ; fi - .travis/test.sh From 237c18024e66a4f30476cea14ea51f221f6d1398 Mon Sep 17 00:00:00 2001 From: fosslinux Date: Sun, 27 Dec 2020 09:34:40 +1100 Subject: [PATCH 5/5] Fix issues with macos and systemd --- Makefile.in | 24 ++++++++++++----- configure | 75 +++++++++++++++++++++++++++++------------------------ 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/Makefile.in b/Makefile.in index 134f58e..0151ebf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -78,7 +78,8 @@ clean-shm: # Install cases install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INSTALL_HAIKU@ @INSTALL_SYSTEMD@ @INSTALL_XINETD@ @INSTALL_INETD_MANUAL@ @INSTALL_INETD_UPDATE@ - $(INSTALL) -s -m 755 -D -t $(DESTDIR)$(SBINDIR) src/$(BINARY) + $(INSTALL) -d -m 755 $(DESTDIR)$(SBINDIR) + $(INSTALL) -s -m 755 -t $(DESTDIR)$(SBINDIR) src/$(BINARY) @echo @echo "======================================================================" @echo @@ -92,10 +93,12 @@ install: src/$(BINARY) @CLEAN_SHM@ install-man @INSTALL_ROOT@ @INSTALL_OSX@ @INS @echo install-man: - $(INSTALL) -m 644 -D -t $(DESTDIR)$(MAN8DIR) $(MANPAGE) + $(INSTALL) -d -m 755 $(DESTDIR)$(MAN8DIR) + $(INSTALL) -m 644 -t $(DESTDIR)$(MAN8DIR) $(MANPAGE) install-root: - $(INSTALL) -m 644 -D $(MAP).sample $(DESTDIR)$(ROOT)/gophermap + $(INSTALL) -d -m 755 $(DESTDIR)$(ROOT) + $(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT)/gophermap install-inetd-update: install-root update-inetd --add $$(sed -e "s/@BINARY_PATH@/$(DESTDIR)$(SBINDIR)$(BINARY)/g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in) @@ -104,20 +107,27 @@ install-inetd-manual: install-root sed -e "s:@BINARY_PATH@:$(DESTDIR)$(SBINDIR)/$(BINARY):g" -e "s/@BINARY_NAME@/$(BINARY)/g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in >> $(DESTDIR)$(INETD) install-xinetd: install-root - $(INSTALL) -T -m 644 init/$(NAME).xinetd $(DESTDIR)$(XINETD) + $(INSTALL) -d -m 755 $(DESTDIR)/etc/xinetd.d + $(INSTALL) -m 644 -T init/$(NAME).xinetd $(DESTDIR)$(XINETD) install-osx: install-root $(INSTALL) -m 644 init/$(PLIST) $(DESTDIR)$(LAUNCHD) chown -h root:admin $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/* - chmod -h 0775 $(DESTDIR)$(ROOT) $(DESTDIR)$(ROOT)/docs + chmod -h 0775 $(DESTDIR)$(ROOT) install-haiku: install-root sed -e "s/@BINARY@/$(BINARY)/g" init/haiku_snippet.in >> $(DESTDIR)$(HAIKU_SRV) chown user:root $(DESTDIR)$(DOCDIR)/* $(DESTDIR)$(SBINDIR)/$(BINARY) $(DESTDIR)$(ROOT)/$(MAP) install-systemd: install-root - $(INSTALL) -m 644 init/$(NAME).env init/$(NAME).socket init/$(NAME)\@.service $(DESTDIR)$(SYSCONF)/$(NAME) - $(INSTALL) -m 644 init/$(NAME).env init/$(NAME).socket init/$(NAME)\@.service $(DESTDIR)$(DEFAULT)/$(NAME) + $(INSTALL) -d -m 755 $(DESTDIR)$(SYSCONF) + $(INSTALL) -m 644 -T init/$(NAME).env $(DESTDIR)$(SYSCONF)/$(NAME) + $(INSTALL) -m 644 -T init/$(NAME).socket $(DESTDIR)$(SYSCONF)/$(NAME) + $(INSTALL) -m 644 -T init/$(NAME)\@.service $(DESTDIR)$(SYSCONF)/$(NAME) + $(INSTALL) -d -m 755 $(DESTDIR)$(DEFAULT) + $(INSTALL) -m 644 -T init/$(NAME).env $(DESTDIR)$(DEFAULT)/$(NAME) + $(INSTALL) -m 644 -T init/$(NAME).socket $(DESTDIR)$(DEFAULT)/$(NAME) + $(INSTALL) -m 644 init/$(NAME)\@.service $(DESTDIR)$(DEFAULT)/$(NAME) uninstall: @UNINSTALL_INETD_UPDATE@ @UNINSTALL_INETD_MANUAL@ @UNINSTALL_XINETD@ @UNINSTALL_OSX@ @UNINSTALL_SYSTEMD@ rm -f $(DESTDIR)$(SBINDIR)/$(BINARY) diff --git a/configure b/configure index 21f29fb..8c61336 100755 --- a/configure +++ b/configure @@ -107,6 +107,13 @@ if ! INSTALL="$(command -v install)"; then printf "install-sh" INSTALL=build-aux/install-sh else + # Check it has required features (*cough* macos) + mkdir testconf + touch testfile + ${INSTALL} -t testconf testfile || INSTALL=build-aux/install-sh + rm testconf/testfile + ${INSTALL} -T testfile testconf/testfile || INSTALL=build-aux/install-sh + rm -r testconf testfile printf "%s" "${INSTALL}" fi printf "\\n" @@ -269,46 +276,46 @@ printf "\\n" cp Makefile.in Makefile printf "creating Makefile... " -sed -i "s:@CC@:${CC}:" Makefile -sed -i "s:@HOSTCC@:${HOSTCC}:" Makefile -sed -i "s:@LIBWRAP@:${LIBWRAP}:" Makefile -sed -i "s:@INSTALL@:${INSTALL}:" Makefile -sed -i "s:@MAKE@:${MAKE}:" Makefile +sed -i -e "s:@CC@:${CC}:" Makefile +sed -i -e "s:@HOSTCC@:${HOSTCC}:" Makefile +sed -i -e "s:@LIBWRAP@:${LIBWRAP}:" Makefile +sed -i -e "s:@INSTALL@:${INSTALL}:" Makefile +sed -i -e "s:@MAKE@:${MAKE}:" Makefile -sed -i "s:@PREFIX@:${PREFIX}:" Makefile -sed -i "s:@BINDIR@:${BINDIR}:" Makefile -sed -i "s:@SBINDIR@:${SBINDIR}:" Makefile -sed -i "s:@DOCDIR@:${DOCDIR}:" Makefile -sed -i "s:@MANDIR@:${MANDIR}:" Makefile -sed -i "s:@MAN8DIR@:${MAN8DIR}:" Makefile +sed -i -e "s:@PREFIX@:${PREFIX}:" Makefile +sed -i -e "s:@BINDIR@:${BINDIR}:" Makefile +sed -i -e "s:@SBINDIR@:${SBINDIR}:" Makefile +sed -i -e "s:@DOCDIR@:${DOCDIR}:" Makefile +sed -i -e "s:@MANDIR@:${MANDIR}:" Makefile +sed -i -e "s:@MAN8DIR@:${MAN8DIR}:" Makefile -sed -i "s:@IPCRM@:${IPCRM}:" Makefile -sed -i "s:@CLEAN_SHM@:${CLEAN_SHM}:" Makefile +sed -i -e "s:@IPCRM@:${IPCRM}:" Makefile +sed -i -e "s:@CLEAN_SHM@:${CLEAN_SHM}:" Makefile -sed -i "s:@SYSCONF@:${SYSCONFIG}:" Makefile -sed -i "s:@DEFAULT@:${DEFAULTCONF}:" Makefile -sed -i "s:@HOSTNAME@:${HOSTNAME}:" Makefile -sed -i "s:@ROOT@:${GOPHERROOT}:" Makefile +sed -i -e "s:@SYSCONF@:${SYSCONFIG}:" Makefile +sed -i -e "s:@DEFAULT@:${DEFAULTCONF}:" Makefile +sed -i -e "s:@HOSTNAME@:${HOSTNAME}:" Makefile +sed -i -e "s:@ROOT@:${GOPHERROOT}:" Makefile -sed -i "s:@HAIKUSRV@:${HAIKUSRV}:" Makefile -sed -i "s:@LAUNCHD@:${LAUNCHD}:" Makefile -sed -i "s:@INSTALL_ROOT@:${INSTALL_ROOT}:" Makefile +sed -i -e "s:@HAIKUSRV@:${HAIKUSRV}:" Makefile +sed -i -e "s:@LAUNCHD@:${LAUNCHD}:" Makefile +sed -i -e "s:@INSTALL_ROOT@:${INSTALL_ROOT}:" Makefile -sed -i "s:@INSTALL_OSX@:${INSTALL_OSX}:" Makefile -sed -i "s:@INSTALL_INETD_MANUAL@:${INSTALL_INETD_MANUAL}:" Makefile -sed -i "s:@INSTALL_INETD_UPDATE@:${INSTALL_INETD_UPDATE}:" Makefile -sed -i "s:@INSTALL_XINETD@:${INSTALL_XINETD}:" Makefile -sed -i "s:@INSTALL_SYSTEMD@:${INSTALL_SYSTEMD}:" Makefile -sed -i "s:@INSTALL_HAIKU@:${INSTALL_HAIKU}:" Makefile -sed -i "s:@UNINSTALL_OSX@:${UNINSTALL_OSX}:" Makefile -sed -i "s:@UNINSTALL_INETD_MANUAL@:${UNINSTALL_INETD_MANUAL}:" Makefile -sed -i "s:@UNINSTALL_INETD_UPDATE@:${UNINSTALL_INETD_UPDATE}:" Makefile -sed -i "s:@UNINSTALL_XINETD@:${UNINSTALL_XINETD}:" Makefile -sed -i "s:@UNINSTALL_SYSTEMD@:${UNINSTALL_SYSTEMD}:" Makefile -sed -i "s:@UNINSTALL_HAIKU@:${UNINSTALL_HAIKU}:" Makefile +sed -i -e "s:@INSTALL_OSX@:${INSTALL_OSX}:" Makefile +sed -i -e "s:@INSTALL_INETD_MANUAL@:${INSTALL_INETD_MANUAL}:" Makefile +sed -i -e "s:@INSTALL_INETD_UPDATE@:${INSTALL_INETD_UPDATE}:" Makefile +sed -i -e "s:@INSTALL_XINETD@:${INSTALL_XINETD}:" Makefile +sed -i -e "s:@INSTALL_SYSTEMD@:${INSTALL_SYSTEMD}:" Makefile +sed -i -e "s:@INSTALL_HAIKU@:${INSTALL_HAIKU}:" Makefile +sed -i -e "s:@UNINSTALL_OSX@:${UNINSTALL_OSX}:" Makefile +sed -i -e "s:@UNINSTALL_INETD_MANUAL@:${UNINSTALL_INETD_MANUAL}:" Makefile +sed -i -e "s:@UNINSTALL_INETD_UPDATE@:${UNINSTALL_INETD_UPDATE}:" Makefile +sed -i -e "s:@UNINSTALL_XINETD@:${UNINSTALL_XINETD}:" Makefile +sed -i -e "s:@UNINSTALL_SYSTEMD@:${UNINSTALL_SYSTEMD}:" Makefile +sed -i -e "s:@UNINSTALL_HAIKU@:${UNINSTALL_HAIKU}:" Makefile -sed -i "s:@INETD_CONF@:${INETD_CONF}:" Makefile -sed -i "s:@XINETD_CONF@:${XINETD_CONF}:" Makefile +sed -i -e "s:@INETD_CONF@:${INETD_CONF}:" Makefile +sed -i -e "s:@XINETD_CONF@:${XINETD_CONF}:" Makefile printf "done\\n"