~ubuntu-branches/ubuntu/vivid/apt/vivid-updates

« back to all changes in this revision

Viewing changes to apt-pkg/install-progress.cc

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Michael Vogt, David Kalnischkies, Trần Ngọc Quân, Theppitak Karoonboonyanan, James McCoy
  • Date: 2014-04-25 13:15:03 UTC
  • mto: (223.1.1 utopic-proposed)
  • mto: This revision was merged to the branch mainline in revision 224.
  • Revision ID: package-import@ubuntu.com-20140425131503-t4z0jwou5u64wt6s
Tags: 1.0.2
[ Michael Vogt ]
* fix apt list output for pkgs in dpkg ^rc state
* Notice the user about "apt list -a" when only a single hit if found
* fix test-failure in adt
* apt-private/acqprogress.cc: fix output when ctrl-c is hit during 
  apt update (LP: #1310548, closes: #744297)
* Fix option name DPkg::Progress-Fancy in apt.8 manpage
  (LP: #1310506)

[ David Kalnischkies ]
* don't double-count seeks in FileFd::Skip for bzip/xz
* deal with umask only if we really need to for mkstemp
* consider priorities only for downloadable pkgs in resolver
* force fancy progressbar redraw on window size change
* clear HitEof flag in FileFd::Seek
* use Google C++ Testing Framework for libapt tests
* support dist-upgrade options in full-upgrade

[ Trần Ngọc Quân ]
* l10n: vi.po (624t): Update translation

[ Theppitak Karoonboonyanan ]
* Updated Thai program translation (closes: #745120)

[ James McCoy ]
* Consistently use Dpkg::Progress* in documentation (Closes: 745452)

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
PackageManagerFancy::GetTerminalSize()
257
257
{
258
258
   struct winsize win;
259
 
   PackageManagerFancy::TermSize s;
 
259
   PackageManagerFancy::TermSize s = { 0, 0 };
260
260
 
261
261
   // FIXME: get from "child_pty" instead?
262
262
   if(ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&win) != 0)
263
263
      return s;
264
264
 
265
265
   if(_config->FindB("Debug::InstallProgress::Fancy", false) == true)
266
 
      std::cerr << "GetTerminalSize: " << win.ws_row << std::endl;
 
266
      std::cerr << "GetTerminalSize: " << win.ws_row << " x " << win.ws_col << std::endl;
267
267
 
268
268
   s.rows = win.ws_row;
269
269
   s.columns = win.ws_col;
275
275
     if(_config->FindB("Debug::InstallProgress::Fancy", false) == true)
276
276
        std::cerr << "SetupTerminalScrollArea: " << nr_rows << std::endl;
277
277
 
 
278
     if (unlikely(nr_rows <= 1))
 
279
        return;
 
280
 
278
281
     // scroll down a bit to avoid visual glitch when the screen
279
282
     // area shrinks by one row
280
283
     std::cout << "\n";
296
299
     // setup tty size to ensure xterm/linux console are working properly too
297
300
     // see bug #731738
298
301
     struct winsize win;
299
 
     ioctl(child_pty, TIOCGWINSZ, (char *)&win);
300
 
     win.ws_row = nr_rows - 1;
301
 
     ioctl(child_pty, TIOCSWINSZ, (char *)&win);
 
302
     if (ioctl(child_pty, TIOCGWINSZ, (char *)&win) != -1)
 
303
     {
 
304
        win.ws_row = nr_rows - 1;
 
305
        ioctl(child_pty, TIOCSWINSZ, (char *)&win);
 
306
     }
302
307
}
303
308
 
304
309
void PackageManagerFancy::HandleSIGWINCH(int)
305
310
{
306
 
   int nr_terminal_rows = GetTerminalSize().rows;
 
311
   int const nr_terminal_rows = GetTerminalSize().rows;
307
312
   SetupTerminalScrollArea(nr_terminal_rows);
 
313
   DrawStatusLine();
308
314
}
309
315
 
310
316
void PackageManagerFancy::Start(int a_child_pty)
311
317
{
312
318
   child_pty = a_child_pty;
313
 
   int nr_terminal_rows = GetTerminalSize().rows;
314
 
   if (nr_terminal_rows > 0)
315
 
      SetupTerminalScrollArea(nr_terminal_rows);
 
319
   int const nr_terminal_rows = GetTerminalSize().rows;
 
320
   SetupTerminalScrollArea(nr_terminal_rows);
316
321
}
317
322
 
318
323
void PackageManagerFancy::Stop()
319
324
{
320
 
   int nr_terminal_rows = GetTerminalSize().rows;
 
325
   int const nr_terminal_rows = GetTerminalSize().rows;
321
326
   if (nr_terminal_rows > 0)
322
327
   {
323
328
      SetupTerminalScrollArea(nr_terminal_rows + 1);
358
363
          HumanReadableAction))
359
364
      return false;
360
365
 
361
 
   PackageManagerFancy::TermSize size = GetTerminalSize();
 
366
   return DrawStatusLine();
 
367
}
 
368
bool PackageManagerFancy::DrawStatusLine()
 
369
{
 
370
   PackageManagerFancy::TermSize const size = GetTerminalSize();
 
371
   if (unlikely(size.rows < 1 || size.columns < 1))
 
372
      return false;
362
373
 
363
374
   static std::string save_cursor = "\033[s";
364
375
   static std::string restore_cursor = "\033[u";
388
399
   {
389
400
      int padding = 4;
390
401
      float progressbar_size = size.columns - padding - progress_str.size();
391
 
      float current_percent = (float)StepsDone/(float)TotalSteps;
 
402
      float current_percent = percentage / 100.0;
392
403
      std::cout << " " 
393
404
                << GetTextProgressStr(current_percent, progressbar_size)
394
405
                << " ";