From bda69edc346972df21d8f33edaa976c058b454be Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Wed, 9 Dec 2009 13:56:38 +0100 Subject: [PATCH] zypper.conf: main.showAlias option added --- src/Config.cc | 10 +++- src/Config.h | 6 ++ src/Summary.cc | 6 +- src/Summary.h | 4 ++ src/callbacks/keyring.h | 23 +++++--- src/info.cc | 12 +++- src/repos.cc | 153 +++++++++++++++++++++++++++++------------------- src/search.cc | 16 +++-- src/search.h | 4 +- src/solve-commit.cc | 2 + src/update.cc | 4 +- zypper.conf | 23 ++++++-- 12 files changed, 175 insertions(+), 88 deletions(-) diff --git a/src/Config.cc b/src/Config.cc index 69d02a2..c0a7568 100644 --- a/src/Config.cc +++ b/src/Config.cc @@ -32,6 +32,7 @@ using namespace zypp; static map _table; static map _table_str; +const ConfigOption ConfigOption::MAIN_SHOW_ALIAS(ConfigOption::MAIN_SHOW_ALIAS_e); const ConfigOption ConfigOption::SOLVER_INSTALL_RECOMMENDS(ConfigOption::SOLVER_INSTALL_RECOMMENDS_e); const ConfigOption ConfigOption::SOLVER_FORCE_RESOLUTION_COMMANDS(ConfigOption::SOLVER_FORCE_RESOLUTION_COMMANDS_e); const ConfigOption ConfigOption::COLOR_USE_COLORS(ConfigOption::COLOR_USE_COLORS_e); @@ -55,6 +56,7 @@ ConfigOption::Option ConfigOption::parse(const std::string & strval_r) if (_table.empty()) { // initialize it + _table["main/showAlias"] = SOLVER_INSTALL_RECOMMENDS_e; _table["solver/installRecommends"] = SOLVER_INSTALL_RECOMMENDS_e; _table["solver/forceResolutionCommands"] = SOLVER_FORCE_RESOLUTION_COMMANDS_e; _table["color/useColors"] = COLOR_USE_COLORS_e; @@ -83,6 +85,7 @@ const string ConfigOption::asString() const if (_table.empty()) { // initialize it + _table_str[MAIN_SHOW_ALIAS_e] = "main/showAlias"; _table_str[SOLVER_INSTALL_RECOMMENDS_e] = "solver/installRecommends"; _table_str[SOLVER_FORCE_RESOLUTION_COMMANDS_e] = "solver/forceResolutionCommands"; _table_str[COLOR_USE_COLORS_e] = "color/useColors"; @@ -104,7 +107,8 @@ const string ConfigOption::asString() const Config::Config() - : solver_installRecommends(true) + : show_alias(false) + , solver_installRecommends(true) , do_colors (false) , color_useColors ("never") , color_background (false) // dark background @@ -131,7 +135,9 @@ void Config::read(const string & file) // ---------------[ main ]-------------------------------------------------- - // TODO + s = augeas.getOption(ConfigOption::MAIN_SHOW_ALIAS.asString()); + if (!s.empty()) + show_alias = str::strToBool(s, false); // ---------------[ solver ]------------------------------------------------ diff --git a/src/Config.h b/src/Config.h index fc8e7a3..3a84935 100644 --- a/src/Config.h +++ b/src/Config.h @@ -17,6 +17,8 @@ class ConfigOption { public: + static const ConfigOption MAIN_SHOW_ALIAS; + static const ConfigOption SOLVER_INSTALL_RECOMMENDS; static const ConfigOption SOLVER_FORCE_RESOLUTION_COMMANDS; @@ -34,6 +36,8 @@ public: enum Option { + MAIN_SHOW_ALIAS_e, + SOLVER_INSTALL_RECOMMENDS_e, SOLVER_FORCE_RESOLUTION_COMMANDS_e, @@ -76,6 +80,8 @@ struct Config /** Reads zypper.conf and stores the result */ void read(const std::string & file = ""); + /** Whether to show */ + bool show_alias; bool solver_installRecommends; std::set solver_forceResolutionCommands; diff --git a/src/Summary.cc b/src/Summary.cc index 0ad1ba2..a7caf9c 100644 --- a/src/Summary.cc +++ b/src/Summary.cc @@ -43,7 +43,7 @@ bool Summary::ResPairNameCompare::operator()( // -------------------------------------------------------------------------- Summary::Summary(const zypp::ResPool & pool, const ViewOptions options) - : _viewop(options), _wrap_width(80), _force_no_color(false) + : _viewop(options), _show_repo_alias(false), _wrap_width(80), _force_no_color(false) { readPool(pool); } @@ -329,7 +329,9 @@ void Summary::writeResolvableList(ostream & out, const ResPairSet & resolvables) { // we do not know about repository changes, only show the repo from // which the package will be installed - tr << resit->second->repoInfo().name(); + tr << (_show_repo_alias ? + resit->second->repoInfo().alias() : + resit->second->repoInfo().name()); } if (_viewop & SHOW_VENDOR) { diff --git a/src/Summary.h b/src/Summary.h index 6332e6b..08e530a 100644 --- a/src/Summary.h +++ b/src/Summary.h @@ -62,6 +62,9 @@ public: { _viewop = (ViewOptions) (_viewop & ~option); } void toggleViewOption(const ViewOptions option) { _viewop & option ? unsetViewOption(option) : setViewOption(option); } + /** Show alias instead of name when showing repositories. */ + void setShowRepoAlias(bool value = true) + { _show_repo_alias = value; } void setForceNoColor(bool value = true) { _force_no_color = value; } @@ -108,6 +111,7 @@ private: private: ViewOptions _viewop; + bool _show_repo_alias; mutable unsigned _wrap_width; bool _force_no_color; diff --git a/src/callbacks/keyring.h b/src/callbacks/keyring.h index 009008b..d0a463c 100644 --- a/src/callbacks/keyring.h +++ b/src/callbacks/keyring.h @@ -30,7 +30,10 @@ namespace zypp struct KeyRingReceive : public zypp::callback::ReceiveReport { - KeyRingReceive() : _gopts(Zypper::instance()->globalOpts()) {} + KeyRingReceive() + : _gopts(Zypper::instance()->globalOpts()) + , _show_alias(Zypper::instance()->config().show_alias) + {} //////////////////////////////////////////////////////////////////// @@ -50,7 +53,7 @@ namespace zypp else Zypper::instance()->out().warning(boost::str( boost::format(_("Accepting an unsigned file '%s' from repository '%s'.")) - % file % context.repoInfo().name()), + % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name())), Out::HIGH); return true; @@ -65,7 +68,7 @@ namespace zypp question = boost::str(boost::format( // TranslatorExplanation: speaking of a file _("File '%s' from repository '%s' is unsigned, continue?")) - % file % context.repoInfo().name()); + % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name())); return read_bool_answer(PROMPT_YN_GPG_UNSIGNED_FILE_ACCEPT, question, false); } @@ -92,7 +95,7 @@ namespace zypp else Zypper::instance()->out().warning(boost::str(boost::format( _("Accepting file '%s' from repository '%s' signed with an unknown key '%s'.")) - % file % context.repoInfo().name() % id)); + % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()) % id)); return true; } @@ -106,7 +109,7 @@ namespace zypp question = boost::str(boost::format( // translators: the last %s is gpg key ID _("File '%s' from repository '%s' is signed with an unknown key '%s'. Continue?")) - % file % context.repoInfo().name() % id); + % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()) % id); return read_bool_answer(PROMPT_YN_GPG_UNKNOWN_KEY_ACCEPT, question, false); } @@ -135,7 +138,9 @@ namespace zypp << str::form(_("Key Name: %s"), keyname.c_str()) << std::endl << str::form(_("Key Fingerprint: %s"), fingerprint.c_str()) << std::endl; if (!context.empty()) - s << str::form(_("Repository: %s"), context.repoInfo().name().c_str()) + s << str::form(_("Repository: %s"), _show_alias ? + context.repoInfo().alias().c_str() : + context.repoInfo().name().c_str()) << std::endl; // if --gpg-auto-import-keys or --no-gpg-checks print info and don't ask @@ -217,7 +222,8 @@ namespace zypp else msg << boost::format( _("Ignoring failed signature verification for file '%s'" - " from repository '%s'!")) % file % context.repoInfo().name(); + " from repository '%s'!")) % file + % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()); msg << std::endl @@ -235,7 +241,7 @@ namespace zypp else question << boost::format( _("Signature verification failed for file '%s' from repository '%s'.")) - % file % context.repoInfo().name(); + % file % (_show_alias ? context.repoInfo().alias() : context.repoInfo().name()); question << std::endl @@ -248,6 +254,7 @@ namespace zypp private: const GlobalOptions & _gopts; + bool _show_alias; }; /////////////////////////////////////////////////////////////////// diff --git a/src/info.cc b/src/info.cc index dc4a043..2100bf6 100644 --- a/src/info.cc +++ b/src/info.cc @@ -175,7 +175,9 @@ void printPkgInfo(Zypper & zypper, const ui::Selectable & s) theone = installed; cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: ")) - << theone.resolvable()->repository().info().name() << endl; + << (zypper.config().show_alias ? + theone.resolvable()->repository().info().alias() : + theone.resolvable()->repository().info().name()) << endl; printNVA(theone.resolvable()); @@ -319,7 +321,9 @@ void printPatternInfo(Zypper & zypper, const ui::Selectable & s) const PoolItem & pool_item = s.theObj(); cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: ")) - << pool_item.resolvable()->repository().info().name() << endl; + << (zypper.config().show_alias ? + pool_item.resolvable()->repository().info().alias() : + pool_item.resolvable()->repository().info().name()) << endl; printNVA(pool_item.resolvable()); @@ -390,7 +394,9 @@ void printProductInfo(Zypper & zypper, const ui::Selectable & s) else { cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: ")) - << pool_item.resolvable()->repository().info().name() << endl; + << (zypper.config().show_alias ? + pool_item.resolvable()->repository().info().alias() : + pool_item.resolvable()->repository().info().name()) << endl; printNVA(pool_item.resolvable()); diff --git a/src/repos.cc b/src/repos.cc index 46a7366..0f21fa8 100644 --- a/src/repos.cc +++ b/src/repos.cc @@ -64,6 +64,7 @@ static bool refresh_raw_metadata(Zypper & zypper, gData.current_repo = repo; bool do_refresh = false; string & plabel = zypper.runtimeData().raw_refresh_progress_label; + bool show_alias = zypper.config().show_alias; // reset the gData.current_repo when going out of scope struct Bye { ~Bye() { Zypper::instance()->runtimeData().current_repo = RepoInfo(); } } reset __attribute__ ((__unused__)); @@ -77,7 +78,8 @@ static bool refresh_raw_metadata(Zypper & zypper, // check whether libzypp indicates a refresh is needed, and if so, // print a message zypper.out().info(boost::str(format( - _("Checking whether to refresh metadata for %s")) % repo.name()), + _("Checking whether to refresh metadata for %s")) % + (show_alias ? repo.alias() : repo.name())), Out::HIGH); for(RepoInfo::urls_const_iterator it = repo.baseUrlsBegin(); it != repo.baseUrlsEnd();) @@ -99,12 +101,13 @@ static bool refresh_raw_metadata(Zypper & zypper, { case RepoManager::REPO_UP_TO_DATE: zypper.out().info(boost::str( - format(_("Repository '%s' is up to date.")) % repo.name())); + format(_("Repository '%s' is up to date.")) % + (show_alias ? repo.alias() : repo.name()))); break; case RepoManager::REPO_CHECK_DELAYED: zypper.out().info(boost::str( format(_("The up-to-date check of '%s' has been delayed.")) - % repo.name()), Out::HIGH); + % (show_alias ? repo.alias() : repo.name())), Out::HIGH); break; default: WAR << "new item in enum, which is not covered" << endl; @@ -132,7 +135,7 @@ static bool refresh_raw_metadata(Zypper & zypper, if (do_refresh) { plabel = str::form( - _("Retrieving repository '%s' metadata"), repo.name().c_str()); + _("Retrieving repository '%s' metadata"), show_alias ? repo.alias().c_str() : repo.name().c_str()); zypper.out().progressStart("raw-refresh", plabel, true); manager.refreshMetadata(repo, @@ -156,7 +159,8 @@ static bool refresh_raw_metadata(Zypper & zypper, plabel.clear(); } zypper.out().error(e, - boost::str(format(_("Problem retrieving files from '%s'.")) % repo.name()), + boost::str(format(_("Problem retrieving files from '%s'.")) + % (show_alias ? repo.alias() : repo.name())), _("Please see the above error message for a hint.")); return true; // error @@ -170,12 +174,13 @@ static bool refresh_raw_metadata(Zypper & zypper, plabel.clear(); } zypper.out().error(boost::str( - format(_("No URIs defined for '%s'.")) % repo.name())); + format(_("No URIs defined for '%s'.")) + % (show_alias ? repo.alias() : repo.name()))); if (!repo.filepath().empty()) zypper.out().info(boost::str(format( // TranslatorExplanation the first %s is a .repo file path _("Please add one or more base URI (baseurl=URI) entries to %s for repository '%s'.")) - % repo.filepath() % repo.name())); + % repo.filepath() % (show_alias ? repo.alias() : repo.name()))); return true; // error } @@ -200,7 +205,8 @@ static bool refresh_raw_metadata(Zypper & zypper, plabel.clear(); } zypper.out().error(e, - boost::str(format(_("Repository '%s' is invalid.")) % repo.name()), + boost::str(format(_("Repository '%s' is invalid.")) + % (show_alias ? repo.alias() : repo.name())), _("Please check if the URIs defined for this repository are pointing to a valid repository.")); return true; // error @@ -214,9 +220,11 @@ static bool refresh_raw_metadata(Zypper & zypper, plabel.clear(); } zypper.out().error(e, - boost::str(format(_("Error retrieving metadata for '%s':")) % repo.name())); + boost::str(format(_("Error retrieving metadata for '%s':")) + % (show_alias ? repo.alias() : repo.name()))); // log untranslated message - ERR << format("Error reading repository '%s':") % repo.name() << endl; + ERR << format("Error reading repository '%s':") + % (show_alias ? repo.alias() : repo.name()) << endl; return true; // error } @@ -242,7 +250,8 @@ static bool build_cache(Zypper & zypper, const RepoInfo &repo, bool force_build) ZYPP_CAUGHT(e); zypper.out().error(e, - boost::str(format(_("Error parsing metadata for '%s':")) % repo.name()), + boost::str(format(_("Error parsing metadata for '%s':")) % + (zypper.config().show_alias ? repo.alias() : repo.name())), // TranslatorExplanation Don't translate the URL unless it is translated, too _("This may be caused by invalid metadata in the repository," " or by a bug in the metadata parser. In the latter case," @@ -250,7 +259,7 @@ static bool build_cache(Zypper & zypper, const RepoInfo &repo, bool force_build) " instructions at http://en.opensuse.org/Zypper/Troubleshooting")); // log untranslated message - ERR << format("Error parsing metadata for '%s':") % repo.name() << endl; + ERR << format("Error parsing metadata for '%s':") % repo.alias() << endl; return true; // error } @@ -258,7 +267,9 @@ static bool build_cache(Zypper & zypper, const RepoInfo &repo, bool force_build) { ZYPP_CAUGHT(e); zypper.out().error(e, - boost::str(format(_("Repository metadata for '%s' not found in local cache.")) % repo.name())); + boost::str(format(_( + "Repository metadata for '%s' not found in local cache.")) + % (zypper.config().show_alias ? repo.alias() : repo.name()))); // this should not happend and is probably a bug, rethrowing ZYPP_RETHROW(e); } @@ -502,14 +513,14 @@ void do_init_repos(Zypper & zypper, const Container & container) { zypper.out().info(str::form( _("Ignoring repository '%s' because of '%s' option."), - it->name().c_str(), "no-cd")); + (zypper.config().show_alias ? it->alias().c_str() : it->name().c_str()), "no-cd")); gData.repos.erase(it++); } if (no_remote && (*it->baseUrlsBegin()).schemeIsDownloading()) { zypper.out().info(str::form( _("Ignoring repository '%s' because of '%s' option."), - it->name().c_str(), "no-remote")); + (zypper.config().show_alias ? it->alias().c_str() : it->name().c_str()), "no-remote")); gData.repos.erase(it++); } else @@ -520,7 +531,7 @@ void do_init_repos(Zypper & zypper, const Container & container) it != gData.repos.end(); ++it) { RepoInfo repo(*it); - MIL << "checking if to refresh " << repo.name() << endl; + MIL << "checking if to refresh " << repo.alias() << endl; bool do_refresh = repo.enabled() && @@ -529,7 +540,7 @@ void do_init_repos(Zypper & zypper, const Container & container) if (do_refresh) { - MIL << "calling refresh for " << repo.name() << endl; + MIL << "calling refresh for " << repo.alias() << endl; // handle root user differently if (geteuid() == 0 && !zypper.globalOpts().changedRoot) @@ -539,9 +550,9 @@ void do_init_repos(Zypper & zypper, const Container & container) { zypper.out().warning(boost::str(format( _("Disabling repository '%s' because of the above error.")) - % repo.name()), Out::QUIET); + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET); WAR << format("Disabling repository '%s' because of the above error.") - % repo.name() << endl; + % repo.alias() << endl; it->setEnabled(false); } @@ -557,10 +568,11 @@ void do_init_repos(Zypper & zypper, const Container & container) { zypper.out().info(boost::str(format(_( "Repository '%s' is out-of-date. You can run 'zypper refresh'" - " as root to update it.")) % repo.name())); + " as root to update it.")) + % (zypper.config().show_alias ? repo.alias() : repo.name()))); - MIL << "We're running as non-root, skipping refresh of " << repo.name() - << endl; + MIL << "We're running as non-root, skipping refresh of " + << repo.alias() << endl; } } } @@ -575,9 +587,9 @@ void do_init_repos(Zypper & zypper, const Container & container) { zypper.out().warning(boost::str(format( _("Disabling repository '%s' because of the above error.")) - % repo.name()), Out::QUIET); + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET); WAR << format("Disabling repository '%s' because of the above error.") - % repo.name() << endl; + % repo.alias() << endl; it->setEnabled(false); } @@ -593,14 +605,14 @@ void do_init_repos(Zypper & zypper, const Container & container) zypper.out().warning(boost::str(format(_( "The metadata cache needs to be built for the '%s' repository." " You can run 'zypper refresh' as root to do this.")) - % repo.name()), Out::QUIET); + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET); MIL << "We're running as non-root, skipping building of " - << repo.name() + "cache" << endl; + << repo.alias() + "cache" << endl; zypper.out().info(boost::str(format(_("Disabling repository '%s'.")) - % repo.name())); - WAR << "Disabling repository '" << repo.name() << "'" << endl; + % (zypper.config().show_alias ? repo.alias() : repo.name()))); + WAR << "Disabling repository '" << repo.alias() << "'" << endl; it->setEnabled(false); } } @@ -1043,7 +1055,8 @@ void refresh_repos(Zypper & zypper) if (!repo.enabled()) { string msg = boost::str( - format(_("Skipping disabled repository '%s'")) % repo.name()); + format(_("Skipping disabled repository '%s'")) + % (zypper.config().show_alias ? repo.alias() : repo.name())); if (specified.empty()) zypper.out().info(msg, Out::HIGH); @@ -1059,9 +1072,9 @@ void refresh_repos(Zypper & zypper) { zypper.out().error(boost::str(format( _("Skipping repository '%s' because of the above error.")) - % repo.name())); + % (zypper.config().show_alias ? repo.alias() : repo.name()))); ERR << format("Skipping repository '%s' because of the above error.") - % repo.name() << endl; + % repo.alias() << endl; error_count++; } } @@ -1231,7 +1244,8 @@ void clean_repos(Zypper & zypper) if( clean_metadata ) { zypper.out().info(boost::str(format( - _("Cleaning metadata cache for '%s'.")) % repo.alias ()), + _("Cleaning metadata cache for '%s'.")) + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::HIGH); manager.cleanCache(repo); } @@ -1241,14 +1255,16 @@ void clean_repos(Zypper & zypper) if ( ! ( scheme == "cd" || scheme == "dvd" ) ) { zypper.out().info(boost::str(format( - _("Cleaning raw metadata cache for '%s'.")) % repo.alias ()), + _("Cleaning raw metadata cache for '%s'.")) + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::HIGH); manager.cleanMetadata(repo); } else { zypper.out().info(boost::str(format( - _("Keeping raw metadata cache for %s '%s'.")) %scheme %repo.alias ()), + _("Keeping raw metadata cache for %s '%s'.")) % scheme + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::HIGH); } } @@ -1256,7 +1272,8 @@ void clean_repos(Zypper & zypper) { zypper.out().info(boost::str(format( // translators: meaning the cached rpm files - _("Cleaning packages for '%s'.")) % repo.alias ()), + _("Cleaning packages for '%s'.")) + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::HIGH); manager.cleanPackages(repo); } @@ -1265,9 +1282,9 @@ void clean_repos(Zypper & zypper) { zypper.out().error(boost::str(format( _("Cannot clean repository '%s' because of an error.")) - % repo.name())); + % (zypper.config().show_alias ? repo.alias() : repo.name()))); ERR << format("Cannot clean repository '%s' because of an error.") - % repo.name() << endl; + % repo.alias() << endl; error_count++; } } @@ -1420,14 +1437,16 @@ void add_repo(Zypper & zypper, RepoInfo & repo) } ostringstream s; - s << format(_("Repository '%s' successfully added")) % repo.name(); + s << format(_("Repository '%s' successfully added")) + % (zypper.config().show_alias ? repo.alias() : repo.name()); s << endl; if (zypper.globalOpts().is_rug_compatible) { s << ( repo.enabled() ? "[x]" : "[ ]" ); s << ( repo.autorefresh() ? "* " : " " ); - s << repo.name() << " (" << *repo.baseUrlsBegin() << ")" << endl; + s << (zypper.config().show_alias ? repo.alias() : repo.name()); + s << " (" << *repo.baseUrlsBegin() << ")" << endl; } else { @@ -1449,14 +1468,16 @@ void add_repo(Zypper & zypper, RepoInfo & repo) if(is_cd) { zypper.out().info(boost::str( - format(_("Reading data from '%s' media")) % repo.name())); + format(_("Reading data from '%s' media")) + % (zypper.config().show_alias ? repo.alias() : repo.name()))); bool error = refresh_raw_metadata(zypper, repo, false); if (!error) error = build_cache(zypper, repo, false); if (error) { zypper.out().error(boost::str( - format(_("Problem reading data from '%s' media")) % repo.name()), + format(_("Problem reading data from '%s' media")) + % (zypper.config().show_alias ? repo.alias() : repo.name())), _("Please check if your installation media is valid and readable.")); zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP); return; @@ -1563,7 +1584,8 @@ void add_repo_from_file( Zypper & zypper, if(repo.baseUrlsEmpty()) { zypper.out().warning(boost::str(format( - _("Repository '%s' has no URI defined, skipping.")) % repo.name())); + _("Repository '%s' has no URI defined, skipping.")) + % (zypper.config().show_alias ? repo.alias() : repo.name()))); continue; } @@ -1603,8 +1625,9 @@ void remove_repo(Zypper & zypper, const RepoInfo & repoinfo) RepoManager & manager = zypper.repoManager(); manager.removeRepository(repoinfo); zypper.out().info(boost::str( - format(_("Repository '%s' has been removed.")) % repoinfo.name())); - MIL << format("Repository '%s' has been removed.") % repoinfo.name() << endl; + format(_("Repository '%s' has been removed.")) + % (zypper.config().show_alias ? repoinfo.alias() : repoinfo.name()))); + MIL << format("Repository '%s' has been removed.") % repoinfo.alias() << endl; } @@ -2365,8 +2388,9 @@ void add_service(Zypper & zypper, const ServiceInfo & service) } zypper.out().info(boost::str( - format(_("Service '%s' has been successfully added.")) % service.name())); - MIL << format("Service '%s' has been added.") % service.name() << endl; + format(_("Service '%s' has been successfully added.")) + % (zypper.config().show_alias ? service.alias() : service.name()))); + MIL << format("Service '%s' has been added.") % service.alias() << endl; } // --------------------------------------------------------------------------- @@ -2404,11 +2428,13 @@ void remove_service(Zypper & zypper, const ServiceInfo & service) RepoManager & manager = zypper.repoManager(); zypper.out().info(boost::str( - format(_("Removing service '%s':")) % service.name())); + format(_("Removing service '%s':")) + % (zypper.config().show_alias ? service.alias() : service.name()))); manager.removeService(service); zypper.out().info(boost::str( - format(_("Service '%s' has been removed.")) % service.name())); - MIL << format("Service '%s' has been removed.") % service.name() << endl; + format(_("Service '%s' has been removed.")) + % (zypper.config().show_alias ? service.alias() : service.name()))); + MIL << format("Service '%s' has been removed.") % service.alias() << endl; } // --------------------------------------------------------------------------- @@ -2423,7 +2449,8 @@ static bool refresh_service(Zypper & zypper, const ServiceInfo & service) try { zypper.out().info( - str::form(_("Refreshing service '%s'."), service.name().c_str())); + str::form(_("Refreshing service '%s'."), + (zypper.config().show_alias ? service.alias().c_str() : service.name().c_str()))); manager.refreshService(service); error = false; } @@ -2433,7 +2460,7 @@ static bool refresh_service(Zypper & zypper, const ServiceInfo & service) zypper.out().error(e, str::form( _("Problem retrieving the repository index file for service '%s':"), - service.name().c_str()), + (zypper.config().show_alias ? service.alias().c_str() : service.name().c_str())), _("Check if the URI is valid and accessible.")); zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP); } @@ -2492,7 +2519,8 @@ void refresh_services(Zypper & zypper) if (!service_ptr->enabled()) { string msg = boost::str( - format(_("Skipping disabled service '%s'")) % service_ptr->name()); + format(_("Skipping disabled service '%s'")) + % (zypper.config().show_alias ? service_ptr->alias() : service_ptr->name())); DBG << "skipping disabled service '" << service_ptr->alias() << "'" << endl; if (specified.empty()) @@ -2529,7 +2557,7 @@ void refresh_services(Zypper & zypper) { DBG << str::form( "Skipping non-index service '%s' because '%s' is used.", - service_ptr->name().c_str(), "--no-repos"); + zypper.config().show_alias ? service_ptr->alias().c_str() : service_ptr->name().c_str(), "--no-repos"); continue; } error = refresh_repo(zypper, *dynamic_pointer_cast(service_ptr)); @@ -2539,9 +2567,9 @@ void refresh_services(Zypper & zypper) { zypper.out().error(boost::str(format( _("Skipping service '%s' because of the above error.")) - % service_ptr->name())); + % (zypper.config().show_alias ? service_ptr->alias().c_str() : service_ptr->name().c_str()))); ERR << format("Skipping service '%s' because of the above error.") - % service_ptr->name() << endl; + % service_ptr->alias() << endl; ++error_count; } } @@ -2902,9 +2930,10 @@ void load_repo_resolvables(Zypper & zypper) if (error) { ostringstream s; - s << format(_("Problem loading data from '%s'")) % repo.name() << endl; + s << format(_("Problem loading data from '%s'")) + % (zypper.config().show_alias ? repo.alias() : repo.name()) << endl; s << format(_("Resolvables from '%s' not loaded because of error.")) - % repo.name(); + % (zypper.config().show_alias ? repo.alias() : repo.name()); zypper.out().error(s.str()); continue; } @@ -2920,9 +2949,9 @@ void load_repo_resolvables(Zypper & zypper) zypper.out().warning(boost::str(format( _("Repository '%s' appears to outdated. Consider using a different mirror or server.")) - % repo.name()), Out::QUIET); + % (zypper.config().show_alias ? repo.alias() : repo.name())), Out::QUIET); WAR << format("Repository '%s' seems to be outdated") - % repo.name() << endl; + % repo.alias() << endl; } } @@ -2930,13 +2959,15 @@ void load_repo_resolvables(Zypper & zypper) { ZYPP_CAUGHT(e); zypper.out().error(e, - boost::str(format(_("Problem loading data from '%s'")) % repo.name()), + boost::str(format(_("Problem loading data from '%s'")) + % (zypper.config().show_alias ? repo.alias() : repo.name())), // translators: the first %s is 'zypper refresh' and the second 'zypper clean -m' boost::str(format(_("Try '%s', or even '%s' before doing so.")) % "zypper refresh" % "zypper clean -m") ); zypper.out().info(boost::str(format( - _("Resolvables from '%s' not loaded because of error.")) % repo.name())); + _("Resolvables from '%s' not loaded because of error.")) + % (zypper.config().show_alias ? repo.alias() : repo.name()))); } } } diff --git a/src/search.cc b/src/search.cc index ba1f657..6a58c7b 100644 --- a/src/search.cc +++ b/src/search.cc @@ -28,6 +28,7 @@ FillSearchTableSolvable::FillSearchTableSolvable( : _table( &table ) , _gopts(Zypper::instance()->globalOpts()) , _inst_notinst(inst_notinst) + , _show_alias(Zypper::instance()->config().show_alias) { TableHeader header; @@ -146,7 +147,8 @@ bool FillSearchTableSolvable::operator()(const zypp::ui::Selectable::constPtr & if (_gopts.is_rug_compatible) { row - << pi->repository().info().name() + << (_show_alias ? + pi->repository().info().alias() : pi->repository().info().name()) << "" << pi->name() << pi->edition().asString() @@ -159,7 +161,8 @@ bool FillSearchTableSolvable::operator()(const zypp::ui::Selectable::constPtr & << kind_to_string_localized(pi->kind(), 1) << pi->edition().asString() << pi->arch().asString() - << pi->repository().info().name(); + << (_show_alias ? + pi->repository().info().alias() : pi->repository().info().name()); } *_table << row; @@ -205,7 +208,7 @@ bool FillSearchTableSolvable::operator()(const zypp::ui::Selectable::constPtr & << (string("(") + _("System Packages") + ")"); } - *_table << row;pi->repository().info().name(); + *_table << row; } //! \todo maintain an internal plaindir repo named "Local Packages" @@ -275,6 +278,7 @@ FillPatchesTable::FillPatchesTable( Table & table, zypp::TriBool inst_notinst ) : _table( &table ) , _gopts(Zypper::instance()->globalOpts()) , _inst_notinst(inst_notinst) + , _show_alias(Zypper::instance()->config().show_alias) { TableHeader header; @@ -305,7 +309,8 @@ bool FillPatchesTable::operator()(const zypp::PoolItem & pi) const zypp::Patch::constPtr patch = zypp::asKind(pi.resolvable()); row - << pi->repository().info().name() + << (_show_alias ? + pi->repository().info().alias() : pi->repository().info().name()) << pi->name() << pi->edition().asString() << patch->category() @@ -317,6 +322,7 @@ bool FillPatchesTable::operator()(const zypp::PoolItem & pi) const } +/* string selectable_search_repo_str(const ui::Selectable & s) { string repostr; @@ -335,7 +341,7 @@ string selectable_search_repo_str(const ui::Selectable & s) return repostr; } - +*/ static string string_weak_status(const ResStatus & rs) { diff --git a/src/search.h b/src/search.h index a64f059..811e8a1 100644 --- a/src/search.h +++ b/src/search.h @@ -13,7 +13,7 @@ #include "Zypper.h" #include "Table.h" -std::string selectable_search_repo_str(const zypp::ui::Selectable & s); +//std::string selectable_search_repo_str(const zypp::ui::Selectable & s); /** * Functor for filling search output table in rug style. @@ -24,6 +24,7 @@ struct FillSearchTableSolvable Table * _table; const GlobalOptions & _gopts; zypp::TriBool _inst_notinst; + bool _show_alias; FillSearchTableSolvable( Table & table, @@ -55,6 +56,7 @@ struct FillPatchesTable Table * _table; const GlobalOptions & _gopts; zypp::TriBool _inst_notinst; + bool _show_alias; FillPatchesTable( Table & table, zypp::TriBool inst_notinst = zypp::indeterminate ); diff --git a/src/solve-commit.cc b/src/solve-commit.cc index 6f57d06..31264df 100755 --- a/src/solve-commit.cc +++ b/src/solve-commit.cc @@ -547,6 +547,8 @@ void solve_and_commit (Zypper & zypper) else if (zypper.out().verbosity() == Out::DEBUG) summary.setViewOption(Summary::SHOW_ALL); + summary.setShowRepoAlias(zypper.config().show_alias); + // show the summary if (zypper.out().type() == Out::TYPE_XML) summary.dumpAsXmlTo(cout); diff --git a/src/update.cc b/src/update.cc index ca1ccf1..2ad231e 100755 --- a/src/update.cc +++ b/src/update.cc @@ -209,7 +209,7 @@ static bool list_patch_updates(Zypper & zypper) { TableRow tr (cols); - tr << patch->repoInfo().name(); + tr << (zypper.config().show_alias ? patch->repoInfo().alias() : patch->repoInfo().name()); tr << res->name () << res->edition ().asString(); tr << patch->category(); tr << (it->isBroken() ? _("needed") : _("not needed")); @@ -471,7 +471,7 @@ void list_updates(Zypper & zypper, const ResKindSet & kinds, bool best_effort) TableRow tr (cols); tr << "v"; if (!hide_repo) { - tr << res->repoInfo().name(); + tr << (zypper.config().show_alias ? res->repoInfo().alias() : res->repoInfo().name()); } if (zypper.globalOpts().is_rug_compatible) tr << ""; // Bundle diff --git a/zypper.conf b/zypper.conf index 9ac2cf0..ec2fd12 100644 --- a/zypper.conf +++ b/zypper.conf @@ -18,12 +18,27 @@ [main] -## Level of verbosity to use. +## Show repository alias instead of name. ## -## Valid values: debug, verbose, normal, quiet -## Default value: normal +## Alias is an alternative unique name of repository. Some users prefer +## to define short, handy aliases for their repositories and use them +## when specifying repositories instead of number, name, or URI. +## These users might want to set this option to 'true'. ## -# verbosity = normal +## Other users prefer to keep the aliases and names set by installation, +## registration, YaST, or other software managers, or .repo files (most +## software managers even hide the alias from user's view). +## These users might want to see the descriptive names, thus leave this +## option set to 'false'. +## +## Setting this option to 'true' will tell zypper to show repository +## alias instead of the long name wherever it needs to tell the name of +## the repository. +## +## Valid values: true, false +## Default value: false +## +# showAlias = false [solver] -- 2.7.4