diff --git a/CMakeLists.txt b/CMakeLists.txt index 0623d0a83..4ff37185f 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 ) @@ -30,6 +31,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/CMakeLists.txt b/doc/CMakeLists.txt index 29053dacd..187a31b53 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 2885c582d..bfb15b69e 100644 --- a/doc/zypper.8.txt +++ b/doc/zypper.8.txt @@ -1876,6 +1876,27 @@ Using zypper _global-options_ together with subcommands, as well as executing su FILES ----- +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): ++ +-- + . _Command line options_ + . *$HOME/.zypper.conf* + . */etc/zypp/zypper.conf* (system-wide defaults, defined by the admin) + . *{distconfdir}/zypp/zypper.conf* (system-wide defaults) + . [*/etc/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications, defined by the admin) + . [*{distconfdir}/zypp/zypp.conf*] (system-wide defaults for all libzypp based applications) +-- ++ +See the comments in *{distconfdir}/zypp/zypper.conf* for a list and description of available options. ++ +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. + @@ -1891,9 +1912,15 @@ User's settings are preferred over global settings. Similarly, command line opti 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. + 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. + +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. diff --git a/src/utils/Augeas.cc b/src/utils/Augeas.cc index 2a4decad6..ef04fea7f 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 4097e729c..a21713f47 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 1d10301e6..c9910bd57 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