From aa017a6cbf6d4dd6334906667e53bab345dbca7f Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Fri, 17 Nov 2023 17:10:47 +0100 Subject: [PATCH 1/3] moving zypper.conf to /usr/etc --- CMakeLists.txt | 4 ++++ doc/zypper.8.txt | 17 +++++++++++------ src/utils/Augeas.cc | 7 +++++++ zypper.conf | 16 +++++++++------- zypper.spec.cmake | 14 +++++++++++--- 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0623d0a83f..83975a552c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,10 @@ SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 ) ADD_DEFINITIONS( -DVERSION="${VERSION}" ) +IF ( DISTCONFDIR ) +ADD_DEFINITIONS( -DDISTCONFDIR="${DISTCONFDIR}" ) +ENDIF ( DISTCONFDIR ) + SET( CMAKE_CXX_STANDARD ${ZYPPCOMMON_CXX_STANDARD} ) SET( CMAKE_CXX_EXTENSIONS OFF ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" ) diff --git a/doc/zypper.8.txt b/doc/zypper.8.txt index 2885c582d8..fa44e38fe0 100644 --- a/doc/zypper.8.txt +++ b/doc/zypper.8.txt @@ -1876,7 +1876,7 @@ Using zypper _global-options_ together with subcommands, as well as executing su FILES ----- -*/etc/zypp/zypper.conf*, *$HOME/.zypper.conf*:: +*/usr/etc/zypp/zypper.conf*, */etc/zypp/zypper.conf*, *$HOME/.zypper.conf*:: Global (system-wide) and user's configuration file for _zypper_. These files are read when zypper starts up and *--config* option is not used. + User's settings are preferred over global settings. Similarly, command line options override the settings in either of these files. To sum it up, the order of preference is as follows (from highest to lowest): @@ -1884,16 +1884,21 @@ User's settings are preferred over global settings. Similarly, command line opti -- . _Command line options_ . *$HOME/.zypper.conf* - . */etc/zypp/zypper.conf* - . [*/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications) + . */etc/zypp/zypper.conf* (system-wide defaults, defined by the admin) + . */usr/etc/zypp/zypper.conf* (system-wide defaults) + . [*/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications, defined by the admin) + . [*/usr/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications) -- + -See the comments in */etc/zypp/zypper.conf* for a list and description of available options. +See the comments in */usr/etc/zypp/zypper.conf* for a list and description of available options. + -NOTE: The system-wide */etc/zypp/zypp.conf* is mentioned here just because some zypper command line options allow one to overwrite system-wide defaults defined there. *zypp.conf* and *zypper.conf* have different content and serve different purpose. +NOTE: The system-wide */usr/etc/zypp/zypp.conf* and */etc/zypp/zypp.conf* are mentioned here just because some zypper command line options allow one to overwrite system-wide defaults defined there. *zypp.conf* and *zypper.conf* have different content and serve different purpose. */etc/zypp/zypp.conf*:: - ZYpp configuration file affecting all libzypp based applications. See the comments in the file for description of configurable properties. Many locations of files and directories listed in this section are configurable via zypp.conf. The location for this file itself can be redefined only by setting *$ZYPP_CONF* in the environment. + ZYpp configuration file affecting all libzypp based applications. See the comments in the file for description of configurable properties. Many locations of files and directories listed in this section are configurable via zypp.conf. The location for this file itself can be redefined only by setting *$ZYPP_CONF* in the environment. This file can be changed. + +*/usr/etc/zypp/zypp.conf*:: + This file will be taken if */etc/zypp/zypp.conf* does not exist. */etc/zypp/locks*:: File with package lock definitions. The package lock commands (*locks*, *addlock*, *removelock*, etc.) should be used to manipulate this file. diff --git a/src/utils/Augeas.cc b/src/utils/Augeas.cc index 2a4decad6b..ef04fea7f8 100644 --- a/src/utils/Augeas.cc +++ b/src/utils/Augeas.cc @@ -16,6 +16,10 @@ #include "Zypper.h" #include "utils/Augeas.h" +#ifdef DISTCONFDIR +#define DISTCONFZYPPER DISTCONFDIR "/zypp/zypper.conf" +#endif + /////////////////////////////////////////////////////////////////// namespace env { @@ -547,6 +551,9 @@ Augeas::Augeas( Pathname customcfg_r, bool readmode_r ) // add /etc/zypp/zypper.conf _pimpl->_cfgFiles.push_back( "/etc/zypp/zypper.conf" ); +#ifdef DISTCONFDIR + _pimpl->_cfgFiles.push_back( DISTCONFZYPPER ); +#endif } else { diff --git a/zypper.conf b/zypper.conf index 4097e729c1..a21713f47f 100644 --- a/zypper.conf +++ b/zypper.conf @@ -1,12 +1,13 @@ ## Configuration file for Zypper. ## -## location: /etc/zypp/zypper.conf (system-wide) +## location: /usr/etc/zypp/zypper.conf (system-wide vendor defined settings) +## or: /etc/zypp/zypper.conf (system-wide admin defined settings) ## or: $HOME/.zypper.conf (user-specific) ## -## You can edit this file by hand (try to keep the structure) or by using -## 'zypper conf' command (TODO). If you need user-specific configuration -## and you do not have ~/.zypper.conf yet, use /etc/zypp/zypper.conf -## as template (copy it to ~/.zypper.conf) and adjust to your liking. +## You can create /etc/zypp/zypper.conf for system wide changes. +## If you need user-specific configuration and you do not have ~/.zypper.conf +## yet, use /usr/etc/zypp/zypper.conf as template (copy it to ~/.zypper.conf) +## and adjust to your liking. ## ## The options known also to libzypp will be overriden by zypper.conf, if set. ## @@ -70,8 +71,9 @@ ## Install soft dependencies (recommended packages) ## ## CAUTION: The system wide default for all libzypp based applications (zypper, -## yast, pk,..) is defined in /etc/zypp/zypp.conf(solver.onlyRequires) and it -## will per default install recommended packages. It is NOT RECOMMENDED to define +## yast, pk,..) is defined in /etc/zypp/zypp.conf or /usr/etc/zypp/zypp.conf +## entry solver.onlyRequires. +## It will per default install recommended packages. It is NOT RECOMMENDED to define ## this value here for zypper exclusively, unless you are very certain that you ## want zypper to behave different than other libzypp based packagemanagement software ## on your system. diff --git a/zypper.spec.cmake b/zypper.spec.cmake index 1d10301e6f..c9910bd577 100644 --- a/zypper.spec.cmake +++ b/zypper.spec.cmake @@ -137,6 +137,9 @@ CMAKE_FLAGS= cmake $CMAKE_FLAGS \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + %if %{defined _distconfdir} + -DDISTCONFDIR=%{_distconfdir} \ + %endif -DSYSCONFDIR=%{_sysconfdir} \ -DMANDIR=%{_mandir} \ -DCMAKE_VERBOSE_MAKEFILE=TRUE \ @@ -175,6 +178,9 @@ touch $RPM_BUILD_ROOT%{_var}/log/zypper.log mkdir -p %{buildroot}/%{_distconfdir}/logrotate.d mv %{buildroot}/%{_sysconfdir}/logrotate.d/zypper.lr %{buildroot}%{_distconfdir}/logrotate.d mv %{buildroot}/%{_sysconfdir}/logrotate.d/zypp-refresh.lr %{buildroot}%{_distconfdir}/logrotate.d +# Move /etc/zypp/zypper.conf to /usr/etc/zypp/zypper.conf +mkdir -p %{buildroot}%{_distconfdir}/zypp +mv %{buildroot}%{_sysconfdir}/zypp/zypper.conf %{buildroot}%{_distconfdir}/zypp/zypper.conf %endif %clean @@ -183,7 +189,7 @@ rm -rf "$RPM_BUILD_ROOT" %if %{defined _distconfdir} %pre # Prepare for migration to /usr/etc; save any old .rpmsave -for i in logrotate.d/zypper.lr logrotate.d/zypp-refresh.lr; do +for i in logrotate.d/zypper.lr logrotate.d/zypp-refresh.lr zypp/zypper.conf; do test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i}.rpmsave.old ||: done %endif @@ -191,7 +197,7 @@ done %if %{defined _distconfdir} %posttrans # Migration to /usr/etc, restore just created .rpmsave -for i in logrotate.d/zypper.lr logrotate.d/zypp-refresh.lr; do +for i in logrotate.d/zypper.lr logrotate.d/zypp-refresh.lr zypp/zypper.conf; do test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i} ||: done %endif @@ -201,11 +207,13 @@ done %if 0%{?suse_version} >= 1500 %license COPYING %endif -%config(noreplace) %{_sysconfdir}/zypp/zypper.conf %if %{defined _distconfdir} %{_distconfdir}/logrotate.d/zypper.lr %{_distconfdir}/logrotate.d/zypp-refresh.lr +%dir %{_distconfdir}/zypp +%{_distconfdir}/zypp/zypper.conf %else +%config(noreplace) %{_sysconfdir}/zypp/zypper.conf %config(noreplace) %{_sysconfdir}/logrotate.d/zypper.lr %config(noreplace) %{_sysconfdir}/logrotate.d/zypp-refresh.lr %endif From c3d827828ec471113da13033343a11c7e1b2b6d9 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Mon, 20 Nov 2023 12:01:39 +0100 Subject: [PATCH 2/3] added distconfdir variable in documentation --- doc/CMakeLists.txt | 4 ++++ doc/zypper.8.txt | 34 ++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 29053dacd8..187a31b53c 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,7 +1,11 @@ FIND_PROGRAM(ASCIIDOC asciidoctor) IF (ASCIIDOC) MESSAGE("asciidoctor found: ${ASCIIDOC}") +IF ( DISTCONFDIR ) +SET(ASCDOC_CMD ${ASCIIDOC} -D ${CMAKE_CURRENT_BINARY_DIR} -b manpage -d manpage -a distconfdir=${DISTCONFDIR}) +ELSE ( DISTCONFDIR ) SET(ASCDOC_CMD ${ASCIIDOC} -D ${CMAKE_CURRENT_BINARY_DIR} -b manpage -d manpage) +ENDIF ( DISTCONFDIR ) ENDIF (ASCIIDOC) IF (NOT ASCDOC_CMD) diff --git a/doc/zypper.8.txt b/doc/zypper.8.txt index fa44e38fe0..bfb15b69e7 100644 --- a/doc/zypper.8.txt +++ b/doc/zypper.8.txt @@ -1876,7 +1876,8 @@ Using zypper _global-options_ together with subcommands, as well as executing su FILES ----- -*/usr/etc/zypp/zypper.conf*, */etc/zypp/zypper.conf*, *$HOME/.zypper.conf*:: +ifdef::distconfdir[] +*{distconfdir}/zypp/zypper.conf*, */etc/zypp/zypper.conf*, *$HOME/.zypper.conf*:: Global (system-wide) and user's configuration file for _zypper_. These files are read when zypper starts up and *--config* option is not used. + User's settings are preferred over global settings. Similarly, command line options override the settings in either of these files. To sum it up, the order of preference is as follows (from highest to lowest): @@ -1885,20 +1886,41 @@ User's settings are preferred over global settings. Similarly, command line opti . _Command line options_ . *$HOME/.zypper.conf* . */etc/zypp/zypper.conf* (system-wide defaults, defined by the admin) - . */usr/etc/zypp/zypper.conf* (system-wide defaults) + . *{distconfdir}/zypp/zypper.conf* (system-wide defaults) . [*/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications, defined by the admin) - . [*/usr/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications) + . [*{distconfdir}/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications) -- + -See the comments in */usr/etc/zypp/zypper.conf* for a list and description of available options. +See the comments in *{distconfdir}/zypp/zypper.conf* for a list and description of available options. + -NOTE: The system-wide */usr/etc/zypp/zypp.conf* and */etc/zypp/zypp.conf* are mentioned here just because some zypper command line options allow one to overwrite system-wide defaults defined there. *zypp.conf* and *zypper.conf* have different content and serve different purpose. +NOTE: The system-wide *{distconfdir}/zypp/zypp.conf* and */etc/zypp/zypp.conf* are mentioned here just because some zypper command line options allow one to overwrite system-wide defaults defined there. *zypp.conf* and *zypper.conf* have different content and serve different purpose. +endif::[] + +ifndef::distconfdir[] +*/etc/zypp/zypper.conf*, *$HOME/.zypper.conf*:: + Global (system-wide) and user's configuration file for _zypper_. These files are read when zypper starts up and *--config* option is not used. ++ +User's settings are preferred over global settings. Similarly, command line options override the settings in either of these files. To sum it up, the order of preference is as follows (from highest to lowest): ++ +-- + . _Command line options_ + . *$HOME/.zypper.conf* + . */etc/zypp/zypper.conf* + . [*/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications) +-- ++ +See the comments in */etc/zypp/zypper.conf* for a list and description of available options. ++ +NOTE: The system-wide */etc/zypp/zypp.conf* is mentioned here just because some zypper command line options allow one to overwrite system-wide defaults defined there. *zypp.conf* and *zypper.conf* have different content and serve different purpose. +endif::[] */etc/zypp/zypp.conf*:: ZYpp configuration file affecting all libzypp based applications. See the comments in the file for description of configurable properties. Many locations of files and directories listed in this section are configurable via zypp.conf. The location for this file itself can be redefined only by setting *$ZYPP_CONF* in the environment. This file can be changed. -*/usr/etc/zypp/zypp.conf*:: +ifdef::distconfdir[] +*{distconfdir}/zypp/zypp.conf*:: This file will be taken if */etc/zypp/zypp.conf* does not exist. +endif::[] */etc/zypp/locks*:: File with package lock definitions. The package lock commands (*locks*, *addlock*, *removelock*, etc.) should be used to manipulate this file. From f55201088d64eb030ff329f8ead71885d6c0eab0 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Tue, 21 Nov 2023 17:12:04 +0100 Subject: [PATCH 3/3] added option description --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83975a552c..4ff37185fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE(ZyppCommon) OPTION (ENABLE_BUILD_TRANS "Build translation files by default?" ON) OPTION (ENABLE_BUILD_TESTS "Build and run test suite by default?" OFF) +OPTION (DISTCONFDIR "Vendor defined */etc directory. E.g. /usr/etc") # VERSION INCLUDE( ${ZYPPER_SOURCE_DIR}/VERSION.cmake )