diff --git a/src/PackageArgs.cc b/src/PackageArgs.cc index 291ef85a9a..80b37633b9 100644 --- a/src/PackageArgs.cc +++ b/src/PackageArgs.cc @@ -17,7 +17,7 @@ #include "repos.h" PackageArgs::PackageArgs( const ResKind & kind, const Options & opts ) -: zypper( *Zypper::instance() ) +: zypper( Zypper::instance() ) , _opts( opts ) { preprocess( zypper.arguments() ); @@ -25,7 +25,7 @@ PackageArgs::PackageArgs( const ResKind & kind, const Options & opts ) } PackageArgs::PackageArgs( const std::vector & args, const ResKind & kind, const Options & opts ) -: zypper( *Zypper::instance() ) +: zypper( Zypper::instance() ) , _opts( opts ) { preprocess( args ); diff --git a/src/SolverRequester.cc b/src/SolverRequester.cc index 269bd80f00..1b69f1187d 100644 --- a/src/SolverRequester.cc +++ b/src/SolverRequester.cc @@ -471,19 +471,19 @@ void SolverRequester::updatePatches() MIL << "got some pkgmgmt patches, will install these first" << endl; // When (auto)restricting patch to the updatestack only, drop "--with-update" - if ( Zypper::instance()->runtimeData().solve_with_update ) + if ( Zypper::instance().runtimeData().solve_with_update ) { WAR << "Drop --with-update while patching the update stack" << endl; - Zypper::instance()->out().info( + Zypper::instance().out().info( ColorString( ColorContext::MSG_WARNING, str::Format(_("Ignoring option %s when updating the update stack first.")) % "--with-update" ).str() ); - Zypper::instance()->runtimeData().solve_with_update = false; + Zypper::instance().runtimeData().solve_with_update = false; } } - if ( Zypper::instance()->cOpts().count("updatestack-only") ) + if ( Zypper::instance().cOpts().count("updatestack-only") ) { MIL << "updatestack-only: will stop here!" << endl; break; @@ -518,9 +518,9 @@ bool SolverRequester::installPatch( const PackageSpec & patchspec, const PoolIte if ( ignore_pkgmgmt || patch->restartSuggested() ) { Patch::InteractiveFlags ignoreFlags = Patch::NoFlags; - if ( Zypper::instance()->globalOpts().reboot_req_non_interactive ) + if ( Zypper::instance().globalOpts().reboot_req_non_interactive ) ignoreFlags |= Patch::Reboot; - if ( Zypper::instance()->cOpts().count("auto-agree-with-licenses") ) + if ( Zypper::instance().cOpts().count("auto-agree-with-licenses") ) ignoreFlags |= Patch::License; if ( selected.isUnwanted() ) diff --git a/src/Summary.cc b/src/Summary.cc index 3cebeb5918..8766227917 100644 --- a/src/Summary.cc +++ b/src/Summary.cc @@ -126,7 +126,7 @@ void Summary::readPool( const ResPool & pool ) } } - for ( const auto & spkg : Zypper::instance()->runtimeData().srcpkgs_to_install ) + for ( const auto & spkg : Zypper::instance().runtimeData().srcpkgs_to_install ) { to_be_installed[ResKind::srcpackage].insert(spkg); } // total packages to download & install @@ -359,8 +359,8 @@ bool Summary::writeResolvableList( std::ostream & out, { static const ColorString quoteCh( "\"", ColorContext::HIGHLIGHT ); - TriBool pkglistHighlight = Zypper::instance()->config().color_pkglistHighlight; - ansi::Color pkglistHighlightAttribute = Zypper::instance()->config().color_pkglistHighlightAttribute; + TriBool pkglistHighlight = Zypper::instance().config().color_pkglistHighlight; + ansi::Color pkglistHighlightAttribute = Zypper::instance().config().color_pkglistHighlightAttribute; char firstCh = 0; std::ostringstream s; @@ -1377,16 +1377,16 @@ void Summary::writePackageCounts( std::ostream & out ) void Summary::dumpTo( std::ostream & out ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); struct SetColor { SetColor( bool force ) - : docolors( Zypper::instance()->config().do_colors ) - { if (force) Zypper::instance()->config().do_colors = false; } + : docolors( Zypper::instance().config().do_colors ) + { if (force) Zypper::instance().config().do_colors = false; } ~SetColor() - { Zypper::instance()->config().do_colors = docolors; } + { Zypper::instance().config().do_colors = docolors; } bool docolors; }; diff --git a/src/Table.cc b/src/Table.cc index 552ecc1377..b12285763c 100644 --- a/src/Table.cc +++ b/src/Table.cc @@ -125,7 +125,7 @@ std::ostream & TableRow::dumpTo( std::ostream & stream, const Table & parent ) c } else { - if ( !parent._inHeader && parent.editionStyle( c ) && Zypper::instance()->config().do_colors ) + if ( !parent._inHeader && parent.editionStyle( c ) && Zypper::instance().config().do_colors ) { // Edition column if ( parent._editionStyle.size() == 2 ) diff --git a/src/Zypper.cc b/src/Zypper.cc index a71295bd75..1570f84092 100644 --- a/src/Zypper.cc +++ b/src/Zypper.cc @@ -308,7 +308,7 @@ namespace { { if ( copts_r.count( old_r ) ) { - Zypper::instance()->out().warning( legacyCLIStr( old_r, new_r ), verbosity_r ); + Zypper::instance().out().warning( legacyCLIStr( old_r, new_r ), verbosity_r ); if ( ! copts_r.count( new_r ) ) copts_r[new_r]; copts_r.erase( old_r ); @@ -347,7 +347,7 @@ namespace struct CommandHelpFormater { CommandHelpFormater() - : _mww( _str, Zypper::instance()->out().defaultFormatWidth( 150 ) ) + : _mww( _str, Zypper::instance().out().defaultFormatWidth( 150 ) ) {} /** Allow using the underlying steam directly. */ @@ -453,17 +453,11 @@ Zypper::~Zypper() } -Zypper::Ptr & Zypper::instance() +Zypper & Zypper::instance() { - static Zypper::Ptr _instance; - - if ( !_instance ) - _instance.reset( new Zypper() ); - else - { - // PENDING SigINT? Some frequently called place to avoid exiting from within the signal handler? - _instance->immediateExitCheck(); - } + static Zypper _instance; + // PENDING SigINT? Some frequently called place to avoid exiting from within the signal handler? + _instance.immediateExitCheck(); return _instance; } diff --git a/src/Zypper.h b/src/Zypper.h index bc583ccfa8..8e8897b5d2 100644 --- a/src/Zypper.h +++ b/src/Zypper.h @@ -204,10 +204,9 @@ typedef shared_ptr RepoManager_Ptr; class Zypper : private base::NonCopyable { public: - typedef RW_pointer > Ptr; typedef std::vector ArgList; - static Ptr & instance(); + static Zypper & instance(); int main( int argc, char ** argv ); diff --git a/src/callbacks/job.h b/src/callbacks/job.h index 497271e2cc..7174da42ac 100644 --- a/src/callbacks/job.h +++ b/src/callbacks/job.h @@ -28,7 +28,7 @@ namespace ZmartRecipients { virtual bool message( MsgType type_r, const std::string & msg_r, const UserData & userData_r ) const { - Out & out( Zypper::instance()->out() ); + Out & out( Zypper::instance().out() ); switch ( type_r.asEnum() ) { case MsgType::debug: diff --git a/src/callbacks/keyring.h b/src/callbacks/keyring.h index 0ad7a4c13f..2a2240e1bf 100644 --- a/src/callbacks/keyring.h +++ b/src/callbacks/keyring.h @@ -29,7 +29,7 @@ namespace zypp { inline void hintUnsignedData() { - Zypper::instance()->out().notePar( 4, _("Signing data enables the recipient to verify that no modifications occurred after the data were signed. Accepting data with no, wrong or unknown signature can lead to a corrupted system and in extreme cases even to a system compromise.") ); + Zypper::instance().out().notePar( 4, _("Signing data enables the recipient to verify that no modifications occurred after the data were signed. Accepting data with no, wrong or unknown signature can lead to a corrupted system and in extreme cases even to a system compromise.") ); } inline void hintIfMasterIndex( const std::string & file_r ) @@ -37,23 +37,23 @@ namespace zypp if ( file_r == "repomd.xml" || file_r == "content" ) { // translator: %1% is a file name - Zypper::instance()->out().notePar( 4, str::Format(_("File '%1%' is the repositories master index file. It ensures the integrity of the whole repo.") ) % file_r ); + Zypper::instance().out().notePar( 4, str::Format(_("File '%1%' is the repositories master index file. It ensures the integrity of the whole repo.") ) % file_r ); } } inline void warnCanNotVerifyFile() { - Zypper::instance()->out().warningPar( 4, str::Format(_("We can't verify that no one meddled with this file, so it might not be trustworthy anymore! You should not continue unless you know it's safe.") ) ); + Zypper::instance().out().warningPar( 4, str::Format(_("We can't verify that no one meddled with this file, so it might not be trustworthy anymore! You should not continue unless you know it's safe.") ) ); } inline void warnFileModifiedAfterSigning() { - Zypper::instance()->out().warningPar( 4, str::Format(_("This file was modified after it has been signed. This may have been a malicious change, so it might not be trustworthy anymore! You should not continue unless you know it's safe.") ) ); + Zypper::instance().out().warningPar( 4, str::Format(_("This file was modified after it has been signed. This may have been a malicious change, so it might not be trustworthy anymore! You should not continue unless you know it's safe.") ) ); } std::ostream & dumpKeyInfo( std::ostream & str, const PublicKeyData & key, const KeyContext & context = KeyContext() ) { - Zypper & zypper = *Zypper::instance(); + Zypper & zypper = Zypper::instance(); if ( zypper.out().type() == Out::TYPE_XML ) { { @@ -101,7 +101,7 @@ namespace zypp struct KeyRingReceive : public callback::ReceiveReport { KeyRingReceive() - : _gopts(Zypper::instance()->globalOpts()) + : _gopts(Zypper::instance().globalOpts()) {} //////////////////////////////////////////////////////////////////// @@ -110,18 +110,18 @@ namespace zypp { if ( keyData_r.expired() ) { - Zypper::instance()->out().warning( str::Format(_("The gpg key signing file '%1%' has expired.")) % file_r ); + Zypper::instance().out().warning( str::Format(_("The gpg key signing file '%1%' has expired.")) % file_r ); dumpKeyInfo( (std::ostream&)ColorStream(std::cout,ColorContext::MSG_WARNING), keyData_r, context ); } else if ( keyData_r.daysToLive() < 15 ) { - Zypper::instance()->out().info( str::Format( + Zypper::instance().out().info( str::Format( PL_( "The gpg key signing file '%1%' will expire in %2% day.", "The gpg key signing file '%1%' will expire in %2% days.", keyData_r.daysToLive() )) % file_r % keyData_r.daysToLive() ); dumpKeyInfo( std::cout, keyData_r, context ); } - else if ( Zypper::instance()->out().verbosity() > Out::NORMAL ) + else if ( Zypper::instance().out().verbosity() > Out::NORMAL ) { dumpKeyInfo( std::cout, keyData_r, context ); } @@ -138,11 +138,11 @@ namespace zypp << ")" << std::endl; if (context.empty()) - Zypper::instance()->out().warning( + Zypper::instance().out().warning( str::Format(_("Accepting an unsigned file '%s'.")) % file, Out::HIGH); else - Zypper::instance()->out().warning( + Zypper::instance().out().warning( str::Format(_("Accepting an unsigned file '%s' from repository '%s'.")) % file % context.repoInfo().asUserString(), Out::HIGH); @@ -157,7 +157,7 @@ namespace zypp else // translator: %1% is a file name, %2% a repositories name msg = str::Format(_("File '%1%' from repository '%2%' is unsigned.") ) % file % context.repoInfo().asUserString(); - Zypper::instance()->out().warning( msg ); + Zypper::instance().out().warning( msg ); hintUnsignedData(); @@ -166,7 +166,7 @@ namespace zypp warnCanNotVerifyFile(); - Zypper::instance()->out().gap(); + Zypper::instance().out().gap(); // TODO: use text::join( msg, text::qContinue() ) // once the above texts for mgs are translated std::string question; @@ -199,11 +199,11 @@ namespace zypp << ")" << std::endl; if (context.empty()) - Zypper::instance()->out().warning(str::Format( + Zypper::instance().out().warning(str::Format( _("Accepting file '%s' signed with an unknown key '%s'.")) % file % id); else - Zypper::instance()->out().warning(str::Format( + Zypper::instance().out().warning(str::Format( _("Accepting file '%s' from repository '%s' signed with an unknown key '%s'.")) % file % context.repoInfo().asUserString() % id); @@ -217,7 +217,7 @@ namespace zypp else // translator: %1% is a file name, %2% is a gpg key ID, %3% a repositories name msg = str::Format(_("File '%1%' from repository '%3%' is signed with an unknown key '%2%'.") ) % file % id % context.repoInfo().asUserString(); - Zypper::instance()->out().warning( msg ); + Zypper::instance().out().warning( msg ); hintUnsignedData(); @@ -226,7 +226,7 @@ namespace zypp warnCanNotVerifyFile(); - Zypper::instance()->out().gap(); + Zypper::instance().out().gap(); std::string question; // TODO: use text::join( msg, text::qContinue() ) // once the above texts for mgs are translated @@ -248,7 +248,7 @@ namespace zypp virtual KeyRingReport::KeyTrust askUserToAcceptKey( const PublicKey &key, const KeyContext & context) { - Zypper & zypper = *Zypper::instance(); + Zypper & zypper = Zypper::instance(); std::ostringstream s; s << std::endl; @@ -349,7 +349,7 @@ namespace zypp << _("Double-check this is not caused by some malicious" " changes in the file!"); - Zypper::instance()->out().warning(msg.str(), Out::QUIET); + Zypper::instance().out().warning(msg.str(), Out::QUIET); return true; } @@ -360,7 +360,7 @@ namespace zypp else // translator: %1% is a file name, %2% a repositories name msg = str::Format(_("Signature verification failed for file '%1%' from repository '%2%'.") ) % file % context.repoInfo().asUserString(); - Zypper::instance()->out().error( msg ); + Zypper::instance().out().error( msg ); hintUnsignedData(); @@ -369,7 +369,7 @@ namespace zypp warnFileModifiedAfterSigning(); - Zypper::instance()->out().gap(); + Zypper::instance().out().gap(); return read_bool_answer( PROMPT_YN_GPG_CHECK_FAILED_IGNORE, text::join( msg, text::qContinue() ), false); } @@ -383,7 +383,7 @@ namespace zypp struct DigestReceive : public callback::ReceiveReport { - DigestReceive() : _gopts(Zypper::instance()->globalOpts()) {} + DigestReceive() : _gopts(Zypper::instance().globalOpts()) {} //////////////////////////////////////////////////////////////////// @@ -405,7 +405,7 @@ namespace zypp virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found ) { - Zypper & zypper = *Zypper::instance(); + Zypper & zypper = Zypper::instance(); std::string unblock( found.substr( 0, 4 ) ); zypper.out().gap(); diff --git a/src/callbacks/locks.h b/src/callbacks/locks.h index d2c85723e0..b1ef8ffb2c 100644 --- a/src/callbacks/locks.h +++ b/src/callbacks/locks.h @@ -23,10 +23,10 @@ namespace zypp { virtual Action conflict( const PoolQuery& query, ConflictState state ) { if (state == SAME_RESULTS) - Zypper::instance()->out().error( + Zypper::instance().out().error( _("The following query locks the same objects as the one you want to remove:")); else - Zypper::instance()->out().error( + Zypper::instance().out().error( _("The following query locks some of the objects you want to unlock:")); query.serialize(std::cout); @@ -41,7 +41,7 @@ namespace zypp { { virtual Action execute( const PoolQuery& query ) { - Zypper::instance()->out().error( + Zypper::instance().out().error( _("The following query does not lock anything:")); query.serialize(std::cout); diff --git a/src/callbacks/media.cc b/src/callbacks/media.cc index 225893143b..8e636537c4 100644 --- a/src/callbacks/media.cc +++ b/src/callbacks/media.cc @@ -204,7 +204,7 @@ namespace ZmartRecipients const std::vector & devices, unsigned & index) { - Zypper & zypper = *Zypper::instance(); + Zypper & zypper = Zypper::instance(); DBG << "medium problem, url: " << url.asString() << ", error " << error @@ -271,7 +271,7 @@ namespace ZmartRecipients if ( zypper.runtimeData().action_rpm_download && !zypper.runtimeData().seen_verify_hint ) { - print_verify_hint( Zypper::instance()->out() ); + print_verify_hint( Zypper::instance().out() ); } zypper.requestExit( false ); } @@ -291,7 +291,7 @@ namespace ZmartRecipients const std::string & description, media::AuthData & auth_data ) { - Zypper & zypper = *Zypper::instance(); + Zypper & zypper = Zypper::instance(); if ( geteuid() != 0 && url.getQueryString().find("credentials=") != std::string::npos ) { diff --git a/src/callbacks/media.h b/src/callbacks/media.h index 9b44ef5275..fe41f241ee 100644 --- a/src/callbacks/media.h +++ b/src/callbacks/media.h @@ -70,7 +70,7 @@ namespace ZmartRecipients : public callback::ReceiveReport { DownloadProgressReportReceiver() - : _gopts(Zypper::instance()->globalOpts()), _be_quiet(false) + : _gopts(Zypper::instance().globalOpts()), _be_quiet(false) {} virtual void start( const Url & uri, Pathname localfile ) @@ -78,12 +78,12 @@ namespace ZmartRecipients _last_reported = time(NULL); _last_drate_avg = -1; - Out & out = Zypper::instance()->out(); + Out & out = Zypper::instance().out(); if (out.verbosity() < Out::HIGH && ( // don't show download info unless show_media_progress_hack is used - !Zypper::instance()->runtimeData().show_media_progress_hack || + !Zypper::instance().runtimeData().show_media_progress_hack || // don't report download of the media file (bnc #330614) Pathname(uri.getPathName()).basename() == "media" ) @@ -105,9 +105,9 @@ namespace ZmartRecipients if (now > _last_reported) _last_reported = now; else - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); - Zypper & zypper = *(Zypper::instance()); + Zypper & zypper( Zypper::instance() ); if (zypper.exitRequested()) { @@ -132,13 +132,13 @@ namespace ZmartRecipients { DBG << "media problem" << std::endl; if (_be_quiet) - Zypper::instance()->out().dwnldProgressEnd(uri, _last_drate_avg, true); - Zypper::instance()->out().error(zcb_error2str(error, description)); + Zypper::instance().out().dwnldProgressEnd(uri, _last_drate_avg, true); + Zypper::instance().out().error(zcb_error2str(error, description)); Action action = (Action) read_action_ari( PROMPT_ARI_MEDIA_PROBLEM, DownloadProgressReport::ABORT); if (action == DownloadProgressReport::RETRY) - Zypper::instance()->requestExit(false); + Zypper::instance().requestExit(false); return action; } @@ -148,7 +148,7 @@ namespace ZmartRecipients if (_be_quiet) return; - Zypper::instance()->out().dwnldProgressEnd( + Zypper::instance().out().dwnldProgressEnd( uri, _last_drate_avg, ( error == NOT_FOUND ? indeterminate : TriBool(error != NO_ERROR) ) ); } diff --git a/src/callbacks/repo.h b/src/callbacks/repo.h index ea16ee4036..ffcb53f418 100644 --- a/src/callbacks/repo.h +++ b/src/callbacks/repo.h @@ -48,7 +48,7 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReportout().info(s.str()); + Zypper::instance().out().info(s.str()); } // The progress is reported by the media backend @@ -56,7 +56,7 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReportout().error(description); + Zypper::instance().out().error(description); } // implementation not needed prehaps - the media backend reports the download progress @@ -73,23 +73,23 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReportout().progressStart("apply-delta", _label_apply_delta, false); + Zypper::instance().out().progressStart("apply-delta", _label_apply_delta, false); } virtual void progressDeltaApply( int value ) { - Zypper::instance()->out().progress("apply-delta", _label_apply_delta, value); + Zypper::instance().out().progress("apply-delta", _label_apply_delta, value); } virtual void problemDeltaApply( const std::string & description ) { - Zypper::instance()->out().progressEnd("apply-delta", _label_apply_delta, true); - Zypper::instance()->out().error(description); + Zypper::instance().out().progressEnd("apply-delta", _label_apply_delta, true); + Zypper::instance().out().error(description); } virtual void finishDeltaApply() { - Zypper::instance()->out().progressEnd("apply-delta", _label_apply_delta); + Zypper::instance().out().progressEnd("apply-delta", _label_apply_delta); } void fillsRhs( TermLine & outstr_r, Zypper & zypper_r, Package::constPtr pkg_r ) @@ -106,7 +106,7 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReportout().error(description); + Zypper::instance().out().error(description); DBG << "error report" << std::endl; Action action = (Action) read_action_ari(PROMPT_ARI_RPM_DOWNLOAD_PROBLEM, ABORT); if (action == DownloadResolvableReport::RETRY) - --Zypper::instance()->runtimeData().commit_pkg_current; + --Zypper::instance().runtimeData().commit_pkg_current; else - Zypper::instance()->runtimeData().action_rpm_download = false; + Zypper::instance().runtimeData().action_rpm_download = false; return action; } virtual void pkgGpgCheck( const UserData & userData_r ) { - Zypper & zypper = *Zypper::instance(); + Zypper & zypper = Zypper::instance(); // "ResObject" ResObject::constPtr of the package // "Localpath" Pathname to downloaded package on disk // "CheckPackageResult" RpmDb::CheckPackageResult of signature check @@ -248,7 +248,7 @@ struct DownloadResolvableReportReceiver : public callback::ReceiveReportruntimeData().action_rpm_download = false; + Zypper::instance().runtimeData().action_rpm_download = false; /* display_done ("download-resolvable", cout_v); display_error (error, reason); @@ -260,7 +260,7 @@ struct ProgressReportReceiver : public callback::ReceiveReport { virtual void start( const ProgressData &data ) { - Zypper::instance()->out().progressStart( + Zypper::instance().out().progressStart( str::numstring(data.numericId()), data.name(), data.reportAlive()); @@ -269,14 +269,14 @@ struct ProgressReportReceiver : public callback::ReceiveReport virtual bool progress( const ProgressData &data ) { if (data.reportAlive()) - Zypper::instance()->out().progress( + Zypper::instance().out().progress( str::numstring(data.numericId()), data.name()); else - Zypper::instance()->out().progress( + Zypper::instance().out().progress( str::numstring(data.numericId()), data.name(), data.val()); - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); } // virtual Action problem( Repository /*repo*/, Error error, const std::string & description ) @@ -288,7 +288,7 @@ struct ProgressReportReceiver : public callback::ReceiveReport virtual void finish( const ProgressData &data ) { - Zypper::instance()->out().progressEnd( + Zypper::instance().out().progressEnd( str::numstring(data.numericId()), data.name()); } @@ -300,31 +300,31 @@ struct RepoReportReceiver : public callback::ReceiveReport virtual void start(const ProgressData & pd, const RepoInfo repo) { _repo = repo; - Zypper::instance()->out() + Zypper::instance().out() .progressStart("repo", "(" + _repo.name() + ") " + pd.name()); } virtual bool progress(const ProgressData & pd) { - Zypper::instance()->out() + Zypper::instance().out() .progress("repo", "(" + _repo.name() + ") " + pd.name(), pd.val()); - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); } virtual Action problem( Repository /*repo*/, Error error, const std::string & description ) { - Zypper::instance()->out() + Zypper::instance().out() .progressEnd("repo", "(" + _repo.name() + ") "); - Zypper::instance()->out().error(zcb_error2str(error, description)); + Zypper::instance().out().error(zcb_error2str(error, description)); return (Action) read_action_ari (PROMPT_ARI_REPO_PROBLEM, ABORT); } virtual void finish( Repository /*repo*/, const std::string & task, Error error, const std::string & reason ) { - Zypper::instance()->out() + Zypper::instance().out() .progressEnd("repo", "(" + _repo.name() + ") "); if (error != NO_ERROR) - Zypper::instance()->out().error(zcb_error2str(error, reason)); + Zypper::instance().out().error(zcb_error2str(error, reason)); // display_step(100); // many of these, avoid newline -- probably obsolete?? //if (task.find("Reading patch") == 0) diff --git a/src/callbacks/rpm.h b/src/callbacks/rpm.h index 650e36cc4f..97240a2ffa 100644 --- a/src/callbacks/rpm.h +++ b/src/callbacks/rpm.h @@ -123,7 +123,7 @@ struct PatchMessageReportReceiver : public callback::ReceiveReportout(); + Out & out = Zypper::instance().out(); std::ostringstream s; s << patch; // [patch]important-patch-101 \todo make some meaningfull message out of this out.info(s.str(), Out::HIGH); @@ -155,7 +155,7 @@ struct PatchScriptReportReceiver : public callback::ReceiveReportout().progressEnd("run-script", _label); + Zypper::instance().out().progressEnd("run-script", _label); } /** Catch unexpected end. */ @@ -222,7 +222,7 @@ struct RemoveResolvableReportReceiver : public callback::ReceiveReportset( value ); - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); } virtual Action problem( Resolvable::constPtr resolvable, Error error, const std::string & description ) @@ -254,7 +254,7 @@ struct RemoveResolvableReportReceiver : public callback::ReceiveReportout().error(s.str()); + Zypper::instance().out().error(s.str()); return (Action) read_action_ari (PROMPT_ARI_RPM_REMOVE_PROBLEM, ABORT); } @@ -270,13 +270,13 @@ struct RemoveResolvableReportReceiver : public callback::ReceiveReportsetExitCode(ZYPPER_EXIT_ERR_ZYPP); + Zypper::instance().setExitCode(ZYPPER_EXIT_ERR_ZYPP); else { // print additional rpm output // bnc #369450 if ( !reason.empty() ) - Zypper::instance()->out().info(reason); + Zypper::instance().out().info(reason); } } @@ -293,7 +293,7 @@ struct InstallResolvableReportReceiver : public callback::ReceiveReportset( value ); - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); } virtual Action problem( Resolvable::constPtr resolvable, Error error, const std::string & description, RpmLevel /*unused*/ ) @@ -328,7 +328,7 @@ struct InstallResolvableReportReceiver : public callback::ReceiveReportasString() ) << std::endl; s << zcb_error2str(error, description); - Zypper::instance()->out().error(s.str()); + Zypper::instance().out().error(s.str()); return (Action) read_action_ari (PROMPT_ARI_RPM_INSTALL_PROBLEM, ABORT); } @@ -344,13 +344,13 @@ struct InstallResolvableReportReceiver : public callback::ReceiveReportsetExitCode(ZYPPER_EXIT_ERR_ZYPP); + Zypper::instance().setExitCode(ZYPPER_EXIT_ERR_ZYPP); else { // print additional rpm output // bnc #369450 if ( !reason.empty() ) - Zypper::instance()->out().info(reason); + Zypper::instance().out().info(reason); } } @@ -369,7 +369,7 @@ struct FindFileConflictstReportReceiver : public callback::ReceiveReportout(), + _progress.reset( new Out::ProgressBar( Zypper::instance().out(), "fileconflict-check", // TranslatorExplanation A progressbar label _("Checking for file conflicts:") ) ); @@ -378,13 +378,13 @@ struct FindFileConflictstReportReceiver : public callback::ReceiveReportset( progress_r ); - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); } virtual bool progress( const ProgressData & progress_r, const sat::Queue & noFilelist_r ) { (*_progress)->set( progress_r ); - return !Zypper::instance()->exitRequested(); + return !Zypper::instance().exitRequested(); } virtual bool result( const ProgressData & progress_r, const sat::Queue & noFilelist_r, const sat::FileConflicts & conflicts_r ) @@ -395,10 +395,10 @@ struct FindFileConflictstReportReceiver : public callback::ReceiveReportexitRequested(); + return !Zypper::instance().exitRequested(); // show error result - Out & out( Zypper::instance()->out() ); + Out & out( Zypper::instance().out() ); { Out::XmlNode guard( out, "fileconflict-summary" ); @@ -430,7 +430,7 @@ struct FindFileConflictstReportReceiver : public callback::ReceiveReportcOpts().count("replacefiles") ) + if ( Zypper::instance().cOpts().count("replacefiles") ) { out.info( _("Conflicting files will be replaced."), " [--replacefiles]" ); } @@ -450,7 +450,7 @@ struct FindFileConflictstReportReceiver : public callback::ReceiveReportexitRequested(); + return !Zypper::instance().exitRequested(); } virtual void reportend() diff --git a/src/info.cc b/src/info.cc index af89202c43..9c6a6f4d56 100644 --- a/src/info.cc +++ b/src/info.cc @@ -83,7 +83,7 @@ namespace tab_r.addDetail( _("Description"), ::printRichText( pi_r.description() ) ); // dependencies according to cli options and kind - const auto & cOpts( Zypper::instance()->cOpts() ); + const auto & cOpts( Zypper::instance().cOpts() ); bool isPatch = pi_r.isKind(); for ( const auto & dep : { diff --git a/src/main.cc b/src/main.cc index d9c8f96540..b816d15c81 100644 --- a/src/main.cc +++ b/src/main.cc @@ -19,7 +19,7 @@ void signal_handler( int sig ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); if ( zypper.runtimeData().waiting_for_input ) { /// \todo try to get rid of this by improving the ^C handling when prompting @@ -48,7 +48,7 @@ void signal_handler( int sig ) void signal_nopipe( int sig ) { WAR << "Exiting on SIGPIPE..." << endl; - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); zypper.requestImmediateExit(); } @@ -110,7 +110,7 @@ int main( int argc, char **argv ) return ZYPPER_EXIT_ERR_BUG; } - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); int exitcode = zypper.main( argc, argv ); if ( !exitcode ) exitcode = zypper.exitInfoCode(); // propagate refresh errors even if main action succeeded diff --git a/src/output/Out.cc b/src/output/Out.cc index 0ca99351fe..fc23cdc8ef 100644 --- a/src/output/Out.cc +++ b/src/output/Out.cc @@ -15,7 +15,7 @@ namespace out { unsigned defaultTermwidth() - { return Zypper::instance()->out().termwidth(); } + { return Zypper::instance().out().termwidth(); } } // namespace out /////////////////////////////////////////////////////////////////// @@ -152,4 +152,4 @@ std::string Out::Error::combine( std::string && msg_r, const Exception & ex_r ) return std::move(msg_r); } std::string Out::Error::combine( const Exception & ex_r ) -{ return Zypper::instance()->out().zyppExceptionReport( ex_r ); } +{ return Zypper::instance().out().zyppExceptionReport( ex_r ); } diff --git a/src/output/Out.h b/src/output/Out.h index ad1cfc7a27..6298968fb3 100644 --- a/src/output/Out.h +++ b/src/output/Out.h @@ -55,7 +55,7 @@ namespace text namespace out { static constexpr unsigned termwidthUnlimited = 0u; - unsigned defaultTermwidth(); // Zypper::instance()->out().termwidth() + unsigned defaultTermwidth(); // Zypper::instance().out().termwidth() } // namespace out /////////////////////////////////////////////////////////////////// @@ -844,9 +844,9 @@ class Out : private base::NonCopyable * \code * { * // shut up zypper - * SCOPED_VERBOSITY( Zypper::instance()->out(), Out::QUIET ); + * SCOPED_VERBOSITY( Zypper::instance().out(), Out::QUIET ); * // expands to: - * // const auto & raii __attribute__ ((__unused__))( Zypper::instance()->out().scopedVerbosity( Out::QUIET ) ); + * // const auto & raii __attribute__ ((__unused__))( Zypper::instance().out().scopedVerbosity( Out::QUIET ) ); * ... * // leaving the block restores previous verbosity * } diff --git a/src/repos.cc b/src/repos.cc index 77c170af2c..bf015bba78 100644 --- a/src/repos.cc +++ b/src/repos.cc @@ -227,7 +227,7 @@ static bool refresh_raw_metadata( Zypper & zypper, const RepoInfo & repo, bool f // reset the gData.current_repo when going out of scope struct Bye { - ~Bye() { Zypper::instance()->runtimeData().current_repo = RepoInfo(); } + ~Bye() { Zypper::instance().runtimeData().current_repo = RepoInfo(); } } reset __attribute__ ((__unused__)); RepoManager & manager = zypper.repoManager(); @@ -1691,7 +1691,7 @@ void add_repo( Zypper & zypper, RepoInfo & repo ) gData.current_repo = repo; // reset the gData.current_repo when going out of scope - struct Bye { ~Bye() { Zypper::instance()->runtimeData().current_repo = RepoInfo(); } } reset __attribute__ ((__unused__)); + struct Bye { ~Bye() { Zypper::instance().runtimeData().current_repo = RepoInfo(); } } reset __attribute__ ((__unused__)); manager.addRepository( repo ); repo = manager.getRepo( repo ); diff --git a/src/search.cc b/src/search.cc index 6065262c0c..97d45a16ce 100644 --- a/src/search.cc +++ b/src/search.cc @@ -25,7 +25,7 @@ FillSearchTableSolvable::FillSearchTableSolvable( Table & table, TriBool inst_no : _table( &table ) , _inst_notinst( inst_notinst ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); if ( zypper.cOpts().find("repo") != zypper.cOpts().end() ) { std::list & repos( zypper.runtimeData().repos ); @@ -191,7 +191,7 @@ FillSearchTableSelectable::FillSearchTableSelectable( Table & table, TriBool ins : _table( &table ) , inst_notinst( installed_only ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); if ( zypper.cOpts().find("repo") != zypper.cOpts().end() ) { std::list & repos( zypper.runtimeData().repos ); diff --git a/src/solve-commit.cc b/src/solve-commit.cc index 430cebc0d5..e1605c3402 100755 --- a/src/solve-commit.cc +++ b/src/solve-commit.cc @@ -761,7 +761,7 @@ void solve_and_commit ( Zypper & zypper ) try { - RuntimeData & gData = Zypper::instance()->runtimeData(); + RuntimeData & gData = Zypper::instance().runtimeData(); gData.show_media_progress_hack = true; // Total packages to download & install. // To be used to write overall progress of retrieving packages. diff --git a/src/subcommand.cc b/src/subcommand.cc index 18165b4aa2..94d32edd46 100644 --- a/src/subcommand.cc +++ b/src/subcommand.cc @@ -60,7 +60,7 @@ namespace } str::Format fmter( indent+"%-"+str::numstring(colw)+"s" ); - unsigned maxcols = Zypper::instance()->out().defaultFormatWidth() / ( colw + indent.size() ); + unsigned maxcols = Zypper::instance().out().defaultFormatWidth() / ( colw + indent.size() ); if ( maxcols == 0 ) maxcols = 1; #if 1 @@ -373,7 +373,7 @@ std::ostream & SubcommandOptions::showHelpOn( std::ostream & out ) const if ( _detected._name.empty() ) { // common subcommand help - Zypper & _zypper = *Zypper::instance(); + Zypper & _zypper = Zypper::instance(); if ( _zypper.out().verbosity() > Out::QUIET ) { @@ -443,7 +443,7 @@ std::ostream & SubcommandOptions::showHelpOn( std::ostream & out ) const }; if ( cmd.run() != 0 ) { - Zypper & _zypper = *Zypper::instance(); + Zypper & _zypper = Zypper::instance(); if ( cmd.exitStatus() != 16 ) // man already returned 'No manual entry for...' { _zypper.out().error( cmd.execError() ); diff --git a/src/update.cc b/src/update.cc index 453c154224..819267974b 100755 --- a/src/update.cc +++ b/src/update.cc @@ -60,7 +60,7 @@ struct CliScanIssues : public std::set private: void checkCLI( const std::string & cliOption_r, const std::string & issueType_r ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); bool anyId = false; // plain option without opt. args std::vector issueIds; @@ -100,7 +100,7 @@ namespace { return pi.isBroken() && ! pi.isUnwanted() - && ! ( Zypper::instance()->globalOpts().exclude_optional_patches && pi->asKind()->categoryEnum() == Patch::CAT_OPTIONAL ) + && ! ( Zypper::instance().globalOpts().exclude_optional_patches && pi->asKind()->categoryEnum() == Patch::CAT_OPTIONAL ) && pi->asKind()->restartSuggested(); } @@ -385,12 +385,12 @@ namespace void patch_check() { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); Out & out( zypper.out() ); DBG << "patch check" << endl; PatchCheckStats stats( zypper.globalOpts().exclude_optional_patches ); - bool updatestackOnly = Zypper::instance()->cOpts().count("updatestack-only"); + bool updatestackOnly = Zypper::instance().cOpts().count("updatestack-only"); for_( it, God->pool().byKindBegin(ResKind::patch), God->pool().byKindEnd(ResKind::patch) ) { const PoolItem & pi( *it ); @@ -644,7 +644,7 @@ find_updates( const ResKind & kind, Candidates & candidates ) DBG << "Looking for update candidates of kind " << kind << endl; // package updates - if (kind == ResKind::package && !Zypper::instance()->cOpts().count("all")) + if (kind == ResKind::package && !Zypper::instance().cOpts().count("all")) { God->resolver()->doUpdate(); ResPool::const_iterator diff --git a/src/utils/colors.cc b/src/utils/colors.cc index 0b73288f91..71ff7f227b 100644 --- a/src/utils/colors.cc +++ b/src/utils/colors.cc @@ -26,14 +26,14 @@ bool has_colors() bool do_colors() { - return Zypper::instance()->config().do_colors; + return Zypper::instance().config().do_colors; } /////////////////////////////////////////////////////////////////// ansi::Color customColorCtor( ColorContext ctxt_r ) { - const Config & conf( Zypper::instance()->config() ); + const Config & conf( Zypper::instance().config() ); switch ( ctxt_r ) { case ColorContext::RESULT: return conf.color_result; diff --git a/src/utils/messages.cc b/src/utils/messages.cc index b7f1b63dfd..a6c5782c0f 100644 --- a/src/utils/messages.cc +++ b/src/utils/messages.cc @@ -27,7 +27,7 @@ void report_a_bug( Out & out ) void report_too_many_arguments( const std::string & specific_help ) { - report_too_many_arguments( Zypper::instance()->out(), specific_help ); + report_too_many_arguments( Zypper::instance().out(), specific_help ); } void report_too_many_arguments( Out & out, const std::string & specific_help ) diff --git a/src/utils/misc.cc b/src/utils/misc.cc index 6ff2b93617..ddb5a7f94b 100644 --- a/src/utils/misc.cc +++ b/src/utils/misc.cc @@ -143,7 +143,7 @@ std::string i18nPatchStatus( const PoolItem & pi_r ) if ( pi_r.isUnwanted() ) // Translator: Patch status: needed, optional, unwanted, applied, not needed return ColorString( tUnwanted, ColorContext::HIGHLIGHT ).str(); - if ( Zypper::instance()->globalOpts().exclude_optional_patches && pi_r->asKind()->categoryEnum() == Patch::CAT_OPTIONAL ) + if ( Zypper::instance().globalOpts().exclude_optional_patches && pi_r->asKind()->categoryEnum() == Patch::CAT_OPTIONAL ) return ColorString( tOptional, ColorContext::LOWLIGHT ).str(); return tNeeded; break; @@ -172,7 +172,7 @@ const char * textPatchStatus( const PoolItem & pi_r ) case ResStatus::BROKEN: if ( pi_r.isUnwanted() ) return tUnwanted; - if ( Zypper::instance()->globalOpts().exclude_optional_patches && pi_r->asKind()->categoryEnum() == Patch::CAT_OPTIONAL ) + if ( Zypper::instance().globalOpts().exclude_optional_patches && pi_r->asKind()->categoryEnum() == Patch::CAT_OPTIONAL ) return tOptional; return tNeeded; break; @@ -255,7 +255,7 @@ FillPatchesTable::FillPatchesTable( Table & table_r, TriBool inst_notinst_r ) << _("Summary") ); table_r.defaultSortColumn( 1 ); // by Name - // if ( ! Zypper::instance()->globalOpts().no_abbrev ) table.allowAbbrev( 6 ); // Summary + // if ( ! Zypper::instance().globalOpts().no_abbrev ) table.allowAbbrev( 6 ); // Summary }; bool FillPatchesTable::operator()( const PoolItem & pi_r ) const @@ -364,7 +364,7 @@ Url make_url( const std::string & url_s ) } else { - Zypper::instance()->out().error(_("Specified local path does not exist or is not accessible.")); + Zypper::instance().out().error(_("Specified local path does not exist or is not accessible.")); ERR << "specified local path does not exist or is not accessible" << endl; return u; } @@ -376,7 +376,7 @@ Url make_url( const std::string & url_s ) catch ( const Exception & excpt_r ) { ZYPP_CAUGHT( excpt_r ); - Zypper::instance()->out().error( str::Str() << _("Given URI is invalid") << ": " << urlstr << " (" << excpt_r.asUserString() << ")" ); + Zypper::instance().out().error( str::Str() << _("Given URI is invalid") << ": " << urlstr << " (" << excpt_r.asUserString() << ")" ); } return u; } @@ -456,7 +456,7 @@ Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::s if ( platform.empty() ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); if ( default_platform.empty() ) { @@ -504,8 +504,8 @@ Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::s } else { - Zypper::instance()->out().error(_("Invalid OBS URI."), _("Correct form is obs:///[platform]")); - Zypper::instance()->out().info(str::form(_("Example: %s"), "obs://server:http/openSUSE_11.3")); + Zypper::instance().out().error(_("Invalid OBS URI."), _("Correct form is obs:///[platform]")); + Zypper::instance().out().info(str::form(_("Example: %s"), "obs://server:http/openSUSE_11.3")); } return Url(); @@ -553,7 +553,7 @@ Pathname cache_rpm( const std::string & rpm_uri_str, const Pathname & cache_dir if ( error ) { - Zypper::instance()->out().error( + Zypper::instance().out().error( _("Problem copying the specified RPM file to the cache directory."), _("Perhaps you are running out of disk space.")); return Pathname(); @@ -562,7 +562,7 @@ Pathname cache_rpm( const std::string & rpm_uri_str, const Pathname & cache_dir } catch (const Exception & e) { - Zypper::instance()->out().error(e, + Zypper::instance().out().error(e, _("Problem retrieving the specified RPM file") + std::string(":"), _("Please check whether the file is accessible.")); } @@ -626,7 +626,7 @@ std::string asXML( const Product & p, bool is_installed ) for ( const auto & tag : copts["xmlfwd"] ) { tags.push_back( Pathname::assertprefix( "/product", tag ).asString() ); } - const Pathname & proddir( Pathname::assertprefix( Zypper::instance()->globalOpts().root_dir, "/etc/products.d" ) ); + const Pathname & proddir( Pathname::assertprefix( Zypper::instance().globalOpts().root_dir, "/etc/products.d" ) ); try { XmlFilter::fwd( InputStream( proddir+p.referenceFilename() ), *fwd, std::move(tags) ); diff --git a/src/utils/pager.cc b/src/utils/pager.cc index 260d5d279d..6723c86bf1 100755 --- a/src/utils/pager.cc +++ b/src/utils/pager.cc @@ -49,7 +49,7 @@ static std::string pager_help_navigation( const std::string & pager ) static bool show_in_pager( const std::string & pager, const Pathname & file ) { - if ( Zypper::instance()->globalOpts().non_interactive ) + if ( Zypper::instance().globalOpts().non_interactive ) return true; std::ostringstream cmdline; diff --git a/src/utils/prompt.cc b/src/utils/prompt.cc index 9bebe8ac12..d7bfe33d89 100644 --- a/src/utils/prompt.cc +++ b/src/utils/prompt.cc @@ -131,7 +131,7 @@ bool PromptOptions::isYesNoPrompt() const //! \todo The default values seems to be useless - we always want to auto-return 'retry' in case of no user input. int read_action_ari_with_timeout( PromptId pid, unsigned timeout, int default_action ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); if ( default_action > 2 || default_action < 0 ) { @@ -225,7 +225,7 @@ int read_action_ari_with_timeout( PromptId pid, unsigned timeout, int default_ac //Action ... int read_action_ari( PromptId pid, int default_action ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); // translators: "a/r/i" are the answers to the // "Abort, retry, ignore?" prompt // Translate the letters to whatever is suitable for your language. @@ -243,7 +243,7 @@ int read_action_ari( PromptId pid, int default_action ) bool read_bool_answer( PromptId pid, const std::string & question, bool default_answer ) { - Zypper & zypper( *Zypper::instance() ); + Zypper & zypper( Zypper::instance() ); std::string yn( std::string(_("yes")) + "/" + _("no") ); PromptOptions popts( yn, default_answer ? 0 : 1 ); if ( ! zypper.globalOpts().non_interactive ) diff --git a/tests/lib/TestSetup.h b/tests/lib/TestSetup.h index d0e86fccf8..3983de62b7 100644 --- a/tests/lib/TestSetup.h +++ b/tests/lib/TestSetup.h @@ -417,7 +417,7 @@ class TestSetup private: filesystem::TmpDir _tmprootdir; Pathname _rootdir; - Zypper & _zypper = *Zypper::instance(); + Zypper & _zypper = Zypper::instance(); }; diff --git a/tests/utils/text_test.cc b/tests/utils/text_test.cc index 6581de10f2..9c5cabe66f 100644 --- a/tests/utils/text_test.cc +++ b/tests/utils/text_test.cc @@ -39,8 +39,8 @@ BOOST_AUTO_TEST_CASE(mbs_substr_by_width_test) BOOST_AUTO_TEST_CASE(mbs_iterator) { - Zypper::instance()->config().do_colors = true; - BOOST_CHECK_EQUAL( Zypper::instance()->config().do_colors, true ); + Zypper::instance().config().do_colors = true; + BOOST_CHECK_EQUAL( Zypper::instance().config().do_colors, true ); ColorString cs( "'和\t平'", ColorContext::NEGATIVE ); const std::string & s( cs.str() );