From 9517c6f8486f5f07d125e5eeff6f8c7ac8d5e7c7 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 23 Nov 2020 15:15:03 -0700 Subject: [PATCH] install: support config.sh configuration file If a config.sh file exists, source it to set any desired configuration variables. By supporting this, a custom configuration is possible without needing to change any other sources. Signed-off-by: Kyle J. McKay --- GNUmakefile | 5 +++-- INSTALL | 5 +++-- install.sh | 3 +++ make-apache-conf.sh | 3 +++ src/GNUmakefile | 8 +++++--- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e22f414..c0b488d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,8 @@ # (see INSTALL for details). Set GIROCCO_CONFIG to a different value in order # to install according to custom config. -bindir:=$(shell . ./shlib.sh && test -n "$$cfg_git_bin" && echo $$(dirname "$$cfg_git_bin")) +confnm:=$(shell ! test -s config.sh || . ./config.sh; echo "$${GIROCCO_CONF:-Girocco::Config}.pm" | sed 's,::,/,g') +bindir:=$(shell ! test -s config.sh || . ./config.sh; . ./shlib.sh && test -n "$$cfg_git_bin" && echo $$(dirname "$$cfg_git_bin")) ifeq ($(bindir),) $(error $$Girocco::Config::git_bin is not set) endif @@ -27,7 +28,7 @@ clean:: doc:: @"$(MAKE)" -C docs -apache.conf: apache.conf.in Girocco/Config.pm +apache.conf: apache.conf.in $(confnm) ./make-apache-conf.sh .PHONY: gnu_make_command_name diff --git a/INSTALL b/INSTALL index 70a97c0..81f6e11 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,8 @@ FIRST, you need to configure Girocco: * Edit Girocco/Config.pm - * Alternatively to above, copy over to and edit Girocco/Config2.pm and - run make and make install with GIROCCO_CONF=Girocco::Config2 + * Alternatively to the above, copy over to and edit Girocco/Config2.pm and + run `make` and `make install` with GIROCCO_CONF=Girocco::Config2 or with + `echo GIROCCO_CONF=Girocco::Config2 >> config.sh` Make sure you have the submodules checked out: diff --git a/install.sh b/install.sh index f5c1788..24875a4 100755 --- a/install.sh +++ b/install.sh @@ -4,6 +4,9 @@ set -e +# Include custom configuration, if any +[ ! -e config.sh ] || [ ! -f config.sh ] || [ ! -r config.sh ] || . ./config.sh + [ -n "$MAKE" ] || MAKE="$(MAKEFLAGS= make -s gnu_make_command_name | grep '^gnu_make_command_name=' | sed 's/^[^=]*=//')" if [ -z "$MAKE" ]; then echo "ERROR: cannot determine name of the GNU make command" >&2 diff --git a/make-apache-conf.sh b/make-apache-conf.sh index a61b135..d606fb9 100755 --- a/make-apache-conf.sh +++ b/make-apache-conf.sh @@ -14,6 +14,9 @@ trap "rm -f 'apache.conf.$$'" EXIT trap 'exit 130' INT trap 'exit 143' TERM +# Include custom configuration, if any +[ ! -e config.sh ] || [ ! -f config.sh ] || [ ! -r config.sh ] || . ./config.sh + __girocco_conf="$GIROCCO_CONF" [ -n "$__girocco_conf" ] || __girocco_conf="Girocco::Config" perl -I"$PWD" -M"$__girocco_conf" -- - apache.conf.in >apache.conf.$$ <<'EOT' diff --git a/src/GNUmakefile b/src/GNUmakefile index e9eff74..d11d1c0 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile @@ -26,11 +26,13 @@ install : test : ltsha256 ./ltsha256-test.sh | awk 'BEGIN{c=0} {print} /^ok [0-9]/{++c} END{if(NR!=c+1)exit 1}' -TRACK_GROUP_FILE := $(shell cd .. && . ./shlib.sh && echo "$$cfg_chroot/etc/group") +GET_CONFIG = cd .. && test ! -f config.sh || . ./config.sh && . ./shlib.sh + +TRACK_GROUP_FILE := $(shell $(GET_CONFIG) && echo "$$cfg_chroot/etc/group") export TRACK_GROUP_FILE -TRACK_PASSWD_FILE := $(shell cd .. && . ./shlib.sh && echo "$$cfg_chroot/etc/passwd") +TRACK_PASSWD_FILE := $(shell $(GET_CONFIG) && echo "$$cfg_chroot/etc/passwd") export TRACK_PASSWD_FILE -TRACK_SOCKET_FILE := $(shell cd .. && . ./shlib.sh && echo "$$cfg_chroot/etc/taskd.socket") +TRACK_SOCKET_FILE := $(shell $(GET_CONFIG) && echo "$$cfg_chroot/etc/taskd.socket") export TRACK_SOCKET_FILE GROUP-FILE: FORCE -- 2.11.4.GIT