From bea92c0abd0af13f398ac7ca8b8577e5c14ca711 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Sun, 13 Apr 2008 12:15:55 +0000 Subject: [PATCH] - allow to specify repo list in init_repos() --- src/zypper-repos.cc | 18 +++++++++++++----- src/zypper-repos.h | 13 ++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/zypper-repos.cc b/src/zypper-repos.cc index 3c2b521..b7b74bc 100644 --- a/src/zypper-repos.cc +++ b/src/zypper-repos.cc @@ -371,7 +371,9 @@ static void report_unknown_repos(Out & out, list not_found) * Fill gData.repositories with active repos (enabled or specified) and refresh * if autorefresh is on. */ -static void do_init_repos(Zypper & zypper) + +template +static void do_init_repos(Zypper & zypper, const Container & container) { MIL << "Going to initialize repositories." << endl; @@ -379,14 +381,19 @@ static void do_init_repos(Zypper & zypper) init_target(zypper); RepoManager manager(zypper.globalOpts().rm_options); - // get repositories specified with --repo or --catalog + // get repositories specified with --repo or --catalog or in the container + list not_found; parsed_opts::const_iterator it; + // --repo if ((it = copts.find("repo")) != copts.end()) get_repos(zypper, it->second.begin(), it->second.end(), gData.repos, not_found); - // rug compatibility + // --catalog - rug compatibility if ((it = copts.find("catalog")) != copts.end()) get_repos(zypper, it->second.begin(), it->second.end(), gData.repos, not_found); + // container + if (!container.empty()) + get_repos(zypper, container.begin(), container.end(), gData.repos, not_found); if (!not_found.empty()) { report_unknown_repos(zypper.out(), not_found); @@ -503,7 +510,8 @@ static void do_init_repos(Zypper & zypper) // ---------------------------------------------------------------------------- -void init_repos(Zypper & zypper) +template +void init_repos(Zypper & zypper, const Container & container) { static bool done = false; //! \todo this has to be done so that it works in zypper shell @@ -511,7 +519,7 @@ void init_repos(Zypper & zypper) return; if ( !zypper.globalOpts().disable_system_sources ) - do_init_repos(zypper); + do_init_repos(zypper, container); done = true; } diff --git a/src/zypper-repos.h b/src/zypper-repos.h index c14e62d..5189536 100644 --- a/src/zypper-repos.h +++ b/src/zypper-repos.h @@ -16,6 +16,15 @@ void init_target(Zypper & zypper); /** + * The same as \ref init_repos(), but allows to specify repos to initialize. + * + * \param zypper The zypper instance. + * \param container A string container of identifier (alias|#|URI) to init. + */ +template +void init_repos(Zypper & zypper, const Container & container = Container()); + +/** * Reads known enabled repositories and stores them in gData. * This command also refreshes repos with auto-refresh enabled. * @@ -23,7 +32,9 @@ void init_target(Zypper & zypper); * - ZYPPER_EXIT_ERR_INVALID_ARGS if --repo does not specify a valid repository, * - ZYPPER_EXIT_ERR_ZYPP on error */ -void init_repos(Zypper & zypper); +void init_repos(Zypper & zypper) +{ init_repos(zypper, std::vector()); } + /** * List defined repositories. -- 2.7.4