Hello,

    This patch add a new autoconf argument that allows installation
into the vendor configuration directory (/usr/etc/). Some linux
distribution now move system configuration files from /etc to /usr/etc.
See this ref: [0]. 
    So, it could be a good idea to give the opportunity for a project
to install in both location /etc and /usr/etc in same time. Not just by
overriding the sysconfdir arguments. For example we have two projects
PAM and D-Bus that look both in /etc and /usr/etc.
    As a packager for a Linux distribution, it will save times if we
get this multi choice of configuration directory installation.

This patch was created with a Colleague Jason Sikes. Thanks to him!

[0] https://0pointer.net/blog/projects/stateless.html

-- 
Best regards,
Valentin Lefebvre

Linux Distribution Engineer - packager
Member of System Boot and Init team
SUSE Software Solutions Germany GmbH

56100 Lorient, France

From 0881470cca7a85c8e864a9eaf5cfad50e471002a Mon Sep 17 00:00:00 2001
From: Valentin Lefebvre <valentin.lefeb...@suse.com>
Date: Mon, 6 Feb 2023 16:28:00 +0100
Subject: [PATCH] stateless systems: add vendor conf dir install

This patch add a new autoconf argument that allows installation
into the vendor configuration directory (/usr/etc/). It gives the
opportunity for a project to install in both location /etc and /usr/etc.

Signed-off-by: Valentin Lefebvre <valentin.lefeb...@suse.com>
---
 doc/autoconf.texi       |  7 ++++++-
 doc/make-stds.texi      | 14 +++++++++++++-
 doc/standards.texi      |  2 +-
 lib/autoconf/general.m4 | 11 ++++++++++-
 4 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 9a396fc8..79208550 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -2992,6 +2992,11 @@ The directory for installing modifiable architecture-independent data.
 The directory for installing read-only single-machine data.
 @end defvar
 
+@defvar distconfdir
+@ovindex distconfdir
+The directory for installing distribution-provided read-only single-machine data.
+@end defvar
+
 
 Most of these variables have values that rely on @code{prefix} or
 @code{exec_prefix}.  It is deliberate that the directory output
@@ -27328,7 +27333,7 @@ introduced in this document.
 @c  LocalWords:  Systemology Checkpointing Changequote INTERCAL changequote dfn
 @c  LocalWords:  Quadrigraphs builtins Shellology acconfig Bugward LIBOBJ Imake
 @c  LocalWords:  LIBOBJS IFELSE cindex flushright Pinard Metaconfig uref Simons
-@c  LocalWords:  distclean uninstall noindent versioning Tromey dir vr
+@c  LocalWords:  distclean uninstall noindent versioning Tromey dir vr distconfdir
 @c  LocalWords:  SAMS samp aclocal acsite underquoted emph itemx prepend SUBST
 @c  LocalWords:  evindex automake Gettext autopoint gettext symlink libtoolize
 @c  LocalWords:  defmac INIT tarname ovindex cvindex BUGREPORT PREREQ asis PROG
diff --git a/doc/make-stds.texi b/doc/make-stds.texi
index 132476c7..0da9f28d 100644
--- a/doc/make-stds.texi
+++ b/doc/make-stds.texi
@@ -504,7 +504,19 @@ files that are modified in the normal course of their use (programs
 whose purpose is to change the configuration of the system excluded).
 Those probably belong in @file{$(localstatedir)}.
 
-@item sharedstatedir
+@item distconfdir
+     The directory for installing read-only configuration data files that
+     are provided are part of a distribution (Suse, Red Hat, Debian, etc.).
+     This directory is similar to @samp{sysconfdir}, except that files placed
+     here are intended to be vendor-supplied system defaults and placed
+     in a read-only filesystem. A system administrator should override or
+     suppliment these defaults by placing them in @samp{sysconfdir}.
+
+     This directory should normally be @file{/usr/etc}, but write it as
+     @file{$(prefix)/usr/etc}.  (If you are using Autoconf, write it as
+     @samp{@@distconfdir@@}.)
+
+'@item sharedstatedir
 The directory for installing architecture-independent data files which
 the programs modify while they run.  This should normally be
 @file{/usr/local/com}, but write it as @file{$(prefix)/com}.
diff --git a/doc/standards.texi b/doc/standards.texi
index 30592c65..8713c4b4 100644
--- a/doc/standards.texi
+++ b/doc/standards.texi
@@ -4254,7 +4254,7 @@ corresponding to most of the standard directory variables
 
 @example
 --prefix --exec-prefix --bindir --sbindir --libexecdir --sysconfdir
---sharedstatedir --localstatedir --runstatedir
+--distconfdir --sharedstatedir --localstatedir --runstatedir
 --libdir --includedir --oldincludedir
 --datarootdir --datadir --infodir --localedir --mandir --docdir
 --htmldir --dvidir --pdfdir --psdir
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index ecda0a51..820a0507 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -600,6 +600,7 @@ AC_SUBST([libexecdir],     ['${exec_prefix}/libexec'])dnl
 AC_SUBST([datarootdir],    ['${prefix}/share'])dnl
 AC_SUBST([datadir],        ['${datarootdir}'])dnl
 AC_SUBST([sysconfdir],     ['${prefix}/etc'])dnl
+AC_SUBST([distconfdir],    ['${prefix}/usr/etc'])dnl
 AC_SUBST([sharedstatedir], ['${prefix}/com'])dnl
 AC_SUBST([localstatedir],  ['${prefix}/var'])dnl
 AC_SUBST([runstatedir],    ['${localstatedir}/run'])dnl
@@ -870,6 +871,13 @@ do
   | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
     sysconfdir=$ac_optarg ;;
 
+  -distconfdir | --distconfdir | --distconfdi | --distconfd | --distconf \
+  | --distcon | --distco | --distc | --dist | --dis | --di)
+    ac_prev=distconfdir ;;
+  -distconfdir=* | --distconfdir=* | --distconfdi=* | --distconfd=* | --distconf=* \
+  | --distcon=* | --distco=* | --distc=* | --dist=* | --dis=* | --di=*)
+    distconfdir=$ac_optarg ;;
+
   -target | --target | --targe | --targ | --tar | --ta | --t)
     ac_prev=target_alias ;;
   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
@@ -945,7 +953,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir runstatedir distconfdir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1080,6 +1088,7 @@ Fine tuning of the installation directories:
   --sbindir=DIR           system admin executables [EPREFIX/sbin]
   --libexecdir=DIR        program executables [EPREFIX/libexec]
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --distconfdir=DIR       read-only distribution-provided data [PREFIX/usr/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
   --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
-- 
2.39.1

Reply via email to