#include <map>
#include <pwd.h>
#include <grp.h>
+#include <iomanip>
#include <termios.h>
#include <unistd.h>
{
public:
pkgDPkgPMPrivate() : stdin_is_dev_null(false), dpkgbuf_pos(0),
- term_out(NULL), history_out(NULL)
+ term_out(NULL), history_out(NULL),
+ last_reported_progress(0.0)
{
dpkgbuf[0] = '\0';
}
FILE *term_out;
FILE *history_out;
string dpkg_error;
+
+ float last_reported_progress;
};
namespace
*/
void pkgDPkgPM::SendTerminalProgress(float percentage)
{
+ int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
+
+ if(percentage < (d->last_reported_progress + reporting_steps))
+ return;
+
// FIXME: use colors too
std::cout << "\r\n"
- << "Progress: [" << percentage << "%]"
+ << "Progress: [" << std::setw(3) << int(percentage) << "%]"
<< "\r\n";
+ d->last_reported_progress = percentage;
}
/*}}}*/
/*{{{*/
tcsetattr(0, TCSAFLUSH, &tt);
close(master);
}
-
+
// Check for an error code.
if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
{
}
}
CloseLog();
+
+ // dpkg is done at this point
+ if(_config->FindB("DPkgPM::Progress", false) == true)
+ SendTerminalProgress(100);
if (pkgPackageManager::SigINTStop)
_error->Warning(_("Operation was interrupted before it could finish"));