*/
extern "C"
{
+#include <features.h>
#include <sys/utsname.h>
+#if __GLIBC_PREREQ (2,16)
+#include <sys/auxv.h> // getauxval for PPC64P7 detection
+#endif
#include <unistd.h>
-#include <satsolver/satversion.h>
+#include <solv/solvversion.h>
}
#include <iostream>
#include <fstream>
-#include "zypp/base/Logger.h"
+#include "zypp/base/LogTools.h"
#include "zypp/base/IOStream.h"
#include "zypp/base/InputStream.h"
#include "zypp/base/String.h"
+#include "zypp/base/Regex.h"
#include "zypp/ZConfig.h"
#include "zypp/ZYppFactory.h"
#include "zypp/parser/IniDict.h"
#include "zypp/sat/Pool.h"
+#include "zypp/sat/detail/PoolImpl.h"
using namespace std;
using namespace zypp::filesystem;
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
-
+ /** \addtogroup ZyppConfig Zypp Configuration Options
+ *
+ * The global \c zypp.conf configuration file is per default located in \c /etc/zypp/.
+ * An alternate config file can be set using the environment varaible \c ZYPP_CONF=<PATH>
+ * (see \ref zypp-envars).
+ *
+ * \section ZyppConfig_ZyppConfSample Sample zypp.conf
+ * \include ../zypp.conf
+ */
///////////////////////////////////////////////////////////////////
namespace
{ /////////////////////////////////////////////////////////////////
ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
}
}
+ else if ( architecture == Arch_armv7l || architecture == Arch_armv6l )
+ {
+ std::ifstream platform( "/etc/rpm/platform" );
+ if (platform)
+ {
+ for( iostr::EachLine in( platform ); in; in.next() )
+ {
+ if ( str::hasPrefix( *in, "armv7hl-" ) )
+ {
+ architecture = Arch_armv7hl;
+ WAR << "/etc/rpm/platform contains armv7hl-: architecture upgraded to '" << architecture << "'" << endl;
+ break;
+ }
+ if ( str::hasPrefix( *in, "armv6hl-" ) )
+ {
+ architecture = Arch_armv6hl;
+ WAR << "/etc/rpm/platform contains armv6hl-: architecture upgraded to '" << architecture << "'" << endl;
+ break;
+ }
+ }
+ }
+ }
+#if __GLIBC_PREREQ (2,16)
+ else if ( architecture == Arch_ppc64 )
+ {
+ const char * platform = (const char *)getauxval( AT_PLATFORM );
+ int powerlvl;
+ if ( platform && sscanf( platform, "power%d", &powerlvl ) == 1 && powerlvl > 6 )
+ architecture = Arch_ppc64p7;
+ }
+#endif
return architecture;
}
*/
Locale _autodetectTextLocale()
{
- Locale ret( "en" );
+ Locale ret( Locale::enCode );
const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL };
for ( const char ** envvar = envlist; *envvar; ++envvar )
{
if ( envstr != "POSIX" && envstr != "C" )
{
Locale lang( envstr );
- if ( ! lang.code().empty() )
+ if ( lang )
{
MIL << "Found " << *envvar << "=" << envstr << endl;
ret = lang;
return ret;
}
+
+ inline Pathname _autodetectSystemRoot()
+ {
+ Target_Ptr target( getZYpp()->getTarget() );
+ return target ? target->root() : Pathname();
+ }
+
+ inline Pathname _autodetectZyppConfPath()
+ {
+ const char *env_confpath = getenv( "ZYPP_CONF" );
+ return env_confpath ? env_confpath : "/etc/zypp/zypp.conf";
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
/** Mutable option. */
- template<class _Tp>
+ template<class Tp>
struct Option
{
- typedef _Tp value_type;
+ typedef Tp value_type;
/** No default ctor, explicit initialisation! */
Option( const value_type & initial_r )
};
/** Mutable option with initial value also remembering a config value. */
- template<class _Tp>
- struct DefaultOption : public Option<_Tp>
+ template<class Tp>
+ struct DefaultOption : public Option<Tp>
{
- typedef _Tp value_type;
- typedef Option<_Tp> option_type;
+ typedef Tp value_type;
+ typedef Option<Tp> option_type;
DefaultOption( const value_type & initial_r )
- : Option<_Tp>( initial_r ), _default( initial_r )
+ : Option<Tp>( initial_r ), _default( initial_r )
{}
/** Reset value to the current default. */
*/
class ZConfig::Impl
{
+ typedef std::set<std::string> MultiversionSpec;
+
public:
Impl( const Pathname & override_r = Pathname() )
: _parsedZyppConf ( override_r )
, download_use_deltarpm ( true )
, download_use_deltarpm_always ( false )
, download_media_prefer_download( true )
- , download_max_concurrent_connections( 2 )
+ , download_max_concurrent_connections( 5 )
, download_min_download_speed ( 0 )
, download_max_download_speed ( 0 )
, download_max_silent_tries ( 5 )
+ , download_transfer_timeout ( 180 )
, commit_downloadMode ( DownloadDefault )
+ , gpgCheck ( true )
+ , repoGpgCheck ( indeterminate )
+ , pkgGpgCheck ( indeterminate )
, solver_onlyRequires ( false )
, solver_allowVendorChange ( false )
+ , solver_dupAllowDowngrade ( true )
+ , solver_dupAllowNameChange ( true )
+ , solver_dupAllowArchChange ( true )
+ , solver_dupAllowVendorChange ( true )
, solver_cleandepsOnRemove ( false )
, solver_upgradeTestcasesToKeep ( 2 )
, solverUpgradeRemoveDroppedPackages( true )
// ZYPP_CONF might override /etc/zypp/zypp.conf
if ( _parsedZyppConf.empty() )
{
- const char *env_confpath = getenv( "ZYPP_CONF" );
- _parsedZyppConf = env_confpath ? env_confpath : "/etc/zypp/zypp.conf";
+ _parsedZyppConf = _autodetectZyppConfPath();
}
else
{
{
str::strtonum(value, repo_refresh_delay);
}
+ else if ( entry == "repo.refresh.locales" )
+ {
+ std::vector<std::string> tmp;
+ str::split( value, back_inserter( tmp ), ", \t" );
+
+ boost::function<Locale(const std::string &)> transform(
+ [](const std::string & str_r)->Locale{ return Locale(str_r); }
+ );
+ repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
+ make_transform_iterator( tmp.end(), transform ) );
+ }
else if ( entry == "download.use_deltarpm" )
{
download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
{
str::strtonum(value, download_max_silent_tries);
}
+ else if ( entry == "download.transfer_timeout" )
+ {
+ str::strtonum(value, download_transfer_timeout);
+ if ( download_transfer_timeout < 0 ) download_transfer_timeout = 0;
+ else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600;
+ }
else if ( entry == "commit.downloadMode" )
{
commit_downloadMode.set( deserializeDownloadMode( value ) );
}
+ else if ( entry == "gpgcheck" )
+ {
+ gpgCheck.set( str::strToBool( value, gpgCheck ) );
+ }
+ else if ( entry == "repo_gpgcheck" )
+ {
+ repoGpgCheck.set( str::strToTriBool( value ) );
+ }
+ else if ( entry == "pkg_gpgcheck" )
+ {
+ pkgGpgCheck.set( str::strToTriBool( value ) );
+ }
else if ( entry == "vendordir" )
{
cfg_vendor_path = Pathname(value);
}
+ else if ( entry == "multiversiondir" )
+ {
+ cfg_multiversion_path = Pathname(value);
+ }
else if ( entry == "solver.onlyRequires" )
{
solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
{
solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
}
+ else if ( entry == "solver.dupAllowDowngrade" )
+ {
+ solver_dupAllowDowngrade.set( str::strToBool( value, solver_dupAllowDowngrade ) );
+ }
+ else if ( entry == "solver.dupAllowNameChange" )
+ {
+ solver_dupAllowNameChange.set( str::strToBool( value, solver_dupAllowNameChange ) );
+ }
+ else if ( entry == "solver.dupAllowArchChange" )
+ {
+ solver_dupAllowArchChange.set( str::strToBool( value, solver_dupAllowArchChange ) );
+ }
+ else if ( entry == "solver.dupAllowVendorChange" )
+ {
+ solver_dupAllowVendorChange.set( str::strToBool( value, solver_dupAllowVendorChange ) );
+ }
else if ( entry == "solver.cleandepsOnRemove" )
{
solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
{
solver_checkSystemFile = Pathname(value);
}
+ else if ( entry == "solver.checkSystemFileDir" )
+ {
+ solver_checkSystemFileDir = Pathname(value);
+ }
else if ( entry == "multiversion" )
{
- str::split( value, inserter( multiversion, multiversion.end() ), ", \t" );
+ MultiversionSpec & defSpec( _multiversionMap.getDefaultSpec() );
+ str::splitEscaped( value, std::inserter( defSpec, defSpec.end() ), ", \t" );
}
else if ( entry == "locksfile.path" )
{
}
}
}
+ //
+
}
else
{
Pathname cfg_known_services_path;
Pathname cfg_vendor_path;
+ Pathname cfg_multiversion_path;
Pathname locks_file;
Pathname update_data_path;
Pathname update_messages_path;
DefaultOption<std::string> updateMessagesNotify;
- bool repo_add_probe;
- unsigned repo_refresh_delay;
- bool repoLabelIsAlias;
+ bool repo_add_probe;
+ unsigned repo_refresh_delay;
+ LocaleSet repoRefreshLocales;
+ bool repoLabelIsAlias;
bool download_use_deltarpm;
bool download_use_deltarpm_always;
int download_min_download_speed;
int download_max_download_speed;
int download_max_silent_tries;
+ int download_transfer_timeout;
Option<DownloadMode> commit_downloadMode;
+ Option<bool> gpgCheck;
+ Option<TriBool> repoGpgCheck;
+ Option<TriBool> pkgGpgCheck;
+
Option<bool> solver_onlyRequires;
Option<bool> solver_allowVendorChange;
+ Option<bool> solver_dupAllowDowngrade;
+ Option<bool> solver_dupAllowNameChange;
+ Option<bool> solver_dupAllowArchChange;
+ Option<bool> solver_dupAllowVendorChange;
Option<bool> solver_cleandepsOnRemove;
Option<unsigned> solver_upgradeTestcasesToKeep;
DefaultOption<bool> solverUpgradeRemoveDroppedPackages;
Pathname solver_checkSystemFile;
+ Pathname solver_checkSystemFileDir;
- std::set<std::string> multiversion;
+ MultiversionSpec & multiversion() { return getMultiversion(); }
+ const MultiversionSpec & multiversion() const { return getMultiversion(); }
bool apply_locks_file;
Pathname credentials_global_dir_path;
Pathname credentials_global_file_path;
+ std::string userData;
+
Option<Pathname> pluginsPath;
+
+ private:
+ // HACK for bnc#906096: let pool re-evaluate multiversion spec
+ // if target root changes. ZConfig returns data sensitive to
+ // current target root.
+ // TODO Actually we'd need to scan the target systems zypp.conf and
+ // overlay all system specific values.
+ struct MultiversionMap
+ {
+ typedef std::map<Pathname,MultiversionSpec> SpecMap;
+
+ MultiversionSpec & getSpec( Pathname root_r, const Impl & zConfImpl_r ) // from system at root
+ {
+ // _specMap[] - the plain zypp.conf value
+ // _specMap[/] - combine [] and multiversion.d scan
+ // _specMap[root] - scan root/zypp.conf and root/multiversion.d
+
+ if ( root_r.empty() )
+ root_r == "/";
+ bool cacheHit = _specMap.count( root_r );
+ MultiversionSpec & ret( _specMap[root_r] ); // creates new entry on the fly
+
+ if ( ! cacheHit )
+ {
+ if ( root_r == "/" )
+ ret.swap( _specMap[Pathname()] ); // original zypp.conf
+ else
+ scanConfAt( root_r, ret, zConfImpl_r ); // scan zypp.conf at root_r
+ scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
+ using zypp::operator<<;
+ MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
+ }
+ return ret;
+ }
+
+ MultiversionSpec & getDefaultSpec() // Spec from zypp.conf parsing; called before any getSpec
+ { return _specMap[Pathname()]; }
+
+ private:
+ void scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
+ {
+ static const str::regex rx( "^multiversion *= *(.*)" );
+ str::smatch what;
+ iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
+ [&]( int num_r, std::string line_r )->bool
+ {
+ if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
+ {
+ str::splitEscaped( what[1], std::inserter( spec_r, spec_r.end() ), ", \t" );
+ return false; // stop after match
+ }
+ return true;
+ } );
+ }
+
+ void scanDirAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
+ {
+ // NOTE: Actually we'd need to scan and use the root_r! zypp.conf values.
+ Pathname multiversionDir( zConfImpl_r.cfg_multiversion_path );
+ if ( multiversionDir.empty() )
+ multiversionDir = ( zConfImpl_r.cfg_config_path.empty()
+ ? Pathname("/etc/zypp")
+ : zConfImpl_r.cfg_config_path ) / "multiversion.d";
+
+ filesystem::dirForEach( Pathname::assertprefix( root_r, multiversionDir ),
+ [&spec_r]( const Pathname & dir_r, const char *const & name_r )->bool
+ {
+ MIL << "Parsing " << dir_r/name_r << endl;
+ iostr::simpleParseFile( InputStream( dir_r/name_r ),
+ [&spec_r]( int num_r, std::string line_r )->bool
+ {
+ DBG << " found " << line_r << endl;
+ spec_r.insert( std::move(line_r) );
+ return true;
+ } );
+ return true;
+ } );
+ }
+
+ private:
+ SpecMap _specMap;
+ };
+
+ MultiversionSpec & getMultiversion() const
+ { return _multiversionMap.getSpec( _autodetectSystemRoot(), *this ); }
+
+ mutable MultiversionMap _multiversionMap;
};
///////////////////////////////////////////////////////////////////
{}
Pathname ZConfig::systemRoot() const
- {
- Target_Ptr target( getZYpp()->getTarget() );
- return target ? target->root() : Pathname();
- }
+ { return _autodetectSystemRoot(); }
///////////////////////////////////////////////////////////////////
//
}
///////////////////////////////////////////////////////////////////
+ // user data
+ ///////////////////////////////////////////////////////////////////
+
+ bool ZConfig::hasUserData() const
+ { return !_pimpl->userData.empty(); }
+
+ std::string ZConfig::userData() const
+ { return _pimpl->userData; }
+
+ bool ZConfig::setUserData( const std::string & str_r )
+ {
+ for_( ch, str_r.begin(), str_r.end() )
+ {
+ if ( *ch < ' ' && *ch != '\t' )
+ {
+ ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
+ return false;
+ }
+ }
+ MIL << "Set user data string to '" << str_r << "'" << endl;
+ _pimpl->userData = str_r;
+ return true;
+ }
+
+ ///////////////////////////////////////////////////////////////////
Pathname ZConfig::repoCachePath() const
{
Pathname ZConfig::knownServicesPath() const
{
return ( _pimpl->cfg_known_services_path.empty()
- ? (configPath()/"services.d") : _pimpl->cfg_known_repos_path );
+ ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
}
Pathname ZConfig::vendorPath() const
///////////////////////////////////////////////////////////////////
bool ZConfig::repo_add_probe() const
- {
- return _pimpl->repo_add_probe;
- }
+ { return _pimpl->repo_add_probe; }
unsigned ZConfig::repo_refresh_delay() const
- {
- return _pimpl->repo_refresh_delay;
- }
+ { return _pimpl->repo_refresh_delay; }
+
+ LocaleSet ZConfig::repoRefreshLocales() const
+ { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
bool ZConfig::repoLabelIsAlias() const
{ return _pimpl->repoLabelIsAlias; }
long ZConfig::download_max_silent_tries() const
{ return _pimpl->download_max_silent_tries; }
+ long ZConfig::download_transfer_timeout() const
+ { return _pimpl->download_transfer_timeout; }
+
DownloadMode ZConfig::commit_downloadMode() const
{ return _pimpl->commit_downloadMode; }
+ bool ZConfig::gpgCheck() const
+ { return _pimpl->gpgCheck; }
+
+ TriBool ZConfig::repoGpgCheck() const
+ { return _pimpl->repoGpgCheck; }
+
+ TriBool ZConfig::pkgGpgCheck() const
+ { return _pimpl->pkgGpgCheck; }
+
bool ZConfig::solver_onlyRequires() const
{ return _pimpl->solver_onlyRequires; }
bool ZConfig::solver_allowVendorChange() const
{ return _pimpl->solver_allowVendorChange; }
+ bool ZConfig::solver_dupAllowDowngrade() const { return _pimpl->solver_dupAllowDowngrade; }
+ bool ZConfig::solver_dupAllowNameChange() const { return _pimpl->solver_dupAllowNameChange; }
+ bool ZConfig::solver_dupAllowArchChange() const { return _pimpl->solver_dupAllowArchChange; }
+ bool ZConfig::solver_dupAllowVendorChange() const { return _pimpl->solver_dupAllowVendorChange; }
+
bool ZConfig::solver_cleandepsOnRemove() const
{ return _pimpl->solver_cleandepsOnRemove; }
{ return ( _pimpl->solver_checkSystemFile.empty()
? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
+ Pathname ZConfig::solver_checkSystemFileDir() const
+ { return ( _pimpl->solver_checkSystemFileDir.empty()
+ ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
+
unsigned ZConfig::solver_upgradeTestcasesToKeep() const
{ return _pimpl->solver_upgradeTestcasesToKeep; }
void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); }
void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
- const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion; }
- void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion.insert( name_r ); }
- void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion.erase( name_r ); }
+ namespace
+ {
+ inline void sigMultiversionSpecChanged()
+ {
+ sat::detail::PoolMember::myPool().multiversionSpecChanged();
+ }
+ }
+
+ const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
+ void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); sigMultiversionSpecChanged(); }
+ void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); sigMultiversionSpecChanged(); }
+ void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); sigMultiversionSpecChanged(); }
+ void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); sigMultiversionSpecChanged(); }
bool ZConfig::apply_locks_file() const
{ return _pimpl->apply_locks_file; }
Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
}
-
Pathname ZConfig::credentialsGlobalDir() const
{
return ( _pimpl->credentials_global_dir_path.empty() ?
Pathname ZConfig::pluginsPath() const
{ return _pimpl->pluginsPath.get(); }
- Pathname ZConfig::mediaPluginsPath() const
- { return pluginsPath() / "media"; }
-
- Pathname ZConfig::servicePluginsPath() const
- { return pluginsPath() / "services"; }
-
///////////////////////////////////////////////////////////////////
std::ostream & ZConfig::about( std::ostream & str ) const
{
str << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl;
- str << "satsolver: " << sat_version;
- if ( ::strcmp( sat_version, SATSOLVER_VERSION_STRING ) )
- str << " (built against " << SATSOLVER_VERSION_STRING << ")";
+ str << "libsolv: " << solv_version;
+ if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
+ str << " (built against " << LIBSOLV_VERSION_STRING << ")";
str << endl;
str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;