{
report_problem(e,
boost::str(format(_("Problem downloading files from '%s'.")) % repo.name()),
- _("Please, see the above error message to for a hint."));
+ _("Please see the above error message to for a hint."));
return true; // error
}
if (!repo.filepath().empty())
cerr << format(
// TranslatorExplanation the first %s is a .repo file path
- _("Please, add one or more base URL (baseurl=URL) entries to %s for repository '%s'."))
+ _("Please add one or more base URL (baseurl=URL) entries to %s for repository '%s'."))
% repo.filepath() % repo.name() << endl;
return true; // error
ZYPP_CAUGHT(e);
report_problem(e,
boost::str(format(_("Repository '%s' is invalid.")) % repo.name()),
- _("Please, check if the URLs defined for this repository are pointing to a valid repository."));
+ _("Please check if the URLs defined for this repository are pointing to a valid repository."));
return true; // error
}
else
gData.repos = manager.knownRepositories();
+ // additional repositories (--plus-repo)
+ if (!gData.additional_repos.empty())
+ {
+ for (list<RepoInfo>::iterator it = gData.additional_repos.begin();
+ it != gData.additional_repos.end(); ++it)
+ {
+ add_repo(zypper, *it);
+ gData.repos.push_back(*it);
+ }
+ }
for (std::list<RepoInfo>::iterator it = gData.repos.begin();
it != gData.repos.end(); ++it)
exit(ZYPPER_EXIT_ERR_ZYPP);
}
+ // add the additional repos specified with the --plus-repo to the list
+ if (!gData.additional_repos.empty())
+ repos.insert(repos.end(),
+ gData.additional_repos.begin(),
+ gData.additional_repos.end());
+
// export to file or stdout in repo file format
if (copts.count("export"))
{
// ----------------------------------------------------------------------------
-static
-int add_repo(Zypper & zypper, RepoInfo & repo)
+void add_repo(Zypper & zypper, RepoInfo & repo)
{
RepoManager manager(zypper.globalOpts().rm_options);
catch (const RepoAlreadyExistsException & e)
{
ZYPP_CAUGHT(e);
- cerr << format(_("Repository named '%s' already exists. Please, use another alias."))
+ cerr << format(_("Repository named '%s' already exists. Please use another alias."))
% repo.alias() << endl;
ERR << "Repository named '" << repo.alias() << "' already exists." << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
catch (const RepoUnknownTypeException & e)
{
ZYPP_CAUGHT(e);
cerr << _("Can't find a valid repository at given location:") << endl;
cerr << _("Could not determine the type of the repository."
- " Please, check if the defined URLs (see below) point to a valid repository:");
+ " Please check if the defined URLs (see below) point to a valid repository:");
for(RepoInfo::urls_const_iterator uit = repo.baseUrlsBegin();
uit != repo.baseUrlsEnd(); ++uit)
cerr << (*uit) << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
catch (const RepoException & e)
{
ZYPP_CAUGHT(e);
report_problem(e,
_("Problem transferring repository data from specified URL:"),
- is_cd ? "" : _("Please, check whether the specified URL is accessible."));
+ is_cd ? "" : _("Please check whether the specified URL is accessible."));
ERR << "Problem transferring repository data from specified URL" << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
catch (const Exception & e)
{
ZYPP_CAUGHT(e);
report_problem(e, _("Unknown problem when adding repository:"));
- return ZYPPER_EXIT_ERR_BUG;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_BUG);
+ return;
}
cout << format(_("Repository '%s' successfully added")) % repo.name();
if (error)
{
cerr << format(_("Problem reading data from '%s' media")) % repo.name() << endl;
- cerr << _("Please, check if your installation media is valid and readable.") << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ cerr << _("Please check if your installation media is valid and readable.") << endl;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
}
-
- return ZYPPER_EXIT_OK;
}
// ----------------------------------------------------------------------------
if ( !indeterminate(autorefresh) )
repo.setAutorefresh((autorefresh == true));
- zypper.setExitCode(add_repo(zypper, repo));
+ add_repo(zypper, repo);
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
-/*
-static
-bool looks_like_url (const string& s) {
- static bool schemes_shown = false;
- if (!schemes_shown) {
- cerr_vv << "Registered schemes: " << Url::getRegisteredSchemes () << endl;
- schemes_shown = true;
- }
- string::size_type pos = s.find (':');
- if (pos != string::npos) {
- string scheme (s, 0, pos);
- if (Url::isRegisteredScheme (scheme)) {
- return true;
- }
- }
- return false;
-}
-*/
static bool do_remove_repo(Zypper & zypper, const RepoInfo & repoinfo)
{
RepoManager manager(zypper.globalOpts().rm_options);
* \param type
* \param enabled Whether the repo should be enabled
* \param autorefresh Whether the repo should have autorefresh turned on
- * \return ZYPPER_EXIT_ERR_ZYPP on unexpected zypp exception,
- * ZYPPER_EXIT_OK otherwise
*/
void add_repo_by_url(Zypper & zypper,
const zypp::Url & url,
* \param repo_file_url Valid URL of the repo file.
* \param enabled Whether the repo should be enabled
* \param autorefresh Whether the repo should have autorefresh turned on
- * \return ZYPPER_EXIT_ERR_ZYPP on unexpected zypp exception,
- * ZYPPER_EXIT_OK otherwise
*/
void add_repo_from_file(Zypper & zypper,
const std::string & repo_file_url,
boost::tribool autorefresh = boost::indeterminate);
/**
+ * Add repository specified by \repo to system repositories.
+ */
+void add_repo(Zypper & zypper, zypp::RepoInfo & repo);
+
+/**
* Delte repository specified by \a alias.
*/
bool remove_repo(Zypper & zypper, const std::string &alias );
{
case ZypperCommand::SHELL_e:
commandShell();
- return ZYPPER_EXIT_OK;
+ cleanup();
+ return exitCode();
case ZypperCommand::NONE_e:
{
default:
safeDoCommand();
+ cleanup();
return exitCode();
}
"\t--reposd-dir, D <dir>\tUse alternative repository definition files directory.\n"
"\t--cache-dir, C <dir>\tUse alternative meta-data cache database directory.\n"
"\t--raw-cache-dir <dir>\tUse alternative raw meta-data cache directory\n"
+ "\t--plus-repo, p <URI|file>\tUse an additional repository\n"
);
static string help_commands = _(
{"reposd-dir", required_argument, 0, 'D'},
{"cache-dir", required_argument, 0, 'C'},
{"raw-cache-dir", required_argument, 0, 0 },
+ {"plus-repo", required_argument, 0, 'p'},
{"opt", optional_argument, 0, 'o'},
{"disable-system-resolvables", optional_argument, 0, 'o'},
{0, 0, 0, 0}
cout_v << _("Ignoring installed resolvables...") << endl;
_gopts.disable_system_resolvables = true;
}
-/*
- if (gopts.count("source"))
- {
- list<string> sources = gopts["source"];
- for (list<string>::const_iterator it = sources.begin(); it != sources.end(); ++it )
- {
- Url url = make_url (*it);
- if (!url.isValid())
- setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
- return;
- _gopts.additional_sources.push_back(url);
- }
- }
-*/
+
// testing option
if ((it = gopts.find("opt")) != gopts.end()) {
cout << "Opt arg: ";
}
}
+ // additional repositories
+ if (gopts.count("plus-repo") || gopts.count("source"))
+ {
+ if (command() == ZypperCommand::ADD_REPO ||
+ command() == ZypperCommand::REMOVE_REPO ||
+ command() == ZypperCommand::MODIFY_REPO ||
+ command() == ZypperCommand::RENAME_REPO ||
+ command() == ZypperCommand::REFRESH)
+ {
+ cout << _("The --plus-repo option has no effect here, ignoring.") << endl;
+ }
+ else
+ {
+ list<string> repos = gopts["plus-repo"];
+ if (repos.empty())
+ repos = gopts["sources"];
+
+ int count = 1;
+ for (list<string>::const_iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ Url url = make_url (*it);
+ if (!url.isValid())
+ {
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+
+ RepoInfo repo;
+ repo.addBaseUrl(url);
+ repo.setEnabled(true);
+ repo.setAutorefresh(true);
+ repo.setAlias(boost::str(format("tmp%d") % count));
+ repo.setName(url.asString());
+
+ gData.additional_repos.push_back(repo);
+ DBG << "got additional repo: " << url << endl;
+ count++;
+ }
+ }
+ }
+
MIL << "DONE" << endl;
}
setExitCode(ZYPPER_EXIT_ERR_BUG);
}
+void Zypper::cleanup()
+{
+ MIL << "START" << endl;
+
+ // remove the additional repositories specified by --plus-repo
+ for (list<RepoInfo>::const_iterator it = gData.additional_repos.begin();
+ it != gData.additional_repos.end(); ++it)
+ remove_repo(*this, it->alias());
+}
+
// Local Variables:
// c-basic-offset: 2
// End: