Browse Source

squash merge of the feature/apt-binary branch without the changes from experimental

debian/1.8.y
Michael Vogt 9 years ago
parent
commit
b917917067
  1. 1
      Makefile
  2. 51
      apt-pkg/algorithms.cc
  3. 4
      apt-pkg/algorithms.h
  4. 11
      apt-pkg/cachefilter.cc
  5. 35
      apt-pkg/cachefilter.h
  6. 64
      apt-pkg/cacheset.cc
  7. 13
      apt-pkg/cacheset.h
  8. 48
      apt-pkg/contrib/cmndline.cc
  9. 6
      apt-pkg/contrib/cmndline.h
  10. 12
      apt-pkg/contrib/strutl.cc
  11. 4
      apt-pkg/contrib/strutl.h
  12. 309
      apt-private/acqprogress.cc
  13. 38
      apt-private/acqprogress.h
  14. 28
      apt-private/makefile
  15. 109
      apt-private/private-cachefile.cc
  16. 51
      apt-private/private-cachefile.h
  17. 63
      apt-private/private-cacheset.cc
  18. 265
      apt-private/private-cacheset.h
  19. 268
      apt-private/private-cmndline.cc
  20. 10
      apt-private/private-cmndline.h
  21. 852
      apt-private/private-install.cc
  22. 181
      apt-private/private-install.h
  23. 158
      apt-private/private-list.cc
  24. 9
      apt-private/private-list.h
  25. 26
      apt-private/private-main.cc
  26. 9
      apt-private/private-main.h
  27. 193
      apt-private/private-moo.cc
  28. 12
      apt-private/private-moo.h
  29. 753
      apt-private/private-output.cc
  30. 49
      apt-private/private-output.h
  31. 99
      apt-private/private-search.cc
  32. 9
      apt-private/private-search.h
  33. 122
      apt-private/private-show.cc
  34. 12
      apt-private/private-show.h
  35. 93
      apt-private/private-update.cc
  36. 8
      apt-private/private-update.h
  37. 47
      apt-private/private-upgrade.cc
  38. 11
      apt-private/private-upgrade.h
  39. 116
      cmdline/apt-cache.cc
  40. 30
      cmdline/apt-cdrom.cc
  41. 23
      cmdline/apt-config.cc
  42. 2012
      cmdline/apt-get.cc
  43. 21
      cmdline/apt-mark.cc
  44. 158
      cmdline/apt.cc
  45. 19
      cmdline/makefile

1
Makefile

@ -13,6 +13,7 @@ default: startup all
all headers library clean veryclean binary program doc manpages debiandoc test update-po startup dirs:
$(MAKE) -C apt-pkg $@
$(MAKE) -C apt-inst $@
$(MAKE) -C apt-private $@
$(MAKE) -C methods $@
$(MAKE) -C cmdline $@
$(MAKE) -C ftparchive $@

51
apt-pkg/algorithms.cc

@ -456,6 +456,49 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
Cache.MarkInstall(I, false, 0, false);
}
return Fix.ResolveByKeep();
}
/*}}}*/
// AllUpgradeNoDelete - Upgrade without removing packages /*{{{*/
// ---------------------------------------------------------------------
/* Right now the system must be consistent before this can be called.
* Upgrade as much as possible without deleting anything (useful for
* stable systems)
*/
bool pkgAllUpgradeNoDelete(pkgDepCache &Cache)
{
pkgDepCache::ActionGroup group(Cache);
pkgProblemResolver Fix(&Cache);
if (Cache.BrokenCount() != 0)
return false;
// provide the initial set of stuff we want to upgrade by marking
// all upgradable packages for upgrade
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
{
if (I->CurrentVer != 0 && Cache[I].InstallVer != 0)
{
if (_config->FindB("APT::Ignore-Hold",false) == false)
if (I->SelectedState == pkgCache::State::Hold)
continue;
Cache.MarkInstall(I, false, 0, false);
}
}
// then let auto-install loose
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if (Cache[I].Install())
Cache.MarkInstall(I, true, 0, false);
// ... but it may remove stuff, we we need to clean up afterwards again
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
if (Cache[I].Delete() == true)
Cache.MarkKeep(I, false, false);
// resolve remaining issues via keep
return Fix.ResolveByKeep();
}
/*}}}*/
@ -550,14 +593,12 @@ void pkgProblemResolver::MakeScores()
unsigned long Size = Cache.Head().PackageCount;
memset(Scores,0,sizeof(*Scores)*Size);
// Maps to pkgCache::State::VerPriority
// which is "Important Required Standard Optional Extra"
// (yes, that is confusing, the order of pkgCache::State::VerPriority
// needs to be adjusted but that requires a ABI break)
// maps to pkgCache::State::VerPriority:
// Required Important Standard Optional Extra
int PrioMap[] = {
0,
_config->FindI("pkgProblemResolver::Scores::Important",2),
_config->FindI("pkgProblemResolver::Scores::Required",3),
_config->FindI("pkgProblemResolver::Scores::Important",2),
_config->FindI("pkgProblemResolver::Scores::Standard",1),
_config->FindI("pkgProblemResolver::Scores::Optional",-1),
_config->FindI("pkgProblemResolver::Scores::Extra",-2)

4
apt-pkg/algorithms.h

@ -143,7 +143,11 @@ class pkgProblemResolver /*{{{*/
bool pkgDistUpgrade(pkgDepCache &Cache);
bool pkgApplyStatus(pkgDepCache &Cache);
bool pkgFixBroken(pkgDepCache &Cache);
bool pkgAllUpgrade(pkgDepCache &Cache);
bool pkgAllUpgradeNoDelete(pkgDepCache &Cache);
bool pkgMinimizeUpgrade(pkgDepCache &Cache);
void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List);

11
apt-pkg/cachefilter.cc

@ -55,6 +55,17 @@ PackageNameMatchesRegEx::~PackageNameMatchesRegEx() { /*{{{*/
}
/*}}}*/
// Fnmatch support /*{{{*/
//----------------------------------------------------------------------
bool PackageNameMatchesFnmatch::operator() (pkgCache::PkgIterator const &Pkg) {/*{{{*/
return fnmatch(Pattern.c_str(), Pkg.Name(), FNM_CASEFOLD) == 0;
}
/*}}}*/
bool PackageNameMatchesFnmatch::operator() (pkgCache::GrpIterator const &Grp) {/*{{{*/
return fnmatch(Pattern.c_str(), Grp.Name(), FNM_CASEFOLD) == 0;
}
/*}}}*/
// CompleteArch to <kernel>-<cpu> tuple /*{{{*/
//----------------------------------------------------------------------
/* The complete architecture, consisting of <kernel>-<cpu>. */

35
apt-pkg/cachefilter.h

@ -14,18 +14,41 @@
/*}}}*/
namespace APT {
namespace CacheFilter {
class PackageMatcher {
public:
virtual bool operator() (pkgCache::PkgIterator const &Pkg) { return false; };
virtual bool operator() (pkgCache::GrpIterator const &Grp) { return false; };
virtual bool operator() (pkgCache::VerIterator const &Ver) { return false; };
virtual ~PackageMatcher() {};
};
// PackageNameMatchesRegEx /*{{{*/
class PackageNameMatchesRegEx {
class PackageNameMatchesRegEx : public PackageMatcher {
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
regex_t* pattern;
public:
PackageNameMatchesRegEx(std::string const &Pattern);
bool operator() (pkgCache::PkgIterator const &Pkg);
bool operator() (pkgCache::GrpIterator const &Grp);
virtual bool operator() (pkgCache::PkgIterator const &Pkg);
virtual bool operator() (pkgCache::GrpIterator const &Grp);
~PackageNameMatchesRegEx();
};
/*}}}*/
// PackageNameMatchesFnmatch /*{{{*/
class PackageNameMatchesFnmatch : public PackageMatcher{
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
const std::string Pattern;
public:
PackageNameMatchesFnmatch(std::string const &Pattern)
: Pattern(Pattern) {};
virtual bool operator() (pkgCache::PkgIterator const &Pkg);
virtual bool operator() (pkgCache::GrpIterator const &Grp);
~PackageNameMatchesFnmatch() {};
};
/*}}}*/
// PackageArchitectureMatchesSpecification /*{{{*/
/** \class PackageArchitectureMatchesSpecification
\brief matching against architecture specification strings
@ -35,7 +58,7 @@ public:
debian-policy §11.1 "Architecture specification strings".
Examples: i386, mipsel, linux-any, any-amd64, any */
class PackageArchitectureMatchesSpecification {
class PackageArchitectureMatchesSpecification : public PackageMatcher {
std::string literal;
std::string complete;
bool isPattern;
@ -51,8 +74,8 @@ public:
*/
PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern = true);
bool operator() (char const * const &arch);
bool operator() (pkgCache::PkgIterator const &Pkg);
bool operator() (pkgCache::VerIterator const &Ver);
virtual bool operator() (pkgCache::PkgIterator const &Pkg);
virtual bool operator() (pkgCache::VerIterator const &Ver);
~PackageArchitectureMatchesSpecification();
};
/*}}}*/

64
apt-pkg/cacheset.cc

@ -149,6 +149,69 @@ bool PackageContainerInterface::FromRegEx(PackageContainerInterface * const pci,
return false;
}
if (wasEmpty == false && pci->getConstructor() != UNKNOWN)
pci->setConstructor(UNKNOWN);
return true;
}
/*}}}*/
// FromFnmatch - Returns the package defined by this fnmatch /*{{{*/
bool
PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci,
pkgCacheFile &Cache,
std::string pattern,
CacheSetHelper &helper)
{
static const char * const isfnmatch = ".?*[]!";
if (pattern.find_first_of(isfnmatch) == std::string::npos)
return false;
bool const wasEmpty = pci->empty();
if (wasEmpty == true)
pci->setConstructor(FNMATCH);
size_t archfound = pattern.find_last_of(':');
std::string arch = "native";
if (archfound != std::string::npos) {
arch = pattern.substr(archfound+1);
if (arch.find_first_of(isfnmatch) == std::string::npos)
pattern.erase(archfound);
else
arch = "native";
}
if (unlikely(Cache.GetPkgCache() == 0))
return false;
APT::CacheFilter::PackageNameMatchesFnmatch filter(pattern);
bool found = false;
for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp) {
if (filter(Grp) == false)
continue;
pkgCache::PkgIterator Pkg = Grp.FindPkg(arch);
if (Pkg.end() == true) {
if (archfound == std::string::npos) {
std::vector<std::string> archs = APT::Configuration::getArchitectures();
for (std::vector<std::string>::const_iterator a = archs.begin();
a != archs.end() && Pkg.end() != true; ++a)
Pkg = Grp.FindPkg(*a);
}
if (Pkg.end() == true)
continue;
}
pci->insert(Pkg);
helper.showRegExSelection(Pkg, pattern);
found = true;
}
if (found == false) {
helper.canNotFindRegEx(pci, Cache, pattern);
pci->setConstructor(UNKNOWN);
return false;
}
if (wasEmpty == false && pci->getConstructor() != UNKNOWN)
pci->setConstructor(UNKNOWN);
@ -239,6 +302,7 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci
if (FromGroup(pci, Cache, str, helper) == false &&
FromTask(pci, Cache, str, helper) == false &&
FromFnmatch(pci, Cache, str, helper) == false &&
FromRegEx(pci, Cache, str, helper) == false)
{
helper.canNotFindPackage(pci, Cache, str);

13
apt-pkg/cacheset.h

@ -131,13 +131,14 @@ public:
virtual bool empty() const = 0;
virtual void clear() = 0;
enum Constructor { UNKNOWN, REGEX, TASK };
enum Constructor { UNKNOWN, REGEX, TASK, FNMATCH };
virtual void setConstructor(Constructor const &con) = 0;
virtual Constructor getConstructor() const = 0;
static bool FromTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static bool FromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper);
static bool FromFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static bool FromGroup(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static bool FromString(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &pattern, CacheSetHelper &helper);
static bool FromCommandLine(PackageContainerInterface * const pci, pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper);
@ -259,6 +260,16 @@ public: /*{{{*/
return FromRegEx(Cache, pattern, helper);
}
static PackageContainer FromFnmatch(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) {
PackageContainer cont(FNMATCH);
PackageContainerInterface::FromFnmatch(&cont, Cache, pattern, helper);
return cont;
}
static PackageContainer FromFnMatch(pkgCacheFile &Cache, std::string const &pattern) {
CacheSetHelper helper;
return FromFnmatch(Cache, pattern, helper);
}
/** \brief returns a package specified by a string
\param Cache the package is in

48
apt-pkg/contrib/cmndline.cc

@ -38,6 +38,42 @@ CommandLine::~CommandLine()
delete [] FileList;
}
/*}}}*/
// CommandLine::GetCommand - return the first non-option word /*{{{*/
char const * CommandLine::GetCommand(Dispatch const * const Map,
unsigned int const argc, char const * const * const argv)
{
// if there is a -- on the line there must be the word we search for around it
// as -- marks the end of the options, just not sure if the command can be
// considered an option or not, so accept both
for (size_t i = 1; i < argc; ++i)
{
if (strcmp(argv[i], "--") != 0)
continue;
++i;
if (i < argc)
for (size_t j = 0; Map[j].Match != NULL; ++j)
if (strcmp(argv[i], Map[j].Match) == 0)
return Map[j].Match;
i -= 2;
if (i != 0)
for (size_t j = 0; Map[j].Match != NULL; ++j)
if (strcmp(argv[i], Map[j].Match) == 0)
return Map[j].Match;
return NULL;
}
// no --, so search for the first word matching a command
// FIXME: How like is it that an option parameter will be also a valid Match ?
for (size_t i = 1; i < argc; ++i)
{
if (*(argv[i]) == '-')
continue;
for (size_t j = 0; Map[j].Match != NULL; ++j)
if (strcmp(argv[i], Map[j].Match) == 0)
return Map[j].Match;
}
return NULL;
}
/*}}}*/
// CommandLine::Parse - Main action member /*{{{*/
// ---------------------------------------------------------------------
/* */
@ -390,3 +426,15 @@ void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * co
_config->Set("CommandLine::AsString", cmdline);
}
/*}}}*/
CommandLine::Args CommandLine::MakeArgs(char ShortOpt, char const *LongOpt, char const *ConfName, unsigned long Flags)/*{{{*/
{
/* In theory, this should be a constructor for CommandLine::Args instead,
but this breaks compatibility as gcc thinks this is a c++11 initializer_list */
CommandLine::Args arg;
arg.ShortOpt = ShortOpt;
arg.LongOpt = LongOpt;
arg.ConfName = ConfName;
arg.Flags = Flags;
return arg;
}
/*}}}*/

6
apt-pkg/contrib/cmndline.h

@ -83,6 +83,12 @@ class CommandLine
unsigned int FileSize() const;
bool DispatchArg(Dispatch *List,bool NoMatch = true);
static char const * GetCommand(Dispatch const * const Map,
unsigned int const argc, char const * const * const argv);
static CommandLine::Args MakeArgs(char ShortOpt, char const *LongOpt,
char const *ConfName, unsigned long Flags);
CommandLine(Args *AList,Configuration *Conf);
~CommandLine();
};

12
apt-pkg/contrib/strutl.cc

@ -1291,6 +1291,18 @@ bool CheckDomainList(const string &Host,const string &List)
return false;
}
/*}}}*/
// strv_length - Return the length of a NULL-terminated string array /*{{{*/
// ---------------------------------------------------------------------
/* */
size_t strv_length(const char **str_array)
{
size_t i;
for (i=0; str_array[i] != NULL; i++)
/* nothing */
;
return i;
}
// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/
// ---------------------------------------------------------------------
/* */

4
apt-pkg/contrib/strutl.h

@ -108,6 +108,10 @@ inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterat
APT_MKSTRCMP2(stringcmp,stringcmp);
APT_MKSTRCMP2(stringcasecmp,stringcasecmp);
// Return the length of a NULL-terminated string array
size_t strv_length(const char **str_array);
inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);};
class URI

309
apt-private/acqprogress.cc

@ -0,0 +1,309 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// $Id: acqprogress.cc,v 1.24 2003/04/27 01:56:48 doogie Exp $
/* ######################################################################
Acquire Progress - Command line progress meter
##################################################################### */
/*}}}*/
// Include files /*{{{*/
#include<config.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <stdio.h>
#include <signal.h>
#include <iostream>
#include <unistd.h>
#include "acqprogress.h"
#include <apti18n.h>
/*}}}*/
using namespace std;
// AcqTextStatus::AcqTextStatus - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet) :
ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet)
{
BlankLine[0] = 0;
}
/*}}}*/
// AcqTextStatus::Start - Downloading has started /*{{{*/
// ---------------------------------------------------------------------
/* */
void AcqTextStatus::Start()
{
pkgAcquireStatus::Start();
BlankLine[0] = 0;
ID = 1;
};
/*}}}*/
// AcqTextStatus::IMSHit - Called when an item got a HIT response /*{{{*/
// ---------------------------------------------------------------------
/* */
void AcqTextStatus::IMSHit(pkgAcquire::ItemDesc &Itm)
{
if (Quiet > 1)
return;
if (Quiet <= 0)
cout << '\r' << BlankLine << '\r';
cout << _("Hit ") << Itm.Description;
if (Itm.Owner->FileSize != 0)
cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
cout << endl;
Update = true;
};
/*}}}*/
// AcqTextStatus::Fetch - An item has started to download /*{{{*/
// ---------------------------------------------------------------------
/* This prints out the short description and the expected size */
void AcqTextStatus::Fetch(pkgAcquire::ItemDesc &Itm)
{
Update = true;
if (Itm.Owner->Complete == true)
return;
Itm.Owner->ID = ID++;
if (Quiet > 1)
return;
if (Quiet <= 0)
cout << '\r' << BlankLine << '\r';
cout << _("Get:") << Itm.Owner->ID << ' ' << Itm.Description;
if (Itm.Owner->FileSize != 0)
cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]";
cout << endl;
};
/*}}}*/
// AcqTextStatus::Done - Completed a download /*{{{*/
// ---------------------------------------------------------------------
/* We don't display anything... */
void AcqTextStatus::Done(pkgAcquire::ItemDesc &Itm)
{
Update = true;
};
/*}}}*/
// AcqTextStatus::Fail - Called when an item fails to download /*{{{*/
// ---------------------------------------------------------------------
/* We print out the error text */
void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm)
{
if (Quiet > 1)
return;
// Ignore certain kinds of transient failures (bad code)
if (Itm.Owner->Status == pkgAcquire::Item::StatIdle)
return;
if (Quiet <= 0)
cout << '\r' << BlankLine << '\r';
if (Itm.Owner->Status == pkgAcquire::Item::StatDone)
{
cout << _("Ign ") << Itm.Description << endl;
}
else
{
cout << _("Err ") << Itm.Description << endl;
cout << " " << Itm.Owner->ErrorText << endl;
}
Update = true;
};
/*}}}*/
// AcqTextStatus::Stop - Finished downloading /*{{{*/
// ---------------------------------------------------------------------
/* This prints out the bytes downloaded and the overall average line
speed */
void AcqTextStatus::Stop()
{
pkgAcquireStatus::Stop();
if (Quiet > 1)
return;
if (Quiet <= 0)
cout << '\r' << BlankLine << '\r' << flush;
if (FetchedBytes != 0 && _error->PendingError() == false)
ioprintf(cout,_("Fetched %sB in %s (%sB/s)\n"),
SizeToStr(FetchedBytes).c_str(),
TimeToStr(ElapsedTime).c_str(),
SizeToStr(CurrentCPS).c_str());
}
/*}}}*/
// AcqTextStatus::Pulse - Regular event pulse /*{{{*/
// ---------------------------------------------------------------------
/* This draws the current progress. Each line has an overall percent
meter and a per active item status meter along with an overall
bandwidth and ETA indicator. */
bool AcqTextStatus::Pulse(pkgAcquire *Owner)
{
pkgAcquireStatus::Pulse(Owner);
if (Quiet > 0)
return true;
enum {Long = 0,Medium,Short} Mode = Medium;
char Buffer[sizeof(BlankLine)];
char *End = Buffer + sizeof(Buffer);
char *S = Buffer;
if (ScreenWidth >= sizeof(Buffer))
ScreenWidth = sizeof(Buffer)-1;
// Put in the percent done
sprintf(S,"%.0f%%",((CurrentBytes + CurrentItems)*100.0)/(TotalBytes+TotalItems));
bool Shown = false;
for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
I = Owner->WorkerStep(I))
{
S += strlen(S);
// There is no item running
if (I->CurrentItem == 0)
{
if (I->Status.empty() == false)
{
snprintf(S,End-S," [%s]",I->Status.c_str());
Shown = true;
}
continue;
}
Shown = true;
// Add in the short description
if (I->CurrentItem->Owner->ID != 0)
snprintf(S,End-S," [%lu %s",I->CurrentItem->Owner->ID,
I->CurrentItem->ShortDesc.c_str());
else
snprintf(S,End-S," [%s",I->CurrentItem->ShortDesc.c_str());
S += strlen(S);
// Show the short mode string
if (I->CurrentItem->Owner->Mode != 0)
{
snprintf(S,End-S," %s",I->CurrentItem->Owner->Mode);
S += strlen(S);
}
// Add the current progress
if (Mode == Long)
snprintf(S,End-S," %llu",I->CurrentSize);
else
{
if (Mode == Medium || I->TotalSize == 0)
snprintf(S,End-S," %sB",SizeToStr(I->CurrentSize).c_str());
}
S += strlen(S);
// Add the total size and percent
if (I->TotalSize > 0 && I->CurrentItem->Owner->Complete == false)
{
if (Mode == Short)
snprintf(S,End-S," %.0f%%",
(I->CurrentSize*100.0)/I->TotalSize);
else
snprintf(S,End-S,"/%sB %.0f%%",SizeToStr(I->TotalSize).c_str(),
(I->CurrentSize*100.0)/I->TotalSize);
}
S += strlen(S);
snprintf(S,End-S,"]");
}
// Show something..
if (Shown == false)
snprintf(S,End-S,_(" [Working]"));
/* Put in the ETA and cps meter, block off signals to prevent strangeness
during resizing */
sigset_t Sigs,OldSigs;
sigemptyset(&Sigs);
sigaddset(&Sigs,SIGWINCH);
sigprocmask(SIG_BLOCK,&Sigs,&OldSigs);
if (CurrentCPS != 0)
{
char Tmp[300];
unsigned long long ETA = (TotalBytes - CurrentBytes)/CurrentCPS;
sprintf(Tmp," %sB/s %s",SizeToStr(CurrentCPS).c_str(),TimeToStr(ETA).c_str());
unsigned int Len = strlen(Buffer);
unsigned int LenT = strlen(Tmp);
if (Len + LenT < ScreenWidth)
{
memset(Buffer + Len,' ',ScreenWidth - Len);
strcpy(Buffer + ScreenWidth - LenT,Tmp);
}
}
Buffer[ScreenWidth] = 0;
BlankLine[ScreenWidth] = 0;
sigprocmask(SIG_SETMASK,&OldSigs,0);
// Draw the current status
if (_config->FindB("Apt::Color", false) == true)
cout << _config->Find("APT::Color::Yellow");
if (strlen(Buffer) == strlen(BlankLine))
cout << '\r' << Buffer << flush;
else
cout << '\r' << BlankLine << '\r' << Buffer << flush;
if (_config->FindB("Apt::Color", false) == true)
cout << _config->Find("APT::Color::Neutral");
memset(BlankLine,' ',strlen(Buffer));
BlankLine[strlen(Buffer)] = 0;
Update = false;
return true;
}
/*}}}*/
// AcqTextStatus::MediaChange - Media need to be swapped /*{{{*/
// ---------------------------------------------------------------------
/* Prompt for a media swap */
bool AcqTextStatus::MediaChange(string Media,string Drive)
{
// If we do not output on a terminal and one of the options to avoid user
// interaction is given, we assume that no user is present who could react
// on your media change request
if (isatty(STDOUT_FILENO) != 1 && Quiet >= 2 &&
(_config->FindB("APT::Get::Assume-Yes",false) == true ||
_config->FindB("APT::Get::Force-Yes",false) == true ||
_config->FindB("APT::Get::Trivial-Only",false) == true))
return false;
if (Quiet <= 0)
cout << '\r' << BlankLine << '\r';
ioprintf(cout,_("Media change: please insert the disc labeled\n"
" '%s'\n"
"in the drive '%s' and press enter\n"),
Media.c_str(),Drive.c_str());
char C = 0;
bool bStatus = true;
while (C != '\n' && C != '\r')
{
int len = read(STDIN_FILENO,&C,1);
if(C == 'c' || len <= 0)
bStatus = false;
}
if(bStatus)
Update = true;
return bStatus;
}
/*}}}*/

38
apt-private/acqprogress.h

@ -0,0 +1,38 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################
Acquire Progress - Command line progress meter
##################################################################### */
/*}}}*/
#ifndef ACQPROGRESS_H
#define ACQPROGRESS_H
#include <apt-pkg/acquire.h>
#include <string>
class AcqTextStatus : public pkgAcquireStatus
{
unsigned int &ScreenWidth;
char BlankLine[1024];
unsigned long ID;
unsigned long Quiet;
public:
virtual bool MediaChange(std::string Media,std::string Drive);
virtual void IMSHit(pkgAcquire::ItemDesc &Itm);
virtual void Fetch(pkgAcquire::ItemDesc &Itm);
virtual void Done(pkgAcquire::ItemDesc &Itm);
virtual void Fail(pkgAcquire::ItemDesc &Itm);
virtual void Start();
virtual void Stop();
bool Pulse(pkgAcquire *Owner);
AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
};
#endif

28
apt-private/makefile

@ -0,0 +1,28 @@
# -*- make -*-
BASE=..
SUBDIR=apt-private
# Header location
HEADER_TARGETDIRS = apt-private
# Bring in the default rules
include ../buildlib/defaults.mak
# The library name and version (indirectly used from init.h)
include ../buildlib/libversion.mak
# The library name
LIBRARY=apt-private
MAJOR=0.0
MINOR=0
SLIBS=$(PTHREADLIB) -lapt-pkg
PRIVATES=list install output cachefile cacheset update upgrade cmndline moo search show main
SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc)
HEADERS += $(foreach private, $(PRIVATES), private-$(private).h)
SOURCE+= acqprogress.cc
HEADERS+= acqprogress.h private-cacheset.h
HEADERS := $(addprefix apt-private/,$(HEADERS))
include $(LIBRARY_H)

109
apt-private/private-cachefile.cc

@ -0,0 +1,109 @@
// Include files /*{{{*/
#include<config.h>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/error.h>
#include <cstdlib>
#include "private-output.h"
#include "private-cachefile.h"
#include <apti18n.h>
/*}}}*/
using namespace std;
// CacheFile::NameComp - QSort compare by name /*{{{*/
// ---------------------------------------------------------------------
/* */
pkgCache *CacheFile::SortCache = 0;
int CacheFile::NameComp(const void *a,const void *b)
{
if (*(pkgCache::Package **)a == 0 || *(pkgCache::Package **)b == 0)
return *(pkgCache::Package **)a - *(pkgCache::Package **)b;
const pkgCache::Package &A = **(pkgCache::Package **)a;
const pkgCache::Package &B = **(pkgCache::Package **)b;
return strcmp(SortCache->StrP + A.Name,SortCache->StrP + B.Name);
}
/*}}}*/
// CacheFile::Sort - Sort by name /*{{{*/
// ---------------------------------------------------------------------
/* */
void CacheFile::Sort()
{
delete [] List;
List = new pkgCache::Package *[Cache->Head().PackageCount];
memset(List,0,sizeof(*List)*Cache->Head().PackageCount);
pkgCache::PkgIterator I = Cache->PkgBegin();
for (;I.end() != true; ++I)
List[I->ID] = I;
SortCache = *this;
qsort(List,Cache->Head().PackageCount,sizeof(*List),NameComp);
}
/*}}}*/
// CacheFile::CheckDeps - Open the cache file /*{{{*/
// ---------------------------------------------------------------------
/* This routine generates the caches and then opens the dependency cache
and verifies that the system is OK. */
bool CacheFile::CheckDeps(bool AllowBroken)
{
bool FixBroken = _config->FindB("APT::Get::Fix-Broken",false);
if (_error->PendingError() == true)
return false;
// Check that the system is OK
if (DCache->DelCount() != 0 || DCache->InstCount() != 0)
return _error->Error("Internal error, non-zero counts");
// Apply corrections for half-installed packages
if (pkgApplyStatus(*DCache) == false)
return false;
if (_config->FindB("APT::Get::Fix-Policy-Broken",false) == true)
{
FixBroken = true;
if ((DCache->PolicyBrokenCount() > 0))
{
// upgrade all policy-broken packages with ForceImportantDeps=True
for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); ++I)
if ((*DCache)[I].NowPolicyBroken() == true)
DCache->MarkInstall(I,true,0, false, true);
}
}
// Nothing is broken
if (DCache->BrokenCount() == 0 || AllowBroken == true)
return true;
// Attempt to fix broken things
if (FixBroken == true)
{
c1out << _("Correcting dependencies...") << flush;
if (pkgFixBroken(*DCache) == false || DCache->BrokenCount() != 0)
{
c1out << _(" failed.") << endl;
ShowBroken(c1out,*this,true);
return _error->Error(_("Unable to correct dependencies"));
}
if (pkgMinimizeUpgrade(*DCache) == false)
return _error->Error(_("Unable to minimize the upgrade set"));
c1out << _(" Done") << endl;
}
else
{
c1out << _("You might want to run 'apt-get -f install' to correct these.") << endl;
ShowBroken(c1out,*this,true);
return _error->Error(_("Unmet dependencies. Try using -f."));
}
return true;
}
/*}}}*/

51
apt-private/private-cachefile.h

@ -0,0 +1,51 @@
#ifndef APT_PRIVATE_CACHEFILE_H
#define APT_PRIVATE_CACHEFILE_H
#include <apt-pkg/cachefile.h>
#include <apt-pkg/progress.h>
// class CacheFile - Cover class for some dependency cache functions /*{{{*/
// ---------------------------------------------------------------------
/* */
class CacheFile : public pkgCacheFile
{
static pkgCache *SortCache;
static int NameComp(const void *a,const void *b);
public:
pkgCache::Package **List;
void Sort();
bool CheckDeps(bool AllowBroken = false);
bool BuildCaches(bool WithLock = true)
{
OpTextProgress Prog(*_config);
if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false)
return false;
return true;
}
bool Open(bool WithLock = true)
{
OpTextProgress Prog(*_config);
if (pkgCacheFile::Open(&Prog,WithLock) == false)
return false;
Sort();
return true;
};
bool OpenForInstall()
{
if (_config->FindB("APT::Get::Print-URIs") == true)
return Open(false);
else
return Open(true);
}
CacheFile() : List(0) {};
~CacheFile() {
delete[] List;
}
};
/*}}}*/
#endif

63
apt-private/private-cacheset.cc

@ -0,0 +1,63 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/strutl.h>
#include "private-cacheset.h"
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
LocalitySortedVersionSet &output_set,
OpProgress &progress)
{
Matcher null_matcher = Matcher();
return GetLocalitySortedVersionSet(CacheFile, output_set,
null_matcher, progress);
}
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
LocalitySortedVersionSet &output_set,
Matcher &matcher,
OpProgress &progress)
{
pkgCache *Cache = CacheFile.GetPkgCache();
pkgDepCache *DepCache = CacheFile.GetDepCache();
int Done=0;
progress.SubProgress(Cache->Head().PackageCount, _("Sorting"));
for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
{
if (Done%500 == 0)
progress.Progress(Done);
Done++;
if ((matcher)(P) == false)
continue;
// exclude virtual pkgs
if (P.VersionList() == 0)
continue;
pkgDepCache::StateCache &state = (*DepCache)[P];
if (_config->FindB("APT::Cmd::Installed") == true)
{
if (P.CurrentVer() != NULL)
{
output_set.insert(P.CurrentVer());
}
}
else if (_config->FindB("APT::Cmd::Upgradable") == true)
{
if(P.CurrentVer() && state.Upgradable())
{
pkgPolicy *policy = CacheFile.GetPolicy();
output_set.insert(policy->GetCandidateVer(P));
}
}
else
{
pkgPolicy *policy = CacheFile.GetPolicy();
output_set.insert(policy->GetCandidateVer(P));
}
}
progress.Done();
return true;
}

265
apt-private/private-cacheset.h

@ -0,0 +1,265 @@
#ifndef APT_PRIVATE_CACHESET_H
#define APT_PRIVATE_CACHESET_H
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/sptr.h>
#include <algorithm>
#include <vector>
#include "private-output.h"
#include <apti18n.h>
struct VersionSortDescriptionLocality
{
bool operator () (const pkgCache::VerIterator &v_lhs,
const pkgCache::VerIterator &v_rhs)
{
pkgCache::DescFile *A = v_lhs.TranslatedDescription().FileList();
pkgCache::DescFile *B = v_rhs.TranslatedDescription().FileList();
if (A == 0 && B == 0)
return false;
if (A == 0)
return true;
if (B == 0)
return false;
if (A->File == B->File)
return A->Offset < B->Offset;
return A->File < B->File;
}
};
// sorted by locality which makes iterating much faster
typedef APT::VersionContainer<
std::set<pkgCache::VerIterator,
VersionSortDescriptionLocality> > LocalitySortedVersionSet;
class Matcher {
public:
virtual bool operator () (const pkgCache::PkgIterator &P) {
return true;};
};
// FIXME: add default argument for OpProgress (or overloaded function)
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
LocalitySortedVersionSet &output_set,
Matcher &matcher,
OpProgress &progress);
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
LocalitySortedVersionSet &output_set,
OpProgress &progress);
// CacheSetHelper saving virtual packages /*{{{*/
class CacheSetHelperVirtuals: public APT::CacheSetHelper {
public:
APT::PackageSet virtualPkgs;
virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
virtualPkgs.insert(Pkg);
return CacheSetHelper::canNotFindCandidateVer(Cache, Pkg);
}
virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
virtualPkgs.insert(Pkg);
return CacheSetHelper::canNotFindNewestVer(Cache, Pkg);
}
virtual void canNotFindAllVer(APT::VersionContainerInterface * vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
virtualPkgs.insert(Pkg);
CacheSetHelper::canNotFindAllVer(vci, Cache, Pkg);
}
CacheSetHelperVirtuals(bool const ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE) : CacheSetHelper(ShowErrors, ErrorType) {}
};
/*}}}*/
// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
class CacheSetHelperAPTGet : public APT::CacheSetHelper {
/** \brief stream message should be printed to */
std::ostream &out;
/** \brief were things like Task or RegEx used to select packages? */
bool explicitlyNamed;
APT::PackageSet virtualPkgs;
public:
std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
CacheSetHelperAPTGet(std::ostream &out) : APT::CacheSetHelper(true), out(out) {
explicitlyNamed = true;
}
virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
ioprintf(out, _("Note, selecting '%s' for task '%s'\n"),
Pkg.FullName(true).c_str(), pattern.c_str());
explicitlyNamed = false;
}
virtual void showRegExSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
ioprintf(out, _("Note, selecting '%s' for regex '%s'\n"),
Pkg.FullName(true).c_str(), pattern.c_str());
explicitlyNamed = false;
}
virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver,
std::string const &ver, bool const verIsRel) {
if (ver == Ver.VerStr())
return;
selectedByRelease.push_back(make_pair(Ver, ver));
}
bool showVirtualPackageErrors(pkgCacheFile &Cache) {
if (virtualPkgs.empty() == true)
return true;
for (APT::PackageSet::const_iterator Pkg = virtualPkgs.begin();
Pkg != virtualPkgs.end(); ++Pkg) {
if (Pkg->ProvidesList != 0) {
ioprintf(c1out,_("Package %s is a virtual package provided by:\n"),
Pkg.FullName(true).c_str());
pkgCache::PrvIterator I = Pkg.ProvidesList();
unsigned short provider = 0;
for (; I.end() == false; ++I) {
pkgCache::PkgIterator Pkg = I.OwnerPkg();
if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) {
c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr();
if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false)
c1out << _(" [Installed]");
c1out << std::endl;
++provider;
}
}
// if we found no candidate which provide this package, show non-candidates
if (provider == 0)
for (I = Pkg.ProvidesList(); I.end() == false; ++I)
c1out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr()
<< _(" [Not candidate version]") << std::endl;
else
out << _("You should explicitly select one to install.") << std::endl;
} else {
ioprintf(c1out,
_("Package %s is not available, but is referred to by another package.\n"
"This may mean that the package is missing, has been obsoleted, or\n"
"is only available from another source\n"),Pkg.FullName(true).c_str());
std::string List;
std::string VersionsList;
SPtrArray<bool> Seen = new bool[Cache.GetPkgCache()->Head().PackageCount];
memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen));
for (pkgCache::DepIterator Dep = Pkg.RevDependsList();
Dep.end() == false; ++Dep) {
if (Dep->Type != pkgCache::Dep::Replaces)
continue;
if (Seen[Dep.ParentPkg()->ID] == true)
continue;
Seen[Dep.ParentPkg()->ID] = true;
List += Dep.ParentPkg().FullName(true) + " ";
//VersionsList += std::string(Dep.ParentPkg().CurVersion) + "\n"; ???
}
ShowList(c1out,_("However the following packages replace it:"),List,VersionsList);
}
c1out << std::endl;
}
return false;
}
virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::CANDIDATE);
if (verset.empty() == false)
return *(verset.begin());
else if (ShowError == true) {
_error->Error(_("Package '%s' has no installation candidate"),Pkg.FullName(true).c_str());
virtualPkgs.insert(Pkg);
}
return pkgCache::VerIterator(Cache, 0);
}
virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
if (Pkg->ProvidesList != 0)
{
APT::VersionSet const verset = tryVirtualPackage(Cache, Pkg, APT::VersionSet::NEWEST);
if (verset.empty() == false)
return *(verset.begin());
if (ShowError == true)
ioprintf(out, _("Virtual packages like '%s' can't be removed\n"), Pkg.FullName(true).c_str());
}
else
{
pkgCache::GrpIterator Grp = Pkg.Group();
pkgCache::PkgIterator P = Grp.PackageList();
for (; P.end() != true; P = Grp.NextPkg(P))
{
if (P == Pkg)
continue;
if (P->CurrentVer != 0) {
// TRANSLATORS: Note, this is not an interactive question
ioprintf(c1out,_("Package '%s' is not installed, so not removed. Did you mean '%s'?\n"),
Pkg.FullName(true).c_str(), P.FullName(true).c_str());
break;
}
}
if (P.end() == true)
ioprintf(c1out,_("Package '%s' is not installed, so not removed\n"),Pkg.FullName(true).c_str());
}
return pkgCache::VerIterator(Cache, 0);
}
APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg,
APT::VersionSet::Version const &select) {
/* This is a pure virtual package and there is a single available
candidate providing it. */
if (unlikely(Cache[Pkg].CandidateVer != 0) || Pkg->ProvidesList == 0)
return APT::VersionSet();
pkgCache::PkgIterator Prov;
bool found_one = false;
for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; ++P) {
pkgCache::VerIterator const PVer = P.OwnerVer();
pkgCache::PkgIterator const PPkg = PVer.ParentPkg();
/* Ignore versions that are not a candidate. */
if (Cache[PPkg].CandidateVer != PVer)
continue;
if (found_one == false) {
Prov = PPkg;
found_one = true;
} else if (PPkg != Prov) {
// same group, so it's a foreign package
if (PPkg->Group == Prov->Group) {
// do we already have the requested arch?
if (strcmp(Pkg.Arch(), Prov.Arch()) == 0 ||
strcmp(Prov.Arch(), "all") == 0 ||
unlikely(strcmp(PPkg.Arch(), Prov.Arch()) == 0)) // packages have only on candidate, but just to be sure
continue;
// see which architecture we prefer more and switch to it
std::vector<std::string> archs = APT::Configuration::getArchitectures();
if (std::find(archs.begin(), archs.end(), PPkg.Arch()) < std::find(archs.begin(), archs.end(), Prov.Arch()))
Prov = PPkg;
continue;
}
found_one = false; // we found at least two
break;
}
}
if (found_one == true) {
ioprintf(out, _("Note, selecting '%s' instead of '%s'\n"),
Prov.FullName(true).c_str(), Pkg.FullName(true).c_str());
return APT::VersionSet::FromPackage(Cache, Prov, select, *this);
}
return APT::VersionSet();
}
inline bool allPkgNamedExplicitly() const { return explicitlyNamed; }
};
/*}}}*/
#endif

268
apt-private/private-cmndline.cc

@ -0,0 +1,268 @@
// Include Files /*{{{*/
#include <config.h>
#include <apt-pkg/cmndline.h>
#include <apt-pkg/configuration.h>
#include <vector>
#include <stdarg.h>
#include <string.h>
#include "private-cmndline.h"
#include <apti18n.h>
/*}}}*/
bool strcmp_match_in_list(char const * const Cmd, ...) /*{{{*/
{
va_list args;
bool found = false;
va_start(args, Cmd);
char const * Match = NULL;
while ((Match = va_arg(args, char const *)) != NULL)
{
if (strcmp(Cmd, Match) != 0)
continue;
found = true;
break;
}
va_end(args);
return found;
}
/*}}}*/
#define addArg(w,x,y,z) Args.push_back(CommandLine::MakeArgs(w,x,y,z))
#define CmdMatches(...) strcmp_match_in_list(Cmd, __VA_ARGS__, NULL)
bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("depends", "rdepends", "xvcg", "dotty"))
{
addArg('i', "important", "APT::Cache::Important", 0);
addArg(0, "installed", "APT::Cache::Installed", 0);
addArg(0, "pre-depends", "APT::Cache::ShowPre-Depends", 0);
addArg(0, "depends", "APT::Cache::ShowDepends", 0);
addArg(0, "recommends", "APT::Cache::ShowRecommends", 0);
addArg(0, "suggests", "APT::Cache::ShowSuggests", 0);
addArg(0, "replaces", "APT::Cache::ShowReplaces", 0);
addArg(0, "breaks", "APT::Cache::ShowBreaks", 0);
addArg(0, "conflicts", "APT::Cache::ShowConflicts", 0);
addArg(0, "enhances", "APT::Cache::ShowEnhances", 0);
addArg(0, "recurse", "APT::Cache::RecurseDepends", 0);
}
else if (CmdMatches("search"))
{
addArg('n', "names-only", "APT::Cache::NamesOnly", 0);
addArg('f', "full", "APT::Cache::ShowFull", 0);
}
else if (CmdMatches("show"))
{
addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
}
else if (CmdMatches("pkgnames"))
{
addArg(0, "all-names", "APT::Cache::AllNames", 0);
}
else if (CmdMatches("gencaches", "showsrc", "showpkg", "stats", "dump",
"dumpavail", "unmet", "showauto", "policy", "madison"))
;
else
return false;
// FIXME: move to the correct command(s)
addArg('g', "generate", "APT::Cache::Generate", 0);
addArg('t', "target-release", "APT::Default-Release", CommandLine::HasArg);
addArg('t', "default-release", "APT::Default-Release", CommandLine::HasArg);
addArg('p', "pkg-cache", "Dir::Cache::pkgcache", CommandLine::HasArg);
addArg('s', "src-cache", "Dir::Cache::srcpkgcache", CommandLine::HasArg);
return true;
}
/*}}}*/
bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("add", "ident") == false)
return false;
// FIXME: move to the correct command(s)
addArg(0, "auto-detect", "Acquire::cdrom::AutoDetect", CommandLine::Boolean);
addArg('d', "cdrom", "Acquire::cdrom::mount", CommandLine::HasArg);
addArg('r', "rename", "APT::CDROM::Rename", 0);
addArg('m', "no-mount", "APT::CDROM::NoMount", 0);
addArg('f', "fast", "APT::CDROM::Fast", 0);
addArg('n', "just-print", "APT::CDROM::NoAct", 0);
addArg('n', "recon", "APT::CDROM::NoAct", 0);
addArg('n', "no-act", "APT::CDROM::NoAct", 0);
addArg('a', "thorough", "APT::CDROM::Thorough", 0);
return true;
}
/*}}}*/
bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("dump"))
{
addArg(0,"empty","APT::Config::Dump::EmptyValue",CommandLine::Boolean);
addArg(0,"format","APT::Config::Dump::Format",CommandLine::HasArg);
}
else if (CmdMatches("shell"))
;
else
return false;
return true;
}
/*}}}*/
bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
"deselect-upgrade", "autoremove"))
{
addArg(0, "dpkg-progress", "DpkgPM::Progress", 0);
addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
addArg(0, "purge", "APT::Get::Purge", 0);
addArg('V',"verbose-versions","APT::Get::Show-Versions",0);
addArg(0, "auto-remove", "APT::Get::AutomaticRemove", 0);
addArg(0, "reinstall", "APT::Get::ReInstall", 0);
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
if (CmdMatches("upgrade"))
{
addArg(0, "allow-new", "APT::Get::UpgradeAllowNew", 0);
}
}
else if (CmdMatches("update"))
{
addArg(0, "list-cleanup", "APT::Get::List-Cleanup", 0);
}
else if (CmdMatches("source"))
{
addArg('b', "compile", "APT::Get::Compile", 0);
addArg('b', "build", "APT::Get::Compile", 0);
addArg(0, "diff-only", "APT::Get::Diff-Only", 0);
addArg(0, "debian-only", "APT::Get::Diff-Only", 0);
addArg(0, "tar-only", "APT::Get::Tar-Only", 0);
addArg(0, "dsc-only", "APT::Get::Dsc-Only", 0);
}
else if (CmdMatches("build-dep"))
{
addArg('a', "host-architecture", "APT::Get::Host-Architecture", CommandLine::HasArg);
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
}
else if (CmdMatches("clean", "autoclean", "check", "download", "changelog") ||
CmdMatches("markauto", "unmarkauto")) // deprecated commands
;
<