]>
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() && state
.CandidateVer 
!= NULL
) 
 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    if (P
->CurrentVer 
== 0) 
 169       pkgDepCache 
* const DepCache 
= CacheFile
.GetDepCache(); 
 170       pkgDepCache::StateCache 
const &state 
= (*DepCache
)[P
]; 
 171       if (state
.CandidateVer 
!= NULL
) 
 173          pkgCache::VerIterator 
const CandV(CacheFile
, state
.CandidateVer
); 
 178          pkgCache::VerIterator 
const V 
= P
.VersionList(); 
 179          if (V
.end() == false) 
 186       return P
.CurrentVer().Arch(); 
 189 static std::string 
GetShortDescription(pkgCacheFile 
&CacheFile
, pkgRecords 
&records
, pkgCache::PkgIterator P
)/*{{{*/ 
 191    pkgPolicy 
*policy 
= CacheFile
.GetPolicy(); 
 193    pkgCache::VerIterator ver
; 
 195       ver 
= P
.CurrentVer(); 
 197       ver 
= policy
->GetCandidateVer(P
); 
 199    std::string ShortDescription 
= "(none)"; 
 202       pkgCache::DescIterator Desc 
= ver
.TranslatedDescription(); 
 203       pkgRecords::Parser 
& parser 
= records
.Lookup(Desc
.FileList()); 
 205       ShortDescription 
= parser
.ShortDesc(); 
 207    return ShortDescription
; 
 210 static std::string 
GetLongDescription(pkgCacheFile 
&CacheFile
, pkgRecords 
&records
, pkgCache::PkgIterator P
)/*{{{*/ 
 212    pkgPolicy 
*policy 
= CacheFile
.GetPolicy(); 
 214    pkgCache::VerIterator ver
; 
 215    if (P
->CurrentVer 
!= 0) 
 216       ver 
= P
.CurrentVer(); 
 218       ver 
= policy
->GetCandidateVer(P
); 
 220    std::string 
const EmptyDescription 
= "(none)"; 
 221    if(ver
.end() == true) 
 222       return EmptyDescription
; 
 224    pkgCache::DescIterator 
const Desc 
= ver
.TranslatedDescription(); 
 225    pkgRecords::Parser 
& parser 
= records
.Lookup(Desc
.FileList()); 
 226    std::string 
const longdesc 
= parser
.LongDesc(); 
 227    if (longdesc
.empty() == true) 
 228       return EmptyDescription
; 
 229    return SubstVar(longdesc
, "\n ", "\n  "); 
 232 void ListSingleVersion(pkgCacheFile 
&CacheFile
, pkgRecords 
&records
,    /*{{{*/ 
 233                        pkgCache::VerIterator 
const &V
, std::ostream 
&out
, 
 234                        std::string 
const &format
) 
 236    pkgCache::PkgIterator 
const P 
= V
.ParentPkg(); 
 237    pkgDepCache 
* const DepCache 
= CacheFile
.GetDepCache(); 
 238    pkgDepCache::StateCache 
const &state 
= (*DepCache
)[P
]; 
 241    if (_config
->FindB("APT::Cmd::use-format", false)) 
 242       output 
= _config
->Find("APT::Cmd::format", "${db::Status-Abbrev} ${Package} ${Version} ${Origin} ${Description}"); 
 246    // FIXME: some of these names are really icky – and all is nowhere documented 
 247    output 
= SubstVar(output
, "${db::Status-Abbrev}", GetFlagsStr(CacheFile
, P
)); 
 248    output 
= SubstVar(output
, "${Package}", P
.Name()); 
 249    std::string 
const ArchStr 
= GetArchitecture(CacheFile
, P
); 
 250    output 
= SubstVar(output
, "${Architecture}", ArchStr
); 
 251    std::string 
const InstalledVerStr 
= GetInstalledVersion(CacheFile
, P
); 
 252    output 
= SubstVar(output
, "${installed:Version}", InstalledVerStr
); 
 253    std::string 
const CandidateVerStr 
= GetCandidateVersion(CacheFile
, P
); 
 254    output 
= SubstVar(output
, "${candidate:Version}", CandidateVerStr
); 
 255    std::string 
const VersionStr 
= GetVersion(CacheFile
, V
); 
 256    output 
= SubstVar(output
, "${Version}", VersionStr
); 
 257    output 
= SubstVar(output
, "${Origin}", GetArchiveSuite(CacheFile
, V
)); 
 259    std::string StatusStr 
= ""; 
 260    if (P
->CurrentVer 
!= 0) 
 262       if (P
.CurrentVer() == V
) 
 264          if (state
.Upgradable() && state
.CandidateVer 
!= NULL
) 
 265             strprintf(StatusStr
, _("[installed,upgradable to: %s]"), 
 266                   CandidateVerStr
.c_str()); 
 267          else if (V
.Downloadable() == false) 
 268             StatusStr 
= _("[installed,local]"); 
 269          else if(V
.Automatic() == true && state
.Garbage 
== true) 
 270             StatusStr 
= _("[installed,auto-removable]"); 
 271          else if ((state
.Flags 
& pkgCache::Flag::Auto
) == pkgCache::Flag::Auto
) 
 272             StatusStr 
= _("[installed,automatic]"); 
 274             StatusStr 
= _("[installed]"); 
 276       else if (state
.CandidateVer 
== V 
&& state
.Upgradable()) 
 277          strprintf(StatusStr
, _("[upgradable from: %s]"), 
 278                InstalledVerStr
.c_str()); 
 280    else if (V
.ParentPkg()->CurrentState 
== pkgCache::State::ConfigFiles
) 
 281       StatusStr 
= _("[residual-config]"); 
 282    output 
= SubstVar(output
, "${apt:Status}", StatusStr
); 
 283    output 
= SubstVar(output
, "${color:highlight}", _config
->Find("APT::Color::Highlight", "")); 
 284    output 
= SubstVar(output
, "${color:neutral}", _config
->Find("APT::Color::Neutral", "")); 
 285    output 
= SubstVar(output
, "${Description}", GetShortDescription(CacheFile
, records
, P
)); 
 286    output 
= SubstVar(output
, "${LongDescription}", GetLongDescription(CacheFile
, records
, P
)); 
 287    output 
= SubstVar(output
, "${ }${ }", "${ }"); 
 288    output 
= SubstVar(output
, "${ }\n", "\n"); 
 289    output 
= SubstVar(output
, "${ }", " "); 
 290    if (APT::String::Endswith(output
, " ") == true) 
 291       output
.erase(output
.length() - 1); 
 296 // ShowList - Show a list                                               /*{{{*/ 
 297 // --------------------------------------------------------------------- 
 298 /* This prints out a string of space separated words with a title and  
 299    a two space indent line wraped to the current screen width. */ 
 300 bool ShowList(ostream 
&out
,string Title
,string List
,string VersionsList
) 
 302    if (List
.empty() == true) 
 304    // trim trailing space 
 305    int NonSpace 
= List
.find_last_not_of(' '); 
 308       List 
= List
.erase(NonSpace 
+ 1); 
 309       if (List
.empty() == true) 
 313    // Acount for the leading space 
 314    int ScreenWidth 
= ::ScreenWidth 
- 3; 
 316    out 
<< Title 
<< endl
; 
 317    string::size_type Start 
= 0; 
 318    string::size_type VersionsStart 
= 0; 
 319    while (Start 
< List
.size()) 
 321       if(_config
->FindB("APT::Get::Show-Versions",false) == true && 
 322          VersionsList
.size() > 0) { 
 323          string::size_type End
; 
 324          string::size_type VersionsEnd
; 
 326          End 
= List
.find(' ',Start
); 
 327          VersionsEnd 
= VersionsList
.find('\n', VersionsStart
); 
 329          out 
<< "   " << string(List
,Start
,End 
- Start
) << " (" <<  
 330             string(VersionsList
,VersionsStart
,VersionsEnd 
- VersionsStart
) <<  
 333          if (End 
== string::npos 
|| End 
< Start
) 
 334             End 
= Start 
+ ScreenWidth
; 
 337          VersionsStart 
= VersionsEnd 
+ 1; 
 339          string::size_type End
; 
 341          if (Start 
+ ScreenWidth 
>= List
.size()) 
 344             End 
= List
.rfind(' ',Start
+ScreenWidth
); 
 346          if (End 
== string::npos 
|| End 
< Start
) 
 347             End 
= Start 
+ ScreenWidth
; 
 348          out 
<< "  " << string(List
,Start
,End 
- Start
) << endl
; 
 356 // ShowBroken - Debugging aide                                          /*{{{*/ 
 357 // --------------------------------------------------------------------- 
 358 /* This prints out the names of all the packages that are broken along 
 359    with the name of each each broken dependency and a quite version  
 362    The output looks like: 
 363  The following packages have unmet dependencies: 
 364      exim: Depends: libc6 (>= 2.1.94) but 2.1.3-10 is to be installed 
 365            Depends: libldap2 (>= 2.0.2-2) but it is not going to be installed 
 366            Depends: libsasl7 but it is not going to be installed    
 368 static void ShowBrokenPackage(ostream 
&out
, pkgCacheFile 
* const Cache
, pkgCache::PkgIterator 
const &Pkg
, bool const Now
) 
 372       if ((*Cache
)[Pkg
].NowBroken() == false) 
 377       if ((*Cache
)[Pkg
].InstBroken() == false) 
 381    // Print out each package and the failed dependencies 
 382    out 
<< " " << Pkg
.FullName(true) << " :"; 
 383    unsigned const Indent 
= Pkg
.FullName(true).size() + 3; 
 385    pkgCache::VerIterator Ver
; 
 388       Ver 
= Pkg
.CurrentVer(); 
 390       Ver 
= (*Cache
)[Pkg
].InstVerIter(*Cache
); 
 392    if (Ver
.end() == true) 
 398    for (pkgCache::DepIterator D 
= Ver
.DependsList(); D
.end() == false;) 
 400       // Compute a single dependency element (glob or) 
 401       pkgCache::DepIterator Start
; 
 402       pkgCache::DepIterator End
; 
 403       D
.GlobOr(Start
,End
); // advances D 
 405       if ((*Cache
)->IsImportantDep(End
) == false) 
 410          if (((*Cache
)[End
] & pkgDepCache::DepGNow
) == pkgDepCache::DepGNow
) 
 415          if (((*Cache
)[End
] & pkgDepCache::DepGInstall
) == pkgDepCache::DepGInstall
) 
 423             for (unsigned J 
= 0; J 
!= Indent
; J
++) 
 427          if (FirstOr 
== false) 
 429             for (unsigned J 
= 0; J 
!= strlen(End
.DepType()) + 3; J
++) 
 433             out 
<< ' ' << End
.DepType() << ": "; 
 436          out 
<< Start
.TargetPkg().FullName(true); 
 438          // Show a quick summary of the version requirements 
 439          if (Start
.TargetVer() != 0) 
 440             out 
<< " (" << Start
.CompType() << " " << Start
.TargetVer() << ")"; 
 442          /* Show a summary of the target package if possible. In the case 
 443             of virtual packages we show nothing */ 
 444          pkgCache::PkgIterator Targ 
= Start
.TargetPkg(); 
 445          if (Targ
->ProvidesList 
== 0) 
 448             pkgCache::VerIterator Ver 
= (*Cache
)[Targ
].InstVerIter(*Cache
); 
 450                Ver 
= Targ
.CurrentVer(); 
 452             if (Ver
.end() == false) 
 455                   ioprintf(out
,_("but %s is installed"),Ver
.VerStr()); 
 457                   ioprintf(out
,_("but %s is to be installed"),Ver
.VerStr()); 
 461                if ((*Cache
)[Targ
].CandidateVerIter(*Cache
).end() == true) 
 463                   if (Targ
->ProvidesList 
== 0) 
 464                      out 
<< _("but it is not installable"); 
 466                      out 
<< _("but it is a virtual package"); 
 469                   out 
<< (Now
?_("but it is not installed"):_("but it is not going to be installed")); 
 483 void ShowBroken(ostream 
&out
, CacheFile 
&Cache
, bool const Now
) 
 485    if (Cache
->BrokenCount() == 0) 
 488    out 
<< _("The following packages have unmet dependencies:") << endl
; 
 489    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 491       pkgCache::PkgIterator 
const I(Cache
,Cache
.List
[J
]); 
 492       ShowBrokenPackage(out
, &Cache
, I
, Now
); 
 495 void ShowBroken(ostream 
&out
, pkgCacheFile 
&Cache
, bool const Now
) 
 497    if (Cache
->BrokenCount() == 0) 
 500    out 
<< _("The following packages have unmet dependencies:") << endl
; 
 501    for (pkgCache::PkgIterator Pkg 
= Cache
->PkgBegin(); Pkg
.end() == false; ++Pkg
) 
 502       ShowBrokenPackage(out
, &Cache
, Pkg
, Now
); 
 505 // ShowNew - Show packages to newly install                             /*{{{*/ 
 506 // --------------------------------------------------------------------- 
 508 void ShowNew(ostream 
&out
,CacheFile 
&Cache
) 
 510    /* Print out a list of packages that are going to be installed 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
].NewInstall() == true) { 
 518          List 
+= I
.FullName(true) + " "; 
 519          VersionsList 
+= string(Cache
[I
].CandVersion
) + "\n"; 
 523    ShowList(out
,_("The following NEW packages will be installed:"),List
,VersionsList
); 
 526 // ShowDel - Show packages to delete                                    /*{{{*/ 
 527 // --------------------------------------------------------------------- 
 529 void ShowDel(ostream 
&out
,CacheFile 
&Cache
) 
 531    /* Print out a list of packages that are going to be removed extra 
 532       to what the user asked */ 
 535    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 537       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 538       if (Cache
[I
].Delete() == true) 
 540          if ((Cache
[I
].iFlags 
& pkgDepCache::Purge
) == pkgDepCache::Purge
) 
 541             List 
+= I
.FullName(true) + "* "; 
 543             List 
+= I
.FullName(true) + " "; 
 545      VersionsList 
+= string(Cache
[I
].CandVersion
)+ "\n"; 
 549    ShowList(out
,_("The following packages will be REMOVED:"),List
,VersionsList
); 
 552 // ShowKept - Show kept packages                                        /*{{{*/ 
 553 // --------------------------------------------------------------------- 
 555 void ShowKept(ostream 
&out
,CacheFile 
&Cache
) 
 559    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 561       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 564       if (Cache
[I
].Upgrade() == true || Cache
[I
].Upgradable() == false || 
 565           I
->CurrentVer 
== 0 || Cache
[I
].Delete() == true) 
 568       List 
+= I
.FullName(true) + " "; 
 569       VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 571    ShowList(out
,_("The following packages have been kept back:"),List
,VersionsList
); 
 574 // ShowUpgraded - Show upgraded packages                                /*{{{*/ 
 575 // --------------------------------------------------------------------- 
 577 void ShowUpgraded(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
].Upgrade() == false || Cache
[I
].NewInstall() == true) 
 589       List 
+= I
.FullName(true) + " "; 
 590       VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 592    ShowList(out
,_("The following packages will be upgraded:"),List
,VersionsList
); 
 595 // ShowDowngraded - Show downgraded packages                            /*{{{*/ 
 596 // --------------------------------------------------------------------- 
 598 bool ShowDowngraded(ostream 
&out
,CacheFile 
&Cache
) 
 602    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 604       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 607       if (Cache
[I
].Downgrade() == false || Cache
[I
].NewInstall() == true) 
 610       List 
+= I
.FullName(true) + " "; 
 611       VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 613    return ShowList(out
,_("The following packages will be DOWNGRADED:"),List
,VersionsList
); 
 616 // ShowHold - Show held but changed packages                            /*{{{*/ 
 617 // --------------------------------------------------------------------- 
 619 bool ShowHold(ostream 
&out
,CacheFile 
&Cache
) 
 623    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 625       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 626       if (Cache
[I
].InstallVer 
!= (pkgCache::Version 
*)I
.CurrentVer() && 
 627           I
->SelectedState 
== pkgCache::State::Hold
) { 
 628          List 
+= I
.FullName(true) + " "; 
 629                  VersionsList 
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion 
+ "\n"; 
 633    return ShowList(out
,_("The following held packages will be changed:"),List
,VersionsList
); 
 636 // ShowEssential - Show an essential package warning                    /*{{{*/ 
 637 // --------------------------------------------------------------------- 
 638 /* This prints out a warning message that is not to be ignored. It shows 
 639    all essential packages and their dependents that are to be removed.  
 640    It is insanely risky to remove the dependents of an essential package! */ 
 641 bool ShowEssential(ostream 
&out
,CacheFile 
&Cache
) 
 645    bool *Added 
= new bool[Cache
->Head().PackageCount
]; 
 646    for (unsigned int I 
= 0; I 
!= Cache
->Head().PackageCount
; I
++) 
 649    for (unsigned J 
= 0; J 
< Cache
->Head().PackageCount
; J
++) 
 651       pkgCache::PkgIterator 
I(Cache
,Cache
.List
[J
]); 
 652       if ((I
->Flags 
& pkgCache::Flag::Essential
) != pkgCache::Flag::Essential 
&& 
 653           (I
->Flags 
& pkgCache::Flag::Important
) != pkgCache::Flag::Important
) 
 656       // The essential package is being removed 
 657       if (Cache
[I
].Delete() == true) 
 659          if (Added
[I
->ID
] == false) 
 662             List 
+= I
.FullName(true) + " "; 
 663         //VersionsList += string(Cache[I].CurVersion) + "\n"; ??? 
 669       if (I
->CurrentVer 
== 0) 
 672       // Print out any essential package depenendents that are to be removed 
 673       for (pkgCache::DepIterator D 
= I
.CurrentVer().DependsList(); D
.end() == false; ++D
) 
 675          // Skip everything but depends 
 676          if (D
->Type 
!= pkgCache::Dep::PreDepends 
&& 
 677              D
->Type 
!= pkgCache::Dep::Depends
) 
 680          pkgCache::PkgIterator P 
= D
.SmartTargetPkg(); 
 681          if (Cache
[P
].Delete() == true) 
 683             if (Added
[P
->ID
] == true) 
 688             snprintf(S
,sizeof(S
),_("%s (due to %s) "),P
.FullName(true).c_str(),I
.FullName(true).c_str()); 
 690         //VersionsList += "\n"; ??? 
 696    return ShowList(out
,_("WARNING: The following essential packages will be removed.\n" 
 697                          "This should NOT be done unless you know exactly what you are doing!"),List
,VersionsList
); 
 701 // Stats - Show some statistics                                         /*{{{*/ 
 702 // --------------------------------------------------------------------- 
 704 void Stats(ostream 
&out
,pkgDepCache 
&Dep
) 
 706    unsigned long Upgrade 
= 0; 
 707    unsigned long Downgrade 
= 0; 
 708    unsigned long Install 
= 0; 
 709    unsigned long ReInstall 
= 0; 
 710    for (pkgCache::PkgIterator I 
= Dep
.PkgBegin(); I
.end() == false; ++I
) 
 712       if (Dep
[I
].NewInstall() == true) 
 716          if (Dep
[I
].Upgrade() == true) 
 719             if (Dep
[I
].Downgrade() == true) 
 723       if (Dep
[I
].Delete() == false && (Dep
[I
].iFlags 
& pkgDepCache::ReInstall
) == pkgDepCache::ReInstall
) 
 727    ioprintf(out
,_("%lu upgraded, %lu newly installed, "), 
 731       ioprintf(out
,_("%lu reinstalled, "),ReInstall
); 
 733       ioprintf(out
,_("%lu downgraded, "),Downgrade
); 
 735    ioprintf(out
,_("%lu to remove and %lu not upgraded.\n"), 
 736             Dep
.DelCount(),Dep
.KeepCount()); 
 738    if (Dep
.BadCount() != 0) 
 739       ioprintf(out
,_("%lu not fully installed or removed.\n"), 
 743 // YnPrompt - Yes No Prompt.                                            /*{{{*/ 
 744 // --------------------------------------------------------------------- 
 745 /* Returns true on a Yes.*/ 
 746 bool YnPrompt(bool Default
) 
 748    /* nl_langinfo does not support LANGUAGE setting, so we unset it here 
 749       to have the help-message (hopefully) match the expected characters */ 
 750    char * language 
= getenv("LANGUAGE"); 
 751    if (language 
!= NULL
) 
 752       language 
= strdup(language
); 
 753    if (language 
!= NULL
) 
 754       unsetenv("LANGUAGE"); 
 757       // TRANSLATOR: Yes/No question help-text: defaulting to Y[es] 
 758       //             e.g. "Do you want to continue? [Y/n] " 
 759       //             The user has to answer with an input matching the 
 760       //             YESEXPR/NOEXPR defined in your l10n. 
 761       c2out 
<< " " << _("[Y/n]") << " " << std::flush
; 
 763       // TRANSLATOR: Yes/No question help-text: defaulting to N[o] 
 764       //             e.g. "Should this file be removed? [y/N] " 
 765       //             The user has to answer with an input matching the 
 766       //             YESEXPR/NOEXPR defined in your l10n. 
 767       c2out 
<< " " << _("[y/N]") << " " << std::flush
; 
 769    if (language 
!= NULL
) 
 771       setenv("LANGUAGE", language
, 0); 
 775    if (_config
->FindB("APT::Get::Assume-Yes",false) == true) 
 777       // TRANSLATOR: "Yes" answer printed for a yes/no question if --assume-yes is set 
 778       c1out 
<< _("Y") << std::endl
; 
 781    else if (_config
->FindB("APT::Get::Assume-No",false) == true) 
 783       // TRANSLATOR: "No" answer printed for a yes/no question if --assume-no is set 
 784       c1out 
<< _("N") << std::endl
; 
 788    char response
[1024] = ""; 
 789    std::cin
.getline(response
, sizeof(response
)); 
 794    if (strlen(response
) == 0) 
 800    Res 
= regcomp(&Pattern
, nl_langinfo(YESEXPR
), 
 801                  REG_EXTENDED
|REG_ICASE
|REG_NOSUB
); 
 805       regerror(Res
,&Pattern
,Error
,sizeof(Error
)); 
 806       return _error
->Error(_("Regex compilation error - %s"),Error
); 
 809    Res 
= regexec(&Pattern
, response
, 0, NULL
, 0); 
 815 // AnalPrompt - Annoying Yes No Prompt.                                 /*{{{*/ 
 816 // --------------------------------------------------------------------- 
 817 /* Returns true on a Yes.*/ 
 818 bool AnalPrompt(const char *Text
) 
 821    std::cin
.getline(Buf
,sizeof(Buf
)); 
 822    if (strcmp(Buf
,Text
) == 0)