-------------------------------------------------------------------
+Fri Oct 20 16:55:44 CEST 2006 - mvidner@suse.cz
+
+- zypper: nicer progress reports, with or without --verbose.
+
+-------------------------------------------------------------------
Fri Oct 20 16:25:50 CEST 2006 - ma@suse.de
- Fixed reloading of target data after commit. Broken since
#ifndef ALIVE_CURSOR_H
#define ALIVE_CURSOR_H
+#include <iostream>
+
// VT 100
#define CLEARLN "\x1B[2K\r"
zmart-rpm-callbacks.h \
zmart-media-callbacks.h \
zmart-source-callbacks.h \
+ zypper-callbacks.h \
+ zypper-callbacks.cc \
zmart-sources.h \
zmart-updates.cc \
zmart-updates.h \
zmart-misc.h \
zypper-tabulator.h \
zypper-tabulator.cc \
- zmart.h
+ zmart.h
+
zypper_SOURCES = zypper.cc zmart-sources.cc zmart-misc.cc \
AliveCursor.h \
zmart-rpm-callbacks.h \
zmart-media-callbacks.h \
zmart-source-callbacks.h \
+ zypper-callbacks.h \
+ zypper-callbacks.cc \
zmart-sources.h \
zmart-misc.h \
zypper-tabulator.h \
zypper-tabulator.cc \
zypper-search.h \
zypper-search.cc \
- zmart.h
+ zmart.h
+zypper_LDADD = $(top_srcdir)/zypp/libzypp.la -lboost_regex
zypp_checkpatches_SOURCES = zypp-checkpatches.cc zmart-sources.cc \
zypper-tabulator.h \
#zmart_LDFLAGS = -static
-.PHONY: always
-
-#$(noinst_PROGRAMS): $(top_srcdir)/zypp/lib@PACKAGE@.la
-
-$(top_srcdir)/zypp/lib@PACKAGE@.la: always
- $(MAKE) -C $(top_srcdir)/zypp
-
## ##################################################
#endif // ZMD_BACKEND_KEYRINGCALLBACKS_H
+// Local Variables:
+// c-basic-offset: 2
+// End:
}
void show_problems () {
+ ostream& stm = cerr;
Resolver_Ptr resolver = zypp::getZYpp()->resolver();
ResolverProblemList rproblems = resolver->problems ();
ResolverProblemList::iterator
e = rproblems.end (),
i;
if (b == e) {
- cerr_v << "(none)" << endl;
+ stm << "(none)" << endl;
}
for (i = b; i != e; ++i) {
- cerr_v << "PROB " << (*i)->description () << endl;
- cerr_v << ": " << (*i)->details () << endl;
+ stm << "PROB " << (*i)->description () << endl;
+ stm << ": " << (*i)->details () << endl;
ProblemSolutionList solutions = (*i)->solutions ();
ProblemSolutionList::iterator
ee = solutions.end (),
ii;
for (ii = bb; ii != ee; ++ii) {
- cerr_v << " SOL " << (*ii)->description () << endl;
- cerr_v << " : " << (*ii)->details () << endl;
+ stm << " SOL " << (*ii)->description () << endl;
+ stm << " : " << (*ii)->details () << endl;
}
}
}
if ( it->status().isToBeInstalled() || it->status().isToBeUninstalled() )
{
if ( it->status().isToBeInstalled() )
- cout << "<install> ";
+ cerr << "<install> ";
if ( it->status().isToBeUninstalled() )
- cout << "<uninstall> ";
- cout << *res << std::endl;
+ cerr << "<uninstall> ";
+ cerr << *res << endl;
}
}
}
void cond_load_resolvables ()
{
// something changed
- cerr_v << "loading sources" << endl;
load_sources();
if ( ! gSettings.disable_system_resolvables ) {
- cerr_v << "loading target" << endl;
load_target();
}
}
void load_target()
{
- cerr_v << "Adding system resolvables to the pool..." << endl;
+ cerr << "Adding system resolvables to the pool..." << endl;
ResStore tgt_resolvables(God->target()->resolvables());
cerr_v << " " << tgt_resolvables.size() << " resolvables." << endl;
God->addResolvables(tgt_resolvables, true /*installed*/);
// skip non YUM sources for now
//if ( it->type() == "YUM" )
//{
- cerr_v << "Adding " << it->alias() << " resolvables to the pool..." << endl;
+ cerr << "Adding " << it->alias() << " resolvables to the pool..." << endl;
ResStore src_resolvables(it->resolvables());
cerr_v << " " << src_resolvables.size() << " resolvables." << endl;
God->addResolvables(src_resolvables);
cerr_v << "resolving" << endl;
resolve();
- cerr_v << "Problems:" << endl;
+ cerr << "Problems:" << endl;
show_problems ();
- cerr_v << "Summary:" << endl;
+ cerr << "Summary:" << endl;
show_summary();
cerr << "Continue? [y/n] ";
{
cerr_v << "committing" << endl;
ZYppCommitResult result = God->commit( ZYppCommitPolicy() );
- cerr << result << std::endl;
+ cerr_v << result << std::endl;
}
}
#include <zypp/Package.h>
//#include <zypp/target/rpm/RpmCallbacks.h>
-#include "AliveCursor.h"
+#include "zypper-callbacks.h"
using namespace std;
{
virtual void show( zypp::Message::constPtr message )
{
-
+ std::cerr << message;
}
};
{
int & _step; // step counter for install & receive steps
int last_reported;
- AliveCursor _cursor;
ScanRpmDbReceive( int & step )
: _step( step )
{
}
- ~ScanRpmDbReceive( )
- {
- }
-
- virtual void reportbegin()
- {
- cout << _cursor << " 0 %";
- }
-
- virtual void reportend()
- {
- cout << "\r done..." << endl;
- }
-
virtual void start()
{
last_reported = 0;
-
+ progress (0);
}
virtual bool progress(int value)
{
- cout << "\r" << _cursor << " " << value << "%";
- ++_cursor;
+ display_progress ("RPM database", value);
return true;
}
virtual void finish( Error error, const std::string& reason )
{
- string errmsg;
- switch (error) {
- case NO_ERROR:
- return;
- break;
- case FAILED:
- errmsg = "FAILED";
- break;
- }
- return;
+ display_done ();
+ display_error (error, reason);
}
};
struct RemoveResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::target::rpm::RemoveResolvableReport>
{
virtual void start( zypp::Resolvable::constPtr resolvable )
- {}
+ {
+ std::cerr << "Removing: " << *resolvable << std::endl;
+ }
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
- { return true; }
+ {
+ display_progress ("Removing " + to_string (resolvable), value);
+ return true;
+ }
virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error, const std::string& description )
- { return ABORT; }
+ {
+ cerr << resolvable << error << description << endl;
+ return (Action) read_action_ari ();
+ }
virtual void finish( zypp::Resolvable::constPtr resolvable, Error error, const std::string& reason )
{}
// progress for installing a resolvable
struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::target::rpm::InstallResolvableReport>
{
- AliveCursor _cursor;
zypp::Resolvable::constPtr _resolvable;
void display_step( zypp::Resolvable::constPtr resolvable, int value )
{
- cout << CLEARLN << _cursor << " Installing " << resolvable << " [" << value << " %] " << flush;
- ++_cursor;
+ display_progress ("Installing " /* + to_string (resolvable) */, value);
}
virtual void start( zypp::Resolvable::constPtr resolvable )
{
_resolvable = resolvable;
+ cerr << "Installing: " + to_string (resolvable) << endl;
}
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error, const std::string& description, RpmLevel level )
{
- std::cout << resolvable << " " << description << std::endl;
- return ABORT;
+ cerr << resolvable << " " << description << std::endl;
+ cerr << error << ", " << level << endl;
+ return (Action) read_action_ari ();
}
virtual void finish( zypp::Resolvable::constPtr resolvable, Error error, const std::string& reason, RpmLevel level )
- {}
+ {
+ display_done ();
+ if (error != NO_ERROR) {
+ const char * level_s[] = {
+ "", "(with nodeps)", "(with nodeps+force)"
+ };
+ cerr << level_s[level];
+ }
+ display_error (error, reason);
+ }
};
};
#endif // ZMD_BACKEND_RPMCALLBACKS_H
+// Local Variables:
+// mode: c++
+// c-basic-offset: 2
+// End:
#include <zypp/Url.h>
#include <zypp/Source.h>
-#include "AliveCursor.h"
+#include "zypper-callbacks.h"
///////////////////////////////////////////////////////////////////
namespace ZmartRecipients
{
zypp::Resolvable::constPtr _resolvable_ptr;
zypp::Url _url;
- AliveCursor _cursor;
zypp::Pathname _delta;
zypp::ByteCount _delta_size;
zypp::Pathname _patch;
zypp::ByteCount _patch_size;
- virtual void start( zypp::Resolvable::constPtr resolvable_ptr, const zypp::Url &url )
- {
- _resolvable_ptr = resolvable_ptr;
- _url = url;
- }
-
void display_step( const std::string &what, int value )
{
- cout << CLEARLN << _cursor << " " << what << " [" << value << " %] " << flush;
- ++_cursor;
+ display_progress (what, value);
}
// Dowmload delta rpm:
// - problems are just informal
virtual void startDeltaDownload( const zypp::Pathname & filename, const zypp::ByteCount & downloadsize )
{
-
+ _delta = filename;
+ _delta_size = downloadsize;
+ std::cerr << "Downloading delta: "
+ << _delta << ", " << _delta_size << std::endl;
}
virtual bool progressDeltaDownload( int value )
{
- display_step( "Downloading delta " + _delta.asString(), value );
+ display_step( "Downloading delta " /*+ _delta.asString()*/, value );
return true;
}
virtual void problemDeltaDownload( const std::string &description )
{
- std::cout << description << std::endl;
+ std::cerr << description << std::endl;
}
virtual void finishDeltaDownload()
{
+ display_done ();
}
// Apply delta rpm:
virtual void startDeltaApply( const zypp::Pathname & filename )
{
_delta = filename;
+ std::cerr << "Applying delta: " << _delta << std::endl;
}
virtual void progressDeltaApply( int value )
{
- display_step( "Applying delta " + _delta.asString(), value );
+ display_step( "Applying delta " /* + _delta.asString()*/, value );
}
virtual void problemDeltaApply( const std::string &description )
{
- std::cout << description << std::endl;
+ std::cerr << description << std::endl;
}
virtual void finishDeltaApply()
- {}
+ {
+ display_done ();
+ }
// Dowmload patch rpm:
// - path below url reported on start()
{
_patch = filename;
_patch_size = downloadsize;
+ std::cerr << "Downloading patch.rpm: "
+ << _patch << ", " << _patch_size << std::endl;
}
virtual bool progressPatchDownload( int value )
{
- display_step( "Applying patchrpm " + _patch.asString(), value );
+ display_step( "Applying patchrpm " /* + _patch.asString() */, value );
return true;
}
virtual void problemPatchDownload( const std::string &description )
{
- std::cout << description << std::endl;
+ std::cerr << description << std::endl;
}
virtual void finishPatchDownload()
- {}
+ {
+ display_done ();
+ }
+ virtual void start( zypp::Resolvable::constPtr resolvable_ptr, const zypp::Url &url )
+ {
+ _resolvable_ptr = resolvable_ptr;
+ _url = url;
+ std::cerr << "Downloading: " << _resolvable_ptr;
+// grr, bad class??
+// zypp::ResObject::constPtr ro =
+// dynamic_pointer_cast<const zypp::ResObject::constPtr> (resolvable_ptr);
+ zypp::Package::constPtr ro = zypp::asKind<zypp::Package> (resolvable_ptr);
+ if (ro) {
+ std::cerr << ", " << ro->archivesize ()
+ << "(" << ro->size () << " unpacked)";
+ }
+ std::cerr << std::endl;
+ }
+
// return false if the download should be aborted right now
virtual bool progress(int value, zypp::Resolvable::constPtr resolvable_ptr)
{
- display_step( "Downloading " + resolvable_ptr->name(), value );
+ display_step( "Downloading " /* + resolvable_ptr->name() */, value );
return true;
}
virtual Action problem( zypp::Resolvable::constPtr resolvable_ptr, Error error, const std::string &description )
{
- std::cout << resolvable_ptr << " " << description << std::endl;
+ std::cerr << resolvable_ptr << " " << description << std::endl;
+ std::cerr << "(aborting)" << std::endl;
return ABORT;
}
virtual void finish( zypp::Resolvable::constPtr resolvable_ptr, Error error, const std::string &reason )
- {}
+ {
+ display_done ();
+ }
};
struct SourceReportReceiver : public zypp::callback::ReceiveReport<zypp::source::SourceReport>
{
virtual void start( zypp::Source_Ref source, const std::string &task )
{
- if ( source != _source )
- cout << endl;
-
_task = task;
_source = source;
void display_step( int value )
{
- cout << CLEARLN << _cursor << " " << _task << " [" << value << " %] " << flush;
- ++_cursor;
+ display_progress ("(" + _source.alias() + ") " + _task , value);
}
virtual bool progress( int value )
}
virtual Action problem( zypp::Source_Ref source, Error error, const std::string &description )
- { return ABORT; }
+ {
+ display_done ();
+ display_error (error, description);
+ return (Action) read_action_ari ();
+ }
- virtual void finish( zypp::Source_Ref source, const std::string &task, Error error, const std::string &reason )
+ virtual void finish( zypp::Source_Ref /*source*/, const std::string &/*task*/, Error error, const std::string &reason )
{
- if ( error == SourceReportReceiver::NO_ERROR )
- display_step(100);
+ display_step(100);
+ display_done ();
+ display_error (error, reason);
}
- AliveCursor _cursor;
std::string _task;
zypp::Source_Ref _source;
};
};
#endif
+// Local Variables:
+// mode: c++
+// c-basic-offset: 2
+// End:
}
if ( ! gSettings.disable_system_sources ) {
- cerr_v << "initializing sources" << endl;
init_system_sources();
}
}
manager = SourceManager::sourceManager();
try
{
- cerr_v << "Restoring system sources..." << endl;
+ cerr << "Restoring system sources..." << endl;
manager->restore("/");
}
catch (Exception & excpt_r)
--- /dev/null
+#include "AliveCursor.h"
+#include "zmart.h"
+
+#include <ctype.h>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+void display_progress (const string& s, int percent) {
+ static AliveCursor cursor;
+
+ cerr_v << CLEARLN << cursor++ << " " << s << "[" << percent << "%]" << flush;
+}
+
+void display_done () {
+ cerr_v << endl;
+}
+
+//template<typename Action>
+//Action ...
+int read_action_ari () {
+ // TODO: respect --yes (abort)
+ while (true) {
+ cerr << "(A)bort, (R)etry, (I)gnore?" << endl;
+ char c;
+ cin >> c;
+ c = tolower (c);
+ if (c == 'a')
+ return 0;
+ else if (c == 'r')
+ return 1;
+ else if (c == 'i')
+ return 2;
+ cerr << "?" << endl;
+ }
+}
+
+string to_string (zypp::Resolvable::constPtr resolvable) {
+ ostringstream ss;
+ ss << *resolvable;
+ return ss.str ();
+}
+
+// Local Variables:
+// c-basic-offset: 2
+// End:
--- /dev/null
+/*-----------------------------------------------------------*- c++ -*-\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPPER_CALLBACKS_H
+#define ZYPPER_CALLBACKS_H
+
+#include <string>
+#include <zypp/Resolvable.h>
+
+/*
+enum Error {
+ NO_ERROR,
+ NOT_FOUND,
+ IO,
+ INVALID,
+};
+*/
+void display_progress (const std::string& s, int percent);
+// newline if normal progress is on single line
+void display_done ();
+
+template<typename Error>
+void display_error (Error error, const std::string& reason) {
+ if (error != 0 /*NO_ERROR*/) {
+ static const char * error_s[] = {
+ "", "Not found", "I/O error", "Invalid object"
+ };
+ std::cerr << error_s[error] << ": " << reason << std::endl;
+ }
+}
+
+// abort, retry, ignore
+int read_action_ari ();
+std::string to_string (zypp::Resolvable::constPtr resolvable);
+#endif
+
{
struct Bye {
~Bye() {
- cerr_v << "Exiting main()" << endl;
+ cerr_vv << "Exiting main()" << endl;
}
} say_goodbye __attribute__ ((__unused__));
{
cerr << "Warning! No sources. Operating only over the installed resolvables. You will not be able to install stuff" << endl;
}
-
- // dont add rpms
- cerr_v << "initializing target" << endl;
- God->initializeTarget("/");
-
- cerr_v << "calculating token" << endl;
- std::string token = calculate_token();
- cerr_v << "token:" << token << endl;
-
- if ( token != gSettings.previous_token )
- {
+
+ cond_init_target ();
+ if (true) {
cond_load_resolvables ();
for ( vector<string>::const_iterator it = gData.packages_to_install.begin(); it != gData.packages_to_install.end(); ++it ) {
}
solve_and_commit ();
- }
- else {
- cerr_v << "Token unchanged" << endl;
}
return 0;
}