From c50b39a49f8ebe21673893f833b7a01a85cd3c3f Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Sun, 10 Mar 2024 17:05:42 +1100 Subject: [PATCH 1/5] The supernode is basically a system service, so move it to the right man section --- Makefile | 11 +++++------ edge.8 | 2 +- n3n.7 | 2 +- packages/rpm/n3n.spec | 2 +- supernode.1 => supernode.8 | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) rename supernode.1 => supernode.8 (98%) diff --git a/Makefile b/Makefile index 21669032..17f7065d 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,6 @@ SYSTEMDDIR=$(DESTDIR)/lib/systemd/system BINDIR=$(PREFIX)/bin SBINDIR=$(PREFIX)/sbin MANDIR?=$(PREFIX)/share/man -MAN1DIR=$(MANDIR)/man1 MAN7DIR=$(MANDIR)/man7 MAN8DIR=$(MANDIR)/man8 DOCDIR=$(PREFIX)/share/doc/n3n @@ -209,7 +208,7 @@ LINT_CCODE=\ # TODO: change either the files or the linter to remove these failures LINT_EXCLUDE=include/uthash.h|include/lzodefs.h|src/minilzo.c -DOCS=edge.8.gz supernode.1.gz n3n.7.gz +DOCS=edge.8.gz supernode.8.gz n3n.7.gz # This is the list of Debian/Ubuntu packages that are needed during the build. # Mostly of use in automated build systems. @@ -345,7 +344,7 @@ distclean: rm -f tests/*.out src/*.indent src/*.unc-backup* rm -rf autom4te.cache/ rm -f config.mak config.log config.status configure include/config.h include/config.h.in - rm -f edge.8.gz n3n.7.gz supernode.1.gz + rm -f edge.8.gz n3n.7.gz supernode.8.gz rm -f packages/debian/config.log packages/debian/config.status rm -rf packages/debian/autom4te.cache/ rm -f packages/rpm/config.log packages/rpm/config.status @@ -372,10 +371,10 @@ install.systemd: $(INSTALL_DOC) packages/lib/systemd/system/supernode.service $(SYSTEMDDIR) .PHONY: install.doc -install: edge.8.gz supernode.1.gz n3n.7.gz - $(INSTALL) -d $(MAN1DIR) $(MAN7DIR) $(MAN8DIR) $(DOCDIR) +install: edge.8.gz supernode.8.gz n3n.7.gz + $(INSTALL) -d $(MAN7DIR) $(MAN8DIR) $(DOCDIR) $(INSTALL_DOC) edge.8.gz $(MAN8DIR)/ - $(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/ + $(INSTALL_DOC) supernode.8.gz $(MAN8DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) doc/*.md doc/*.sample $(DOCDIR)/ diff --git a/edge.8 b/edge.8 index 9102e140..835d8bb7 100644 --- a/edge.8 +++ b/edge.8 @@ -233,7 +233,7 @@ deri (at) ntop.org - original author of n2n Don Bindner (--) - significant contributions to n2n-1 .SH SEE ALSO -ifconfig(8) supernode(1) tunctl(8) n3n(7) +ifconfig(8) supernode(8) tunctl(8) n3n(7) .br the documentation contained in the source code .br diff --git a/n3n.7 b/n3n.7 index aaeaf9fa..1f442a98 100644 --- a/n3n.7 +++ b/n3n.7 @@ -129,7 +129,7 @@ deri (at) ntop.org - original author of n2n Don Bindner (--) - significant contributions to n2n-1 .SH SEE ALSO -ifconfig(8) edge(8) supernode(1) +ifconfig(8) edge(8) supernode(8) .br the documentation contained in the source code .br diff --git a/packages/rpm/n3n.spec b/packages/rpm/n3n.spec index b7beeb41..cebd4d7b 100644 --- a/packages/rpm/n3n.spec +++ b/packages/rpm/n3n.spec @@ -70,7 +70,7 @@ rm -fr $RPM_BUILD_ROOT /usr/share/doc/n3n/community.list.sample /usr/share/doc/n3n/edge.conf.sample /usr/share/doc/n3n/supernode.conf.sample -/usr/share/man/man1/supernode.1.gz +/usr/share/man/man1/supernode.8.gz /usr/share/man/man7/n3n.7.gz /usr/share/man/man8/edge.8.gz diff --git a/supernode.1 b/supernode.8 similarity index 98% rename from supernode.1 rename to supernode.8 index ca35bd41..ddc86316 100644 --- a/supernode.1 +++ b/supernode.8 @@ -1,4 +1,4 @@ -.TH supernode 1 "5 Jan 2024" "version 3" "USER COMMANDS" +.TH supernode 8 "5 Jan 2024" "version 3" "USER COMMANDS" .SH NAME supernode \- n3n supernode daemon .SH SYNOPSIS From 4c2e60dbb6422e0cb128d1fe27d59fb32cdc36b5 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Sun, 10 Mar 2024 17:09:23 +1100 Subject: [PATCH 2/5] Prep for more configurable directories --- Makefile | 36 ++++++++++++++++++------------------ apps/Makefile | 6 +++--- tools/Makefile | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 17f7065d..4648f5c5 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ export MKDIR export INSTALL export INSTALL_PROG export INSTALL_DOC -export SBINDIR +export CONFIG_SBINDIR MKDIR=mkdir -p INSTALL=install @@ -65,15 +65,15 @@ PREFIX?=$(DESTDIR)/$(CONFIG_PREFIX) # TODO: both these dirs are outside of the CONFIG_PREFIX, which means that # they would not be in /usr/local if that is the expected install destination -ETCDIR=$(DESTDIR)/etc/n3n -SYSTEMDDIR=$(DESTDIR)/lib/systemd/system +CONFIG_ETCDIR?=$(DESTDIR)/etc +CONFIG_SYSTEMDDIR?=$(DESTDIR)/lib/systemd/system -BINDIR=$(PREFIX)/bin -SBINDIR=$(PREFIX)/sbin -MANDIR?=$(PREFIX)/share/man -MAN7DIR=$(MANDIR)/man7 -MAN8DIR=$(MANDIR)/man8 -DOCDIR=$(PREFIX)/share/doc/n3n +CONFIG_BINDIR?=$(PREFIX)/bin +CONFIG_SBINDIR?=$(PREFIX)/sbin +CONFIG_MANDIR?=$(PREFIX)/share/man +MAN7DIR=$(CONFIG_MANDIR)/man7 +MAN8DIR=$(CONFIG_MANDIR)/man8 +CONFIG_DOCDIR?=$(PREFIX)/share/doc/n3n ####################################### @@ -358,26 +358,26 @@ dpkg: .PHONY: install.bin install.bin: apps - $(MAKE) -C apps install SBINDIR=$(abspath $(SBINDIR)) - $(INSTALL) -d $(BINDIR) $(ETCDIR) - $(INSTALL_PROG) scripts/n3nctl $(BINDIR) + $(MAKE) -C apps install CONFIG_SBINDIR=$(abspath $(CONFIG_SBINDIR)) + $(INSTALL) -d $(CONFIG_BINDIR) $(CONFIG_ETCDIR)/n3n + $(INSTALL_PROG) scripts/n3nctl $(CONFIG_BINDIR) # TODO: dont install.systemd for a non systemd host .PHONY: install.systemd install.systemd: - $(INSTALL) -d $(SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/edge@.service $(SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/edge.service $(SYSTEMDDIR) - $(INSTALL_DOC) packages/lib/systemd/system/supernode.service $(SYSTEMDDIR) + $(INSTALL) -d $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/edge@.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/edge.service $(CONFIG_SYSTEMDDIR) + $(INSTALL_DOC) packages/lib/systemd/system/supernode.service $(CONFIG_SYSTEMDDIR) .PHONY: install.doc install: edge.8.gz supernode.8.gz n3n.7.gz - $(INSTALL) -d $(MAN7DIR) $(MAN8DIR) $(DOCDIR) + $(INSTALL) -d $(MAN7DIR) $(MAN8DIR) $(CONFIG_DOCDIR) $(INSTALL_DOC) edge.8.gz $(MAN8DIR)/ $(INSTALL_DOC) supernode.8.gz $(MAN8DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ $(INSTALL_DOC) n3n.7.gz $(MAN7DIR)/ - $(INSTALL_DOC) doc/*.md doc/*.sample $(DOCDIR)/ + $(INSTALL_DOC) doc/*.md doc/*.sample $(CONFIG_DOCDIR)/ # TODO: # install wireshark dissector diff --git a/apps/Makefile b/apps/Makefile index 35a606c9..794a4435 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -37,9 +37,9 @@ $(APPS) $(EXAMPLES): ../src/libn3n.a .PHONY: install install: $(addsuffix $(EXE),$(APPS)) - $(INSTALL) -d $(SBINDIR) - $(INSTALL_PROG) supernode$(EXE) $(SBINDIR)/ - $(INSTALL_PROG) edge$(EXE) $(SBINDIR)/ + $(INSTALL) -d $(CONFIG_SBINDIR) + $(INSTALL_PROG) supernode$(EXE) $(CONFIG_SBINDIR)/ + $(INSTALL_PROG) edge$(EXE) $(CONFIG_SBINDIR)/ # See comments in the topdir Makefile about how to generate coverage data. gcov: diff --git a/tools/Makefile b/tools/Makefile index fd78a431..36fc12e2 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -37,5 +37,5 @@ clean: rm -f $(TESTS) *.gcno *.gcda install: $(TOOLS) - $(INSTALL) -d $(SBINDIR) - $(INSTALL_PROG) $(addsuffix $(EXE),$(TOOLS)) $(SBINDIR)/ + $(INSTALL) -d $(CONFIG_SBINDIR) + $(INSTALL_PROG) $(addsuffix $(EXE),$(TOOLS)) $(CONFIG_SBINDIR)/ From 58ce8cafdd5421bb4632ca009336dd6ce7bf1d59 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Sun, 10 Mar 2024 18:58:45 +1100 Subject: [PATCH 3/5] Attempt to allow useful install dirs This plumbs in the normal autoconf settings for the docdir and mandir. These autoconf tools dont have an appropriate dir location for the systemd unit files however (the libdir is intended for exec files, not config files) so there is a new --with-systemddir=DIR option to set that with some heuristics to set (hopefully) reasonable default dirs. Addresses #14 and #15 --- Makefile | 16 ++++++++++------ config.mak.in | 6 +++++- configure.ac | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4648f5c5..10c2d39e 100644 --- a/Makefile +++ b/Makefile @@ -61,11 +61,15 @@ INSTALL_PROG=$(INSTALL) -m555 INSTALL_DOC=$(INSTALL) -m444 # DESTDIR set in debian make system -PREFIX?=$(DESTDIR)/$(CONFIG_PREFIX) - -# TODO: both these dirs are outside of the CONFIG_PREFIX, which means that -# they would not be in /usr/local if that is the expected install destination -CONFIG_ETCDIR?=$(DESTDIR)/etc +PREFIX=$(DESTDIR)/$(CONFIG_PREFIX) + +# Note that both these install dirs are outside of the CONFIG_PREFIX. +# The ETCDIR is not configurable in the code, so no changes should be done +# without code changes. +# The systemd unit dir should default to /lib for most Debian packages (if +# CONFIG_PREFIX is /usr) otherwise it should be based on the prefix. +# The current autotools has hacks to apply this logic. +ETCDIR=$(DESTDIR)/etc/n3n CONFIG_SYSTEMDDIR?=$(DESTDIR)/lib/systemd/system CONFIG_BINDIR?=$(PREFIX)/bin @@ -359,7 +363,7 @@ dpkg: .PHONY: install.bin install.bin: apps $(MAKE) -C apps install CONFIG_SBINDIR=$(abspath $(CONFIG_SBINDIR)) - $(INSTALL) -d $(CONFIG_BINDIR) $(CONFIG_ETCDIR)/n3n + $(INSTALL) -d $(CONFIG_BINDIR) $(ETCDIR) $(INSTALL_PROG) scripts/n3nctl $(CONFIG_BINDIR) # TODO: dont install.systemd for a non systemd host diff --git a/config.mak.in b/config.mak.in index ece0046a..250c8d7e 100644 --- a/config.mak.in +++ b/config.mak.in @@ -3,7 +3,11 @@ CONFIG_HOST=@host@ CONFIG_HOST_OS=@host_os@ -CONFIG_PREFIX=@prefix@ + +CONFIG_DOCDIR=@CONFIG_DOCDIR@ +CONFIG_MANDIR=@CONFIG_MANDIR@ +CONFIG_PREFIX=@CONFIG_PREFIX@ +CONFIG_SYSTEMDDIR=@CONFIG_SYSTEMDDIR@ CONFIG_WITH_OPENSSL=@with_openssl@ diff --git a/configure.ac b/configure.ac index 1e9fe7c5..29c0d4d0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -odnl> Do not add anything above -AC_INIT([edge], m4_esyscmd([scripts/version.sh | tr -d '\n'])) +dnl> Do not add anything above +AC_INIT([n3n], m4_esyscmd([scripts/version.sh | tr -d '\n'])) dnl> Do not add anything above # Older versions of the autotools expect to find install-sh here. @@ -43,6 +43,12 @@ case "$host_os" in ;; esac +AC_ARG_WITH([systemddir], + AS_HELP_STRING([--with-systemddir=DIR], [Where to install systemd units]), + [systemddir=$withval], + [systemddir=""] +) + # TODO: ideally, should use AC_ARG_ENABLE AC_ARG_WITH([zstd], AS_HELP_STRING([--with-zstd], [use zstd library]), @@ -108,6 +114,32 @@ AS_IF([test "x$enable_pthread" != xno], )], ) +# The prefix var has no default at this point, so we cannot eval it without +# this hack +AS_IF([test "x$prefix" = "xNONE" ], + prefix=/usr/local +) + +# The systemd unit dir should be in a sane location (based on the prefix) but +# that is not always a dir underneath the prefix. Apply another hack +AS_IF([test "x$systemddir" = "x" ], + AS_IF([test "x$prefix" = "x/usr"], + systemddir=/lib/systemd/system, + systemddir=$prefix/lib/systemd/system + ) +) + +# All this indirection would be great, if the namespace wasnt poluted +# (and for many of the dirs, if the directories were more modern) +CONFIG_DOCDIR=$(eval echo $(eval echo $docdir)) +CONFIG_MANDIR=$(eval echo $(eval echo $mandir)) +CONFIG_PREFIX=$prefix +CONFIG_SYSTEMDDIR=$systemddir + +AC_SUBST(CONFIG_DOCDIR) +AC_SUBST(CONFIG_MANDIR) +AC_SUBST(CONFIG_PREFIX) +AC_SUBST(CONFIG_SYSTEMDDIR) AC_SUBST(host) AC_SUBST(host_os) From 9318d9bc79e6bba206bfe8b20aaced32f0b9557b Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 11 Mar 2024 00:56:00 +1100 Subject: [PATCH 4/5] Fix paths used for installation --- Makefile | 20 +++++++++----------- config.mak.in | 6 +++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 10c2d39e..d786b9a9 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,19 @@ # Our default make target all: -export CC export AR -export EXE +export CC export CFLAGS +export CONFIG_HOST_OS +export EXE +export INSTALL +export INSTALL_DOC +export INSTALL_PROG export LDFLAGS -export LDLIBS_LOCAL export LDLIBS_EXTRA -export CONFIG_HOST_OS +export LDLIBS_LOCAL +export MKDIR + VERSION:=$(shell scripts/version.sh) CFLAGS+=-DVERSION='"$(VERSION)"' @@ -49,12 +54,6 @@ ifndef UNAME_S $(error Could not run uname command, cannot continue) endif -export MKDIR -export INSTALL -export INSTALL_PROG -export INSTALL_DOC -export CONFIG_SBINDIR - MKDIR=mkdir -p INSTALL=install INSTALL_PROG=$(INSTALL) -m555 @@ -79,7 +78,6 @@ MAN7DIR=$(CONFIG_MANDIR)/man7 MAN8DIR=$(CONFIG_MANDIR)/man8 CONFIG_DOCDIR?=$(PREFIX)/share/doc/n3n - ####################################### # All the additiona needed for using the n3n library # diff --git a/config.mak.in b/config.mak.in index 250c8d7e..f45bc230 100644 --- a/config.mak.in +++ b/config.mak.in @@ -4,10 +4,10 @@ CONFIG_HOST=@host@ CONFIG_HOST_OS=@host_os@ -CONFIG_DOCDIR=@CONFIG_DOCDIR@ -CONFIG_MANDIR=@CONFIG_MANDIR@ CONFIG_PREFIX=@CONFIG_PREFIX@ -CONFIG_SYSTEMDDIR=@CONFIG_SYSTEMDDIR@ +CONFIG_DOCDIR=$(DESTDIR)/@CONFIG_DOCDIR@ +CONFIG_MANDIR=$(DESTDIR)/@CONFIG_MANDIR@ +CONFIG_SYSTEMDDIR=$(DESTDIR)/@CONFIG_SYSTEMDDIR@ CONFIG_WITH_OPENSSL=@with_openssl@ From ceb46d944c957c6b24f1dbb25315decf1fbe8117 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Mon, 11 Mar 2024 09:41:22 +1100 Subject: [PATCH 5/5] Fix rpm with corrected filename --- packages/rpm/n3n.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rpm/n3n.spec b/packages/rpm/n3n.spec index cebd4d7b..dd1da6e1 100644 --- a/packages/rpm/n3n.spec +++ b/packages/rpm/n3n.spec @@ -70,9 +70,9 @@ rm -fr $RPM_BUILD_ROOT /usr/share/doc/n3n/community.list.sample /usr/share/doc/n3n/edge.conf.sample /usr/share/doc/n3n/supernode.conf.sample -/usr/share/man/man1/supernode.8.gz /usr/share/man/man7/n3n.7.gz /usr/share/man/man8/edge.8.gz +/usr/share/man/man8/supernode.8.gz # Set the default attributes of all of the files specified to have an # owner and group of root and to inherit the permissions of the file