From 82e369c4b93b5b81db7988ab377a3c5bd388268e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 5 Oct 2013 12:15:03 +0200 Subject: * move upgrade releated code into upgrade.{cc,h} The upgrade releated code is moved into upgrade.{cc,h} and all pkg*Upgrade* prototypes are included in algorihms.h to avoid breaking API (unless build with APT_9_CLEANER_HEADERS). --- apt-pkg/makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg/makefile') diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 59729faf5..262f8fd41 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -43,7 +43,8 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \ srcrecords.cc cachefile.cc versionmatch.cc policy.cc \ pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \ indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \ - aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc + aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc \ + upgrade.cc HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ orderlist.h sourcelist.h packagemanager.h tagfile.h \ init.h pkgcache.h version.h progress.h pkgrecords.h \ @@ -51,7 +52,7 @@ HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \ - cachefilter.h cacheset.h edsp.h + cachefilter.h cacheset.h edsp.h upgrade.h # Source code for the debian specific components # In theory the deb headers do not need to be exported.. -- cgit v1.2.3-70-g09d2 From d428d131a29a08fa7c1d95b98b684fb2ebb554c0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 5 Oct 2013 12:22:55 +0200 Subject: Move ListUpdate/AquireUpdate into update.{cc,h} This moves the ListUpdate/AquireUpdate out of the "catch-all" algorithm.{cc,h} file into its own update.{cc,h} --- apt-pkg/algorithms.cc | 99 --------------------------------- apt-pkg/algorithms.h | 6 +- apt-pkg/makefile | 4 +- apt-pkg/update.cc | 126 ++++++++++++++++++++++++++++++++++++++++++ apt-pkg/update.h | 21 +++++++ apt-private/private-update.cc | 1 + 6 files changed, 151 insertions(+), 106 deletions(-) create mode 100644 apt-pkg/update.cc create mode 100644 apt-pkg/update.h (limited to 'apt-pkg/makefile') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 22701f8a6..8644a8138 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1337,102 +1337,3 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List) qsort(List,Count,sizeof(*List),PrioComp); } /*}}}*/ -// ListUpdate - construct Fetcher and update the cache files /*{{{*/ -// --------------------------------------------------------------------- -/* This is a simple wrapper to update the cache. it will fetch stuff - * from the network (or any other sources defined in sources.list) - */ -bool ListUpdate(pkgAcquireStatus &Stat, - pkgSourceList &List, - int PulseInterval) -{ - pkgAcquire Fetcher; - if (Fetcher.Setup(&Stat, _config->FindDir("Dir::State::Lists")) == false) - return false; - - // Populate it with the source selection - if (List.GetIndexes(&Fetcher) == false) - return false; - - return AcquireUpdate(Fetcher, PulseInterval, true); -} - /*}}}*/ -// AcquireUpdate - take Fetcher and update the cache files /*{{{*/ -// --------------------------------------------------------------------- -/* This is a simple wrapper to update the cache with a provided acquire - * If you only need control over Status and the used SourcesList use - * ListUpdate method instead. - */ -bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, - bool const RunUpdateScripts, bool const ListCleanup) -{ - // Run scripts - if (RunUpdateScripts == true) - RunScripts("APT::Update::Pre-Invoke"); - - pkgAcquire::RunResult res; - if(PulseInterval > 0) - res = Fetcher.Run(PulseInterval); - else - res = Fetcher.Run(); - - if (res == pkgAcquire::Failed) - return false; - - bool Failed = false; - bool TransientNetworkFailure = false; - for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); - I != Fetcher.ItemsEnd(); ++I) - { - if ((*I)->Status == pkgAcquire::Item::StatDone) - continue; - - (*I)->Finished(); - - ::URI uri((*I)->DescURI()); - uri.User.clear(); - uri.Password.clear(); - string descUri = string(uri); - _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(), - (*I)->ErrorText.c_str()); - - if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) - { - TransientNetworkFailure = true; - continue; - } - - Failed = true; - } - - // Clean out any old list files - // Keep "APT::Get::List-Cleanup" name for compatibility, but - // this is really a global option for the APT library now - if (!TransientNetworkFailure && !Failed && ListCleanup == true && - (_config->FindB("APT::Get::List-Cleanup",true) == true && - _config->FindB("APT::List-Cleanup",true) == true)) - { - if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false || - Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false) - // something went wrong with the clean - return false; - } - - if (TransientNetworkFailure == true) - _error->Warning(_("Some index files failed to download. They have been ignored, or old ones used instead.")); - else if (Failed == true) - return _error->Error(_("Some index files failed to download. They have been ignored, or old ones used instead.")); - - - // Run the success scripts if all was fine - if (RunUpdateScripts == true) - { - if(!TransientNetworkFailure && !Failed) - RunScripts("APT::Update::Post-Invoke-Success"); - - // Run the other scripts - RunScripts("APT::Update::Post-Invoke"); - } - return true; -} - /*}}}*/ diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index 9dfa1538a..80f6578eb 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -46,10 +46,9 @@ using std::ostream; #ifndef APT_9_CLEANER_HEADERS #include +#include #endif -class pkgAcquireStatus; - class pkgSimulate : public pkgPackageManager /*{{{*/ { @@ -152,8 +151,5 @@ bool pkgFixBroken(pkgDepCache &Cache); void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List); -bool ListUpdate(pkgAcquireStatus &progress, pkgSourceList &List, int PulseInterval=0); -bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval = 0, - bool const RunUpdateScripts = true, bool const ListCleanup = true); #endif diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 262f8fd41..dc943aad4 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -44,7 +44,7 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \ pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \ indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \ aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc \ - upgrade.cc + upgrade.cc update.cc HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ orderlist.h sourcelist.h packagemanager.h tagfile.h \ init.h pkgcache.h version.h progress.h pkgrecords.h \ @@ -52,7 +52,7 @@ HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \ - cachefilter.h cacheset.h edsp.h upgrade.h + cachefilter.h cacheset.h edsp.h upgrade.h update.h # Source code for the debian specific components # In theory the deb headers do not need to be exported.. diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc new file mode 100644 index 000000000..97be5490b --- /dev/null +++ b/apt-pkg/update.cc @@ -0,0 +1,126 @@ + +// Include Files /*{{{*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + /*}}}*/ + +using namespace std; + +// ListUpdate - construct Fetcher and update the cache files /*{{{*/ +// --------------------------------------------------------------------- +/* This is a simple wrapper to update the cache. it will fetch stuff + * from the network (or any other sources defined in sources.list) + */ +bool ListUpdate(pkgAcquireStatus &Stat, + pkgSourceList &List, + int PulseInterval) +{ + pkgAcquire Fetcher; + if (Fetcher.Setup(&Stat, _config->FindDir("Dir::State::Lists")) == false) + return false; + + // Populate it with the source selection + if (List.GetIndexes(&Fetcher) == false) + return false; + + return AcquireUpdate(Fetcher, PulseInterval, true); +} + /*}}}*/ +// AcquireUpdate - take Fetcher and update the cache files /*{{{*/ +// --------------------------------------------------------------------- +/* This is a simple wrapper to update the cache with a provided acquire + * If you only need control over Status and the used SourcesList use + * ListUpdate method instead. + */ +bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval, + bool const RunUpdateScripts, bool const ListCleanup) +{ + // Run scripts + if (RunUpdateScripts == true) + RunScripts("APT::Update::Pre-Invoke"); + + pkgAcquire::RunResult res; + if(PulseInterval > 0) + res = Fetcher.Run(PulseInterval); + else + res = Fetcher.Run(); + + if (res == pkgAcquire::Failed) + return false; + + bool Failed = false; + bool TransientNetworkFailure = false; + for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); + I != Fetcher.ItemsEnd(); ++I) + { + if ((*I)->Status == pkgAcquire::Item::StatDone) + continue; + + (*I)->Finished(); + + ::URI uri((*I)->DescURI()); + uri.User.clear(); + uri.Password.clear(); + string descUri = string(uri); + _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(), + (*I)->ErrorText.c_str()); + + if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) + { + TransientNetworkFailure = true; + continue; + } + + Failed = true; + } + + // Clean out any old list files + // Keep "APT::Get::List-Cleanup" name for compatibility, but + // this is really a global option for the APT library now + if (!TransientNetworkFailure && !Failed && ListCleanup == true && + (_config->FindB("APT::Get::List-Cleanup",true) == true && + _config->FindB("APT::List-Cleanup",true) == true)) + { + if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false || + Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false) + // something went wrong with the clean + return false; + } + + if (TransientNetworkFailure == true) + _error->Warning(_("Some index files failed to download. They have been ignored, or old ones used instead.")); + else if (Failed == true) + return _error->Error(_("Some index files failed to download. They have been ignored, or old ones used instead.")); + + + // Run the success scripts if all was fine + if (RunUpdateScripts == true) + { + if(!TransientNetworkFailure && !Failed) + RunScripts("APT::Update::Post-Invoke-Success"); + + // Run the other scripts + RunScripts("APT::Update::Post-Invoke"); + } + return true; +} + /*}}}*/ diff --git a/apt-pkg/update.h b/apt-pkg/update.h new file mode 100644 index 000000000..3835644de --- /dev/null +++ b/apt-pkg/update.h @@ -0,0 +1,21 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + Update - ListUpdate releated code + + ##################################################################### */ + /*}}}*/ + +#ifndef PKGLIB_UPDATE_H +#define PKGLIB_UPDATE_H + +class pkgAcquireStatus; + + +bool ListUpdate(pkgAcquireStatus &progress, pkgSourceList &List, int PulseInterval=0); +bool AcquireUpdate(pkgAcquire &Fetcher, int const PulseInterval = 0, + bool const RunUpdateScripts = true, bool const ListCleanup = true); + + +#endif diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc index 61259748d..f6c12c26a 100644 --- a/apt-private/private-update.cc +++ b/apt-private/private-update.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3-70-g09d2 From 31f97d7b862ccf3de93b30a15f24d76e806031a3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 11 Oct 2013 19:27:23 +0200 Subject: first iteration of install progress refactor --- apt-pkg/deb/dpkgpm.cc | 111 +++++++++-------------------------------------- apt-pkg/deb/dpkgpm.h | 1 + apt-pkg/iprogress.cc | 111 +++++++++++++++++++++++++++++++++++++++++++++++ apt-pkg/iprogress.h | 59 +++++++++++++++++++++++++ apt-pkg/makefile | 4 +- apt-pkg/packagemanager.h | 1 + 6 files changed, 194 insertions(+), 93 deletions(-) create mode 100644 apt-pkg/iprogress.cc create mode 100644 apt-pkg/iprogress.h (limited to 'apt-pkg/makefile') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index b4d812d26..cd4f5c31e 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -54,16 +55,21 @@ class pkgDPkgPMPrivate public: pkgDPkgPMPrivate() : stdin_is_dev_null(false), dpkgbuf_pos(0), term_out(NULL), history_out(NULL), - last_reported_progress(0.0), nr_terminal_rows(0), - fancy_progress_output(false) + last_reported_progress(0.0) { dpkgbuf[0] = '\0'; - if(_config->FindB("Dpkg::Progress-Fancy", false) == true) - { - fancy_progress_output = true; - _config->Set("DpkgPM::Progress", true); - } + if(_config->FindB("DpkgPM::Progress-Fancy", false) == true) + progress = new APT::Progress::PackageManagerFancy(); + else if (_config->FindB("DpkgPM::Progress", false) == true) + progress = new APT::Progress::PackageManagerText(); + else + progress = new APT::Progress::PackageManager(); } + ~pkgDPkgPMPrivate() + { + delete progress; + } + bool stdin_is_dev_null; // the buffer we use for the dpkg status-fd reading char dpkgbuf[1024]; @@ -73,8 +79,7 @@ public: string dpkg_error; float last_reported_progress; - int nr_terminal_rows; - bool fancy_progress_output; + APT::Progress::PackageManager *progress; }; namespace @@ -644,8 +649,7 @@ void pkgDPkgPM::ProcessDpkgStatusLine(int OutStatusFd, char *line) << ":" << (PackagesDone/float(PackagesTotal)*100.0) << ":" << s << endl; - if(_config->FindB("DPkgPM::Progress", false) == true) - SendTerminalProgress(PackagesDone/float(PackagesTotal)*100.0); + d->progress->StatusChanged(pkg, PackagesDone, PackagesTotal); if(OutStatusFd > 0) FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size()); @@ -889,52 +893,6 @@ bool pkgDPkgPM::CloseLog() return true; } /*}}}*/ -// DPkgPM::SendTerminalProgress /*{{{*/ -// --------------------------------------------------------------------- -/* Send progress info to the terminal - */ -void pkgDPkgPM::SendTerminalProgress(float percentage) -{ - int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); - - if(percentage < (d->last_reported_progress + reporting_steps)) - return; - - std::string progress_str; - strprintf(progress_str, "Progress: [%3i%%]", (int)percentage); - if (d->fancy_progress_output) - { - int row = d->nr_terminal_rows; - - static string save_cursor = "\033[s"; - static string restore_cursor = "\033[u"; - - static string set_bg_color = "\033[42m"; // green - static string set_fg_color = "\033[30m"; // black - - static string restore_bg = "\033[49m"; - static string restore_fg = "\033[39m"; - - std::cout << save_cursor - // move cursor position to last row - << "\033[" << row << ";0f" - << set_bg_color - << set_fg_color - << progress_str - << restore_cursor - << restore_bg - << restore_fg; - } - else - { - std::cout << progress_str << "\r\n"; - } - std::flush(std::cout); - - d->last_reported_progress = percentage; -} - /*}}}*/ -/*{{{*/ // This implements a racy version of pselect for those architectures // that don't have a working implementation. // FIXME: Probably can be removed on Lenny+1 @@ -956,27 +914,6 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, } /*}}}*/ -void pkgDPkgPM::SetupTerminalScrollArea(int nr_rows) -{ - if(!d->fancy_progress_output) - return; - - // scroll down a bit to avoid visual glitch when the screen - // area shrinks by one row - std::cout << "\n"; - - // save cursor - std::cout << "\033[s"; - - // set scroll region (this will place the cursor in the top left) - std::cout << "\033[1;" << nr_rows - 1 << "r"; - - // restore cursor but ensure its inside the scrolling area - std::cout << "\033[u"; - static const char *move_cursor_up = "\033[1A"; - std::cout << move_cursor_up; - std::flush(std::cout); -} // DPkgPM::Go - Run the sequence /*{{{*/ // --------------------------------------------------------------------- @@ -1334,8 +1271,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) _error->PushToStack(); if (tcgetattr(STDOUT_FILENO, &tt) == 0) { - ioctl(1, TIOCGWINSZ, (char *)&win); - d->nr_terminal_rows = win.ws_row; + ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win); if (openpty(&master, &slave, NULL, &tt, &win) < 0) { _error->Errno("openpty", _("Can not write log (%s)"), _("Is /dev/pts mounted?")); @@ -1415,7 +1351,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0) _exit(100); } - SetupTerminalScrollArea(d->nr_terminal_rows); /* No Job Control Stop Env is a magic dpkg var that prevents it from using sigstop */ @@ -1424,6 +1359,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) cerr << "Could not exec dpkg!" << endl; _exit(100); } + d->progress->Started(); // apply ionice if (_config->FindB("DPkg::UseIoNice", false) == true) @@ -1510,14 +1446,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) signal(SIGHUP,old_SIGHUP); - // reset scroll area - SetupTerminalScrollArea(d->nr_terminal_rows + 1); - if(d->fancy_progress_output) - { - // override the progress line (sledgehammer) - static const char* clear_screen_below_cursor = "\033[J"; - std::cout << clear_screen_below_cursor; - } + // tell the progress + d->progress->Finished(); if(master >= 0) { @@ -1556,8 +1486,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) CloseLog(); // dpkg is done at this point - if(_config->FindB("DPkgPM::Progress", false) == true) - SendTerminalProgress(100); + d->progress->StatusChanged("", PackagesDone, PackagesTotal); if (pkgPackageManager::SigINTStop) _error->Warning(_("Operation was interrupted before it could finish")); diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 3b8d36623..53e352d4e 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -23,6 +23,7 @@ using std::map; class pkgDPkgPMPrivate; + class pkgDPkgPM : public pkgPackageManager { private: diff --git a/apt-pkg/iprogress.cc b/apt-pkg/iprogress.cc new file mode 100644 index 000000000..4de8c0492 --- /dev/null +++ b/apt-pkg/iprogress.cc @@ -0,0 +1,111 @@ +#include +#include + +#include +#include + +namespace APT { +namespace Progress { + +static void SetupTerminalScrollArea(int nr_rows) +{ + // scroll down a bit to avoid visual glitch when the screen + // area shrinks by one row + std::cout << "\n"; + + // save cursor + std::cout << "\033[s"; + + // set scroll region (this will place the cursor in the top left) + std::cout << "\033[1;" << nr_rows - 1 << "r"; + + // restore cursor but ensure its inside the scrolling area + std::cout << "\033[u"; + static const char *move_cursor_up = "\033[1A"; + std::cout << move_cursor_up; + std::flush(std::cout); +} + +PackageManagerFancy::PackageManagerFancy() + : nr_terminal_rows(-1) +{ + struct winsize win; + if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) == 0) + { + nr_terminal_rows = win.ws_row; + } +} + +void PackageManagerFancy::Started() +{ + SetupTerminalScrollArea(nr_terminal_rows); +} + +void PackageManagerFancy::Finished() +{ + SetupTerminalScrollArea(nr_terminal_rows + 1); + + // override the progress line (sledgehammer) + static const char* clear_screen_below_cursor = "\033[J"; + std::cout << clear_screen_below_cursor; +} + +void PackageManagerFancy::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps) +{ + int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); + float percentage = StepsDone/(float)TotalSteps * 100.0; + + if(percentage < (last_reported_progress + reporting_steps)) + return; + + std::string progress_str; + strprintf(progress_str, "Progress: [%3i%%]", (int)percentage); + + int row = nr_terminal_rows; + + static string save_cursor = "\033[s"; + static string restore_cursor = "\033[u"; + + static string set_bg_color = "\033[42m"; // green + static string set_fg_color = "\033[30m"; // black + + static string restore_bg = "\033[49m"; + static string restore_fg = "\033[39m"; + + std::cout << save_cursor + // move cursor position to last row + << "\033[" << row << ";0f" + << set_bg_color + << set_fg_color + << progress_str + << restore_cursor + << restore_bg + << restore_fg; + std::flush(std::cout); + last_reported_progress = percentage; +} + +void PackageManagerText::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps) +{ + int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); + float percentage = StepsDone/(float)TotalSteps * 100.0; + + if(percentage < (last_reported_progress + reporting_steps)) + return; + + std::string progress_str; + strprintf(progress_str, "Progress: [%3i%%]", (int)percentage); + + std::cout << progress_str << "\r\n"; + std::flush(std::cout); + + last_reported_progress = percentage; +} + + +}; // namespace progress +}; // namespace apt diff --git a/apt-pkg/iprogress.h b/apt-pkg/iprogress.h new file mode 100644 index 000000000..14fc89bff --- /dev/null +++ b/apt-pkg/iprogress.h @@ -0,0 +1,59 @@ +#ifndef PKGLIB_IPROGRESS_H +#define PKGLIB_IPROGRSS_H + + +#include + +namespace APT { +namespace Progress { + + + class PackageManager + { + private: + /** \brief dpointer placeholder */ + void *d; + + public: + virtual ~PackageManager() {}; + + virtual void Started() {}; + virtual void Finished() {}; + + virtual void StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps) {}; + }; + + class PackageManagerFancy : public PackageManager + { + protected: + int last_reported_progress; + int nr_terminal_rows; + public: + PackageManagerFancy(); + virtual void Started(); + virtual void Finished(); + virtual void StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps); + }; + + class PackageManagerText : public PackageManager + { + protected: + int last_reported_progress; + + public: + PackageManagerText() : last_reported_progress(0) {}; + virtual void StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps); + + }; + + +}; // namespace Progress +}; // namespace APT + +#endif diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 59729faf5..e69b5ce7f 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -43,7 +43,7 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \ srcrecords.cc cachefile.cc versionmatch.cc policy.cc \ pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \ indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \ - aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc + aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc iprogress.cc HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ orderlist.h sourcelist.h packagemanager.h tagfile.h \ init.h pkgcache.h version.h progress.h pkgrecords.h \ @@ -51,7 +51,7 @@ HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \ - cachefilter.h cacheset.h edsp.h + cachefilter.h cacheset.h edsp.h iprogress.h # Source code for the debian specific components # In theory the deb headers do not need to be exported.. diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 1a6a9f01c..4956e816f 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -39,6 +39,7 @@ class pkgDepCache; class pkgSourceList; class pkgOrderList; class pkgRecords; + class pkgPackageManager : protected pkgCache::Namespace { public: -- cgit v1.2.3-70-g09d2 From 1c6cedc489b5eaeed1b7fdb845eca06bc1fccd4f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 21 Oct 2013 21:23:07 +0200 Subject: move iprogress.{cc,h} to private-progress.{cc,h} until its fully stable --- apt-pkg/iprogress.cc | 221 ---------------------------------------- apt-pkg/iprogress.h | 109 -------------------- apt-pkg/makefile | 4 +- apt-private/makefile | 2 +- apt-private/private-progress.cc | 221 ++++++++++++++++++++++++++++++++++++++++ apt-private/private-progress.h | 109 ++++++++++++++++++++ 6 files changed, 333 insertions(+), 333 deletions(-) delete mode 100644 apt-pkg/iprogress.cc delete mode 100644 apt-pkg/iprogress.h create mode 100644 apt-private/private-progress.cc create mode 100644 apt-private/private-progress.h (limited to 'apt-pkg/makefile') diff --git a/apt-pkg/iprogress.cc b/apt-pkg/iprogress.cc deleted file mode 100644 index daa7695e2..000000000 --- a/apt-pkg/iprogress.cc +++ /dev/null @@ -1,221 +0,0 @@ -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -namespace APT { -namespace Progress { - -bool PackageManager::StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) -{ - int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); - percentage = StepsDone/(float)TotalSteps * 100.0; - strprintf(progress_str, _("Progress: [%3i%%]"), (int)percentage); - - if(percentage < (last_reported_progress + reporting_steps)) - return false; - - return true; -} - -PackageManagerProgressFd::PackageManagerProgressFd(int progress_fd) - : StepsDone(0), StepsTotal(1) -{ - OutStatusFd = progress_fd; -} - -void PackageManagerProgressFd::WriteToStatusFd(std::string s) -{ - if(OutStatusFd <= 0) - return; - FileFd::Write(OutStatusFd, s.c_str(), s.size()); -} - -void PackageManagerProgressFd::Start() -{ - if(OutStatusFd <= 0) - return; - - // FIXME: use SetCloseExec here once it taught about throwing - // exceptions instead of doing _exit(100) on failure - fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); - - // send status information that we are about to fork dpkg - std::ostringstream status; - status << "pmstatus:dpkg-exec:" - << (StepsDone/float(StepsTotal)*100.0) - << ":" << _("Running dpkg") - << std::endl; - WriteToStatusFd(status.str()); -} - -void PackageManagerProgressFd::Stop() -{ - // clear the Keep-Fd again - _config->Clear("APT::Keep-Fds", OutStatusFd); -} - -void PackageManagerProgressFd::Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage) -{ - std::ostringstream status; - status << "pmerror:" << PackageName - << ":" << (StepsDone/float(TotalSteps)*100.0) - << ":" << ErrorMessage - << std::endl; - WriteToStatusFd(status.str()); -} - -void PackageManagerProgressFd::ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage) -{ - std::ostringstream status; - status << "pmconffile:" << PackageName - << ":" << (StepsDone/float(TotalSteps)*100.0) - << ":" << ConfMessage - << std::endl; - WriteToStatusFd(status.str()); -} - - -bool PackageManagerProgressFd::StatusChanged(std::string PackageName, - unsigned int xStepsDone, - unsigned int xTotalSteps, - std::string pkg_action) -{ - StepsDone = xStepsDone; - StepsTotal = xTotalSteps; - - // build the status str - std::ostringstream status; - status << "pmstatus:" << StringSplit(PackageName, ":")[0] - << ":" << (StepsDone/float(StepsTotal)*100.0) - << ":" << pkg_action - << std::endl; - WriteToStatusFd(status.str()); - - if(_config->FindB("Debug::APT::Progress::PackageManagerFd", false) == true) - std::cerr << "progress: " << PackageName << " " << xStepsDone - << " " << xTotalSteps << " " << pkg_action - << std::endl; - - - return true; -} - -void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) -{ - // scroll down a bit to avoid visual glitch when the screen - // area shrinks by one row - std::cout << "\n"; - - // save cursor - std::cout << "\033[s"; - - // set scroll region (this will place the cursor in the top left) - std::cout << "\033[1;" << nr_rows - 1 << "r"; - - // restore cursor but ensure its inside the scrolling area - std::cout << "\033[u"; - static const char *move_cursor_up = "\033[1A"; - std::cout << move_cursor_up; - - std::flush(std::cout); -} - -PackageManagerFancy::PackageManagerFancy() - : nr_terminal_rows(-1) -{ - struct winsize win; - if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) == 0) - { - nr_terminal_rows = win.ws_row; - } -} - -void PackageManagerFancy::Start() -{ - if (nr_terminal_rows > 0) - SetupTerminalScrollArea(nr_terminal_rows); -} - -void PackageManagerFancy::Stop() -{ - if (nr_terminal_rows > 0) - { - SetupTerminalScrollArea(nr_terminal_rows + 1); - - // override the progress line (sledgehammer) - static const char* clear_screen_below_cursor = "\033[J"; - std::cout << clear_screen_below_cursor; - } -} - -bool PackageManagerFancy::StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) -{ - if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, - HumanReadableAction)) - return false; - - int row = nr_terminal_rows; - - static string save_cursor = "\033[s"; - static string restore_cursor = "\033[u"; - - static string set_bg_color = "\033[42m"; // green - static string set_fg_color = "\033[30m"; // black - - static string restore_bg = "\033[49m"; - static string restore_fg = "\033[39m"; - - std::cout << save_cursor - // move cursor position to last row - << "\033[" << row << ";0f" - << set_bg_color - << set_fg_color - << progress_str - << restore_cursor - << restore_bg - << restore_fg; - std::flush(std::cout); - last_reported_progress = percentage; - - return true; -} - -bool PackageManagerText::StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) -{ - if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, HumanReadableAction)) - return false; - - std::cout << progress_str << "\r\n"; - std::flush(std::cout); - - last_reported_progress = percentage; - - return true; -} - - -}; // namespace progress -}; // namespace apt diff --git a/apt-pkg/iprogress.h b/apt-pkg/iprogress.h deleted file mode 100644 index 42fa89be4..000000000 --- a/apt-pkg/iprogress.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef PKGLIB_IPROGRESS_H -#define PKGLIB_IPROGRESS_H - -#include -#include - - -namespace APT { -namespace Progress { - - class PackageManager - { - private: - /** \brief dpointer placeholder */ - void *d; - - protected: - std::string progress_str; - float percentage; - int last_reported_progress; - - public: - PackageManager() - : percentage(0.0), last_reported_progress(-1) {}; - virtual ~PackageManager() {}; - - virtual void Start() {}; - virtual void Stop() {}; - - virtual pid_t fork() {return fork(); }; - - virtual void Pulse() {}; - virtual long GetPulseInterval() { - return 500000; - }; - - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) ; - virtual void Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage) {}; - virtual void ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage) {}; - }; - - class PackageManagerProgressFd : public PackageManager - { - protected: - int OutStatusFd; - int StepsDone; - int StepsTotal; - void WriteToStatusFd(std::string msg); - - public: - PackageManagerProgressFd(int progress_fd); - - virtual void Start(); - virtual void Stop(); - - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - virtual void Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage); - virtual void ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage); - - }; - - class PackageManagerFancy : public PackageManager - { - protected: - int nr_terminal_rows; - void SetupTerminalScrollArea(int nr_rows); - - public: - PackageManagerFancy(); - virtual void Start(); - virtual void Stop(); - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - }; - - class PackageManagerText : public PackageManager - { - public: - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - }; - - -}; // namespace Progress -}; // namespace APT - -#endif diff --git a/apt-pkg/makefile b/apt-pkg/makefile index e69b5ce7f..abf701511 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -43,7 +43,7 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \ srcrecords.cc cachefile.cc versionmatch.cc policy.cc \ pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \ indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \ - aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc iprogress.cc + aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ orderlist.h sourcelist.h packagemanager.h tagfile.h \ init.h pkgcache.h version.h progress.h pkgrecords.h \ @@ -51,7 +51,7 @@ HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \ - cachefilter.h cacheset.h edsp.h iprogress.h + cachefilter.h cacheset.h edsp.h # Source code for the debian specific components # In theory the deb headers do not need to be exported.. diff --git a/apt-private/makefile b/apt-private/makefile index 1d179f0b2..9b074f189 100644 --- a/apt-private/makefile +++ b/apt-private/makefile @@ -17,7 +17,7 @@ MAJOR=0.0 MINOR=0 SLIBS=$(PTHREADLIB) -lapt-pkg -PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main +PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main progress SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc) HEADERS += $(foreach private, $(PRIVATES), private-$(private).h) diff --git a/apt-private/private-progress.cc b/apt-private/private-progress.cc new file mode 100644 index 000000000..daa7695e2 --- /dev/null +++ b/apt-private/private-progress.cc @@ -0,0 +1,221 @@ +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +namespace APT { +namespace Progress { + +bool PackageManager::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) +{ + int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); + percentage = StepsDone/(float)TotalSteps * 100.0; + strprintf(progress_str, _("Progress: [%3i%%]"), (int)percentage); + + if(percentage < (last_reported_progress + reporting_steps)) + return false; + + return true; +} + +PackageManagerProgressFd::PackageManagerProgressFd(int progress_fd) + : StepsDone(0), StepsTotal(1) +{ + OutStatusFd = progress_fd; +} + +void PackageManagerProgressFd::WriteToStatusFd(std::string s) +{ + if(OutStatusFd <= 0) + return; + FileFd::Write(OutStatusFd, s.c_str(), s.size()); +} + +void PackageManagerProgressFd::Start() +{ + if(OutStatusFd <= 0) + return; + + // FIXME: use SetCloseExec here once it taught about throwing + // exceptions instead of doing _exit(100) on failure + fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); + + // send status information that we are about to fork dpkg + std::ostringstream status; + status << "pmstatus:dpkg-exec:" + << (StepsDone/float(StepsTotal)*100.0) + << ":" << _("Running dpkg") + << std::endl; + WriteToStatusFd(status.str()); +} + +void PackageManagerProgressFd::Stop() +{ + // clear the Keep-Fd again + _config->Clear("APT::Keep-Fds", OutStatusFd); +} + +void PackageManagerProgressFd::Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage) +{ + std::ostringstream status; + status << "pmerror:" << PackageName + << ":" << (StepsDone/float(TotalSteps)*100.0) + << ":" << ErrorMessage + << std::endl; + WriteToStatusFd(status.str()); +} + +void PackageManagerProgressFd::ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage) +{ + std::ostringstream status; + status << "pmconffile:" << PackageName + << ":" << (StepsDone/float(TotalSteps)*100.0) + << ":" << ConfMessage + << std::endl; + WriteToStatusFd(status.str()); +} + + +bool PackageManagerProgressFd::StatusChanged(std::string PackageName, + unsigned int xStepsDone, + unsigned int xTotalSteps, + std::string pkg_action) +{ + StepsDone = xStepsDone; + StepsTotal = xTotalSteps; + + // build the status str + std::ostringstream status; + status << "pmstatus:" << StringSplit(PackageName, ":")[0] + << ":" << (StepsDone/float(StepsTotal)*100.0) + << ":" << pkg_action + << std::endl; + WriteToStatusFd(status.str()); + + if(_config->FindB("Debug::APT::Progress::PackageManagerFd", false) == true) + std::cerr << "progress: " << PackageName << " " << xStepsDone + << " " << xTotalSteps << " " << pkg_action + << std::endl; + + + return true; +} + +void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) +{ + // scroll down a bit to avoid visual glitch when the screen + // area shrinks by one row + std::cout << "\n"; + + // save cursor + std::cout << "\033[s"; + + // set scroll region (this will place the cursor in the top left) + std::cout << "\033[1;" << nr_rows - 1 << "r"; + + // restore cursor but ensure its inside the scrolling area + std::cout << "\033[u"; + static const char *move_cursor_up = "\033[1A"; + std::cout << move_cursor_up; + + std::flush(std::cout); +} + +PackageManagerFancy::PackageManagerFancy() + : nr_terminal_rows(-1) +{ + struct winsize win; + if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) == 0) + { + nr_terminal_rows = win.ws_row; + } +} + +void PackageManagerFancy::Start() +{ + if (nr_terminal_rows > 0) + SetupTerminalScrollArea(nr_terminal_rows); +} + +void PackageManagerFancy::Stop() +{ + if (nr_terminal_rows > 0) + { + SetupTerminalScrollArea(nr_terminal_rows + 1); + + // override the progress line (sledgehammer) + static const char* clear_screen_below_cursor = "\033[J"; + std::cout << clear_screen_below_cursor; + } +} + +bool PackageManagerFancy::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) +{ + if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, + HumanReadableAction)) + return false; + + int row = nr_terminal_rows; + + static string save_cursor = "\033[s"; + static string restore_cursor = "\033[u"; + + static string set_bg_color = "\033[42m"; // green + static string set_fg_color = "\033[30m"; // black + + static string restore_bg = "\033[49m"; + static string restore_fg = "\033[39m"; + + std::cout << save_cursor + // move cursor position to last row + << "\033[" << row << ";0f" + << set_bg_color + << set_fg_color + << progress_str + << restore_cursor + << restore_bg + << restore_fg; + std::flush(std::cout); + last_reported_progress = percentage; + + return true; +} + +bool PackageManagerText::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) +{ + if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, HumanReadableAction)) + return false; + + std::cout << progress_str << "\r\n"; + std::flush(std::cout); + + last_reported_progress = percentage; + + return true; +} + + +}; // namespace progress +}; // namespace apt diff --git a/apt-private/private-progress.h b/apt-private/private-progress.h new file mode 100644 index 000000000..42fa89be4 --- /dev/null +++ b/apt-private/private-progress.h @@ -0,0 +1,109 @@ +#ifndef PKGLIB_IPROGRESS_H +#define PKGLIB_IPROGRESS_H + +#include +#include + + +namespace APT { +namespace Progress { + + class PackageManager + { + private: + /** \brief dpointer placeholder */ + void *d; + + protected: + std::string progress_str; + float percentage; + int last_reported_progress; + + public: + PackageManager() + : percentage(0.0), last_reported_progress(-1) {}; + virtual ~PackageManager() {}; + + virtual void Start() {}; + virtual void Stop() {}; + + virtual pid_t fork() {return fork(); }; + + virtual void Pulse() {}; + virtual long GetPulseInterval() { + return 500000; + }; + + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) ; + virtual void Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage) {}; + virtual void ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage) {}; + }; + + class PackageManagerProgressFd : public PackageManager + { + protected: + int OutStatusFd; + int StepsDone; + int StepsTotal; + void WriteToStatusFd(std::string msg); + + public: + PackageManagerProgressFd(int progress_fd); + + virtual void Start(); + virtual void Stop(); + + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + virtual void Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage); + virtual void ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage); + + }; + + class PackageManagerFancy : public PackageManager + { + protected: + int nr_terminal_rows; + void SetupTerminalScrollArea(int nr_rows); + + public: + PackageManagerFancy(); + virtual void Start(); + virtual void Stop(); + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + }; + + class PackageManagerText : public PackageManager + { + public: + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + }; + + +}; // namespace Progress +}; // namespace APT + +#endif -- cgit v1.2.3-70-g09d2 From 8336ae355b8a22877cd233063c715688155aa617 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 22 Oct 2013 18:44:14 +0200 Subject: move install-progress.{cc,h} to apt-pkg --- apt-pkg/install-progress.cc | 306 ++++++++++++++++++++++++++++++++++++++++ apt-pkg/install-progress.h | 137 ++++++++++++++++++ apt-pkg/makefile | 5 +- apt-private/makefile | 2 +- apt-private/private-progress.cc | 306 ---------------------------------------- apt-private/private-progress.h | 137 ------------------ 6 files changed, 447 insertions(+), 446 deletions(-) create mode 100644 apt-pkg/install-progress.cc create mode 100644 apt-pkg/install-progress.h delete mode 100644 apt-private/private-progress.cc delete mode 100644 apt-private/private-progress.h (limited to 'apt-pkg/makefile') diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc new file mode 100644 index 000000000..1d15228c2 --- /dev/null +++ b/apt-pkg/install-progress.cc @@ -0,0 +1,306 @@ +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +namespace APT { +namespace Progress { + +bool PackageManager::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) +{ + int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); + percentage = StepsDone/(float)TotalSteps * 100.0; + strprintf(progress_str, _("Progress: [%3i%%]"), (int)percentage); + + if(percentage < (last_reported_progress + reporting_steps)) + return false; + + return true; +} + +PackageManagerProgressFd::PackageManagerProgressFd(int progress_fd) + : StepsDone(0), StepsTotal(1) +{ + OutStatusFd = progress_fd; +} + +void PackageManagerProgressFd::WriteToStatusFd(std::string s) +{ + if(OutStatusFd <= 0) + return; + FileFd::Write(OutStatusFd, s.c_str(), s.size()); +} + +void PackageManagerProgressFd::Start() +{ + if(OutStatusFd <= 0) + return; + + // FIXME: use SetCloseExec here once it taught about throwing + // exceptions instead of doing _exit(100) on failure + fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); + + // send status information that we are about to fork dpkg + std::ostringstream status; + status << "pmstatus:dpkg-exec:" + << (StepsDone/float(StepsTotal)*100.0) + << ":" << _("Running dpkg") + << std::endl; + WriteToStatusFd(status.str()); +} + +void PackageManagerProgressFd::Stop() +{ + // clear the Keep-Fd again + _config->Clear("APT::Keep-Fds", OutStatusFd); +} + +void PackageManagerProgressFd::Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage) +{ + std::ostringstream status; + status << "pmerror:" << PackageName + << ":" << (StepsDone/float(TotalSteps)*100.0) + << ":" << ErrorMessage + << std::endl; + WriteToStatusFd(status.str()); +} + +void PackageManagerProgressFd::ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage) +{ + std::ostringstream status; + status << "pmconffile:" << PackageName + << ":" << (StepsDone/float(TotalSteps)*100.0) + << ":" << ConfMessage + << std::endl; + WriteToStatusFd(status.str()); +} + + +bool PackageManagerProgressFd::StatusChanged(std::string PackageName, + unsigned int xStepsDone, + unsigned int xTotalSteps, + std::string pkg_action) +{ + StepsDone = xStepsDone; + StepsTotal = xTotalSteps; + + // build the status str + std::ostringstream status; + status << "pmstatus:" << StringSplit(PackageName, ":")[0] + << ":" << (StepsDone/float(StepsTotal)*100.0) + << ":" << pkg_action + << std::endl; + WriteToStatusFd(status.str()); + + if(_config->FindB("Debug::APT::Progress::PackageManagerFd", false) == true) + std::cerr << "progress: " << PackageName << " " << xStepsDone + << " " << xTotalSteps << " " << pkg_action + << std::endl; + + + return true; +} + + +PackageManagerProgressDeb822Fd::PackageManagerProgressDeb822Fd(int progress_fd) + : StepsDone(0), StepsTotal(1) +{ + OutStatusFd = progress_fd; +} + +void PackageManagerProgressDeb822Fd::WriteToStatusFd(std::string s) +{ + FileFd::Write(OutStatusFd, s.c_str(), s.size()); +} + +void PackageManagerProgressDeb822Fd::Start() +{ + // FIXME: use SetCloseExec here once it taught about throwing + // exceptions instead of doing _exit(100) on failure + fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); + + // send status information that we are about to fork dpkg + std::ostringstream status; + status << "Status: " << "progress" << std::endl + << "Percent: " << (StepsDone/float(StepsTotal)*100.0) << std::endl + << "Message: " << _("Running dpkg") << std::endl + << std::endl; + WriteToStatusFd(status.str()); +} + +void PackageManagerProgressDeb822Fd::Stop() +{ + // clear the Keep-Fd again + _config->Clear("APT::Keep-Fds", OutStatusFd); +} + +void PackageManagerProgressDeb822Fd::Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage) +{ + std::ostringstream status; + status << "Status: " << "Error" << std::endl + << "Package:" << PackageName << std::endl + << "Percent: " << (StepsDone/float(TotalSteps)*100.0) << std::endl + << "Message: " << ErrorMessage << std::endl + << std::endl; + WriteToStatusFd(status.str()); +} + +void PackageManagerProgressDeb822Fd::ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage) +{ + std::ostringstream status; + status << "Status: " << "ConfFile" << std::endl + << "Package:" << PackageName << std::endl + << "Percent: " << (StepsDone/float(TotalSteps)*100.0) << std::endl + << "Message: " << ConfMessage << std::endl + << std::endl; + WriteToStatusFd(status.str()); +} + + +bool PackageManagerProgressDeb822Fd::StatusChanged(std::string PackageName, + unsigned int xStepsDone, + unsigned int xTotalSteps, + std::string message) +{ + StepsDone = xStepsDone; + StepsTotal = xTotalSteps; + + // build the status str + std::ostringstream status; + status << "Status: " << "progress" << std::endl + << "Package: " << PackageName << std::endl + << "Percent: " << (StepsDone/float(StepsTotal)*100.0) << std::endl + << "Message: " << message << std::endl + << std::endl; + WriteToStatusFd(status.str()); + + return true; +} + + +void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) +{ + // scroll down a bit to avoid visual glitch when the screen + // area shrinks by one row + std::cout << "\n"; + + // save cursor + std::cout << "\033[s"; + + // set scroll region (this will place the cursor in the top left) + std::cout << "\033[1;" << nr_rows - 1 << "r"; + + // restore cursor but ensure its inside the scrolling area + std::cout << "\033[u"; + static const char *move_cursor_up = "\033[1A"; + std::cout << move_cursor_up; + + std::flush(std::cout); +} + +PackageManagerFancy::PackageManagerFancy() + : nr_terminal_rows(-1) +{ + struct winsize win; + if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) == 0) + { + nr_terminal_rows = win.ws_row; + } +} + +void PackageManagerFancy::Start() +{ + if (nr_terminal_rows > 0) + SetupTerminalScrollArea(nr_terminal_rows); +} + +void PackageManagerFancy::Stop() +{ + if (nr_terminal_rows > 0) + { + SetupTerminalScrollArea(nr_terminal_rows + 1); + + // override the progress line (sledgehammer) + static const char* clear_screen_below_cursor = "\033[J"; + std::cout << clear_screen_below_cursor; + } +} + +bool PackageManagerFancy::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) +{ + if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, + HumanReadableAction)) + return false; + + int row = nr_terminal_rows; + + static string save_cursor = "\033[s"; + static string restore_cursor = "\033[u"; + + static string set_bg_color = "\033[42m"; // green + static string set_fg_color = "\033[30m"; // black + + static string restore_bg = "\033[49m"; + static string restore_fg = "\033[39m"; + + std::cout << save_cursor + // move cursor position to last row + << "\033[" << row << ";0f" + << set_bg_color + << set_fg_color + << progress_str + << restore_cursor + << restore_bg + << restore_fg; + std::flush(std::cout); + last_reported_progress = percentage; + + return true; +} + +bool PackageManagerText::StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) +{ + if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, HumanReadableAction)) + return false; + + std::cout << progress_str << "\r\n"; + std::flush(std::cout); + + last_reported_progress = percentage; + + return true; +} + + + +}; // namespace progress +}; // namespace apt diff --git a/apt-pkg/install-progress.h b/apt-pkg/install-progress.h new file mode 100644 index 000000000..9c31eac92 --- /dev/null +++ b/apt-pkg/install-progress.h @@ -0,0 +1,137 @@ +#ifndef PKGLIB_IPROGRESS_H +#define PKGLIB_IPROGRESS_H + +#include +#include + + +namespace APT { +namespace Progress { + + class PackageManager + { + private: + /** \brief dpointer placeholder */ + void *d; + + protected: + std::string progress_str; + float percentage; + int last_reported_progress; + + public: + PackageManager() + : percentage(0.0), last_reported_progress(-1) {}; + virtual ~PackageManager() {}; + + virtual void Start() {}; + virtual void Stop() {}; + + virtual pid_t fork() {return fork(); }; + + virtual void Pulse() {}; + virtual long GetPulseInterval() { + return 500000; + }; + + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction) ; + virtual void Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage) {}; + virtual void ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage) {}; + }; + + class PackageManagerProgressFd : public PackageManager + { + protected: + int OutStatusFd; + int StepsDone; + int StepsTotal; + void WriteToStatusFd(std::string msg); + + public: + PackageManagerProgressFd(int progress_fd); + + virtual void Start(); + virtual void Stop(); + + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + virtual void Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage); + virtual void ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage); + + }; + + class PackageManagerProgressDeb822Fd : public PackageManager + { + protected: + int OutStatusFd; + int StepsDone; + int StepsTotal; + void WriteToStatusFd(std::string msg); + + public: + PackageManagerProgressDeb822Fd(int progress_fd); + + virtual void Start(); + virtual void Stop(); + + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + virtual void Error(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ErrorMessage); + virtual void ConffilePrompt(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string ConfMessage); + }; + + class PackageManagerFancy : public PackageManager + { + protected: + int nr_terminal_rows; + void SetupTerminalScrollArea(int nr_rows); + + public: + PackageManagerFancy(); + virtual void Start(); + virtual void Stop(); + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + }; + + class PackageManagerText : public PackageManager + { + public: + virtual bool StatusChanged(std::string PackageName, + unsigned int StepsDone, + unsigned int TotalSteps, + std::string HumanReadableAction); + }; + + +}; // namespace Progress +}; // namespace APT + +#endif diff --git a/apt-pkg/makefile b/apt-pkg/makefile index abf701511..503bd7839 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -43,7 +43,8 @@ SOURCE+= pkgcache.cc version.cc depcache.cc \ srcrecords.cc cachefile.cc versionmatch.cc policy.cc \ pkgsystem.cc indexfile.cc pkgcachegen.cc acquire-item.cc \ indexrecords.cc vendor.cc vendorlist.cc cdrom.cc indexcopy.cc \ - aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc + aptconfiguration.cc cachefilter.cc cacheset.cc edsp.cc \ + install-progress.cc HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ orderlist.h sourcelist.h packagemanager.h tagfile.h \ init.h pkgcache.h version.h progress.h pkgrecords.h \ @@ -51,7 +52,7 @@ HEADERS+= algorithms.h depcache.h pkgcachegen.h cacheiterators.h \ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ vendorlist.h cdrom.h indexcopy.h aptconfiguration.h \ - cachefilter.h cacheset.h edsp.h + cachefilter.h cacheset.h edsp.h install-progress.h # Source code for the debian specific components # In theory the deb headers do not need to be exported.. diff --git a/apt-private/makefile b/apt-private/makefile index 9b074f189..1d179f0b2 100644 --- a/apt-private/makefile +++ b/apt-private/makefile @@ -17,7 +17,7 @@ MAJOR=0.0 MINOR=0 SLIBS=$(PTHREADLIB) -lapt-pkg -PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main progress +PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc) HEADERS += $(foreach private, $(PRIVATES), private-$(private).h) diff --git a/apt-private/private-progress.cc b/apt-private/private-progress.cc deleted file mode 100644 index 1d15228c2..000000000 --- a/apt-private/private-progress.cc +++ /dev/null @@ -1,306 +0,0 @@ -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -namespace APT { -namespace Progress { - -bool PackageManager::StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) -{ - int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1); - percentage = StepsDone/(float)TotalSteps * 100.0; - strprintf(progress_str, _("Progress: [%3i%%]"), (int)percentage); - - if(percentage < (last_reported_progress + reporting_steps)) - return false; - - return true; -} - -PackageManagerProgressFd::PackageManagerProgressFd(int progress_fd) - : StepsDone(0), StepsTotal(1) -{ - OutStatusFd = progress_fd; -} - -void PackageManagerProgressFd::WriteToStatusFd(std::string s) -{ - if(OutStatusFd <= 0) - return; - FileFd::Write(OutStatusFd, s.c_str(), s.size()); -} - -void PackageManagerProgressFd::Start() -{ - if(OutStatusFd <= 0) - return; - - // FIXME: use SetCloseExec here once it taught about throwing - // exceptions instead of doing _exit(100) on failure - fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); - - // send status information that we are about to fork dpkg - std::ostringstream status; - status << "pmstatus:dpkg-exec:" - << (StepsDone/float(StepsTotal)*100.0) - << ":" << _("Running dpkg") - << std::endl; - WriteToStatusFd(status.str()); -} - -void PackageManagerProgressFd::Stop() -{ - // clear the Keep-Fd again - _config->Clear("APT::Keep-Fds", OutStatusFd); -} - -void PackageManagerProgressFd::Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage) -{ - std::ostringstream status; - status << "pmerror:" << PackageName - << ":" << (StepsDone/float(TotalSteps)*100.0) - << ":" << ErrorMessage - << std::endl; - WriteToStatusFd(status.str()); -} - -void PackageManagerProgressFd::ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage) -{ - std::ostringstream status; - status << "pmconffile:" << PackageName - << ":" << (StepsDone/float(TotalSteps)*100.0) - << ":" << ConfMessage - << std::endl; - WriteToStatusFd(status.str()); -} - - -bool PackageManagerProgressFd::StatusChanged(std::string PackageName, - unsigned int xStepsDone, - unsigned int xTotalSteps, - std::string pkg_action) -{ - StepsDone = xStepsDone; - StepsTotal = xTotalSteps; - - // build the status str - std::ostringstream status; - status << "pmstatus:" << StringSplit(PackageName, ":")[0] - << ":" << (StepsDone/float(StepsTotal)*100.0) - << ":" << pkg_action - << std::endl; - WriteToStatusFd(status.str()); - - if(_config->FindB("Debug::APT::Progress::PackageManagerFd", false) == true) - std::cerr << "progress: " << PackageName << " " << xStepsDone - << " " << xTotalSteps << " " << pkg_action - << std::endl; - - - return true; -} - - -PackageManagerProgressDeb822Fd::PackageManagerProgressDeb822Fd(int progress_fd) - : StepsDone(0), StepsTotal(1) -{ - OutStatusFd = progress_fd; -} - -void PackageManagerProgressDeb822Fd::WriteToStatusFd(std::string s) -{ - FileFd::Write(OutStatusFd, s.c_str(), s.size()); -} - -void PackageManagerProgressDeb822Fd::Start() -{ - // FIXME: use SetCloseExec here once it taught about throwing - // exceptions instead of doing _exit(100) on failure - fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); - - // send status information that we are about to fork dpkg - std::ostringstream status; - status << "Status: " << "progress" << std::endl - << "Percent: " << (StepsDone/float(StepsTotal)*100.0) << std::endl - << "Message: " << _("Running dpkg") << std::endl - << std::endl; - WriteToStatusFd(status.str()); -} - -void PackageManagerProgressDeb822Fd::Stop() -{ - // clear the Keep-Fd again - _config->Clear("APT::Keep-Fds", OutStatusFd); -} - -void PackageManagerProgressDeb822Fd::Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage) -{ - std::ostringstream status; - status << "Status: " << "Error" << std::endl - << "Package:" << PackageName << std::endl - << "Percent: " << (StepsDone/float(TotalSteps)*100.0) << std::endl - << "Message: " << ErrorMessage << std::endl - << std::endl; - WriteToStatusFd(status.str()); -} - -void PackageManagerProgressDeb822Fd::ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage) -{ - std::ostringstream status; - status << "Status: " << "ConfFile" << std::endl - << "Package:" << PackageName << std::endl - << "Percent: " << (StepsDone/float(TotalSteps)*100.0) << std::endl - << "Message: " << ConfMessage << std::endl - << std::endl; - WriteToStatusFd(status.str()); -} - - -bool PackageManagerProgressDeb822Fd::StatusChanged(std::string PackageName, - unsigned int xStepsDone, - unsigned int xTotalSteps, - std::string message) -{ - StepsDone = xStepsDone; - StepsTotal = xTotalSteps; - - // build the status str - std::ostringstream status; - status << "Status: " << "progress" << std::endl - << "Package: " << PackageName << std::endl - << "Percent: " << (StepsDone/float(StepsTotal)*100.0) << std::endl - << "Message: " << message << std::endl - << std::endl; - WriteToStatusFd(status.str()); - - return true; -} - - -void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows) -{ - // scroll down a bit to avoid visual glitch when the screen - // area shrinks by one row - std::cout << "\n"; - - // save cursor - std::cout << "\033[s"; - - // set scroll region (this will place the cursor in the top left) - std::cout << "\033[1;" << nr_rows - 1 << "r"; - - // restore cursor but ensure its inside the scrolling area - std::cout << "\033[u"; - static const char *move_cursor_up = "\033[1A"; - std::cout << move_cursor_up; - - std::flush(std::cout); -} - -PackageManagerFancy::PackageManagerFancy() - : nr_terminal_rows(-1) -{ - struct winsize win; - if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) == 0) - { - nr_terminal_rows = win.ws_row; - } -} - -void PackageManagerFancy::Start() -{ - if (nr_terminal_rows > 0) - SetupTerminalScrollArea(nr_terminal_rows); -} - -void PackageManagerFancy::Stop() -{ - if (nr_terminal_rows > 0) - { - SetupTerminalScrollArea(nr_terminal_rows + 1); - - // override the progress line (sledgehammer) - static const char* clear_screen_below_cursor = "\033[J"; - std::cout << clear_screen_below_cursor; - } -} - -bool PackageManagerFancy::StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) -{ - if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, - HumanReadableAction)) - return false; - - int row = nr_terminal_rows; - - static string save_cursor = "\033[s"; - static string restore_cursor = "\033[u"; - - static string set_bg_color = "\033[42m"; // green - static string set_fg_color = "\033[30m"; // black - - static string restore_bg = "\033[49m"; - static string restore_fg = "\033[39m"; - - std::cout << save_cursor - // move cursor position to last row - << "\033[" << row << ";0f" - << set_bg_color - << set_fg_color - << progress_str - << restore_cursor - << restore_bg - << restore_fg; - std::flush(std::cout); - last_reported_progress = percentage; - - return true; -} - -bool PackageManagerText::StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) -{ - if (!PackageManager::StatusChanged(PackageName, StepsDone, TotalSteps, HumanReadableAction)) - return false; - - std::cout << progress_str << "\r\n"; - std::flush(std::cout); - - last_reported_progress = percentage; - - return true; -} - - - -}; // namespace progress -}; // namespace apt diff --git a/apt-private/private-progress.h b/apt-private/private-progress.h deleted file mode 100644 index 9c31eac92..000000000 --- a/apt-private/private-progress.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef PKGLIB_IPROGRESS_H -#define PKGLIB_IPROGRESS_H - -#include -#include - - -namespace APT { -namespace Progress { - - class PackageManager - { - private: - /** \brief dpointer placeholder */ - void *d; - - protected: - std::string progress_str; - float percentage; - int last_reported_progress; - - public: - PackageManager() - : percentage(0.0), last_reported_progress(-1) {}; - virtual ~PackageManager() {}; - - virtual void Start() {}; - virtual void Stop() {}; - - virtual pid_t fork() {return fork(); }; - - virtual void Pulse() {}; - virtual long GetPulseInterval() { - return 500000; - }; - - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction) ; - virtual void Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage) {}; - virtual void ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage) {}; - }; - - class PackageManagerProgressFd : public PackageManager - { - protected: - int OutStatusFd; - int StepsDone; - int StepsTotal; - void WriteToStatusFd(std::string msg); - - public: - PackageManagerProgressFd(int progress_fd); - - virtual void Start(); - virtual void Stop(); - - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - virtual void Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage); - virtual void ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage); - - }; - - class PackageManagerProgressDeb822Fd : public PackageManager - { - protected: - int OutStatusFd; - int StepsDone; - int StepsTotal; - void WriteToStatusFd(std::string msg); - - public: - PackageManagerProgressDeb822Fd(int progress_fd); - - virtual void Start(); - virtual void Stop(); - - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - virtual void Error(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ErrorMessage); - virtual void ConffilePrompt(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string ConfMessage); - }; - - class PackageManagerFancy : public PackageManager - { - protected: - int nr_terminal_rows; - void SetupTerminalScrollArea(int nr_rows); - - public: - PackageManagerFancy(); - virtual void Start(); - virtual void Stop(); - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - }; - - class PackageManagerText : public PackageManager - { - public: - virtual bool StatusChanged(std::string PackageName, - unsigned int StepsDone, - unsigned int TotalSteps, - std::string HumanReadableAction); - }; - - -}; // namespace Progress -}; // namespace APT - -#endif -- cgit v1.2.3-70-g09d2