]>
git.saurik.com Git - apt.git/blob - apt-private/private-output.cc
   1 // Include files                                                        /*{{{*/ 
   4 #include <apt-pkg/configuration.h> 
   5 #include <apt-pkg/strutl.h> 
   6 #include <apt-pkg/error.h> 
   7 #include <apt-pkg/cachefile.h> 
   8 #include <apt-pkg/pkgrecords.h> 
   9 #include <apt-pkg/policy.h> 
  10 #include <apt-pkg/depcache.h> 
  11 #include <apt-pkg/pkgcache.h> 
  12 #include <apt-pkg/cacheiterators.h> 
  14 #include <apt-private/private-output.h> 
  15 #include <apt-private/private-cachefile.h> 
  26 #include <sys/ioctl.h> 
  33 std::ostream 
c0out(0); 
  34 std::ostream 
c1out(0); 
  35 std::ostream 
c2out(0); 
  36 std::ofstream 
devnull("/dev/null"); 
  39 unsigned int ScreenWidth 
= 80 - 1; /* - 1 for the cursor */ 
  41 // SigWinch - Window size change signal handler                         /*{{{*/ 
  42 // --------------------------------------------------------------------- 
  44 static void SigWinch(int) 
  50    if (ioctl(1, TIOCGWINSZ
, &ws
) != -1 && ws
.ws_col 
>= 5) 
  51       ScreenWidth 
= ws
.ws_col 
- 1; 
  55 bool InitOutput()                                                       /*{{{*/ 
  57    if (!isatty(STDOUT_FILENO
) && _config
->FindI("quiet", -1) == -1) 
  58       _config
->Set("quiet","1"); 
  60    c0out
.rdbuf(cout
.rdbuf()); 
  61    c1out
.rdbuf(cout
.rdbuf()); 
  62    c2out
.rdbuf(cout
.rdbuf()); 
  63    if (_config
->FindI("quiet",0) > 0) 
  64       c0out
.rdbuf(devnull
.rdbuf()); 
  65    if (_config
->FindI("quiet",0) > 1) 
  66       c1out
.rdbuf(devnull
.rdbuf()); 
  68    // deal with window size changes 
  69    signal(SIGWINCH
,SigWinch
); 
  74       _config
->Set("APT::Color", "false"); 
  75       _config
->Set("APT::Color::Highlight", ""); 
  76       _config
->Set("APT::Color::Neutral", ""); 
  79       _config
->CndSet("APT::Color::Highlight", "\x1B[32m"); 
  80       _config
->CndSet("APT::Color::Neutral", "\x1B[0m"); 
  82       _config
->CndSet("APT::Color::Red", "\x1B[31m"); 
  83       _config
->CndSet("APT::Color::Green", "\x1B[32m"); 
  84       _config
->CndSet("APT::Color::Yellow", "\x1B[33m"); 
  85       _config
->CndSet("APT::Color::Blue", "\x1B[34m"); 
  86       _config
->CndSet("APT::Color::Magenta", "\x1B[35m"); 
  87       _config
->CndSet("APT::Color::Cyan", "\x1B[36m"); 
  88       _config
->CndSet("APT::Color::White", "\x1B[37m"); 
  94 static std::string 
GetArchiveSuite(pkgCacheFile 
&/*CacheFile*/, pkgCache::VerIterator ver
) /*{{{*/ 
  96    std::string suite 
= ""; 
  97    if (ver 
&& ver
.FileList()) 
  99       pkgCache::VerFileIterator VF 
= ver
.FileList(); 
 100       for (; VF
.end() == false ; ++VF
) 
 102          if(VF
.File() == NULL 
|| VF
.File().Archive() == NULL
) 
 103             suite 
= suite 
+ "," + _("unknown"); 
 105             suite 
= suite 
+ "," + VF
.File().Archive(); 
 106          //suite = VF.File().Archive(); 
 108       suite 
= suite
.erase(0, 1); 
 113 static std::string 
GetFlagsStr(pkgCacheFile 
&CacheFile
, pkgCache::PkgIterator P
)/*{{{*/ 
 115    pkgDepCache 
*DepCache 
= CacheFile
.GetDepCache(); 
 116    pkgDepCache::StateCache 
&state 
= (*DepCache
)[P
]; 
 118    std::string flags_str
; 
 119    if (state
.NowBroken()) 
 121    if (P
.CurrentVer() && state
.Upgradable()) 
 123    else if (P
.CurrentVer() != NULL
) 
 130 static std::string 
GetCandidateVersion(pkgCacheFile 
&CacheFile
, pkgCache::PkgIterator P
)/*{{{*/ 
 132    pkgPolicy 
*policy 
= CacheFile
.GetPolicy(); 
 133    pkgCache::VerIterator cand 
= policy
->GetCandidateVer(P
); 
 135    return cand 
? cand
.VerStr() : "(none)"; 
 138 static std::string 
GetInstalledVersion(pkgCacheFile 
&/*CacheFile*/, pkgCache::PkgIterator P
)/*{{{*/ 
 140    pkgCache::VerIterator inst 
= P
.CurrentVer(); 
 142    return inst 
? inst
.VerStr() : "(none)"; 
 145 static std::string 
GetVersion(pkgCacheFile 
&/*CacheFile*/, pkgCache::VerIterator V
)/*{{{*/ 
 147    pkgCache::PkgIterator P 
= V
.ParentPkg(); 
 148    if (V 
== P
.CurrentVer()) 
 150       std::string inst_str 
= DeNull(V
.VerStr()); 
 151 #if 0 // FIXME: do we want this or something like this? 
 152       pkgDepCache 
*DepCache 
= CacheFile
.GetDepCache(); 
 153       pkgDepCache::StateCache 
&state 
= (*DepCache
)[P
]; 
 154       if (state
.Upgradable()) 
 155          return "**"+inst_str
; 
 161       return DeNull(V
.VerStr()); 
 165 static std::string 
GetArchitecture(pkgCacheFile 
&CacheFile
, pkgCache::PkgIterator P
)/*{{{*/ 
 167    pkgPolicy 
*policy 
= CacheFile
.GetPolicy(); 
 168    pkgCache::VerIterator inst 
= P
.CurrentVer(); 
 169    pkgCache::VerIterator cand 
= policy
->GetCandidateVer(P
); 
 171    // this may happen for packages in dpkg "deinstall ok config-file" state 
 172    if (inst
.IsGood() == false && cand
.IsGood() == false) 
 173       return P
.VersionList().Arch(); 
 175    return inst 
? inst
.Arch() : cand
.Arch(); 
 178 static std::string 
GetShortDescription(pkgCacheFile 
&CacheFile
, pkgRecords 
&records
, pkgCache::PkgIterator P
)/*{{{*/ 
 180    pkgPolicy 
*policy 
= CacheFile
.GetPolicy(); 
 182    pkgCache::VerIterator ver
; 
 184       ver 
= P
.CurrentVer(); 
 186       ver 
= policy
->GetCandidateVer(P
); 
 188    std::string ShortDescription 
= "(none)"; 
 191       pkgCache::DescIterator Desc 
= ver
.TranslatedDescription(); 
 192       pkgRecords::Parser 
& parser 
= records
.Lookup(Desc
.FileList()); 
 194       ShortDescription 
= parser
.ShortDesc(); 
 196    return ShortDescription
; 
 199 void ListSingleVersion(pkgCacheFile 
&CacheFile
, pkgRecords 
&records
,    /*{{{*/ 
 200                        pkgCache::VerIterator V
, std::ostream 
&out
, 
 201                        bool include_summary
) 
 203    pkgCache::PkgIterator P 
= V
.ParentPkg(); 
 205    pkgDepCache 
*DepCache 
= CacheFile
.GetDepCache(); 
 206    pkgDepCache::StateCache 
&state 
= (*DepCache
)[P
]; 
 208    std::string suite 
= GetArchiveSuite(CacheFile
, V
); 
 209    std::string name_str 
= P
.Name(); 
 211    if (_config
->FindB("APT::Cmd::use-format", false)) 
 213       std::string format 
= _config
->Find("APT::Cmd::format", "${db::Status-Abbrev} ${Package} ${Version} ${Origin} ${Description}"); 
 214       std::string output 
= format
; 
 216       output 
= SubstVar(output
, "${db::Status-Abbrev}", GetFlagsStr(CacheFile
, P
)); 
 217       output 
= SubstVar(output
, "${Package}", name_str
); 
 218       output 
= SubstVar(output
, "${installed:Version}", GetInstalledVersion(CacheFile
, P
)); 
 219       output 
= SubstVar(output
, "${candidate:Version}", GetCandidateVersion(CacheFile
, P
)); 
 220       output 
= SubstVar(output
, "${Version}", GetVersion(CacheFile
, V
)); 
 221       output 
= SubstVar(output
, "${Description}", GetShortDescription(CacheFile
, records
, P
)); 
 222       output 
= SubstVar(output
, "${Origin}", GetArchiveSuite(CacheFile
, V
)); 
 223       out 
<< output 
<< std::endl
; 
 225       // raring/linux-kernel version [upradable: new-version] 
 227       pkgPolicy 
*policy 
= CacheFile
.GetPolicy(); 
 228       std::string VersionStr 
= GetVersion(CacheFile
, V
); 
 229       std::string CandidateVerStr 
= GetCandidateVersion(CacheFile
, P
); 
 230       std::string InstalledVerStr 
= GetInstalledVersion(CacheFile
, P
); 
 231       std::string StatusStr
; 
 232       if(P
.CurrentVer() == V 
&& state
.Upgradable()) { 
 233          strprintf(StatusStr
, _("[installed,upgradable to: %s]"), 
 234                    CandidateVerStr
.c_str()); 
 235       } else if (P
.CurrentVer() == V
) { 
 236          if(!V
.Downloadable()) 
 237             StatusStr 
= _("[installed,local]"); 
 239             if(V
.Automatic() && state
.Garbage
) 
 240                StatusStr 
= _("[installed,auto-removable]"); 
 241             else if (state
.Flags 
& pkgCache::Flag::Auto
) 
 242                StatusStr 
= _("[installed,automatic]"); 
 244                StatusStr 
= _("[installed]"); 
 245       } else if (P
.CurrentVer() &&  
 246                  policy
->GetCandidateVer(P
) == V 
&&  
 247                  state
.Upgradable()) { 
 248             strprintf(StatusStr
, _("[upgradable from: %s]"), 
 249                       InstalledVerStr
.c_str()); 
 251          if (V
.ParentPkg()->CurrentState 
== pkgCache::State::ConfigFiles
) 
 252             StatusStr 
= _("[residual-config]"); 
 256       out 
<< std::setiosflags(std::ios::left
) 
 257           << _config
->Find("APT::Color::Highlight", "") 
 259           << _config
->Find("APT::Color::Neutral", "") 
 263           << GetArchitecture(CacheFile
, P
); 
 265          out 
<< " " << StatusStr
; 
 269              << "  " << GetShortDescription(CacheFile
, records
, P
) 
 275 // ShowList - Show a list                                               /*{{{*/ 
 276 // --------------------------------------------------------------------- 
 277 /* This prints out a string of space separated words with a title and  
 278    a two space indent line wraped to the current screen width. */ 
 279 bool ShowList(ostream 
&out
,string Title
,string List
,string VersionsList
) 
 281    if (List
.empty() == true) 
 283    // trim trailing space 
 284    int NonSpace 
= List
.find_last_not_of(' '); 
 287       List 
= List
.erase(NonSpace 
+ 1); 
 288       if (List
.empty() == true) 
 292    // Acount for the leading space 
 293    int ScreenWidth 
= ::ScreenWidth 
- 3; 
 295    out 
<< Title 
<< endl
; 
 296    string::size_type Start 
= 0; 
 297    string::size_type VersionsStart 
= 0; 
 298    while (Start 
< List
.size()) 
 300       if(_config
->FindB("APT::Get::Show-Versions",false) == true && 
 301          VersionsList
.size() > 0) { 
 302          string::size_type End
; 
 303          string::size_type VersionsEnd
; 
 305          End 
= List
.find(' ',Start
); 
 306          VersionsEnd 
= VersionsList
.find('\n', VersionsStart
); 
 308          out 
<< "   " << string(List
,Start
,End 
- Start
) << " (" <<  
 309             string(VersionsList
,VersionsStart
,VersionsEnd 
- VersionsStart
) <<  
 312          if (End 
== string::npos 
|| End 
< Start
) 
 313             End 
= Start 
+ ScreenWidth
; 
 316          VersionsStart 
= VersionsEnd 
+ 1; 
 318          string::size_type End
; 
 320          if (Start 
+ ScreenWidth 
>= List
.size()) 
 323             End 
= List
.rfind(' ',Start
+ScreenWidth
); 
 325          if (End 
== string::npos 
|| End 
< Start
) 
 326             End 
= Start 
+ ScreenWidth
; 
 327          out 
<< "  " << string(List
,Start
,End 
- Start
) << endl
; 
 335 // ShowBroken - Debugging aide                                          /*{{{*/ 
 336 // --------------------------------------------------------------------- 
 337 /* This prints out the names of all the packages that are broken along 
 338    with the name of each each broken dependency and a quite version  
 341    The output looks like: 
 342  The following packages have unmet dependencies: 
 343      exim: Depends: libc6 (>= 2.1.94) but 2.1.3-10 is to be installed 
 344            Depends: libldap2 (>= 2.0.2-2) but it is not going to be installed 
 345            Depends: libsasl7 but it is not going to be installed    
 347 static void ShowBrokenPackage(ostream 
&out
, pkgCacheFile 
* const Cache
, pkgCache::PkgIterator 
const &Pkg
, bool const Now
) 
 351       if ((*Cache
)[Pkg
].NowBroken() == false) 
 356       if ((*Cache
)[Pkg
].InstBroken() == false) 
 360    // Print out each package and the failed dependencies 
 361    out 
<< " " << Pkg
.FullName(true) << " :"; 
 362    unsigned const Indent 
= Pkg
.FullName(true).size() + 3; 
 364    pkgCache::VerIterator Ver
; 
 367       Ver 
= Pkg
.CurrentVer(); 
 369       Ver 
= (*Cache
)[Pkg
].InstVerIter(*Cache
); 
 371    if (Ver
.end() == true) 
 377    for (pkgCache::DepIterator D 
= Ver
.DependsList(); D
.end() == false;) 
 379       // Compute a single dependency element (glob or) 
 380       pkgCache::DepIterator Start
; 
 381       pkgCache::DepIterator End
; 
 382       D
.GlobOr(Start
,End
); // advances D 
 384       if ((*Cache
)->IsImportantDep(End
) == false) 
 389          if (((*Cache
)[End
] & pkgDepCache::DepGNow
) == pkgDepCache::DepGNow
) 
 394          if (((*Cache
)[End
] & pkgDepCache::DepGInstall
) == pkgDepCache::DepGInstall
) 
 402             for (unsigned J 
= 0; J 
!= Indent
; J
++) 
 406          if (FirstOr 
== false) 
 408             for (unsigned J 
= 0; J 
!= strlen(End
.DepType()) + 3; J
++) 
 412             out 
<< ' ' << End
.DepType() << ": "; 
 415          out 
<< Start
.TargetPkg().FullName(true); 
 417          // Show a quick summary of the version requirements 
 418          if (Start
.TargetVer() != 0) 
 419             out 
<< " (" << Start
.CompType() << " " << Start
.TargetVer() << ")"; 
 421          /* Show a summary of the target package if possible. In the case 
 422             of virtual packages we show nothing */ 
 423          pkgCache::PkgIterator Targ 
= Start
.TargetPkg(); 
 424          if (Targ
->ProvidesList 
== 0) 
 427             pkgCache::VerIterator Ver 
= (*Cache
)[Targ
].InstVerIter(*Cache
); 
 429                Ver 
= Targ
.CurrentVer(); 
 431             if (Ver
.end() == false) 
 434                   ioprintf(out
,_("but %s is installed"),Ver
.VerStr()); 
 436                   ioprintf(out
,_("but %s is to be installed"),Ver
.VerStr()); 
 440                if ((*Cache
)[Targ
].CandidateVerIter(*Cache
).end() == true) 
 442                   if (Targ
->ProvidesList 
== 0) 
 443                      out 
<< _("but it is not installable"); 
 445                      out 
<< _("but it is a virtual package"); 
 448                   out 
<< (Now
?_("but it is not installed"):_("but it is not going to be installed")); 
 462 void ShowBroken(ostream 
&out
, CacheFile 
&Cache
, bool const Now
) 
 464    if (Cache
->BrokenCount() == 0) 
 467    out 
<< _("The following packages have unmet dependencies:") << endl
; 
 468    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 470       pkgCache::PkgIterator 
const I(Cache
,Cache
.List
[J
]); 
 471       ShowBrokenPackage(out
, &Cache
, I
, Now
); 
 474 void ShowBroken(ostream 
&out
, pkgCacheFile 
&Cache
, bool const Now
) 
 476    if (Cache
->BrokenCount() == 0) 
 479    out 
<< _("The following packages have unmet dependencies:") << endl
; 
 480    for (pkgCache::PkgIterator Pkg 
= Cache
->PkgBegin(); Pkg
.end() == false; ++Pkg
) 
 481       ShowBrokenPackage(out
, &Cache
, Pkg
, Now
); 
 484 // ShowNew - Show packages to newly install                             /*{{{*/ 
 485 // --------------------------------------------------------------------- 
 487 void ShowNew(ostream 
&out
,CacheFile 
&Cache
) 
 489    /* Print out a list of packages that are going to be installed extra 
 490       to what the user asked */ 
 493    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 495       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 496       if (Cache
[I
].NewInstall() == true) { 
 497          List 
+= I
.FullName(true) + " "; 
 498          VersionsList 
+= string(Cache
[I
].CandVersion
) + "\n"; 
 502    ShowList(out
,_("The following NEW packages will be installed:"),List
,VersionsList
); 
 505 // ShowDel - Show packages to delete                                    /*{{{*/ 
 506 // --------------------------------------------------------------------- 
 508 void ShowDel(ostream 
&out
,CacheFile 
&Cache
) 
 510    /* Print out a list of packages that are going to be removed extra 
 511       to what the user asked */ 
 514    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 516       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 517       if (Cache
[I
].Delete() == true) 
 519          if ((Cache
[I
].iFlags 
& pkgDepCache::Purge
) == pkgDepCache::Purge
) 
 520             List 
+= I
.FullName(true) + "* "; 
 522             List 
+= I
.FullName(true) + " "; 
 524      VersionsList 
+= string(Cache
[I
].CandVersion
)+ "\n"; 
 528    ShowList(out
,_("The following packages will be REMOVED:"),List
,VersionsList
); 
 531 // ShowKept - Show kept packages                                        /*{{{*/ 
 532 // --------------------------------------------------------------------- 
 534 void ShowKept(ostream 
&out
,CacheFile 
&Cache
) 
 538    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 540       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 543       if (Cache
[I
].Upgrade() == true || Cache
[I
].Upgradable() == false || 
 544           I
->CurrentVer 
== 0 || Cache
[I
].Delete() == true) 
 547       List 
+= I
.FullName(true) + " "; 
 548       VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 550    ShowList(out
,_("The following packages have been kept back:"),List
,VersionsList
); 
 553 // ShowUpgraded - Show upgraded packages                                /*{{{*/ 
 554 // --------------------------------------------------------------------- 
 556 void ShowUpgraded(ostream 
&out
,CacheFile 
&Cache
) 
 560    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 562       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 565       if (Cache
[I
].Upgrade() == false || Cache
[I
].NewInstall() == true) 
 568       List 
+= I
.FullName(true) + " "; 
 569       VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 571    ShowList(out
,_("The following packages will be upgraded:"),List
,VersionsList
); 
 574 // ShowDowngraded - Show downgraded packages                            /*{{{*/ 
 575 // --------------------------------------------------------------------- 
 577 bool ShowDowngraded(ostream 
&out
,CacheFile 
&Cache
) 
 581    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 583       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 586       if (Cache
[I
].Downgrade() == false || Cache
[I
].NewInstall() == true) 
 589       List 
+= I
.FullName(true) + " "; 
 590       VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 592    return ShowList(out
,_("The following packages will be DOWNGRADED:"),List
,VersionsList
); 
 595 // ShowHold - Show held but changed packages                            /*{{{*/ 
 596 // --------------------------------------------------------------------- 
 598 bool ShowHold(ostream 
&out
,CacheFile 
&Cache
) 
 602    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 604       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 605       if (Cache
[I
].InstallVer 
!= (pkgCache::Version 
*)I
.CurrentVer() && 
 606           I
->SelectedState 
== pkgCache::State::Hold
) { 
 607          List 
+= I
.FullName(true) + " "; 
 608                  VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 612    return ShowList(out
,_("The following held packages will be changed:"),List
,VersionsList
); 
 615 // ShowEssential - Show an essential package warning                    /*{{{*/ 
 616 // --------------------------------------------------------------------- 
 617 /* This prints out a warning message that is not to be ignored. It shows 
 618    all essential packages and their dependents that are to be removed.  
 619    It is insanely risky to remove the dependents of an essential package! */ 
 620 bool ShowEssential(ostream 
&out
,CacheFile 
&Cache
) 
 624    bool *Added 
= new bool[Cache
->Head().PackageCount
]; 
 625    for (unsigned int I 
= 0; I 
!= Cache
->Head().PackageCount
; I
++) 
 628    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 630       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 631       if ((I
->Flags 
& pkgCache::Flag::Essential
) != pkgCache::Flag::Essential 
&& 
 632           (I
->Flags 
& pkgCache::Flag::Important
) != pkgCache::Flag::Important
) 
 635       // The essential package is being removed 
 636       if (Cache
[I
].Delete() == true) 
 638          if (Added
[I
->ID
] == false) 
 641             List 
+= I
.FullName(true) + " "; 
 642         //VersionsList += string(Cache[I].CurVersion) + "\n"; ??? 
 648       if (I
->CurrentVer 
== 0) 
 651       // Print out any essential package depenendents that are to be removed 
 652       for (pkgCache::DepIterator D 
= I
.CurrentVer().DependsList(); D
.end() == false; ++D
) 
 654          // Skip everything but depends 
 655          if (D
->Type 
!= pkgCache::Dep::PreDepends 
&& 
 656              D
->Type 
!= pkgCache::Dep::Depends
) 
 659          pkgCache::PkgIterator P 
= D
.SmartTargetPkg(); 
 660          if (Cache
[P
].Delete() == true) 
 662             if (Added
[P
->ID
] == true) 
 667             snprintf(S
,sizeof(S
),_("%s (due to %s) "),P
.FullName(true).c_str(),I
.FullName(true).c_str()); 
 669         //VersionsList += "\n"; ??? 
 675    return ShowList(out
,_("WARNING: The following essential packages will be removed.\n" 
 676                          "This should NOT be done unless you know exactly what you are doing!"),List
,VersionsList
); 
 680 // Stats - Show some statistics                                         /*{{{*/ 
 681 // --------------------------------------------------------------------- 
 683 void Stats(ostream 
&out
,pkgDepCache 
&Dep
) 
 685    unsigned long Upgrade 
= 0; 
 686    unsigned long Downgrade 
= 0; 
 687    unsigned long Install 
= 0; 
 688    unsigned long ReInstall 
= 0; 
 689    for (pkgCache::PkgIterator I 
= Dep
.PkgBegin(); I
.end() == false; ++I
) 
 691       if (Dep
[I
].NewInstall() == true) 
 695          if (Dep
[I
].Upgrade() == true) 
 698             if (Dep
[I
].Downgrade() == true) 
 702       if (Dep
[I
].Delete() == false && (Dep
[I
].iFlags 
& pkgDepCache::ReInstall
) == pkgDepCache::ReInstall
) 
 706    ioprintf(out
,_("%lu upgraded, %lu newly installed, "), 
 710       ioprintf(out
,_("%lu reinstalled, "),ReInstall
); 
 712       ioprintf(out
,_("%lu downgraded, "),Downgrade
); 
 714    ioprintf(out
,_("%lu to remove and %lu not upgraded.\n"), 
 715             Dep
.DelCount(),Dep
.KeepCount()); 
 717    if (Dep
.BadCount() != 0) 
 718       ioprintf(out
,_("%lu not fully installed or removed.\n"), 
 722 // YnPrompt - Yes No Prompt.                                            /*{{{*/ 
 723 // --------------------------------------------------------------------- 
 724 /* Returns true on a Yes.*/ 
 725 bool YnPrompt(bool Default
) 
 727    /* nl_langinfo does not support LANGUAGE setting, so we unset it here 
 728       to have the help-message (hopefully) match the expected characters */ 
 729    char * language 
= getenv("LANGUAGE"); 
 730    if (language 
!= NULL
) 
 731       language 
= strdup(language
); 
 732    if (language 
!= NULL
) 
 733       unsetenv("LANGUAGE"); 
 736       // TRANSLATOR: Yes/No question help-text: defaulting to Y[es] 
 737       //             e.g. "Do you want to continue? [Y/n] " 
 738       //             The user has to answer with an input matching the 
 739       //             YESEXPR/NOEXPR defined in your l10n. 
 740       c2out 
<< " " << _("[Y/n]") << " " << std::flush
; 
 742       // TRANSLATOR: Yes/No question help-text: defaulting to N[o] 
 743       //             e.g. "Should this file be removed? [y/N] " 
 744       //             The user has to answer with an input matching the 
 745       //             YESEXPR/NOEXPR defined in your l10n. 
 746       c2out 
<< " " << _("[y/N]") << " " << std::flush
; 
 748    if (language 
!= NULL
) 
 750       setenv("LANGUAGE", language
, 0); 
 754    if (_config
->FindB("APT::Get::Assume-Yes",false) == true) 
 756       // TRANSLATOR: "Yes" answer printed for a yes/no question if --assume-yes is set 
 757       c1out 
<< _("Y") << std::endl
; 
 760    else if (_config
->FindB("APT::Get::Assume-No",false) == true) 
 762       // TRANSLATOR: "No" answer printed for a yes/no question if --assume-no is set 
 763       c1out 
<< _("N") << std::endl
; 
 767    char response
[1024] = ""; 
 768    std::cin
.getline(response
, sizeof(response
)); 
 773    if (strlen(response
) == 0) 
 779    Res 
= regcomp(&Pattern
, nl_langinfo(YESEXPR
), 
 780                  REG_EXTENDED
|REG_ICASE
|REG_NOSUB
); 
 784       regerror(Res
,&Pattern
,Error
,sizeof(Error
)); 
 785       return _error
->Error(_("Regex compilation error - %s"),Error
); 
 788    Res 
= regexec(&Pattern
, response
, 0, NULL
, 0); 
 794 // AnalPrompt - Annoying Yes No Prompt.                                 /*{{{*/ 
 795 // --------------------------------------------------------------------- 
 796 /* Returns true on a Yes.*/ 
 797 bool AnalPrompt(const char *Text
) 
 800    std::cin
.getline(Buf
,sizeof(Buf
)); 
 801    if (strcmp(Buf
,Text
) == 0)