~ubuntu-branches/ubuntu/vivid/aptitude/vivid

« back to all changes in this revision

Viewing changes to .pc/09_ubuntu_fortify_source/src/cmdline/cmdline_changelog.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-06-22 12:32:56 UTC
  • mfrom: (1.8.6 sid)
  • Revision ID: james.westby@ubuntu.com-20110622123256-8aox9w9ch3x72dci
Tags: 0.6.4-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/05aptitude: never autoremove kernels
  - drop aptitude-doc to Suggests
  - 03_branding.dpatch: ubuntu branding
  - 04_changelog.dpatch: take changelogs from changelogs.ubuntu.com
  - 09_ubuntu_fortify_source.dpatch: Suppress a number of warnings (turned
    into errors by -Werror) triggered by Ubuntu's default of
    -D_FORTIFY_SOURCE=2.
  - 11_ubuntu_uses_sudo.dpatch: fix status line of 'Become root' menu entry
    to not refer to su.
  - 12_point_manpage_to_doc_package.dpatch: point Finnish manpage to the
    correct place for further info
  - 14_html2text_preferred.dpatch: switch back to html2text in favor of
    elinks, since html2text is in main and elinks isn't.
* dropped 01_intltool_update.dpatch
* updated 15_ftbfs_new_apt

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
using namespace std;
55
55
 
56
56
using aptitude::cmdline::create_terminal;
57
 
using aptitude::cmdline::terminal;
 
57
using aptitude::cmdline::terminal_io;
 
58
using aptitude::cmdline::terminal_metrics;
58
59
using boost::shared_ptr;
59
60
 
60
61
namespace
74
75
  {
75
76
    std::string description;
76
77
    bool quiet;
77
 
    shared_ptr<terminal> term;
 
78
    shared_ptr<terminal_metrics> term_metrics;
78
79
 
79
80
  public:
80
81
    single_download_progress(const std::string &_description,
81
82
                             bool _quiet,
82
 
                             const shared_ptr<terminal> &_term)
 
83
                             const shared_ptr<terminal_metrics> &_term_metrics)
83
84
      : description(_description),
84
85
        quiet(_quiet),
85
 
        term(_term)
 
86
        term_metrics(_term_metrics)
86
87
    {
87
88
    }
88
89
 
95
96
      if (quiet)
96
97
        return;
97
98
 
98
 
      const int screen_width = term->get_screen_width();
 
99
      const int screen_width = term_metrics->get_screen_width();
99
100
 
100
101
      unsigned long TotalBytes = totalSize;
101
102
      unsigned long CurrentBytes = currentSize;
129
130
    {
130
131
      if(!quiet)
131
132
        std::cout << "\r"
132
 
                  << std::string(term->get_screen_width(), ' ')
 
133
                  << std::string(term_metrics->get_screen_width(), ' ')
133
134
                  << "\r";
134
135
 
135
136
      std::cout << _("Get:") << " " << description << std::endl;
139
140
    {
140
141
      if(!quiet)
141
142
        std::cout << "\r"
142
 
                  << std::string(term->get_screen_width(), ' ')
 
143
                  << std::string(term_metrics->get_screen_width(), ' ')
143
144
                  << "\r";
144
145
 
145
146
      std::cout << _("Err ") << description << std::endl;
154
155
  public:
155
156
    changelog_download_callbacks(temp::name &_out_changelog_file,
156
157
                                 const std::string &short_description,
157
 
                                 const shared_ptr<terminal> &term)
 
158
                                 const shared_ptr<terminal_metrics> &term_metrics)
158
159
      : single_download_progress(short_description,
159
160
                                 aptcfg->FindI("Quiet", 0) > 0,
160
 
                                 term),
 
161
                                 term_metrics),
161
162
        out_changelog_file(_out_changelog_file)
162
163
    {
163
164
    }
185
186
 
186
187
  void get_changelog(const pkgCache::VerIterator &ver,
187
188
                     temp::name &out_changelog_file,
188
 
                     const shared_ptr<terminal> &term)
 
189
                     const shared_ptr<terminal_metrics> &term_metrics)
189
190
  {
190
191
    const std::string short_description =
191
192
      (boost::format("Changelog of %s") % ver.ParentPkg().Name()).str();
193
194
    boost::shared_ptr<changelog_download_callbacks>
194
195
      callbacks = boost::make_shared<changelog_download_callbacks>(boost::ref(out_changelog_file),
195
196
                                                                   short_description,
196
 
                                                                   term);
 
197
                                                                   term_metrics);
197
198
 
198
199
    get_changelog(aptitude::apt::changelog_info::create(ver),
199
200
                  callbacks,
219
220
                                 const std::string &section,
220
221
                                 const std::string &name,
221
222
                                 temp::name &out_changelog_file,
222
 
                                 const shared_ptr<terminal> &term)
 
223
                                 const shared_ptr<terminal_metrics> &term_metrics)
223
224
  {
224
225
    const std::string short_description =
225
226
      (boost::format("Changelog of %s") % name).str();
227
228
    boost::shared_ptr<changelog_download_callbacks>
228
229
      callbacks = boost::make_shared<changelog_download_callbacks>(boost::ref(out_changelog_file),
229
230
                                                                   short_description,
230
 
                                                                   term);
 
231
                                                                   term_metrics);
231
232
 
232
233
    boost::shared_ptr<aptitude::apt::changelog_info>
233
234
      info = aptitude::apt::changelog_info::create(srcpkg, ver, section, name);
246
247
 */
247
248
temp::name changelog_by_version(const std::string &pkg,
248
249
                                const std::string &ver,
249
 
                                const shared_ptr<terminal> &term)
 
250
                                const shared_ptr<terminal_metrics> &term_metrics)
250
251
{
251
252
  // Try forcing the particular version that was
252
253
  // selected, using various sections.  FIXME: relies
256
257
 
257
258
  temp::name rval;
258
259
 
259
 
  get_changelog_from_source(pkg, ver, "", pkg, rval, term);
 
260
  get_changelog_from_source(pkg, ver, "", pkg, rval, term_metrics);
260
261
 
261
262
  if(!rval.valid())
262
263
    {
263
 
      get_changelog_from_source(pkg, ver, "contrib/foo", pkg, rval, term);
 
264
      get_changelog_from_source(pkg, ver, "contrib/foo", pkg, rval, term_metrics);
264
265
    }
265
266
 
266
267
  if(!rval.valid())
267
268
    {
268
 
      get_changelog_from_source(pkg, ver, "non-free/foo", pkg, rval, term);
 
269
      get_changelog_from_source(pkg, ver, "non-free/foo", pkg, rval, term_metrics);
269
270
    }
270
271
 
271
272
  return rval;
273
274
}
274
275
 
275
276
void do_cmdline_changelog(const vector<string> &packages,
276
 
                          const shared_ptr<terminal> &term)
 
277
                          const shared_ptr<terminal_metrics> &term_metrics)
277
278
{
278
279
  const char *pager="/usr/bin/sensible-pager";
279
280
 
356
357
                                        p.get_section(),
357
358
                                        pkg.Name(),
358
359
                                        filename,
359
 
                                        term);
 
360
                                        term_metrics);
360
361
            }
361
362
          else
362
363
            {
365
366
              if(ver.end())
366
367
                {
367
368
                  if(source == cmdline_version_version)
368
 
                    filename = changelog_by_version(package, sourcestr, term);
 
369
                    filename = changelog_by_version(package, sourcestr, term_metrics);
369
370
                  // If we don't even have a version string, leave
370
371
                  // filename blank; we'll fail below.
371
372
                }
372
373
              else
373
374
                {
374
 
                  get_changelog(ver, filename, term);
 
375
                  get_changelog(ver, filename, term_metrics);
375
376
                }
376
377
            }
377
378
        }
389
390
                                        p.get_section(),
390
391
                                        p.get_package(),
391
392
                                        filename,
392
 
                                        term);
 
393
                                        term_metrics);
393
394
            }
394
395
          else
395
396
            {
414
415
                  break;
415
416
 
416
417
                case cmdline_version_version:
417
 
                  filename = changelog_by_version(package, sourcestr, term);
 
418
                  filename = changelog_by_version(package, sourcestr, term_metrics);
418
419
                  break;
419
420
                }
420
421
            }
433
434
// TODO: fetch them all in one go.
434
435
int cmdline_changelog(int argc, char *argv[])
435
436
{
436
 
  shared_ptr<terminal> term = create_terminal();
 
437
  shared_ptr<terminal_io> term = create_terminal();
437
438
 
438
439
  _error->DumpErrors();
439
440