// copied from yast2-pkg-bindings:PkgModuleFunctions::DoProvideNameKind
bool ProvideProcess::operator()( const PoolItem& provider )
{
- cerr_vv << "Considering " << provider << endl;
+ DBG << "Considering " << provider << endl;
// 1. compatible arch
// 2. best arch
// 3. best edition
// check the version if it's specified
if (!version.empty() && version != provider->edition().asString()) {
- cerr_vv << format ("Skipping version %s (requested: %s)")
+ DBG << format ("Skipping version %s (requested: %s)")
% provider->edition().asString() % version << endl;
return true;
}
// deselect the item if it's already selected,
// only one item should be selected
if (provider.status().isToBeInstalled()) {
- cerr_vv << " Deselecting" << endl;
+ DBG << " Deselecting" << endl;
provider.status().resetTransact(whoWantsIt);
}
// regarding items which are installable only
if (!provider->arch().compatibleWith( _architecture )) {
- cerr_vv << format ("provider %s has incompatible arch '%s'")
+ DBG << format ("provider %s has incompatible arch '%s'")
% provider->name() % provider->arch().asString() << endl;
}
else if (!item) {
- cerr_vv << " First match" << endl;
+ DBG << " First match" << endl;
item = provider;
}
else if (item->arch().compare( provider->arch() ) < 0) {
- cerr_vv << " Better arch" << endl;
+ DBG << " Better arch" << endl;
item = provider;
}
else if (item->edition().compare( provider->edition() ) < 0) {
- cerr_vv << " Better edition" << endl;
+ DBG << " Better edition" << endl;
item = provider;
}
}
};
// on error print a message and return noCap
-Capability safe_parse_cap (const Zypper & zypper,
+Capability safe_parse_cap (Zypper & zypper,
const ResObject::Kind &kind, const string & capstr)
{
Capability cap;
// expect named caps as NAME[OP<EDITION>]
// transform to NAME[ OP <EDITION>] (add spaces)
string new_capstr = capstr;
- cout_vv << "capstr: " << capstr << endl;
+ DBG << "capstr: " << capstr << endl;
string::size_type op_pos = capstr.find_first_of("<>=");
if (op_pos != string::npos)
{
new_capstr.insert(op_pos, " ");
- cout_vv << "new capstr: " << new_capstr << endl;
+ DBG << "new capstr: " << new_capstr << endl;
op_pos = new_capstr.find_first_not_of("<>=", op_pos + 1);
if (op_pos != string::npos && new_capstr.size() > op_pos)
{
new_capstr.insert(op_pos, " ");
- cout_vv << "new capstr: " << new_capstr << endl;
+ DBG << "new capstr: " << new_capstr << endl;
}
}
// if we are about to install stuff and
// newer version found
if (nvg.found)
{
- cout_vv << "installed resolvable named " << capstr
+ DBG << "installed resolvable named " << capstr
<< " found, changing capability to " << new_capstr << endl;
new_capstr = capstr + " > " + vg.edition.asString();
}
catch (const Exception& e) {
//! \todo check this handling (should we fail or set a special exit code?)
ZYPP_CAUGHT(e);
- cerr << format (_("Cannot parse capability '%s'.")) % capstr << endl;
+ zypper.out().error(boost::str(
+ format(_("Cannot parse capability '%s'.")) % capstr));
}
return cap;
}
{
// name and kind match:
ProvideProcess installer (ZConfig::instance().systemArchitecture(), "" /*version*/);
- cout_vv << "Iterating over [" << kind << "]" << name << endl;
+ DBG << "Iterating over [" << kind << "]" << name << endl;
invokeOnEach(
God->pool().byIdentBegin(kind, name),
God->pool().byIdentEnd(kind, name),
zypp::functor::functorRef<bool,const zypp::PoolItem&> (installer));
- cout_vv << "... done" << endl;
+ DBG << "... done" << endl;
if (!installer.item) {
// TranslatorExplanation e.g. "package 'pornview' not found"
- cerr << format(_("%s '%s' not found")) % kind_to_string_localized(kind,1) % name << endl;
+ zypper.out().warning(boost::str(
+ format(_("%s '%s' not found")) % kind_to_string_localized(kind,1) % name));
WAR << format("%s '%s' not found") % kind % name << endl;
zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
return;
installer.item.status().setTransact( true, zypp::ResStatus::USER );
}
- cout_n << format(_("skipping %s '%s' (the newest version already installed)")) % kind_to_string_localized(kind,1) % name << endl;
+ zypper.out().info(boost::str(format(
+ _("skipping %s '%s' (the newest version already installed)"))
+ % kind_to_string_localized(kind,1) % name));
}
else {
- // TODO don't use setToBeInstalled for this purpose but higher level solver API
+ //! \todo don't use setToBeInstalled for this purpose but higher level solver API
bool result = installer.item.status().setToBeInstalled( zypp::ResStatus::USER );
if (!result)
{
// this is because the resolvable is installed and we are forcing.
installer.item.status().setTransact( true, zypp::ResStatus::USER );
- //cerr << format(_("Failed to add '%s' to the list of packages to be installed.")) % name << endl;
- //ERR << "Could not set " << name << " as to-be-installed" << endl;
+ if (!copts.count("force"))
+ {
+ zypper.out().error(boost::str(
+ format(_("Failed to add '%s' to the list of packages to be installed."))
+ % name));
+ ERR << "Could not set " << name << " as to-be-installed" << endl;
+ }
}
}
}
bool operator() ( const PoolItem& provider )
{
found = true;
- cout_vv << "Marking for deletion: " << provider << endl;
+ DBG << "Marking for deletion: " << provider << endl;
bool result = provider.status().setToBeUninstalled( zypp::ResStatus::USER );
if (!result) {
- cerr << format(
+ Zypper::instance()->out().error(boost::str(format(
_("Failed to add '%s' to the list of packages to be removed."))
- % provider.resolvable()->name() << endl;
+ % provider.resolvable()->name()));
ERR << "Could not set " << provider.resolvable()->name()
<< " as to-be-uninstalled" << endl;
}
// name and kind match:
DeleteProcess deleter;
- cerr_vv << "Iterating over " << name << endl;
+ DBG << "Iterating over " << name << endl;
invokeOnEach( pool.byIdentBegin( kind, name ),
pool.byIdentEnd( kind, name ),
resfilter::ByInstalled(),
zypp::functor::functorRef<bool,const zypp::PoolItem&> (deleter)
);
- cerr_vv << "... done" << endl;
+ DBG << "... done" << endl;
if (!deleter.found) {
// TranslatorExplanation e.g. "package 'pornview' not found"
- cerr << format(_("%s '%s' not found")) % kind_to_string_localized(kind,1) % name << endl;
+ zypper.out().error(boost::str(
+ format(_("%s '%s' not found")) % kind_to_string_localized(kind,1) % name));
zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
return;
}
*/
-void mark_by_capability (const Zypper & zypper,
+void mark_by_capability (Zypper & zypper,
bool install_not_remove,
const ResObject::Kind &kind,
const string &capstr )
Capability cap = safe_parse_cap (zypper, kind, capstr);
if (!cap.empty()) {
- cout_vv << "Capability: " << cap << endl;
+ DBG << "Capability: " << cap << endl;
Resolver_Ptr resolver = zypp::getZYpp()->resolver();
if (install_not_remove) {
- cerr_vv << "Adding requirement " << cap << endl;
+ DBG << "Adding requirement " << cap << endl;
resolver->addRequire (cap);
}
else {
- cerr_vv << "Adding conflict " << cap << endl;
+ DBG << "Adding conflict " << cap << endl;
resolver->addConflict (cap);
}
}
tribool show_problem (Zypper & zypper,
const ResolverProblem & prob, ProblemSolutionList & todo)
{
+ //! \todo use Out
ostream& stm = cerr;
string det;
stm << _("Problem: ") << prob.description () << endl;
bool show_problems(Zypper & zypper)
{
bool retry = true;
- ostream& stm = cerr;
Resolver_Ptr resolver = zypp::getZYpp()->resolver();
ResolverProblemList rproblems = resolver->problems ();
ResolverProblemList::iterator
ProblemSolutionList todo;
// display the number of problems
- if (rproblems.size() > 1) {
- stm << format (_("%s Problems:")) % rproblems.size() << endl;
- }
- else if (rproblems.empty()) {
+ if (rproblems.size() > 1)
+ zypper.out().info(boost::str(format(_("%s Problems:")) % rproblems.size()));
+ else if (rproblems.empty())
+ {
// should not happen! If solve() failed at least one problem must be set!
- stm << _("Specified capability not found") << endl;
+ zypper.out().error(_("Specified capability not found"));
zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
return false;
}
//! \todo handle resolver problems caused by --capability mode arguments specially to give proper output (bnc #337007)
if (rproblems.size() > 1)
{
- for (i = b; i != e; ++i) {
- stm << _("Problem: ") << (*i)->description () << endl;
- }
+ for (i = b; i != e; ++i)
+ zypper.out().info(boost::str(
+ format(_("Problem: %s")) % (*i)->description()));
}
// now list all problems with solution proposals
- for (i = b; i != e; ++i) {
- stm << endl;
+ for (i = b; i != e; ++i)
+ {
+ zypper.out().info("", Out::NORMAL, Out::TYPE_NORMAL); // visual separator
tribool stopnow = show_problem(zypper, *(*i), todo);
if (! indeterminate (stopnow)) {
retry = stopnow == true;
if (retry)
{
- cout_n << _("Resolving dependencies...") << endl;
+ zypper.out().info(_("Resolving dependencies..."));
resolver->applySolutions (todo);
}
return retry;
KindToResObjectSet::const_iterator it,
int verbosity)
{
- cout << endl << label << endl;
+ Out & out = Zypper::instance()->out();
+ ostringstream s;
+ s << endl << label << endl;
// get terminal width from COLUMNS env. var.
unsigned cols = 0, cols_written = 0;
{
ResObject::constPtr res(*resit);
- if (verbosity == VERBOSITY_NORMAL)
+ if (out.verbosity() == Out::NORMAL)
{
// watch the terminal widht
if (cols_written == 0)
- cout << INDENT;
+ s << INDENT;
else if (cols_written + res->name().size() + 1 > cols)
{
- cout << endl;
+ s << endl;
cols_written = 0;
}
cols_written += res->name().size();
}
else
- cout << INDENT;
+ s << INDENT;
// resolvable name
- cout << res->name() << (verbosity ? "" : " ");
+ s << res->name() << (out.verbosity() > Out::NORMAL ? "" : " ");
// plus edition and architecture for verbose output
- cout_v << "-" << res->edition() << "." << res->arch();
+ //cout_v << "-" << res->edition() << "." << res->arch();
// plus repo providing this package
- if (!res->repoInfo().alias().empty())
- cout_v << " (" << res->repoInfo().name() << ")";
+ //if (!res->repoInfo().alias().empty())
+ //cout_v << " (" << res->repoInfo().name() << ")";
// new line after each package in the verbose mode
- cout_v << endl;
+ //cout_v << endl;
}
- if (verbosity == VERBOSITY_NORMAL)
- cout << endl;
+ if (out.verbosity() == Out::NORMAL)
+ s << endl;
+
+ out.info(s.str(), Out::QUIET); //! \todo special output needed for this
}
if (retv == -1)
{
- if (zypper.globalOpts().machine_readable)
- cout << "<message type=\"warning\">" << _("Nothing to do.") << "</message>" << endl;
- else
- cout << _("Nothing to do.") << endl;
-
+ zypper.out().info(_("Nothing to do."));
return retv;
}
- // no output for machines for now
+ //! \todo no output for machines for now
if (zypper.globalOpts().machine_readable)
return retv;
show_summary_resolvable_list(title, it, zypper.globalOpts().verbosity);
}
- cout << endl;
+ zypper.out().info("", Out::NORMAL, Out::TYPE_NORMAL); // visual separator
+ ostringstream s;
if (download_size > 0)
{
- cout_n << format(_("Overall download size: %s.")) % download_size;
- cout_n << " ";
+ s << format(_("Overall download size: %s.")) % download_size;
+ s << " ";
}
if (new_installed_size > 0)
// TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K
- cout_n << format(_("After the operation, additional %s will be used."))
+ s << format(_("After the operation, additional %s will be used."))
% new_installed_size.asString(0,1,1);
//! \todo uncomment the following for bug #309112
/*
else if (new_installed_size == 0)
- cout_n << _("No additional space will be used or freed after the operation.");*/
+ s << _("No additional space will be used or freed after the operation.");*/
else
{
// get the absolute size
ByteCount abs;
abs = (-new_installed_size);
// TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K
- cout_n << format(_("After the operation, %s will be freed."))
+ s << format(_("After the operation, %s will be freed."))
% abs.asString(0,1,1);
}
- cout_n << endl;
+ zypper.out().info(s.str());
return retv;
}
force_resolution = false;
else
{
- cerr << format(_("Invalid value '%s' of the %s parameter"))
- % value % "force-resolution" << endl;
- cerr << format(_("Valid values are '%s' and '%s'")) % "on" % "off" << endl;
+ zypper.out().error(
+ boost::str(format(_("Invalid value '%s' of the %s parameter"))
+ % value % "force-resolution"),
+ boost::str(format(_("Valid values are '%s' and '%s'")) % "on" % "off"));
}
if (count > 1)
- cout << format(_("Considering only the first value of the %s parameter, ignoring the rest"))
- % "force-resolution" << endl;
+ zypper.out().warning(boost::str(format(
+ _("Considering only the first value of the %s parameter, ignoring the rest"))
+ % "force-resolution"));
}
// if --force-resolution was not specified on the command line, force
}
DBG << "force resolution: " << force_resolution << endl;
- cout_v << _("Force resolution:") << " " <<
- (force_resolution ? _("Yes") : _("No")) << endl;
+ ostringstream s;
+ s << _("Force resolution:") << " " << (force_resolution ? _("Yes") : _("No"));
+ zypper.out().info(s.str(), Out::HIGH);
God->resolver()->setForceResolve( force_resolution );
- cout_v << _("Resolving dependencies...") << endl;
+ zypper.out().info(_("Resolving dependencies..."), Out::HIGH);
DBG << "Calling the solver..." << endl;
return God->resolver()->resolvePool();
}
{
Out & out = Zypper::instance()->out();
- cout_vv << "patch check" << endl;
+ DBG << "patch check" << endl;
gData.patches_count = gData.security_patches_count = 0;
ResPool::byKind_iterator
tbl.sort (1); // Name
if (tbl.empty())
- cout_n << _("No needed patches found.") << endl;
+ zypper.out().info(_("No needed patches found."));
else
// display the result, even if --quiet specified
cout << tbl;
// ----------------------------------------------------------------------------
-void list_patch_updates(const Zypper & zypper, bool best_effort)
+void list_patch_updates(Zypper & zypper, bool best_effort)
{
Table tbl;
Table pm_tbl; // only those that affect packagemanager: they have priority
// those that affect the package manager go first
// (TODO: user option for this?)
- if (!pm_tbl.empty ()) {
- if (!tbl.empty ()) {
- cerr << _("WARNING: These are only the updates affecting the updater itself.\n"
- "There are others available too.\n") << flush;
-
- }
+ if (!pm_tbl.empty ())
+ {
+ if (!tbl.empty ())
+ zypper.out().warning(
+ _("These are only the updates affecting the updater itself.\n"
+ "There are others available too.\n"));
tbl = pm_tbl;
}
tbl.sort (1); // Name
if (tbl.empty())
- cout_n << _("No updates found.") << endl;
+ zypper.out().info(_("No updates found."));
else
cout << tbl;
}
ResPool::byKind_iterator
it = pool.byKindBegin (kind),
e = pool.byKindEnd (kind);
- cerr_vv << "Finding update candidates" << endl;
+ DBG << "Finding update candidates" << endl;
for (; it != e; ++it)
{
if (it->status().isUninstalled())
if (!candidate.resolvable())
continue;
- cerr_vv << "item " << *it << endl;
- cerr_vv << "cand " << candidate << endl;
+ DBG << "item " << *it << endl;
+ DBG << "cand " << candidate << endl;
candidates.insert (candidate);
}
}
// ----------------------------------------------------------------------------
-void list_updates(const Zypper & zypper, const ResObject::Kind &kind, bool best_effort )
+void list_updates(Zypper & zypper, const ResObject::Kind &kind, bool best_effort )
{
bool k_is_patch = kind == ResTraits<Patch>::kind;
if (k_is_patch)
tbl.sort( name_col );
if (tbl.empty())
- cout_n << _("No updates found.") << endl;
+ zypper.out().info(_("No updates found."));
else
cout << tbl;
}
bool mark_item_install (const PoolItem& pi) {
bool result = pi.status().setToBeInstalled( zypp::ResStatus::USER );
if (!result) {
- cerr_vv << "Marking " << pi << "for installation failed" << endl;
+ DBG << "Marking " << pi << "for installation failed" << endl;
}
return result;
}
}
catch (const Exception& e) {
ZYPP_CAUGHT(e);
- cerr << "Cannot parse '" << installed->name() << " < " << installed->edition() << "'" << endl;
+ Zypper::instance()->out().error(boost::str(format(
+ _("Cannot parse '%s < %s'")) % installed->name() % installed->edition()));
}
return true;
// Skipping a patch because it is marked as interactive or has
// license to confirm and --skip-interactive is requested.
// TranslatorExplanation %s is the name of a patch
- cerr << format (_("WARNING: %s is interactive, skipped."))
- % res << endl;
+ Zypper::instance()->out().warning(boost::str(format(
+ _("WARNING: %s is interactive, skipped."))
+ % res));
}
else {
nothing_found = false;
//! \todo fix the media reporting correctly
gData.show_media_progress_hack = true;
- cerr_v << _("committing"); MIL << "committing...";
+ ostringstream s;
+ s << _("committing"); MIL << "committing...";
ZYppCommitResult result;
if (copts.count("dry-run"))
{
- cerr_v << " " << _("(dry run)") << endl; MIL << "(dry run)";
+ s << " " << _("(dry run)") << endl; MIL << "(dry run)";
+ zypper.out().info(s.str(), Out::HIGH);
result = God->commit(ZYppCommitPolicy().dryRun(true));
}
else
{
- cerr_v << endl; // endl after 'committing'
+ zypper.out().info(s.str(), Out::HIGH);
result = God->commit(
ZYppCommitPolicy().syncPoolAfterCommit(zypper.runningShell()));
was_installed = true;
}
+
MIL << endl << "DONE" << endl;
gData.show_media_progress_hack = false;
-
+
if (!result._errors.empty())
retv = ZYPPER_EXIT_ERR_ZYPP;
- cerr_v << result << std::endl;
+ s.clear(); s << result;
+ zypper.out().info(s.str(), Out::HIGH);
}
catch ( const media::MediaException & e ) {
ZYPP_CAUGHT(e);
else if (was_installed)
{
if (retv == ZYPPER_EXIT_INF_REBOOT_NEEDED)
- {
- if (zypper.globalOpts().machine_readable)
- cout << "<message type=\"warning\">" << _("One of installed patches requires reboot of"
- " your machine. Please do it as soon as possible.") << "</message>" << endl;
- else
- cout << _("WARNING: One of installed patches requires a reboot of"
- " your machine. Please do it as soon as possible.") << endl;
- }
+ zypper.out().warning(
+ _("One of installed patches requires reboot of"
+ " your machine. Please do it as soon as possible."));
else if (retv == ZYPPER_EXIT_INF_RESTART_NEEDED)
- {
- if (!zypper.globalOpts().machine_readable)
- cout << _("WARNING: One of installed patches affects the package"
- " manager itself, thus it requires its restart before executing"
- " any further operations.") << endl;
- }
+ zypper.out().warning(
+ _("One of installed patches affects the package"
+ " manager itself, thus it requires its restart before executing"
+ " any further operations."),
+ Out::NORMAL, Out::TYPE_NORMAL);
}
if (zypper.exitCode() == ZYPPER_EXIT_OK) // don't overwrite previously set exit code
{
if (zypper.cmdOpts().license_auto_agree)
{
- // TranslatorExplanation The first %s is name of the resolvable, the second is its kind (e.g. 'zypper package')
- if (!zypper.globalOpts().machine_readable)
- cout << format(_("Automatically agreeing with %s %s license."))
- % it->resolvable()->name()
- % kind_to_string_localized(it->resolvable()->kind(),1)
- << endl;
+ zypper.out().info(boost::str(
+ // TranslatorExplanation The first %s is name of the resolvable, the second is its kind (e.g. 'zypper package')
+ format(_("Automatically agreeing with %s %s license."))
+ % it->resolvable()->name()
+ % kind_to_string_localized(it->resolvable()->kind(),1)));
MIL << format("Automatically agreeing with %s %s license.")
% it->resolvable()->name() % it->resolvable()->kind().asString()
continue;
}
- cout << format(_("%s %s license:")) % it->resolvable()->name()
- % kind_to_string_localized(it->resolvable()->kind(), 1)
- << it->resolvable()->licenseToConfirm() << endl;
+ // license text
+ ostringstream s;
+ s << format(_("%s %s license:")) % it->resolvable()->name()
+ % kind_to_string_localized(it->resolvable()->kind(), 1)
+ << it->resolvable()->licenseToConfirm();
+ zypper.out().info(s.str(), Out::QUIET);
+ // lincense prompt
string question = _("In order to install this package, you must agree"
" to terms of the above license. Continue?");
-
if (!read_bool_answer(PROMPT_YN_LICENSE_AGREE, question, zypper.cmdOpts().license_auto_agree))
{
confirmed = false;
if (zypper.globalOpts().non_interactive)
{
- //! \todo do this with _PL()
- cout << endl <<
- _("Aborting installation due to the need for"
- " license(s) confirmation.") << " ";
- // TranslatorExplanation Don't translate the '--auto-agree-with-licenses',
- // it is a command line option
- cout << _("Please restart the operation in interactive"
- " mode and confirm your agreement with required license(s),"
- " or use the --auto-agree-with-licenses option.")
- << endl;
+ zypper.out().info(
+ _("Aborting installation due to the need for license confirmation."),
+ Out::QUIET);
+ zypper.out().info(boost::str(format(
+ // translators: %sanslate the '--auto-agree-with-licenses',
+ // it is a command line option
+ _("Please restart the operation in interactive"
+ " mode and confirm your agreement with required licenses,"
+ " or use the %s option.")) % "--auto-agree-with-licenses"),
+ Out::QUIET);
+
MIL << "License(s) NOT confirmed (non-interactive without auto confirmation)" << endl;
}
else
{
- cout << endl;
- // TranslatorExplanation e.g. "... with flash package license."
- cout << format(
+ zypper.out().info(boost::str(format(
+ // translators: e.g. "... with flash package license."
_("Aborting installation due to user disagreement with %s %s license."))
% it->resolvable()->name()
- % kind_to_string_localized(it->resolvable()->kind(), 1)
- << endl;
+ % kind_to_string_localized(it->resolvable()->kind(), 1)),
+ Out::QUIET);
MIL << "License(s) NOT confirmed (interactive)" << endl;
}
SrcPackage::constPtr srcpkg;
ResPool pool(God->pool());
- cout_vv << "looking source for : " << arg << endl;
+ DBG << "looking source for : " << arg << endl;
for_( srcit, pool.byIdentBegin<SrcPackage>(arg),
pool.byIdentEnd<SrcPackage>(arg) )
{
- cout_vv << *srcit << endl;
+ DBG << *srcit << endl;
if ( ! srcit->status().isInstalled() )
{
SrcPackage::constPtr _srcpkg = asKind<SrcPackage>(srcit->resolvable());
- cout_vv << "Considering srcpakcage " << srcpkg->name() << "-" << srcpkg->edition() << ": ";
+ DBG << "Considering srcpakcage " << srcpkg->name() << "-" << srcpkg->edition() << ": ";
if (_srcpkg)
{
if (_srcpkg->edition() < srcpkg->edition())
- cout_vv << "newer edition (" << srcpkg->edition() << " > " << _srcpkg->edition() << ")" << endl;
+ DBG << "newer edition (" << srcpkg->edition() << " > " << _srcpkg->edition() << ")" << endl;
else
- cout_vv << "is older than the current candidate";
+ DBG << "is older than the current candidate";
}
else
- cout_vv << "first candindate";
+ DBG << "first candindate";
- cout_vv << endl;
+ DBG << endl;
_srcpkg.swap(srcpkg);
}
if (srcpkg)
{
- cout << format(_("Installing source package %s-%s dependencies"))
- % srcpkg->name() % srcpkg->edition() << endl;
-
+ Zypper::instance()->out().info(boost::str(format(
+ _("Installing source package %s-%s dependencies"))
+ % srcpkg->name() % srcpkg->edition()));
+
// add all src requires to pool
for_( itc, srcpkg->dep(Dep::REQUIRES).begin(), srcpkg->dep(Dep::REQUIRES).end() )
{
God->resolver()->addRequire(*itc);
}
-
- ret = ZYPPER_EXIT_ERR_ZYPP;
-
}
else
{
- cerr << format(_("Source package '%s' not found.")) % (*it) << endl;
+ Zypper::instance()->out().error(boost::str(format(
+ _("Source package '%s' not found.")) % (*it)));
+ ret = ZYPPER_EXIT_INF_CAP_NOT_FOUND;
}
}
if (srcpkg)
{
- cout << format(_("Installing source package %s-%s"))
- % srcpkg->name() % srcpkg->edition() << endl;
+ Zypper::instance()->out().info(boost::str(format(
+ _("Installing source package %s-%s"))
+ % srcpkg->name() % srcpkg->edition()));
MIL << "Going to install srcpackage: " << srcpkg << endl;
try
{
God->installSrcPackage(srcpkg);
- cout << format(_("Source package %s-%s successfully installed."))
- % srcpkg->name() % srcpkg->edition() << endl;
+ Zypper::instance()->out().info(boost::str(format(
+ _("Source package %s-%s successfully installed."))
+ % srcpkg->name() % srcpkg->edition()));
}
catch (const Exception & ex)
{
ZYPP_CAUGHT(ex);
- cerr << format(_("Problem installing source package %s-%s:"))
- % srcpkg->name() % srcpkg->edition() << endl;
- cerr << ex.asUserString() << endl;
+ Zypper::instance()->out().error(ex,
+ boost::str(format(_("Problem installing source package %s-%s:"))
+ % srcpkg->name() % srcpkg->edition()));
ret = ZYPPER_EXIT_ERR_ZYPP;
}
}
else
- cerr << format(_("Source package '%s' not found.")) % (*it) << endl;
+ Zypper::instance()->out().error(boost::str(format(
+ _("Source package '%s' not found.")) % (*it)));
}
return ret;
if (refresh_raw_metadata(zypper, repo, false)
|| build_cache(zypper, repo, false))
{
- cerr << format(_("Disabling repository '%s' because of the above error."))
- % repo.name() << endl;
- ERR << format("Disabling repository '%s' because of the above error.")
+ zypper.out().warning(boost::str(format(
+ _("Disabling repository '%s' because of the above error."))
+ % repo.name()), Out::QUIET);
+ WAR << format("Disabling repository '%s' because of the above error.")
% repo.name() << endl;
it->setEnabled(false);
// user
catch (const Exception & ex)
{
- cout << format(_(
+ zypper.out().info(boost::str(format(_(
"Repository '%s' is out-of-date. You can run 'zypper refresh'"
- " as root to update it.")) % repo.name()
- << endl;
+ " as root to update it.")) % repo.name()));
- string nonroot =
- "We're running as non-root, skipping refresh of " + repo.name();
- MIL << nonroot << endl;
- cout_vv << nonroot << endl;
+ MIL << "We're running as non-root, skipping refresh of " << repo.name()
+ << endl;
}
}
}
{
if (build_cache(zypper, repo, false))
{
- cerr << format(_("Disabling repository '%s' because of the above error."))
- % repo.name() << endl;
- ERR << format("Disabling repository '%s' because of the above error.")
+ zypper.out().warning(boost::str(format(
+ _("Disabling repository '%s' because of the above error."))
+ % repo.name()), Out::QUIET);
+ WAR << format("Disabling repository '%s' because of the above error.")
% repo.name() << endl;
it->setEnabled(false);
// non-root user
else
{
- // if error is returned, it means zypp attempted to build the sqlite
+ // if error is returned, it means zypp attempted to build the meta-data
// cache for the repo and failed because writing is not allowed for
- // non-root Thus, just display refresh hint for non-root user.
+ // non-root. Thus, just display refresh hint for non-root user.
if (build_cache(zypper, repo, false))
{
- cout << format(_(
- "The cache database needs to be built for the '%s' repository."
- " You can run 'zypper refresh' as root to do this.")) % repo.name()
- << endl;
+ zypper.out().warning(boost::str(format(_(
+ "The meta-data cache needs to be built for the '%s' repository."
+ " You can run 'zypper refresh' as root to do this."))
+ % repo.name()), Out::QUIET);
- string nonroot =
- "We're running as non-root, skipping building of " + repo.name() + "cache";
- MIL << nonroot << endl;
- cout_vv << nonroot << endl;
+ MIL << "We're running as non-root, skipping building of "
+ << repo.name() + "cache" << endl;
- cerr << format(_("Disabling repository '%s'."))
- % repo.name() << endl << endl;
- ERR << "Disabling repository '" << repo.name() << "'" << endl;
+ zypper.out().info(boost::str(format(_("Disabling repository '%s'."))
+ % repo.name()));
+ WAR << "Disabling repository '" << repo.name() << "'" << endl;
it->setEnabled(false);
}
}
// ----------------------------------------------------------------------------
-void init_target (Zypper & zypper) {
+void init_target (Zypper & zypper)
+{
static bool done = false;
- //! \todo do this so that it works in zypper shell
- if (!done) {
- cout_v << _("Initializing Target") << endl;
+ if (!done)
+ {
+ zypper.out().info(_("Initializing Target"), Out::HIGH);
try
{
// ----------------------------------------------------------------------------
-static void print_repo_list(const Zypper & zypper,
+static void print_repo_list(Zypper & zypper,
const std::list<zypp::RepoInfo> &repos )
{
Table tbl;
// header
TableHeader th;
th << "#" << _("Enabled") << _("Refresh") << _("Type") << _("Alias") << _("Name");
- if (zypper.globalOpts().verbosity > VERBOSITY_NORMAL)
+ if (zypper.out().verbosity() > Out::NORMAL)
th << "URI";
tbl << th;
it != repos.end(); ++it)
{
RepoInfo repo = *it;
- TableRow tr (zypper.globalOpts().verbosity > VERBOSITY_NORMAL ? 6 : 7);
+ TableRow tr (zypper.out().verbosity() > Out::NORMAL ? 6 : 7);
// number
tr << str::numstring (i);
// name
tr << repo.name();
// url
- if (zypper.globalOpts().verbosity > VERBOSITY_NORMAL)
+ if (zypper.out().verbosity() > Out::NORMAL)
tr << (*repo.baseUrlsBegin()).asString(); //! \todo properly handle multiple baseurls
tbl << tr;
}
if (tbl.empty())
- cout_n << _("No repositories defined."
- " Use the 'zypper addrepo' command to add one or more repositories.")
- << endl;
+ zypper.out().info(_("No repositories defined."
+ " Use the 'zypper addrepo' command to add one or more repositories."));
else
cout << tbl;
}
catch ( const Exception &e )
{
ZYPP_CAUGHT(e);
- cerr << _("Error reading repositories:") << endl
- << e.asUserString() << endl;
+ zypper.out().error(e, _("Error reading repositories:"));
exit(ZYPPER_EXIT_ERR_ZYPP);
}
std::ofstream stream(file.c_str());
if (!stream)
{
- cerr << format(_("Can't open %s for writing. Maybe you don't have write permissions?"))
- % file.asString() << endl;
+ zypper.out().error(boost::str(format(
+ _("Can't open %s for writing."))
+ % file.asString()),
+ _("Maybe you do not have write permissions?"));
exit(ZYPPER_EXIT_ERR_INVALID_ARGS);
}
else
{
print_repos_to(repos, stream);
- cout << format(
+ zypper.out().info(boost::str(format(
_("Repositories have been successfully exported to %s."))
- % (file.absolute() ? file.asString() : file.asString().substr(2))
- << endl;
+ % (file.absolute() ? file.asString() : file.asString().substr(2))),
+ Out::QUIET);
}
}
}
get_repos(zypper, tmp1->second.begin(), tmp1->second.end(), specified, not_found);
report_unknown_repos(zypper.out(), not_found);
- cout_v << _("Specified repositories: ");
+ ostringstream s;
+ s << _("Specified repositories: ");
for (list<RepoInfo>::const_iterator it = specified.begin();
it != specified.end(); ++it)
- cout_v << it->alias() << " ";
- cout_v << endl;
+ s << it->alias() << " ";
+ zypper.out().info(s.str(), Out::HIGH);
// should we clean packages or metadata ?
bool clean_metadata = (copts.find("metadata") != copts.end());
clean_packages = true;
}
- cout_vv << "Metadata will be cleaned: " << clean_metadata << endl;
- cout_vv << "Packages will be cleaned: " << clean_packages << endl;
+ DBG << "Metadata will be cleaned: " << clean_metadata << endl;
+ DBG << "Packages will be cleaned: " << clean_packages << endl;
unsigned error_count = 0;
unsigned enabled_repo_count = repos.size();
try {
if( clean_metadata )
{
- cout_v << "Cleaning metadata for '" << repo.alias () << "'" << endl;
+ zypper.out().info(boost::str(format(
+ _("Cleaning metadata for '%s'.")) % repo.alias ()),
+ Out::HIGH);
manager.cleanMetadata(repo);
}
if( clean_packages )
{
- cout_v << "Cleaning packages for '" << repo.alias () << "'" << endl;
+ zypper.out().info(boost::str(format(
+ // translators: meaning the cached rpm files
+ _("Cleaning packages for '%s'.")) % repo.alias ()),
+ Out::HIGH);
manager.cleanPackages(repo);
}
} catch(...) {
if (error)
{
- cerr << format(_("Skipping repository '%s' because of the above error."))
- % repo.name() << endl;
- ERR << format("Skipping repository '%s' because of the above error.")
+ zypper.out().error(boost::str(format(
+ _("Cannot clean repository '%s' because of an error."))
+ % repo.name()));
+ ERR << format("Cannot clean repository '%s' because of an error.")
% repo.name() << endl;
error_count++;
}
if (error_count == enabled_repo_count)
{
- cerr << _("Could not clean the repositories because of errors.") << endl;
+ zypper.out().error(_("Could not clean the repositories because of errors."));
zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
return;
}
else if (error_count)
{
- cerr << _("Some of the repositories have not been cleaned up because of an error.") << endl;
+ zypper.out().error(
+ _("Some of the repositories have not been cleaned up because of an error."));
zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
return;
}
else if (!specified.empty())
- cout << _("Specified repositories have been cleaned up.") << endl;
+ zypper.out().info(_("Specified repositories have been cleaned up."));
else
- cout << _("All repositories have been cleaned up.") << endl;
+ zypper.out().info(_("All repositories have been cleaned up."));
}
// ----------------------------------------------------------------------------
}
if (is_cd)
{
- cout_v << _("This is a changeable read-only media (CD/DVD), disabling autorefresh.") << endl;
+ zypper.out().info(
+ _("This is a changeable read-only media (CD/DVD), disabling autorefresh."),
+ Out::QUIET);
repo.setAutorefresh(false);
}
catch (const RepoAlreadyExistsException & e)
{
ZYPP_CAUGHT(e);
- cerr << format(_("Repository named '%s' already exists. Please use another alias."))
- % repo.alias() << endl;
+ zypper.out().error(boost::str(format(
+ _("Repository named '%s' already exists. Please use another alias."))
+ % repo.alias()));
ERR << "Repository named '" << repo.alias() << "' already exists." << endl;
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."
+
+ ostringstream s;
+ s << _("Could not determine the type of the 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;
+ s << (*uit) << endl;
+
+ zypper.out().error(e,
+ _("Can't find a valid repository at given location:"), s.str());
+
zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
return;
}
return;
}
- cout << format(_("Repository '%s' successfully added")) % repo.name();
- cout_n << ":";
- cout << endl;
+ ostringstream s;
+ s << format(_("Repository '%s' successfully added")) % repo.name();
if (zypper.globalOpts().is_rug_compatible)
{
- cout_n << ( repo.enabled() ? "[x]" : "[ ]" );
- cout_n << ( repo.autorefresh() ? "* " : " " );
- cout_n << repo.name() << " (" << *repo.baseUrlsBegin() << ")" << endl;
+ s << ( repo.enabled() ? "[x]" : "[ ]" );
+ s << ( repo.autorefresh() ? "* " : " " );
+ s << repo.name() << " (" << *repo.baseUrlsBegin() << ")" << endl;
}
else
{
// TranslatorExplanation used as e.g. "Enabled: Yes"
- cout_n << _("Enabled") << ": " << (repo.enabled() ? _("Yes") : _("No")) << endl;
+ s << _("Enabled") << ": " << (repo.enabled() ? _("Yes") : _("No")) << endl;
// TranslatorExplanation used as e.g. "Autorefresh: Yes"
- cout_n << _("Autorefresh") << ": " << (repo.autorefresh() ? _("Yes") : _("No")) << endl;
+ s << _("Autorefresh") << ": " << (repo.autorefresh() ? _("Yes") : _("No")) << endl;
- cout_n << "URL:";
+ s << "URL:";
for (RepoInfo::urls_const_iterator uit = repo.baseUrlsBegin();
uit != repo.baseUrlsEnd(); uit++)
- cout_n << " " << *uit;
- cout_n << endl;
+ s << " " << *uit;
+ s << endl;
}
+ zypper.out().info(s.str());
MIL << "Repository successfully added: " << repo << endl;
if(is_cd)
{
- cout_n << format(_("Reading data from '%s' media")) % repo.name() << endl;
+ zypper.out().info(boost::str(
+ format(_("Reading data from '%s' media")) % repo.name()));
bool error = refresh_raw_metadata(zypper, repo, false);
if (!error)
error = build_cache(zypper, repo, false);
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;
+ zypper.out().error(boost::str(
+ format(_("Problem reading data from '%s' media")) % repo.name()),
+ _("Please check if your installation media is valid and readable."));
zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
return;
}
if(repo.alias().empty())
{
- cerr << _("A repository with no alias defined found in the file, skipping.") << endl;
+ zypper.out().warning(
+ _("Repository with no alias defined found in the file, skipping."));
continue;
}
if(repo.baseUrlsEmpty())
{
- cerr << format(_("Repository '%s' has no URL defined, skipping.")) % repo.name() << endl;
+ zypper.out().warning(boost::str(format(
+ _("Repository '%s' has no URL defined, skipping.")) % repo.name()));
continue;
}
try
{
manager.removeRepository(repoinfo);
- cout << format(_("Repository '%s' has been removed.")) % repoinfo.name() << endl;
+ zypper.out().info(boost::str(
+ format(_("Repository '%s' has been removed.")) % repoinfo.name()));
MIL << format("Repository '%s' has been removed.") % repoinfo.name() << endl;
}
catch (const repo::RepoNotFoundException & ex)
repo.setAlias(newalias);
manager.modifyRepository(alias, repo);
- cout << format(_("Repository '%s' renamed to '%s'")) % alias % repo.alias() << endl;
+ zypper.out().info(boost::str(format(
+ _("Repository '%s' renamed to '%s'.")) % alias % repo.alias()));
MIL << format("Repository '%s' renamed to '%s'") % alias % repo.alias() << endl;
}
catch (const RepoNotFoundException & ex)
{
- cerr << format(_("Repository '%s' not found.")) % alias << endl;
+ zypper.out().error(boost::str(format(
+ _("Repository '%s' not found.")) % alias));
ERR << "Repo " << alias << " not found" << endl;
}
catch (const RepoAlreadyExistsException & ex)
{
- cerr << format(_(
- "Repository named '%s' already exists. Please use another alias."))
- % newalias << endl;
+ zypper.out().error(boost::str(format(
+ _("Repository named '%s' already exists. Please use another alias."))
+ % newalias));
}
catch (const Exception & ex)
{
- cerr << _("Error while modifying the repository:") << endl;
- cerr << ex.asUserString() << endl;
- cerr << format(_("Leaving repository '%s' unchanged.")) % alias << endl;
+ zypper.out().error(ex,
+ _("Error while modifying the repository:"),
+ boost::str(format(_("Leaving repository '%s' unchanged.")) % alias));
ERR << "Error while modifying the repository:" << ex.asUserString() << endl;
}
{
// tell whether currenlty processed options are contradicting each other
// bool contradiction = false;
- // TranslatorExplanation speaking of two mutually contradicting command line options
string msg_contradition =
+ // translators: speaking of two mutually contradicting command line options
_("%s used together with %s, which contradict each other."
" This property will be left unchanged.");
{
if (enable)
{
- cerr << format(msg_contradition) % "--enable" % "--disable" << endl;
+ zypper.out().warning(boost::str(format(msg_contradition)
+ % "--enable" % "--disable"), Out::QUIET);
enable = indeterminate;
}
{
if (autoref)
{
- cerr << format(msg_contradition)
- % "--refresh" % "--no-refresh" << endl;
+ zypper.out().warning(boost::str(format(msg_contradition)
+ % "--refresh" % "--no-refresh"));
autoref = indeterminate;
}
manager.modifyRepository(alias, repo);
- cout << format(_("Repository %s has been sucessfully modified.")) % alias << endl;
+ zypper.out().info(boost::str(format(
+ _("Repository %s has been sucessfully modified.")) % alias));
MIL << format("Repository %s modified:") % alias << repo << endl;
}
catch (const RepoNotFoundException & ex)
{
- cerr << format(_("Repository %s not found.")) % alias << endl;
+ zypper.out().error(
+ boost::str(format(_("Repository %s not found.")) % alias));
ERR << "Repo " << alias << " not found" << endl;
}
catch (const Exception & ex)
{
- cerr << _("Error while modifying the repository:") << endl;
- cerr << ex.asUserString();
- cerr << format(_("Leaving repository %s unchanged.")) % alias << endl;
+ zypper.out().error(ex,
+ _("Error while modifying the repository:"),
+ boost::str(format(_("Leaving repository %s unchanged.")) % alias));
ERR << "Error while modifying the repository:" << ex.asUserString() << endl;
}
// if there is no metadata locally
if ( manager.metadataStatus(repo).empty() )
{
- cout_v << format(_("Retrieving repository '%s' data..."))
- % repo.name() << endl;
+ zypper.out().info(boost::str(
+ format(_("Retrieving repository '%s' data...")) % repo.name()));
error = refresh_raw_metadata(zypper, repo, false);
}
if (!error && !manager.isCached(repo))
{
- cout_v << format(_("Repository '%s' not cached. Caching..."))
- % repo.name() << endl;
+ zypper.out().info(boost::str(
+ format(_("Repository '%s' not cached. Caching...")) % repo.name()));
error = build_cache(zypper, repo, false);
}
if (error)
{
- cerr << format(_("Problem loading data from '%s'")) % repo.name() << endl;
- cerr << format(_("Resolvables from '%s' not loaded because of error."))
- % repo.name() << endl;
+ ostringstream s;
+ s << format(_("Problem loading data from '%s'")) % repo.name() << endl;
+ s << format(_("Resolvables from '%s' not loaded because of error."))
+ % repo.name();
+ zypper.out().error(s.str());
continue;
}
manager.loadFromCache(repo);
- //cout_v << " " << format(_("(%d resolvables found)")) % store.size() << endl;
}
catch (const Exception & e)
{
zypper.out().error(e,
boost::str(format(_("Problem loading data from '%s'")) % repo.name()),
_("Try 'zypper refresh', or even remove /var/cache/zypp/zypp.db before doing so."));
- cerr << format(_("Resolvables from '%s' not loaded because of error."))
- % repo.name() << endl;
+ zypper.out().info(boost::str(format(
+ _("Resolvables from '%s' not loaded because of error.")) % repo.name()));
}
}
}
MIL << "Going to read RPM database" << endl;
God->target()->load();
-
- if (!zypper.globalOpts().machine_readable)
- {
- //cout_v << " " << format(_("(%s resolvables)")) % tgt_resolvables.size();
- cout_n << endl;
- }
- //DBG << tgt_resolvables.size() << " resolvables read";
-
- //if (to_pool)
- // God->addResolvables(tgt_resolvables, true /*installed*/);
- //else
- // gData.target_resolvables = tgt_resolvables;
}
// ---------------------------------------------------------------------------
{
if (system ("pgrep -lx zmd") == 0)
{ // list name, exact match
- cout_n << _("ZENworks Management Daemon is running.\n"
+ Zypper::instance()->out().info(_("ZENworks Management Daemon is running.\n"
"WARNING: this command will not synchronize changes.\n"
- "Use rug or yast2 for that.\n");
+ "Use rug or yast2 for that."));
USR << ("ZMD is running. Tell the user this will get"
" ZMD and libzypp out of sync.") << endl;
}