From bfe801045f5998df0379269ed7a8b74ea016e440 Mon Sep 17 00:00:00 2001 From: Gioele Barabucci Date: Fri, 20 Dec 2024 23:20:18 +0100 Subject: [PATCH 1/4] configure.ac: Add defaultconfigdir and PATH_SANE_DEFAULT_CONFIG_DIR --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6807c6823..0fc5cf5fa 100644 --- a/configure.ac +++ b/configure.ac @@ -643,12 +643,16 @@ AC_SUBST(locksanedir) configdir="${sysconfdir}/sane.d" AC_SUBST(configdir) +defaultconfigdir="${prefix}/lib/sane.d" +AC_SUBST(defaultconfigdir) + dnl *********************************************************************** dnl enable/disable backends and features based on previous tests and user's dnl choice dnl *********************************************************************** AM_CPPFLAGS="${AM_CPPFLAGS} -DPATH_SANE_CONFIG_DIR=\$(configdir) \ + -DPATH_SANE_DEFAULT_CONFIG_DIR=\$(defaultconfigdir) \ -DPATH_SANE_DATA_DIR=\$(datadir) \ -DPATH_SANE_LOCK_DIR=\$(locksanedir) \ -DV_MAJOR=${V_MAJOR} -DV_MINOR=${V_MINOR}" @@ -842,7 +846,7 @@ echo AM_CXXFLAGS=\"${AM_CXXFLAGS}\" echo AM_LDFLAGS=\"${AM_LDFLAGS}\" echo LIBS=\"${LIBS}\" echo "-> Installation directories:" -echo "Configuration: `eval eval echo ${sysconfdir}`" +echo "Configuration: `eval eval echo ${defaultconfigdir}` and `eval eval echo ${configdir}`" echo "Libraries: `eval eval echo ${libdir}`" echo "Binaries: `eval eval echo ${bindir}` and `eval eval echo ${sbindir}`" echo "Manpages: `eval eval echo ${mandir}`" From 79ccbb210a2d98b9f4ad23809a1d7f972a02066f Mon Sep 17 00:00:00 2001 From: Gioele Barabucci Date: Fri, 20 Dec 2024 23:21:21 +0100 Subject: [PATCH 2/4] sanei_config: Add PATH_SANE_DEFAULT_CONFIG_DIR to searched config dirs --- include/sane/sanei_config.h | 7 +++++-- sanei/sanei_config.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/sane/sanei_config.h b/include/sane/sanei_config.h index ed2de6f0a..571698245 100644 --- a/include/sane/sanei_config.h +++ b/include/sane/sanei_config.h @@ -59,8 +59,11 @@ extern "C" { * * The following directory list is used: * 1st: SANE_CONFIG_DIR environment variable. - * 2nd: PATH_SANE_CONFIG_DIR set during configuration. - * 3rd: Current directory. + * 2nd: PATH_SANE_CONFIG_DIR with admin-managed files (usually + * /etc/sane.d). + * 3rd: PATH_SANE_DEFAULT_CONFIG_DIR with distro-managed files (usually + * /usr/lib/sane). + * 4th: Current directory. * @param name filename with extension but without path (such as "mustek.conf") * * @return file pointer, or NULL if not found diff --git a/sanei/sanei_config.c b/sanei/sanei_config.c index fc883eee5..7a7c81ab6 100644 --- a/sanei/sanei_config.c +++ b/sanei/sanei_config.c @@ -65,7 +65,7 @@ # define PATH_SEP '/' #endif -#define DEFAULT_DIRS "." DIR_SEP STRINGIFY(PATH_SANE_CONFIG_DIR) +#define DEFAULT_DIRS "." DIR_SEP STRINGIFY(PATH_SANE_CONFIG_DIR) DIR_SEP STRINGIFY(PATH_SANE_DEFAULT_CONFIG_DIR) #ifdef __BEOS__ #include From 213b00271427f0b32ebfc2e10308ad7494ffade7 Mon Sep 17 00:00:00 2001 From: Gioele Barabucci Date: Fri, 20 Dec 2024 23:22:26 +0100 Subject: [PATCH 3/4] backend/Makefile.am: Install default config files in defaultconfigdir --- backend/Makefile.am | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/Makefile.am b/backend/Makefile.am index 4bf4e6f54..663988fb7 100644 --- a/backend/Makefile.am +++ b/backend/Makefile.am @@ -115,15 +115,15 @@ install-becfg: becfg @# installed library in $(execsanelibdir) to libsane.*, which @# causes a conflict with the actual libsane.* in $(libdir). -rm -f $(DESTDIR)$(execsanelibdir)/libsane.* - test -z "$(configdir)" || $(MKDIR_P) "$(DESTDIR)$(configdir)" - test -z "$(configdir)/dll.d" || $(MKDIR_P) "$(DESTDIR)$(configdir)/dll.d" + test -z "$(defaultconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(defaultconfigdir)" + test -z "$(defaultconfigdir)/dll.d" || $(MKDIR_P) "$(DESTDIR)$(defaultconfigdir)/dll.d" @list="$(BACKEND_CONFS_ENABLED) saned.conf dll.conf"; for cfg in $$list; do \ if test ! -r $${cfg}; then continue; fi; \ - if test -f $(DESTDIR)$(configdir)/$${cfg}; then \ - echo NOT overwriting $${cfg} in $(configdir)...; \ + if test -f $(DESTDIR)$(defaultconfigdir)/$${cfg}; then \ + echo NOT overwriting $${cfg} in $(defaultconfigdir)...; \ else \ - echo installing $${cfg} in $(configdir)/$${cfg}...; \ - $(INSTALL_DATA) $${cfg} $(DESTDIR)$(configdir)/$${cfg} \ + echo installing $${cfg} in $(defaultconfigdir)/$${cfg}...; \ + $(INSTALL_DATA) $${cfg} $(DESTDIR)$(defaultconfigdir)/$${cfg} \ || exit 1; \ fi; \ done @@ -137,7 +137,7 @@ install-lockpath: $(mkinstalldirs) -m 775 $(DESTDIR)$(locksanedir) uninstall-hook: - rm -rf $(DESTDIR)$(libdir)/sane $(DESTDIR)$(configdir) $(DESTDIR)$(locksanedir) + rm -rf $(DESTDIR)$(libdir)/sane $(DESTDIR)$(defaultconfigdir) $(DESTDIR)$(locksanedir) rm -f $(DESTDIR)$(libdir)/libsane.* -for dir in $(FIRMWARE_DIRS) ; do \ rmdir $(DESTDIR)$(datadir)/sane/$${dir} ; \ From 5921ee45ca9b47671507b1aaa65f3130ceba9675 Mon Sep 17 00:00:00 2001 From: Gioele Barabucci Date: Fri, 20 Dec 2024 22:05:44 +0100 Subject: [PATCH 4/4] WIP: doc: Document DEFAULTCONFIGDIR in manpages --- doc/Makefile.am | 1 + doc/sane-u12.man | 12 +++++++++--- doc/sane.man | 6 +++++- doc/scanimage.man | 8 +++++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 27c3b5907..d5f2e62d8 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -99,6 +99,7 @@ MAN2HTML = nroff -c -man |\ @if $(AM_V_P); then echo "Generating manpage $@..."; fi @sed -e 's|@DATADIR@|$(datadir)|g' \ -e 's|@CONFIGDIR@|$(configdir)|g' \ + -e 's|@DEFAULTCONFIGDIR@|$(defaultconfigdir)|g' \ -e 's|@DOCDIR@|$(docdir)|g' \ -e 's|@LIBDIR@|$(libdir)/sane|g' \ -e 's|@BINDIR@|$(bindir)|g' \ diff --git a/doc/sane-u12.man b/doc/sane-u12.man index 25c868909..002302a2b 100644 --- a/doc/sane-u12.man +++ b/doc/sane-u12.man @@ -115,6 +115,9 @@ If there's no configuration file, the backend defaults to .I @CONFIGDIR@/u12.conf The backend configuration file .TP +.I @DEFAULTCONFIGDIR@/u12.conf +The backend default configuration file +.TP .I @LIBDIR@/libsane\-u12.a The static library implementing this backend. .TP @@ -130,8 +133,10 @@ contain the configuration file. On *NIX systems, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working -directory (".") and then in -.IR @CONFIGDIR@ . +directory ("."), then in +.IR @CONFIGDIR@ +and then in +.IR @DEFAULTCONFIGDIR@ . If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified @@ -140,8 +145,9 @@ directories. For example, setting to "/tmp/config:" would result in directories .IR tmp/config , .IR . , +.IR @CONFIGDIR@ , and -.I @CONFIGDIR@ +.I @DEFAULTCONFIGDIR@ being searched (in this order). .TP .B SANE_DEBUG_U12 diff --git a/doc/sane.man b/doc/sane.man index 701e3ea88..10b370378 100644 --- a/doc/sane.man +++ b/doc/sane.man @@ -716,7 +716,11 @@ that work is not duplicated. .SH "FILES" .TP .I @CONFIGDIR@/*.conf -The backend configuration files. +The backend configuration files (preferred to the default configuration +files, if present). +.TP +.I @DEFAULTCONFIGDIR@/*.conf +The backend default configuration files (read-only). .TP .I @LIBDIR@/libsane\-*.a The static libraries implementing the backends. diff --git a/doc/scanimage.man b/doc/scanimage.man index 710b8f369..887db1832 100644 --- a/doc/scanimage.man +++ b/doc/scanimage.man @@ -138,7 +138,8 @@ is used to include an ICC profile into a TIFF file. requests a (partial) list of devices that are available. The list may not be complete since some devices may be available, but are not listed in any of the configuration files (which are typically stored -in directory +in +.IR @DEFAULTCONFIGDIR@ and .IR @CONFIGDIR@ ). This is particularly the case when accessing scanners through the network. If a device is not listed in a configuration file, the only way to access it is @@ -478,8 +479,9 @@ filename The default device-name. .SH FILES .TP -.I @CONFIGDIR@ -This directory holds various configuration files. For details, please +.IR @CONFIGDIR@ , \ \&\c +.I @DEFAULTCONFIGDIR@ +These directories holds various configuration files. For details, please refer to the manual pages listed below. .TP .I ~/.sane/pass