Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving /etc/zypp/zypper.conf to /usr/etc/zypp/zypper.conf #518

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ 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 )
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" )
Expand Down
4 changes: 4 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
29 changes: 28 additions & 1 deletion doc/zypper.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
+
Expand All @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/utils/Augeas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "Zypper.h"
#include "utils/Augeas.h"

#ifdef DISTCONFDIR
#define DISTCONFZYPPER DISTCONFDIR "/zypp/zypper.conf"
#endif

///////////////////////////////////////////////////////////////////
namespace env
{
Expand Down Expand Up @@ -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
{
Expand Down
16 changes: 9 additions & 7 deletions zypper.conf
Original file line number Diff line number Diff line change
@@ -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.
##
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 11 additions & 3 deletions zypper.spec.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand All @@ -183,15 +189,15 @@ 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

%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
Expand All @@ -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
Expand Down