summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/acqprogress.cc76
-rw-r--r--apt-private/acqprogress.h11
-rw-r--r--apt-private/makefile1
-rw-r--r--apt-private/private-cachefile.cc12
-rw-r--r--apt-private/private-cachefile.h9
-rw-r--r--apt-private/private-cacheset.cc22
-rw-r--r--apt-private/private-cacheset.h28
-rw-r--r--apt-private/private-cmndline.cc27
-rw-r--r--apt-private/private-cmndline.h3
-rw-r--r--apt-private/private-download.cc5
-rw-r--r--apt-private/private-download.h8
-rw-r--r--apt-private/private-install.cc72
-rw-r--r--apt-private/private-install.h26
-rw-r--r--apt-private/private-list.cc69
-rw-r--r--apt-private/private-list.h6
-rw-r--r--apt-private/private-main.cc12
-rw-r--r--apt-private/private-main.h5
-rw-r--r--apt-private/private-moo.cc38
-rw-r--r--apt-private/private-moo.h2
-rw-r--r--apt-private/private-output.cc94
-rw-r--r--apt-private/private-output.h26
-rw-r--r--apt-private/private-search.cc54
-rw-r--r--apt-private/private-search.h6
-rw-r--r--apt-private/private-show.cc127
-rw-r--r--apt-private/private-show.h6
-rw-r--r--apt-private/private-sources.cc26
-rw-r--r--apt-private/private-sources.h11
-rw-r--r--apt-private/private-update.cc38
-rw-r--r--apt-private/private-update.h4
-rw-r--r--apt-private/private-upgrade.cc25
-rw-r--r--apt-private/private-upgrade.h7
-rw-r--r--apt-private/private-utils.cc8
-rw-r--r--apt-private/private-utils.h8
33 files changed, 516 insertions, 356 deletions
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index af2d0f461..fe7a45e12 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -10,18 +10,21 @@
// Include files /*{{{*/
#include<config.h>
+#include <apt-pkg/acquire.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 <apt-private/acqprogress.h>
+
+#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <iostream>
#include <unistd.h>
-#include "acqprogress.h"
#include <apti18n.h>
/*}}}*/
@@ -30,21 +33,24 @@ using namespace std;
// AcqTextStatus::AcqTextStatus - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet) :
- ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet)
+AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int const Quiet) :
+ pkgAcquireStatus(), ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet)
{
BlankLine[0] = 0;
+ // testcases use it to disable pulses without disabling other user messages
+ if (Quiet == 0 && _config->FindB("quiet::NoUpdate", false) == true)
+ this->Quiet = 1;
}
/*}}}*/
// AcqTextStatus::Start - Downloading has started /*{{{*/
// ---------------------------------------------------------------------
/* */
-void AcqTextStatus::Start()
+void AcqTextStatus::Start()
{
- pkgAcquireStatus::Start();
+ pkgAcquireStatus::Start();
BlankLine[0] = 0;
ID = 1;
-};
+}
/*}}}*/
// AcqTextStatus::IMSHit - Called when an item got a HIT response /*{{{*/
// ---------------------------------------------------------------------
@@ -55,14 +61,14 @@ void AcqTextStatus::IMSHit(pkgAcquire::ItemDesc &Itm)
return;
if (Quiet <= 0)
- cout << '\r' << BlankLine << '\r';
-
+ 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 /*{{{*/
// ---------------------------------------------------------------------
@@ -72,28 +78,28 @@ 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)
+void AcqTextStatus::Done(pkgAcquire::ItemDesc &/*Itm*/)
{
Update = true;
-};
+}
/*}}}*/
// AcqTextStatus::Fail - Called when an item fails to download /*{{{*/
// ---------------------------------------------------------------------
@@ -106,10 +112,10 @@ void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm)
// 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;
@@ -119,9 +125,9 @@ void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm)
cout << _("Err ") << Itm.Description << endl;
cout << " " << Itm.Owner->ErrorText << endl;
}
-
+
Update = true;
-};
+}
/*}}}*/
// AcqTextStatus::Stop - Finished downloading /*{{{*/
// ---------------------------------------------------------------------
@@ -151,12 +157,12 @@ void AcqTextStatus::Stop()
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;
@@ -171,8 +177,8 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
I = Owner->WorkerStep(I))
{
S += strlen(S);
-
- // There is no item running
+
+ // There is no item running
if (I->CurrentItem == 0)
{
if (I->Status.empty() == false)
@@ -180,12 +186,12 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
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,
@@ -200,7 +206,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
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);
@@ -210,7 +216,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
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)
{
@@ -220,7 +226,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
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,"]");
}
@@ -228,26 +234,26 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
// 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;
@@ -265,7 +271,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
memset(BlankLine,' ',strlen(Buffer));
BlankLine[strlen(Buffer)] = 0;
-
+
Update = false;
return true;
diff --git a/apt-private/acqprogress.h b/apt-private/acqprogress.h
index e47bfb72d..71a10d78a 100644
--- a/apt-private/acqprogress.h
+++ b/apt-private/acqprogress.h
@@ -10,18 +10,19 @@
#define ACQPROGRESS_H
#include <apt-pkg/acquire.h>
+#include <apt-pkg/macros.h>
#include <string>
-class AcqTextStatus : public pkgAcquireStatus
+class APT_PUBLIC 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);
@@ -29,10 +30,10 @@ class AcqTextStatus : public pkgAcquireStatus
virtual void Fail(pkgAcquire::ItemDesc &Itm);
virtual void Start();
virtual void Stop();
-
+
bool Pulse(pkgAcquire *Owner);
- AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet);
+ AcqTextStatus(unsigned int &ScreenWidth,unsigned int const Quiet);
};
#endif
diff --git a/apt-private/makefile b/apt-private/makefile
index 728890b9b..09736c6d3 100644
--- a/apt-private/makefile
+++ b/apt-private/makefile
@@ -16,6 +16,7 @@ LIBRARY=apt-private
MAJOR=0.0
MINOR=0
SLIBS=$(PTHREADLIB) -lapt-pkg
+CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main utils sources
SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc)
diff --git a/apt-private/private-cachefile.cc b/apt-private/private-cachefile.cc
index c822b9bad..5e955ac39 100644
--- a/apt-private/private-cachefile.cc
+++ b/apt-private/private-cachefile.cc
@@ -4,11 +4,17 @@
#include <apt-pkg/algorithms.h>
#include <apt-pkg/upgrade.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
-#include <cstdlib>
+#include <apt-private/private-output.h>
+#include <apt-private/private-cachefile.h>
-#include "private-output.h"
-#include "private-cachefile.h"
+#include <string.h>
+#include <ostream>
+#include <cstdlib>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-private/private-cachefile.h b/apt-private/private-cachefile.h
index f24d93020..dce7e0a3a 100644
--- a/apt-private/private-cachefile.h
+++ b/apt-private/private-cachefile.h
@@ -3,16 +3,19 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/progress.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
// class CacheFile - Cover class for some dependency cache functions /*{{{*/
// ---------------------------------------------------------------------
/* */
-class CacheFile : public pkgCacheFile
+class APT_PUBLIC CacheFile : public pkgCacheFile
{
static pkgCache *SortCache;
- static int NameComp(const void *a,const void *b);
-
+ APT_HIDDEN static int NameComp(const void *a,const void *b) APT_PURE;
+
public:
pkgCache::Package **List;
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index 6fb224010..4a63c7e81 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -1,9 +1,18 @@
+#include <config.h>
+
#include <apt-pkg/cachefile.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/depcache.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/policy.h>
+
+#include <apt-private/private-cacheset.h>
+
+#include <stddef.h>
-#include "private-cacheset.h"
+#include <apti18n.h>
bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
LocalitySortedVersionSet &output_set,
@@ -52,6 +61,15 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
output_set.insert(policy->GetCandidateVer(P));
}
}
+ else if (_config->FindB("APT::Cmd::Manual-Installed") == true)
+ {
+ if (P.CurrentVer() &&
+ ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false)
+ {
+ pkgPolicy *policy = CacheFile.GetPolicy();
+ output_set.insert(policy->GetCandidateVer(P));
+ }
+ }
else
{
pkgPolicy *policy = CacheFile.GetPolicy();
diff --git a/apt-private/private-cacheset.h b/apt-private/private-cacheset.h
index 15b531e9d..854d16922 100644
--- a/apt-private/private-cacheset.h
+++ b/apt-private/private-cacheset.h
@@ -1,17 +1,32 @@
#ifndef APT_PRIVATE_CACHESET_H
#define APT_PRIVATE_CACHESET_H
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/sptr.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/macros.h>
#include <algorithm>
#include <vector>
+#include <string.h>
+#include <list>
+#include <ostream>
+#include <set>
+#include <string>
+#include <utility>
#include "private-output.h"
#include <apti18n.h>
+class OpProgress;
+
struct VersionSortDescriptionLocality
{
bool operator () (const pkgCache::VerIterator &v_lhs,
@@ -42,8 +57,8 @@ typedef APT::VersionContainer<
class Matcher {
public:
- virtual bool operator () (const pkgCache::PkgIterator &P) {
- return true;};
+ virtual bool operator () (const pkgCache::PkgIterator &/*P*/) {
+ return true;}
};
// FIXME: add default argument for OpProgress (or overloaded function)
@@ -101,13 +116,18 @@ public:
Pkg.FullName(true).c_str(), pattern.c_str());
explicitlyNamed = false;
}
+ virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) {
+ ioprintf(out, _("Note, selecting '%s' for glob '%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) {
+ 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));
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 28309af07..682be0a19 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -2,19 +2,17 @@
#include <config.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/configuration.h>
-#include <vector>
+#include <apt-private/private-cmndline.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, ...) /*{{{*/
+APT_SENTINEL static bool strcmp_match_in_list(char const * const Cmd, ...) /*{{{*/
{
va_list args;
bool found = false;
@@ -33,7 +31,7 @@ bool strcmp_match_in_list(char const * const Cmd, ...) /*{{{*/
/*}}}*/
#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)/*{{{*/
+static bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("depends", "rdepends", "xvcg", "dotty"))
{
@@ -82,7 +80,7 @@ bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * con
return true;
}
/*}}}*/
-bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("add", "ident") == false)
return false;
@@ -100,7 +98,7 @@ bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * con
return true;
}
/*}}}*/
-bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("dump"))
{
@@ -115,7 +113,7 @@ bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * co
return true;
}
/*}}}*/
-bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
"dselect-upgrade", "autoremove"))
@@ -141,6 +139,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
{
addArg('b', "compile", "APT::Get::Compile", 0);
addArg('b', "build", "APT::Get::Compile", 0);
+ addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
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);
@@ -149,6 +148,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
else if (CmdMatches("build-dep"))
{
addArg('a', "host-architecture", "APT::Get::Host-Architecture", CommandLine::HasArg);
+ addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
addArg(0, "purge", "APT::Get::Purge", 0);
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
// this has no effect *but* sbuild is using it (see LP: #1255806)
@@ -200,7 +200,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
return true;
}
/*}}}*/
-bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("auto", "manual", "hold", "unhold", "showauto",
"showmanual", "showhold", "showholds", "install",
@@ -220,15 +220,20 @@ bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * cons
return true;
}
/*}}}*/
-bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
{
if (CmdMatches("list"))
{
addArg(0,"installed","APT::Cmd::Installed",0);
addArg(0,"upgradable","APT::Cmd::Upgradable",0);
+ addArg(0,"manual-installed","APT::Cmd::Manual-Installed",0);
addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
addArg('a', "all-versions", "APT::Cmd::All-Versions", 0);
}
+ else if (CmdMatches("show"))
+ {
+ addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
+ }
else if (addArgumentsAPTGet(Args, Cmd) || addArgumentsAPTCache(Args, Cmd))
{
// we have no (supported) command-name overlaps so far, so we call
diff --git a/apt-private/private-cmndline.h b/apt-private/private-cmndline.h
index 76045ffe7..d0af16782 100644
--- a/apt-private/private-cmndline.h
+++ b/apt-private/private-cmndline.h
@@ -2,9 +2,10 @@
#define APT_PRIVATE_CMNDLINE_H
#include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
#include <vector>
-std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char const * const Cmd);
+APT_PUBLIC std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char const * const Cmd);
#endif
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc
index f02991cde..a095f0c67 100644
--- a/apt-private/private-download.cc
+++ b/apt-private/private-download.cc
@@ -7,9 +7,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
-#include "private-output.h"
-
-#include <locale.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-download.h>
#include <fstream>
#include <string>
diff --git a/apt-private/private-download.h b/apt-private/private-download.h
index b8cc8da1e..a108aa531 100644
--- a/apt-private/private-download.h
+++ b/apt-private/private-download.h
@@ -1,9 +1,11 @@
#ifndef APT_PRIVATE_DOWNLOAD_H
#define APT_PRIVATE_DOWNLOAD_H
-#include <apt-pkg/acquire.h>
+#include <apt-pkg/macros.h>
-bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
-bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure);
+class pkgAcquire;
+
+APT_PUBLIC bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
+APT_PUBLIC bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure);
#endif
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 3adb00b23..107ed398e 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -1,57 +1,45 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/cmndline.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/depcache.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/algorithms.h>
+#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/clean.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
+#include <apt-pkg/algorithms.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/md5.h>
-#include <apt-pkg/versionmatch.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/install-progress.h>
-#include <apt-pkg/init.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/sptr.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
-#include <set>
-#include <locale.h>
-#include <langinfo.h>
-#include <fstream>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
-#include <signal.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <regex.h>
-#include <sys/wait.h>
-#include <sstream>
+#include <algorithm>
+#include <iostream>
+#include <set>
+#include <vector>
-#include "private-install.h"
-#include "private-download.h"
-#include "private-cachefile.h"
-#include "private-output.h"
-#include "private-cacheset.h"
-#include "acqprogress.h"
+#include <apt-private/acqprogress.h>
+#include <apt-private/private-install.h>
+#include <apt-private/private-cachefile.h>
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-download.h>
+#include <apt-private/private-output.h>
#include <apti18n.h>
/*}}}*/
+class pkgSourceList;
// InstallPackages - Actually download and install the packages /*{{{*/
// ---------------------------------------------------------------------
@@ -156,7 +144,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
if (DebBytes != Cache->DebSize())
{
c0out << DebBytes << ',' << Cache->DebSize() << std::endl;
- c0out << _("How odd.. The sizes didn't match, email apt@packages.debian.org") << std::endl;
+ c0out << _("How odd... The sizes didn't match, email apt@packages.debian.org") << std::endl;
}
// Number of bytes
@@ -386,7 +374,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
// DoAutomaticRemove - Remove all automatic unused packages /*{{{*/
// ---------------------------------------------------------------------
/* Remove unused automatic packages */
-bool DoAutomaticRemove(CacheFile &Cache)
+static bool DoAutomaticRemove(CacheFile &Cache)
{
bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
diff --git a/apt-private/private-install.h b/apt-private/private-install.h
index 2187146d3..5e18560c5 100644
--- a/apt-private/private-install.h
+++ b/apt-private/private-install.h
@@ -1,24 +1,40 @@
#ifndef APT_PRIVATE_INSTALL_H
#define APT_PRIVATE_INSTALL_H
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/cmndline.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/algorithms.h>
+#include <apt-pkg/macros.h>
+
+#include <apt-private/private-output.h>
+
+#include <stddef.h>
+#include <iosfwd>
+#include <list>
+#include <map>
+#include <string>
+#include <utility>
-#include "private-cachefile.h"
-#include "private-output.h"
#include <apti18n.h>
+class CacheFile;
+class CommandLine;
+
#define RAMFS_MAGIC 0x858458f6
-bool DoInstall(CommandLine &Cmd);
+APT_PUBLIC bool DoInstall(CommandLine &Cmd);
bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
std::map<unsigned short, APT::VersionSet> &verset);
bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache);
-bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
+APT_PUBLIC bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
bool Safety = true);
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index a02ebf02d..7664ca134 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -1,43 +1,28 @@
// Include Files /*{{{*/
#include <config.h>
-#include <apt-pkg/error.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-list.h>
+#include <apt-private/private-output.h>
+#include <iostream>
#include <sstream>
-#include <vector>
+#include <map>
+#include <string>
#include <utility>
-#include <cassert>
-#include <locale.h>
-#include <iostream>
-#include <unistd.h>
-#include <errno.h>
-#include <regex.h>
-#include <stdio.h>
-#include <algorithm>
-
-#include "private-cmndline.h"
-#include "private-list.h"
-#include "private-output.h"
-#include "private-cacheset.h"
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -61,7 +46,7 @@ class PackageNameMatcher : public Matcher /*{{{*/
public:
PackageNameMatcher(const char **patterns)
{
- for(int i=0; patterns[i] != NULL; i++)
+ for(int i=0; patterns[i] != NULL; ++i)
{
std::string pattern = patterns[i];
#ifdef PACKAGE_MATCHER_ABI_COMPAT
@@ -79,12 +64,12 @@ class PackageNameMatcher : public Matcher /*{{{*/
}
virtual ~PackageNameMatcher()
{
- for(J=filters.begin(); J != filters.end(); J++)
+ for(J=filters.begin(); J != filters.end(); ++J)
delete *J;
}
virtual bool operator () (const pkgCache::PkgIterator &P)
{
- for(J=filters.begin(); J != filters.end(); J++)
+ for(J=filters.begin(); J != filters.end(); ++J)
{
APT::CacheFilter::PackageMatcher *cachefilter = *J;
if((*cachefilter)(P))
@@ -99,13 +84,17 @@ private:
#undef PackageMatcher
};
/*}}}*/
-void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
+static void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,/*{{{*/
pkgCache::PkgIterator P,
- std::ostream &outs)
+ std::ostream &outs,
+ bool include_summary=true)
{
for (pkgCache::VerIterator Ver = P.VersionList();
- Ver.end() == false; Ver++)
- ListSingleVersion(CacheFile, records, Ver, outs);
+ Ver.end() == false; ++Ver)
+ {
+ ListSingleVersion(CacheFile, records, Ver, outs, include_summary);
+ outs << "\n";
+ }
}
/*}}}*/
// list - list package based on criteria /*{{{*/
@@ -136,18 +125,18 @@ bool List(CommandLine &Cmd)
PackageNameMatcher matcher(patterns);
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0,
Cache->Head().PackageCount,
Cache->Head().PackageCount,
_("Listing"));
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
- for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); V++)
+ for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
{
std::stringstream outs;
if(_config->FindB("APT::Cmd::All-Versions", false) == true)
{
- ListAllVersions(CacheFile, records, V.ParentPkg(), outs);
+ ListAllVersions(CacheFile, records, V.ParentPkg(), outs, includeSummary);
output_map.insert(std::make_pair<std::string, std::string>(
V.ParentPkg().Name(), outs.str()));
} else {
@@ -159,7 +148,7 @@ bool List(CommandLine &Cmd)
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
- for (K = output_map.begin(); K != output_map.end(); K++)
+ for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;
diff --git a/apt-private/private-list.h b/apt-private/private-list.h
index 6f5aad27a..461f527cb 100644
--- a/apt-private/private-list.h
+++ b/apt-private/private-list.h
@@ -1,9 +1,11 @@
#ifndef APT_PRIVATE_LIST_H
#define APT_PRIVATE_LIST_H
-#include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
-bool List(CommandLine &Cmd);
+class CommandLine;
+
+APT_PUBLIC bool List(CommandLine &Cmd);
#endif
diff --git a/apt-private/private-main.cc b/apt-private/private-main.cc
index 1fdf3f0be..2d3965172 100644
--- a/apt-private/private-main.cc
+++ b/apt-private/private-main.cc
@@ -1,9 +1,13 @@
+#include <config.h>
-#include<unistd.h>
-#include<cstring>
-
+#include <apt-pkg/cmndline.h>
#include <apt-pkg/configuration.h>
-#include "private-main.h"
+
+#include <apt-private/private-main.h>
+
+#include <iostream>
+#include <string.h>
+#include <unistd.h>
#include <apti18n.h>
diff --git a/apt-private/private-main.h b/apt-private/private-main.h
index f9a95c4ec..23d4aca68 100644
--- a/apt-private/private-main.h
+++ b/apt-private/private-main.h
@@ -1,9 +1,10 @@
#ifndef APT_PRIVATE_MAIN_H
#define APT_PRIVATE_MAIN_H
-#include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
-void CheckSimulateMode(CommandLine &CmdL);
+class CommandLine;
+APT_PUBLIC void CheckSimulateMode(CommandLine &CmdL);
#endif
diff --git a/apt-private/private-moo.cc b/apt-private/private-moo.cc
index 9b5b94654..a87999150 100644
--- a/apt-private/private-moo.cc
+++ b/apt-private/private-moo.cc
@@ -13,16 +13,20 @@
#include <apt-pkg/cmndline.h>
#include <apt-pkg/strutl.h>
-#include <strings.h>
-#include <sstream>
+#include <apt-private/private-moo.h>
+#include <apt-private/private-output.h>
-#include "private-moo.h"
-#include "private-output.h"
+#include <stddef.h>
+#include <string.h>
+#include <time.h>
+#include <iostream>
+#include <sstream>
+#include <string>
#include <apti18n.h>
/*}}}*/
-std::string getMooLine() { /*{{{*/
+static std::string getMooLine() { /*{{{*/
time_t const timenow = time(NULL);
struct tm special;
localtime_r(&timenow, &special);
@@ -60,12 +64,12 @@ std::string getMooLine() { /*{{{*/
return out.str();
}
/*}}}*/
-bool printMooLine() { /*{{{*/
+static bool printMooLine() { /*{{{*/
std::cerr << getMooLine() << std::endl;
return true;
}
/*}}}*/
-bool DoMoo1(CommandLine &CmdL) /*{{{*/
+bool DoMoo1(CommandLine &) /*{{{*/
{
// our trustworthy super cow since 2001
if (_config->FindI("quiet") >= 2)
@@ -83,7 +87,7 @@ bool DoMoo1(CommandLine &CmdL) /*{{{*/
return true;
}
/*}}}*/
-bool DoMoo2(CommandLine &CmdL) /*{{{*/
+bool DoMoo2(CommandLine &) /*{{{*/
{
// by Fernando Ribeiro in lp:56125
if (_config->FindI("quiet") >= 2)
@@ -102,22 +106,22 @@ bool DoMoo2(CommandLine &CmdL) /*{{{*/
else
{
c1out <<
- OutputInDepth(depth, " ") << " \e[1;97m(\e[0;33m__\e[1;97m)\e[0m\n" <<
- OutputInDepth(depth, " ") << " \e[31m_______\e[33m~(\e[1;34m..\e[0;33m)~\e[0m\n" <<
- OutputInDepth(depth, " ") << " \e[33m,----\e[31m\\\e[33m(\e[1;4;35moo\e[0;33m)\e[0m\n" <<
- OutputInDepth(depth, " ") << " \e[33m/|____|,'\e[0m\n" <<
- OutputInDepth(depth, " ") << " \e[1;5;97m*\e[0;33m /\\ /\\\e[0m\n" <<
- "\e[32m";
+ OutputInDepth(depth, " ") << " \033[1;97m(\033[0;33m__\033[1;97m)\033[0m\n" <<
+ OutputInDepth(depth, " ") << " \033[31m_______\033[33m~(\033[1;34m..\033[0;33m)~\033[0m\n" <<
+ OutputInDepth(depth, " ") << " \033[33m,----\033[31m\\\033[33m(\033[1;4;35moo\033[0;33m)\033[0m\n" <<
+ OutputInDepth(depth, " ") << " \033[33m/|____|,'\033[0m\n" <<
+ OutputInDepth(depth, " ") << " \033[1;5;97m*\033[0;33m /\\ /\\\033[0m\n" <<
+ "\033[32m";
for (size_t i = moo.length()/2; i > 1; --i)
c1out << "wW";
- c1out << "w\e[0m\n" << moo;
+ c1out << "w\033[0m\n" << moo;
}
return true;
}
/*}}}*/
-bool DoMoo3(CommandLine &CmdL) /*{{{*/
+bool DoMoo3(CommandLine &) /*{{{*/
{
// by Robert Millan in deb:134156
if (_config->FindI("quiet") >= 2)
@@ -134,7 +138,7 @@ bool DoMoo3(CommandLine &CmdL) /*{{{*/
return true;
}
/*}}}*/
-bool DoMooApril(CommandLine &CmdL) /*{{{*/
+bool DoMooApril(CommandLine &) /*{{{*/
{
// by Christopher Allan Webber and proposed by Paul Tagliamonte
// in a "Community outreach": https://lists.debian.org/debian-devel/2013/04/msg00045.html
diff --git a/apt-private/private-moo.h b/apt-private/private-moo.h
index 7bfc5c1fc..b8e1cfed6 100644
--- a/apt-private/private-moo.h
+++ b/apt-private/private-moo.h
@@ -3,7 +3,7 @@
class CommandLine;
-bool DoMoo(CommandLine &CmdL);
+APT_PUBLIC bool DoMoo(CommandLine &CmdL);
bool DoMoo1(CommandLine &CmdL);
bool DoMoo2(CommandLine &CmdL);
bool DoMoo3(CommandLine &CmdL);
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 91d13f31b..bbd8545ad 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -7,16 +7,22 @@
#include <apt-pkg/cachefile.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/policy.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-cachefile.h>
+
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <iomanip>
#include <iostream>
-#include <locale.h>
#include <langinfo.h>
#include <unistd.h>
-#include "private-output.h"
-#include "private-cachefile.h"
-
#include <apti18n.h>
/*}}}*/
@@ -30,6 +36,9 @@ unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
bool InitOutput() /*{{{*/
{
+ if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
+ _config->Set("quiet","1");
+
c0out.rdbuf(cout.rdbuf());
c1out.rdbuf(cout.rdbuf());
c2out.rdbuf(cout.rdbuf());
@@ -60,7 +69,7 @@ bool InitOutput() /*{{{*/
return true;
}
/*}}}*/
-std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver) /*{{{*/
+static std::string GetArchiveSuite(pkgCacheFile &/*CacheFile*/, pkgCache::VerIterator ver) /*{{{*/
{
std::string suite = "";
if (ver && ver.FileList() && ver.FileList())
@@ -68,8 +77,10 @@ std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver)
pkgCache::VerFileIterator VF = ver.FileList();
for (; VF.end() == false ; ++VF)
{
- // XXX: how to figure out the relevant suite? if its in multiple ones?
- suite = suite + "," + VF.File().Archive();
+ if(VF.File() == NULL || VF.File().Archive() == NULL)
+ suite = suite + "," + _("unknown");
+ else
+ suite = suite + "," + VF.File().Archive();
//suite = VF.File().Archive();
}
suite = suite.erase(0, 1);
@@ -77,7 +88,7 @@ std::string GetArchiveSuite(pkgCacheFile &CacheFile, pkgCache::VerIterator ver)
return suite;
}
/*}}}*/
-std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
+static std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
@@ -94,7 +105,7 @@ std::string GetFlagsStr(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
return flags_str;
}
/*}}}*/
-std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
+static std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
pkgCache::VerIterator cand = policy->GetCandidateVer(P);
@@ -102,23 +113,25 @@ std::string GetCandidateVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P
return cand ? cand.VerStr() : "(none)";
}
/*}}}*/
-std::string GetInstalledVersion(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
+static std::string GetInstalledVersion(pkgCacheFile &/*CacheFile*/, pkgCache::PkgIterator P)/*{{{*/
{
pkgCache::VerIterator inst = P.CurrentVer();
return inst ? inst.VerStr() : "(none)";
}
/*}}}*/
-std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)/*{{{*/
+static std::string GetVersion(pkgCacheFile &/*CacheFile*/, pkgCache::VerIterator V)/*{{{*/
{
pkgCache::PkgIterator P = V.ParentPkg();
if (V == P.CurrentVer())
{
+ std::string inst_str = DeNull(V.VerStr());
+#if 0 // FIXME: do we want this or something like this?
pkgDepCache *DepCache = CacheFile.GetDepCache();
pkgDepCache::StateCache &state = (*DepCache)[P];
- std::string inst_str = DeNull(V.VerStr());
if (state.Upgradable())
return "**"+inst_str;
+#endif
return inst_str;
}
@@ -127,16 +140,16 @@ std::string GetVersion(pkgCacheFile &CacheFile, pkgCache::VerIterator V)/*{{{*/
return "(none)";
}
/*}}}*/
-std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
+static std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
pkgCache::VerIterator inst = P.CurrentVer();
pkgCache::VerIterator cand = policy->GetCandidateVer(P);
-
+
return inst ? inst.Arch() : cand.Arch();
}
/*}}}*/
-std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::PkgIterator P)/*{{{*/
+static std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::PkgIterator P)/*{{{*/
{
pkgPolicy *policy = CacheFile.GetPolicy();
@@ -186,49 +199,48 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
// raring/linux-kernel version [upradable: new-version]
// description
pkgPolicy *policy = CacheFile.GetPolicy();
- out << std::setiosflags(std::ios::left)
- << _config->Find("APT::Color::Highlight", "")
- << name_str
- << _config->Find("APT::Color::Neutral", "")
- << "/" << suite
- << " ";
+ std::string VersionStr = GetVersion(CacheFile, V);
+ std::string CandidateVerStr = GetCandidateVersion(CacheFile, P);
+ std::string InstalledVerStr = GetInstalledVersion(CacheFile, P);
+ std::string StatusStr;
if(P.CurrentVer() == V && state.Upgradable()) {
- out << GetVersion(CacheFile, V)
- << " "
- << "[" << _("installed,upgradable to: ")
- << GetCandidateVersion(CacheFile, P) << "]";
+ strprintf(StatusStr, _("[installed,upgradable to: %s]"),
+ CandidateVerStr.c_str());
} else if (P.CurrentVer() == V) {
- out << GetVersion(CacheFile, V)
- << " ";
if(!V.Downloadable())
- out << _("[installed,local]");
+ StatusStr = _("[installed,local]");
else
if(V.Automatic() && state.Garbage)
- out << _("[installed,auto-removable]");
+ StatusStr = _("[installed,auto-removable]");
else if (state.Flags & pkgCache::Flag::Auto)
- out << _("[installed,automatic]");
+ StatusStr = _("[installed,automatic]");
else
- out << _("[installed]");
+ StatusStr = _("[installed]");
} else if (P.CurrentVer() &&
policy->GetCandidateVer(P) == V &&
state.Upgradable()) {
- out << GetVersion(CacheFile, V)
- << " "
- << _("[upgradable from: ")
- << GetInstalledVersion(CacheFile, P) << "]";
+ strprintf(StatusStr, _("[upgradable from: %s]"),
+ InstalledVerStr.c_str());
} else {
if (V.ParentPkg()->CurrentState == pkgCache::State::ConfigFiles)
- out << GetVersion(CacheFile, V)
- << " "
- << _("[residual-config]");
+ StatusStr = _("[residual-config]");
else
- out << GetVersion(CacheFile, V);
+ StatusStr = "";
}
- out << " " << GetArchitecture(CacheFile, P) << " ";
+ out << std::setiosflags(std::ios::left)
+ << _config->Find("APT::Color::Highlight", "")
+ << name_str
+ << _config->Find("APT::Color::Neutral", "")
+ << "/" << suite
+ << " "
+ << VersionStr << " "
+ << GetArchitecture(CacheFile, P);
+ if (StatusStr != "")
+ out << " " << StatusStr;
if (include_summary)
{
out << std::endl
- << " " << GetShortDescription(CacheFile, records, P)
+ << " " << GetShortDescription(CacheFile, records, P)
<< std::endl;
}
}
diff --git a/apt-private/private-output.h b/apt-private/private-output.h
index c3c76bb92..9633d0c37 100644
--- a/apt-private/private-output.h
+++ b/apt-private/private-output.h
@@ -1,37 +1,37 @@
#ifndef APT_PRIVATE_OUTPUT_H
#define APT_PRIVATE_OUTPUT_H
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
-#include <iostream>
#include <fstream>
#include <string>
-#include "private-cachefile.h"
-
// forward declaration
class pkgCacheFile;
class CacheFile;
-class pkgCache;
class pkgDepCache;
class pkgRecords;
-extern std::ostream c0out;
-extern std::ostream c1out;
-extern std::ostream c2out;
-extern std::ofstream devnull;
-extern unsigned int ScreenWidth;
+APT_PUBLIC extern std::ostream c0out;
+APT_PUBLIC extern std::ostream c1out;
+APT_PUBLIC extern std::ostream c2out;
+APT_PUBLIC extern std::ofstream devnull;
+APT_PUBLIC extern unsigned int ScreenWidth;
+
+APT_PUBLIC bool InitOutput();
-bool InitOutput();
-void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
+void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
pkgCache::VerIterator V, std::ostream &out,
bool include_summary=true);
+// helper to describe global state
+APT_PUBLIC void ShowBroken(std::ostream &out,CacheFile &Cache,bool Now);
-bool ShowList(std::ostream &out, std::string Title, std::string List,
+APT_PUBLIC bool ShowList(std::ostream &out, std::string Title, std::string List,
std::string VersionsList);
-void ShowBroken(std::ostream &out,CacheFile &Cache,bool Now);
void ShowNew(std::ostream &out,CacheFile &Cache);
void ShowDel(std::ostream &out,CacheFile &Cache);
void ShowKept(std::ostream &out,CacheFile &Cache);
diff --git a/apt-private/private-search.cc b/apt-private/private-search.cc
index ff4140fa7..8106333b6 100644
--- a/apt-private/private-search.cc
+++ b/apt-private/private-search.cc
@@ -1,40 +1,30 @@
// Includes /*{{{*/
-#include <apt-pkg/error.h>
+#include <config.h>
+
#include <apt-pkg/cachefile.h>
-#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/policy.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
-#include <sstream>
-#include <utility>
-#include <cassert>
-#include <locale.h>
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-search.h>
+
+#include <string.h>
#include <iostream>
-#include <unistd.h>
-#include <errno.h>
-#include <regex.h>
-#include <stdio.h>
-#include <iomanip>
-#include <algorithm>
+#include <sstream>
#include <map>
+#include <string>
+#include <utility>
-#include "private-search.h"
-#include "private-cacheset.h"
+#include <apti18n.h>
/*}}}*/
bool FullTextSearch(CommandLine &CmdL) /*{{{*/
@@ -53,7 +43,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
std::map<std::string, std::string>::const_iterator K;
LocalitySortedVersionSet bag;
- OpTextProgress progress;
+ OpTextProgress progress(*_config);
progress.OverallProgress(0, 100, 50, _("Sorting"));
GetLocalitySortedVersionSet(CacheFile, bag, progress);
LocalitySortedVersionSet::iterator V = bag.begin();
@@ -61,18 +51,18 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
progress.OverallProgress(50, 100, 50, _("Full Text Search"));
progress.SubProgress(bag.size());
int Done = 0;
- for ( ;V != bag.end(); V++)
+ for ( ;V != bag.end(); ++V)
{
if (Done%500 == 0)
progress.Progress(Done);
- Done++;
+ ++Done;
int i;
pkgCache::DescIterator Desc = V.TranslatedDescription();
pkgRecords::Parser &parser = records.Lookup(Desc.FileList());
bool all_found = true;
- for(i=0; patterns[i] != NULL; i++)
+ for(i=0; patterns[i] != NULL; ++i)
{
// FIXME: use regexp instead of simple find()
const char *pattern = patterns[i];
@@ -93,7 +83,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
// output the sorted map
- for (K = output_map.begin(); K != output_map.end(); K++)
+ for (K = output_map.begin(); K != output_map.end(); ++K)
std::cout << (*K).second << std::endl;
return true;
diff --git a/apt-private/private-search.h b/apt-private/private-search.h
index 17faffebc..d4786233a 100644
--- a/apt-private/private-search.h
+++ b/apt-private/private-search.h
@@ -1,9 +1,11 @@
#ifndef APT_PRIVATE_SEARCH_H
#define APT_PRIVATE_SEARCH_H
-#include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
-bool FullTextSearch(CommandLine &CmdL);
+class CommandLine;
+
+APT_PUBLIC bool FullTextSearch(CommandLine &CmdL);
#endif
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index ddc75dbeb..8ae6a6dac 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -1,29 +1,32 @@
// Includes /*{{{*/
-#include <apt-pkg/error.h>
+#include <config.h>
+
#include <apt-pkg/cachefile.h>
-#include <apt-pkg/cachefilter.h>
#include <apt-pkg/cacheset.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/indexfile.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
-#include <apt-pkg/policy.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/algorithms.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
-#include <apti18n.h>
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-show.h>
+
+#include <stdio.h>
+#include <ostream>
+#include <string>
-#include "private-output.h"
-#include "private-cacheset.h"
+#include <apti18n.h>
/*}}}*/
namespace APT {
@@ -31,12 +34,15 @@ namespace APT {
// DisplayRecord - Displays the complete record for the package /*{{{*/
// ---------------------------------------------------------------------
-bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
- ostream &out)
+static bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
+ std::ostream &out)
{
pkgCache *Cache = CacheFile.GetPkgCache();
if (unlikely(Cache == NULL))
return false;
+ pkgDepCache *depCache = CacheFile.GetDepCache();
+ if (unlikely(depCache == NULL))
+ return false;
// Find an appropriate file
pkgCache::VerFileIterator Vf = V.FileList();
@@ -51,36 +57,78 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V,
if (I.IsOk() == false)
return _error->Error(_("Package file %s is out of sync."),I.FileName());
+ // find matching sources.list metaindex
+ pkgSourceList *SrcList = CacheFile.GetSourceList();
+ pkgIndexFile *Index;
+ if (SrcList->FindIndex(I, Index) == false &&
+ _system->FindIndex(I, Index) == false)
+ return _error->Error("Can not find indexfile for Package %s (%s)",
+ V.ParentPkg().Name(), V.VerStr());
+ std::string source_index_file = Index->Describe(true);
+
// Read the record
FileFd PkgF;
if (PkgF.Open(I.FileName(), FileFd::ReadOnly, FileFd::Extension) == false)
return false;
pkgTagSection Tags;
pkgTagFile TagF(&PkgF);
-
+
+ if (TagF.Jump(Tags, V.FileList()->Offset) == false)
+ return _error->Error("Internal Error, Unable to parse a package record");
+
+ // make size nice
+ std::string installed_size;
+ if (Tags.FindI("Installed-Size") > 0)
+ strprintf(installed_size, "%sB", SizeToStr(Tags.FindI("Installed-Size")*1024).c_str());
+ else
+ installed_size = _("unknown");
+ std::string package_size;
+ if (Tags.FindI("Size") > 0)
+ strprintf(package_size, "%sB", SizeToStr(Tags.FindI("Size")).c_str());
+ else
+ package_size = _("unknown");
+
+ pkgDepCache::StateCache &state = (*depCache)[V.ParentPkg()];
+ bool is_installed = V.ParentPkg().CurrentVer() == V;
+ const char *manual_installed;
+ if (is_installed)
+ manual_installed = !(state.Flags & pkgCache::Flag::Auto) ? "yes" : "no";
+ else
+ manual_installed = 0;
+
+ // FIXME: add verbose that does not do the removal of the tags?
TFRewriteData RW[] = {
- {"Conffiles",0},
- {"Description",0},
- {"Description-md5",0},
- {}
+ // delete, apt-cache show has this info and most users do not care
+ {"MD5sum", NULL, NULL},
+ {"SHA1", NULL, NULL},
+ {"SHA256", NULL, NULL},
+ {"Filename", NULL, NULL},
+ {"Multi-Arch", NULL, NULL},
+ {"Architecture", NULL, NULL},
+ {"Conffiles", NULL, NULL},
+ // we use the translated description
+ {"Description", NULL, NULL},
+ {"Description-md5", NULL, NULL},
+ // improve
+ {"Installed-Size", installed_size.c_str(), NULL},
+ {"Size", package_size.c_str(), "Download-Size"},
+ // add
+ {"APT-Manual-Installed", manual_installed, NULL},
+ {"APT-Sources", source_index_file.c_str(), NULL},
+ {NULL, NULL, NULL}
};
- const char *Zero = 0;
- if (TagF.Jump(Tags, V.FileList()->Offset) == false ||
- TFRewrite(stdout,Tags,&Zero,RW) == false)
- {
- _error->Error("Internal Error, Unable to parse a package record");
- return false;
- }
+
+ if(TFRewrite(stdout, Tags, NULL, RW) == false)
+ return _error->Error("Internal Error, Unable to parse a package record");
// write the description
pkgRecords Recs(*Cache);
+ // FIXME: show (optionally) all available translations(?)
pkgCache::DescIterator Desc = V.TranslatedDescription();
if (Desc.end() == false)
{
pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- if (strcmp(Desc.LanguageCode(),"") != 0)
- out << "Description-lang: " << Desc.LanguageCode() << std::endl;
- out << "Description" << P.LongDesc();
+ out << "Description: " << P.LongDesc();
}
// write a final newline (after the description)
@@ -93,12 +141,21 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/
{
pkgCacheFile CacheFile;
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
- APT::VersionList::Version const select = APT::VersionList::CANDIDATE;
+ APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", false) ?
+ APT::VersionList::ALL : APT::VersionList::CANDIDATE;
APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
if (DisplayRecord(CacheFile, Ver, c1out) == false)
return false;
+ if (select == APT::VersionList::CANDIDATE)
+ {
+ APT::VersionList const verset_all = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::ALL, helper);
+ int const records = verset_all.size() - verset.size();
+ if (records > 0)
+ _error->Notice(P_("There is %i additional record. Please use the '-a' switch to see it", "There are %i additional records. Please use the '-a' switch to see them.", records), records);
+ }
+
for (APT::PackageSet::const_iterator Pkg = helper.virtualPkgs.begin();
Pkg != helper.virtualPkgs.end(); ++Pkg)
{
diff --git a/apt-private/private-show.h b/apt-private/private-show.h
index b428c7af0..359aeeb28 100644
--- a/apt-private/private-show.h
+++ b/apt-private/private-show.h
@@ -1,12 +1,14 @@
#ifndef APT_PRIVATE_SHOW_H
#define APT_PRIVATE_SHOW_H
-#include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
+
+class CommandLine;
namespace APT {
namespace Cmd {
- bool ShowPackage(CommandLine &CmdL);
+ APT_PUBLIC bool ShowPackage(CommandLine &CmdL);
}
}
#endif
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc
index 65706e785..301936b9d 100644
--- a/apt-private/private-sources.cc
+++ b/apt-private/private-sources.cc
@@ -1,10 +1,23 @@
+#include <config.h>
#include <apt-pkg/hashes.h>
-#include <apti18n.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+
+#include <apt-private/private-output.h>
+#include <apt-private/private-sources.h>
+#include <apt-private/private-utils.h>
-#include "private-output.h"
-#include "private-sources.h"
-#include "private-utils.h"
+#include <stddef.h>
+#include <unistd.h>
+#include <iostream>
+#include <string>
+
+#include <apti18n.h>
/* Interface discussion with donkult (for the future):
apt [add-{archive,release,component}|edit|change-release|disable]-sources
@@ -32,6 +45,10 @@ bool EditSources(CommandLine &CmdL)
if (FileExists(sourceslist))
before.FromFile(sourceslist);
+ int lockfd = GetLock(sourceslist);
+ if (lockfd < 0)
+ return false;
+
do {
EditFileInSensibleEditor(sourceslist);
_error->PushToStack();
@@ -46,6 +63,7 @@ bool EditSources(CommandLine &CmdL)
}
_error->RevertToStack();
} while (res == false);
+ close(lockfd);
if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
strprintf(
diff --git a/apt-private/private-sources.h b/apt-private/private-sources.h
index b394622be..0c421902e 100644
--- a/apt-private/private-sources.h
+++ b/apt-private/private-sources.h
@@ -1,3 +1,10 @@
-#include <apt-pkg/cmndline.h>
+#ifndef APT_PRIVATE_SOURCES_H
+#define APT_PRIVATE_SOURCES_H
-bool EditSources(CommandLine &CmdL);
+#include <apt-pkg/macros.h>
+
+class CommandLine;
+
+APT_PUBLIC bool EditSources(CommandLine &CmdL);
+
+#endif
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index f6c12c26a..da83d7741 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -1,37 +1,23 @@
// Include files /*{{{*/
#include<config.h>
-#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/cmndline.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/depcache.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/algorithms.h>
#include <apt-pkg/acquire-item.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/fileutl.h>
-#include <apt-pkg/clean.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
#include <apt-pkg/cachefile.h>
-#include <apt-pkg/cacheset.h>
-#include <apt-pkg/sptr.h>
-#include <apt-pkg/md5.h>
-#include <apt-pkg/versionmatch.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/sourcelist.h>
#include <apt-pkg/update.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/configuration.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#include <apt-private/acqprogress.h>
+#include <apt-private/private-cachefile.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-update.h>
-#include "private-cachefile.h"
-#include "private-output.h"
-#include "acqprogress.h"
+#include <ostream>
+#include <string>
#include <apti18n.h>
/*}}}*/
diff --git a/apt-private/private-update.h b/apt-private/private-update.h
index d3d0b7af9..e584f70cf 100644
--- a/apt-private/private-update.h
+++ b/apt-private/private-update.h
@@ -1,8 +1,10 @@
#ifndef APT_PRIVATE_UPDATE_H
#define APT_PRIVATE_UPDATE_H
+#include <apt-pkg/macros.h>
+
class CommandLine;
-bool DoUpdate(CommandLine &CmdL);
+APT_PUBLIC bool DoUpdate(CommandLine &CmdL);
#endif
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc
index e76b5d7fc..68b2c5e00 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -1,11 +1,18 @@
// Includes /*{{{*/
-#include <apt-pkg/algorithms.h>
+#include <config.h>
+
#include <apt-pkg/upgrade.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
+
+#include <apt-private/private-install.h>
+#include <apt-private/private-cachefile.h>
+#include <apt-private/private-upgrade.h>
+#include <apt-private/private-output.h>
+
#include <iostream>
-#include "private-install.h"
-#include "private-cachefile.h"
-#include "private-upgrade.h"
-#include "private-output.h"
+
+#include <apti18n.h>
/*}}}*/
// this is actually performing the various upgrade operations
@@ -39,6 +46,14 @@ bool DoDistUpgrade(CommandLine &CmdL)
return UpgradeHelper(CmdL, 0);
}
/*}}}*/
+bool DoUpgrade(CommandLine &CmdL) /*{{{*/
+{
+ if (_config->FindB("APT::Get::Upgrade-Allow-New", false) == true)
+ return DoUpgradeWithAllowNewPackages(CmdL);
+ else
+ return DoUpgradeNoNewPackages(CmdL);
+}
+ /*}}}*/
// DoUpgradeNoNewPackages - Upgrade all packages /*{{{*/
// ---------------------------------------------------------------------
/* Upgrade all packages without installing new packages or erasing old
diff --git a/apt-private/private-upgrade.h b/apt-private/private-upgrade.h
index 050d3a668..16bb93c9b 100644
--- a/apt-private/private-upgrade.h
+++ b/apt-private/private-upgrade.h
@@ -1,12 +1,13 @@
#ifndef APTPRIVATE_PRIVATE_UPGRADE_H
#define APTPRIVATE_PRIVATE_UPGRADE_H
-#include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
+class CommandLine;
-bool DoDistUpgrade(CommandLine &CmdL);
+APT_PUBLIC bool DoDistUpgrade(CommandLine &CmdL);
+APT_PUBLIC bool DoUpgrade(CommandLine &CmdL);
bool DoUpgradeNoNewPackages(CommandLine &CmdL);
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL);
-
#endif
diff --git a/apt-private/private-utils.cc b/apt-private/private-utils.cc
index 813f19329..9547a1b75 100644
--- a/apt-private/private-utils.cc
+++ b/apt-private/private-utils.cc
@@ -1,9 +1,12 @@
-#include <cstdlib>
+#include <config.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/fileutl.h>
-#include "private-utils.h"
+#include <apt-private/private-utils.h>
+
+#include <cstdlib>
+#include <unistd.h>
// DisplayFileInPager - Display File with pager /*{{{*/
void DisplayFileInPager(std::string filename)
@@ -26,7 +29,6 @@ void DisplayFileInPager(std::string filename)
ExecWait(Process, "sensible-pager", false);
}
/*}}}*/
-
// EditFileInSensibleEditor - Edit File with editor /*{{{*/
void EditFileInSensibleEditor(std::string filename)
{
diff --git a/apt-private/private-utils.h b/apt-private/private-utils.h
index 258dd06a8..432699787 100644
--- a/apt-private/private-utils.h
+++ b/apt-private/private-utils.h
@@ -1,11 +1,11 @@
#ifndef APT_PRIVATE_UTILS_H
#define APT_PRIVATE_UTILS_H
-#include<string>
-
-void DisplayFileInPager(std::string filename);
-void EditFileInSensibleEditor(std::string filename);
+#include <apt-pkg/macros.h>
+#include <string>
+APT_PUBLIC void DisplayFileInPager(std::string filename);
+APT_PUBLIC void EditFileInSensibleEditor(std::string filename);
#endif