summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-06-12 08:36:58 +0200
committerMichael Vogt <mvo@debian.org>2014-06-12 08:36:58 +0200
commitcfc7f735774ba30dbee1897248f8dfedf0229a4c (patch)
treeb4e0ac29a6b398045a803e890f5cdabcca189d6a /cmdline
parenta0187f0f82a184b850b05b62e5a59b6a2055a506 (diff)
parent7701680af12a2c1a65121533c6ebcd635c013c25 (diff)
Merge tag '1.0.1ubuntu2' into ubuntu/trusty
Conflicts: configure.ac debian/changelog debian/control test/integration/framework
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/acqprogress.cc2
-rw-r--r--cmdline/apt-cache.cc103
-rw-r--r--cmdline/apt-cdrom.cc243
-rw-r--r--cmdline/apt-config.cc13
-rw-r--r--cmdline/apt-dump-solver.cc8
-rw-r--r--cmdline/apt-extracttemplates.cc34
-rw-r--r--cmdline/apt-extracttemplates.h3
-rw-r--r--cmdline/apt-get.cc136
-rw-r--r--cmdline/apt-helper.cc125
-rw-r--r--cmdline/apt-internal-solver.cc12
-rw-r--r--cmdline/apt-mark.cc41
-rw-r--r--cmdline/apt-sortpkgs.cc10
-rw-r--r--cmdline/apt.cc46
-rw-r--r--cmdline/makefile7
14 files changed, 441 insertions, 342 deletions
diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc
index 3ac350aca..c362c1edf 100644
--- a/cmdline/acqprogress.cc
+++ b/cmdline/acqprogress.cc
@@ -10,12 +10,14 @@
// 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 <string.h>
#include <stdio.h>
#include <signal.h>
#include <iostream>
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index b8892d23d..84b775390 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -15,40 +15,49 @@
// Include Files /*{{{*/
#include<config.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/algorithms.h>
#include <apt-pkg/cachefile.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/init.h>
+#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/srcrecords.h>
-#include <apt-pkg/version.h>
+#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/policy.h>
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/algorithms.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/sourcelist.h>
#include <apt-pkg/sptr.h>
-#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/indexfile.h>
-#include <apt-pkg/metaindex.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/mmap.h>
+#include <apt-pkg/pkgcache.h>
-#include <apt-private/private-list.h>
-#include <apt-private/private-cmndline.h>
-#include <apt-private/private-show.h>
#include <apt-private/private-cacheset.h>
+#include <apt-private/private-cmndline.h>
-#include <cassert>
-#include <locale.h>
-#include <iostream>
-#include <unistd.h>
-#include <errno.h>
#include <regex.h>
+#include <stddef.h>
#include <stdio.h>
-#include <iomanip>
+#include <stdlib.h>
+#include <unistd.h>
#include <algorithm>
+#include <cstring>
+#include <iomanip>
+#include <iostream>
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -58,7 +67,7 @@ using namespace std;
// LocalitySort - Sort a version list by package file locality /*{{{*/
// ---------------------------------------------------------------------
/* */
-int LocalityCompare(const void *a, const void *b)
+static int LocalityCompare(const void *a, const void *b)
{
pkgCache::VerFile *A = *(pkgCache::VerFile **)a;
pkgCache::VerFile *B = *(pkgCache::VerFile **)b;
@@ -75,13 +84,13 @@ int LocalityCompare(const void *a, const void *b)
return A->File - B->File;
}
-void LocalitySort(pkgCache::VerFile **begin,
+static void LocalitySort(pkgCache::VerFile **begin,
unsigned long Count,size_t Size)
{
qsort(begin,Count,Size,LocalityCompare);
}
-void LocalitySort(pkgCache::DescFile **begin,
+static void LocalitySort(pkgCache::DescFile **begin,
unsigned long Count,size_t Size)
{
qsort(begin,Count,Size,LocalityCompare);
@@ -90,7 +99,7 @@ void LocalitySort(pkgCache::DescFile **begin,
// UnMet - Show unmet dependencies /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
+static bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
{
bool Header = false;
for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;)
@@ -163,7 +172,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
}
return true;
}
-bool UnMet(CommandLine &CmdL)
+static bool UnMet(CommandLine &CmdL)
{
bool const Important = _config->FindB("APT::Cache::Important",false);
@@ -193,7 +202,7 @@ bool UnMet(CommandLine &CmdL)
// DumpPackage - Show a dump of a package record /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DumpPackage(CommandLine &CmdL)
+static bool DumpPackage(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
APT::CacheSetHelper helper(true, GlobalError::NOTICE);
@@ -258,7 +267,7 @@ bool DumpPackage(CommandLine &CmdL)
// Stats - Dump some nice statistics /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Stats(CommandLine &Cmd)
+static bool Stats(CommandLine &)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -371,7 +380,7 @@ bool Stats(CommandLine &Cmd)
// Dump - show everything /*{{{*/
// ---------------------------------------------------------------------
/* This is worthless except fer debugging things */
-bool Dump(CommandLine &Cmd)
+static bool Dump(CommandLine &)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -423,7 +432,7 @@ bool Dump(CommandLine &Cmd)
// ---------------------------------------------------------------------
/* This is needed to make dpkg --merge happy.. I spent a bit of time to
make this run really fast, perhaps I went a little overboard.. */
-bool DumpAvail(CommandLine &Cmd)
+static bool DumpAvail(CommandLine &)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -532,7 +541,7 @@ bool DumpAvail(CommandLine &Cmd)
if ((File->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource)
{
pkgTagSection Tags;
- TFRewriteData RW[] = {{"Status",0},{"Config-Version",0},{}};
+ TFRewriteData RW[] = {{"Status", NULL, NULL},{"Config-Version", NULL, NULL},{NULL, NULL, NULL}};
const char *Zero = 0;
if (Tags.Scan(Buffer+Jitter,VF.Size+1) == false ||
TFRewrite(stdout,Tags,&Zero,RW) == false)
@@ -562,7 +571,7 @@ bool DumpAvail(CommandLine &Cmd)
}
/*}}}*/
// ShowDepends - Helper for printing out a dependency tree /*{{{*/
-bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
+static bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -676,7 +685,7 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
// Depends - Print out a dependency tree /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Depends(CommandLine &CmdL)
+static bool Depends(CommandLine &CmdL)
{
return ShowDepends(CmdL, false);
}
@@ -684,7 +693,7 @@ bool Depends(CommandLine &CmdL)
// RDepends - Print out a reverse dependency tree /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool RDepends(CommandLine &CmdL)
+static bool RDepends(CommandLine &CmdL)
{
return ShowDepends(CmdL, true);
}
@@ -693,7 +702,7 @@ bool RDepends(CommandLine &CmdL)
// ---------------------------------------------------------------------
// Code contributed from Junichi Uekawa <dancer@debian.org> on 20 June 2002.
-bool XVcg(CommandLine &CmdL)
+static bool XVcg(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -905,7 +914,7 @@ bool XVcg(CommandLine &CmdL)
/* Dotty is the graphvis program for generating graphs. It is a fairly
simple queuing algorithm that just writes dependencies and nodes.
http://www.research.att.com/sw/tools/graphviz/ */
-bool Dotty(CommandLine &CmdL)
+static bool Dotty(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -1109,7 +1118,7 @@ bool Dotty(CommandLine &CmdL)
/* This displays the package record from the proper package index file.
It is not used by DumpAvail for performance reasons. */
-static unsigned char const* skipDescriptionFields(unsigned char const * DescP)
+static APT_PURE unsigned char const* skipDescriptionFields(unsigned char const * DescP)
{
char const * const TagName = "\nDescription";
size_t const TagLen = strlen(TagName);
@@ -1126,7 +1135,7 @@ static unsigned char const* skipDescriptionFields(unsigned char const * DescP)
++DescP;
return DescP;
}
-bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
+static bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
{
pkgCache *Cache = CacheFile.GetPkgCache();
if (unlikely(Cache == NULL))
@@ -1228,7 +1237,7 @@ struct ExDescFile
// Search - Perform a search /*{{{*/
// ---------------------------------------------------------------------
/* This searches the package names and package descriptions for a pattern */
-bool Search(CommandLine &CmdL)
+static bool Search(CommandLine &CmdL)
{
bool const ShowFull = _config->FindB("APT::Cache::ShowFull",false);
bool const NamesOnly = _config->FindB("APT::Cache::NamesOnly",false);
@@ -1388,7 +1397,7 @@ bool Search(CommandLine &CmdL)
}
/*}}}*/
/* ShowAuto - show automatically installed packages (sorted) {{{*/
-bool ShowAuto(CommandLine &CmdL)
+static bool ShowAuto(CommandLine &)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -1415,7 +1424,7 @@ bool ShowAuto(CommandLine &CmdL)
// ShowPackage - Dump the package record to the screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowPackage(CommandLine &CmdL)
+static bool ShowPackage(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
@@ -1439,7 +1448,7 @@ bool ShowPackage(CommandLine &CmdL)
// ShowPkgNames - Show package names /*{{{*/
// ---------------------------------------------------------------------
/* This does a prefix match on the first argument */
-bool ShowPkgNames(CommandLine &CmdL)
+static bool ShowPkgNames(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
if (unlikely(CacheFile.BuildCaches(NULL, false) == false))
@@ -1478,7 +1487,7 @@ bool ShowPkgNames(CommandLine &CmdL)
// ShowSrcPackage - Show source package records /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowSrcPackage(CommandLine &CmdL)
+static bool ShowSrcPackage(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgSourceList *List = CacheFile.GetSourceList();
@@ -1515,7 +1524,7 @@ bool ShowSrcPackage(CommandLine &CmdL)
// Policy - Show the results of the preferences file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Policy(CommandLine &CmdL)
+static bool Policy(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -1644,7 +1653,7 @@ bool Policy(CommandLine &CmdL)
// Madison - Look a bit like katie's madison /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Madison(CommandLine &CmdL)
+static bool Madison(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgSourceList *SrcList = CacheFile.GetSourceList();
@@ -1717,7 +1726,7 @@ bool Madison(CommandLine &CmdL)
// GenCaches - Call the main cache generator /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool GenCaches(CommandLine &Cmd)
+static bool GenCaches(CommandLine &)
{
OpTextProgress Progress(*_config);
@@ -1728,7 +1737,7 @@ bool GenCaches(CommandLine &Cmd)
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp(CommandLine &Cmd)
+static bool ShowHelp(CommandLine &)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc
index 20c6e8892..53efe65b8 100644
--- a/cmdline/apt-cdrom.cc
+++ b/cmdline/apt-cdrom.cc
@@ -20,33 +20,20 @@
#include <apt-pkg/progress.h>
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/strutl.h>
-#include <apt-pkg/acquire.h>
-#include <apt-pkg/acquire-item.h>
#include <apt-pkg/cdrom.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgsystem.h>
-#include <locale.h>
#include <iostream>
-#include <fstream>
#include <vector>
-#include <algorithm>
+#include <string>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
#include <unistd.h>
-#include <stdio.h>
#include <apt-private/private-cmndline.h>
#include <apti18n.h>
/*}}}*/
-static const char *W_NO_CDROM_FOUND = \
- N_("No CD-ROM could be auto-detected or found using "
- "the default mount point.\n"
- "You may try the --cdrom option to set the CD-ROM mount point. "
- "See 'man apt-cdrom' for more "
- "information about the CD-ROM auto-detection and mount point.");
using namespace std;
@@ -54,7 +41,7 @@ class pkgCdromTextStatus : public pkgCdromStatus /*{{{*/
{
protected:
OpTextProgress Progress;
- void Prompt(const char *Text);
+ void Prompt(const char *Text);
string PromptLine(const char *Text);
bool AskCdromName(string &name);
@@ -64,12 +51,12 @@ public:
virtual OpProgress* GetOpProgress();
};
-void pkgCdromTextStatus::Prompt(const char *Text)
+void pkgCdromTextStatus::Prompt(const char *Text)
{
char C;
cout << Text << ' ' << flush;
if (read(STDIN_FILENO,&C,1) < 0)
- _error->Errno("pkgCdromTextStatus::Prompt",
+ _error->Errno("pkgCdromTextStatus::Prompt",
"Failed to read from standard input (not a terminal?)");
if (C != '\n')
cout << endl;
@@ -78,176 +65,144 @@ void pkgCdromTextStatus::Prompt(const char *Text)
string pkgCdromTextStatus::PromptLine(const char *Text)
{
cout << Text << ':' << endl;
-
+
string Res;
getline(cin,Res);
return Res;
}
-bool pkgCdromTextStatus::AskCdromName(string &name)
+bool pkgCdromTextStatus::AskCdromName(string &name)
{
cout << _("Please provide a name for this Disc, such as 'Debian 5.0.3 Disk 1'") << flush;
name = PromptLine("");
-
+
return true;
}
-
-void pkgCdromTextStatus::Update(string text, int current)
+
+void pkgCdromTextStatus::Update(string text, int /*current*/)
{
if(text.size() > 0)
cout << text << flush;
}
-bool pkgCdromTextStatus::ChangeCdrom()
+bool pkgCdromTextStatus::ChangeCdrom()
{
Prompt(_("Please insert a Disc in the drive and press enter"));
return true;
}
-OpProgress* pkgCdromTextStatus::GetOpProgress()
-{
- return &Progress;
-};
- /*}}}*/
-// SetupAutoDetect /*{{{*/
-bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &automounted)
+APT_CONST OpProgress* pkgCdromTextStatus::GetOpProgress()
{
- bool Debug = _config->FindB("Debug::Acquire::cdrom", false);
-
- automounted = false;
-
- vector<struct CdromDevice> v = UdevCdroms.Scan();
- if (i >= v.size())
- return false;
-
- if (Debug)
- clog << "Looking at devce " << i
- << " DeviveName: " << v[i].DeviceName
- << " IsMounted: '" << v[i].Mounted << "'"
- << " MountPoint: '" << v[i].MountPath << "'"
- << endl;
-
- if (v[i].Mounted)
- {
- // set the right options
- _config->Set("Acquire::cdrom::mount", v[i].MountPath);
- _config->Set("APT::CDROM::NoMount", true);
- } else {
- string AptMountPoint = _config->FindDir("Dir::Media::MountPath");
- if (!FileExists(AptMountPoint))
- mkdir(AptMountPoint.c_str(), 0750);
- if(MountCdrom(AptMountPoint, v[i].DeviceName) == false)
- _error->Warning(_("Failed to mount '%s' to '%s'"), v[i].DeviceName.c_str(), AptMountPoint.c_str());
- else
- automounted = true;
- _config->Set("Acquire::cdrom::mount", AptMountPoint);
- _config->Set("APT::CDROM::NoMount", true);
- }
- i++;
-
- return true;
+ return &Progress;
}
/*}}}*/
-// DoAdd - Add a new CDROM /*{{{*/
-// ---------------------------------------------------------------------
-/* This does the main add bit.. We show some status and things. The
- sequence is to mount/umount the CD, Ident it then scan it for package
- files and reduce that list. Then we copy over the package files and
- verify them. Then rewrite the database files */
-bool DoAdd(CommandLine &)
+// AddOrIdent - Add or Ident a CDROM /*{{{*/
+static bool AddOrIdent(bool const Add)
{
pkgUdevCdromDevices UdevCdroms;
pkgCdromTextStatus log;
pkgCdrom cdrom;
- bool res = true;
+ bool oneSuccessful = false;
bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true);
- unsigned int count = 0;
- string AptMountPoint = _config->FindDir("Dir::Media::MountPath");
- bool automounted = false;
- if (AutoDetect && UdevCdroms.Dlopen())
- while (AutoDetectCdrom(UdevCdroms, count, automounted)) {
- if (count == 1) {
- // begin loop with res false to detect any success using OR
- res = false;
+ if (AutoDetect == true && UdevCdroms.Dlopen() == true)
+ {
+ bool const Debug = _config->FindB("Debug::Acquire::cdrom", false);
+ std::string const CDMount = _config->Find("Acquire::cdrom::mount");
+ bool const NoMount = _config->FindB("APT::CDROM::NoMount", false);
+ if (NoMount == false)
+ _config->Set("APT::CDROM::NoMount", true);
+
+ vector<struct CdromDevice> const v = UdevCdroms.Scan();
+ for (std::vector<struct CdromDevice>::const_iterator cd = v.begin(); cd != v.end(); ++cd)
+ {
+ if (Debug)
+ clog << "Looking at device:"
+ << "\tDeviveName: '" << cd->DeviceName << "'"
+ << "\tIsMounted: '" << cd->Mounted << "'"
+ << "\tMountPoint: '" << cd->MountPath << "'"
+ << endl;
+
+ std::string AptMountPoint;
+ if (cd->Mounted)
+ _config->Set("Acquire::cdrom::mount", cd->MountPath);
+ else if (NoMount == true)
+ continue;
+ else
+ {
+ AptMountPoint = _config->FindDir("Dir::Media::MountPath");
+ if (FileExists(AptMountPoint) == false)
+ mkdir(AptMountPoint.c_str(), 0750);
+ if(MountCdrom(AptMountPoint, cd->DeviceName) == false)
+ {
+ _error->Warning(_("Failed to mount '%s' to '%s'"), cd->DeviceName.c_str(), AptMountPoint.c_str());
+ continue;
+ }
+ _config->Set("Acquire::cdrom::mount", AptMountPoint);
}
- // dump any warnings/errors from autodetect
- if (_error->empty() == false)
- _error->DumpErrors();
-
- res |= cdrom.Add(&log);
+ _error->PushToStack();
+ if (Add == true)
+ oneSuccessful = cdrom.Add(&log);
+ else
+ {
+ std::string id;
+ oneSuccessful = cdrom.Ident(id, &log);
+ }
+ _error->MergeWithStack();
- if (automounted)
+ if (AptMountPoint.empty() == false)
UnmountCdrom(AptMountPoint);
-
- // dump any warnings/errors from add/unmount
- if (_error->empty() == false)
- _error->DumpErrors();
}
+ if (NoMount == false)
+ _config->Set("APT::CDROM::NoMount", NoMount);
+ _config->Set("Acquire::cdrom::mount", CDMount);
+ }
- if (count == 0)
- res = cdrom.Add(&log);
+ // fallback if auto-detect didn't work
+ if (oneSuccessful == false)
+ {
+ _error->PushToStack();
+ if (Add == true)
+ oneSuccessful = cdrom.Add(&log);
+ else
+ {
+ std::string id;
+ oneSuccessful = cdrom.Ident(id, &log);
+ }
+ _error->MergeWithStack();
+ }
- if (res == false)
- _error->Error("%s", _(W_NO_CDROM_FOUND));
- else
+ if (oneSuccessful == false)
+ _error->Error("%s", _("No CD-ROM could be auto-detected or found using the default mount point.\n"
+ "You may try the --cdrom option to set the CD-ROM mount point.\n"
+ "See 'man apt-cdrom' for more information about the CD-ROM auto-detection and mount point."));
+ else if (Add == true)
cout << _("Repeat this process for the rest of the CDs in your set.") << endl;
- return res;
+ return oneSuccessful;
}
/*}}}*/
-// DoIdent - Ident a CDROM /*{{{*/
+// DoAdd - Add a new CDROM /*{{{*/
// ---------------------------------------------------------------------
-/* */
-bool DoIdent(CommandLine &)
+/* This does the main add bit.. We show some status and things. The
+ sequence is to mount/umount the CD, Ident it then scan it for package
+ files and reduce that list. Then we copy over the package files and
+ verify them. Then rewrite the database files */
+static bool DoAdd(CommandLine &)
{
- pkgUdevCdromDevices UdevCdroms;
- string ident;
- pkgCdromTextStatus log;
- pkgCdrom cdrom;
- bool res = true;
-
- bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true);
-
- unsigned int count = 0;
- string AptMountPoint = _config->FindDir("Dir::Media::MountPath");
- bool automounted = false;
- if (AutoDetect && UdevCdroms.Dlopen())
- while (AutoDetectCdrom(UdevCdroms, count, automounted)) {
- if (count == 1) {
- // begin loop with res false to detect any success using OR
- res = false;
- }
-
- // dump any warnings/errors from autodetect
- if (_error->empty() == false)
- _error->DumpErrors();
-
- res |= cdrom.Ident(ident, &log);
-
- if (automounted)
- UnmountCdrom(AptMountPoint);
-
- // dump any warnings/errors from add/unmount
- if (_error->empty() == false)
- _error->DumpErrors();
- }
-
- if (count == 0)
- res = cdrom.Ident(ident, &log);
-
- if (res == false)
- _error->Error("%s", _(W_NO_CDROM_FOUND));
-
- return res;
+ return AddOrIdent(true);
+}
+ /*}}}*/
+// DoIdent - Ident a CDROM /*{{{*/
+static bool DoIdent(CommandLine &)
+{
+ return AddOrIdent(false);
}
/*}}}*/
// ShowHelp - Show the help screen /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool ShowHelp(CommandLine &)
+static bool ShowHelp(CommandLine &)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
@@ -313,14 +268,12 @@ int main(int argc,const char *argv[]) /*{{{*/
_config->Set("quiet","1");
// Match the operation
- CmdL.DispatchArg(Cmds);
+ bool returned = CmdL.DispatchArg(Cmds);
- // Print any errors or warnings found during parsing
- bool const Errors = _error->PendingError();
if (_config->FindI("quiet",0) > 0)
_error->DumpErrors();
else
_error->DumpErrors(GlobalError::DEBUG);
- return Errors == true ? 100 : 0;
+ return returned == true ? 0 : 100;
}
/*}}}*/
diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc
index 8b63507a7..40ba468eb 100644
--- a/cmdline/apt-config.cc
+++ b/cmdline/apt-config.cc
@@ -26,10 +26,10 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/pkgsystem.h>
-#include <locale.h>
#include <iostream>
#include <string>
#include <vector>
+#include <string.h>
#include <apt-private/private-cmndline.h>
@@ -40,7 +40,7 @@ using namespace std;
// DoShell - Handle the shell command /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DoShell(CommandLine &CmdL)
+static bool DoShell(CommandLine &CmdL)
{
for (const char **I = CmdL.FileList + 1; *I != 0; I += 2)
{
@@ -63,7 +63,7 @@ bool DoShell(CommandLine &CmdL)
// DoDump - Dump the configuration space /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DoDump(CommandLine &CmdL)
+static bool DoDump(CommandLine &CmdL)
{
bool const empty = _config->FindB("APT::Config::Dump::EmptyValue", true);
std::string const format = _config->Find("APT::Config::Dump::Format", "%f \"%v\";\n");
@@ -78,7 +78,7 @@ bool DoDump(CommandLine &CmdL)
// ShowHelp - Show the help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp(CommandLine &CmdL)
+static bool ShowHelp(CommandLine &)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
@@ -155,6 +155,11 @@ int main(int argc,const char *argv[]) /*{{{*/
_config->Set(comp + "UncompressArg::", *a);
}
+ std::vector<std::string> const profiles = APT::Configuration::getBuildProfiles();
+ _config->Clear("APT::Build-Profiles");
+ for (std::vector<std::string>::const_iterator p = profiles.begin(); p != profiles.end(); ++p)
+ _config->Set("APT::Build-Profiles::", *p);
+
// Match the operation
CmdL.DispatchArg(Cmds);
diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc
index aa16b1271..04e13bde9 100644
--- a/cmdline/apt-dump-solver.cc
+++ b/cmdline/apt-dump-solver.cc
@@ -9,16 +9,18 @@
// Include Files /*{{{*/
#include <apt-pkg/edsp.h>
-#include <config.h>
-
+#include <string.h>
+#include <unistd.h>
#include <cstdio>
#include <iostream>
+
+#include <config.h>
/*}}}*/
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp() {
+static bool ShowHelp() {
std::cout <<
PACKAGE " " PACKAGE_VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl <<
diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc
index 2408a7d9d..e4428e051 100644
--- a/cmdline/apt-extracttemplates.cc
+++ b/cmdline/apt-extracttemplates.cc
@@ -18,8 +18,8 @@
#include <apt-pkg/init.h>
#include <apt-pkg/cmndline.h>
#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/progress.h>
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/pkgcachegen.h>
#include <apt-pkg/version.h>
@@ -30,14 +30,14 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/dirstream.h>
+#include <apt-pkg/mmap.h>
+#include <iostream>
#include <stdio.h>
#include <string.h>
-#include <stdlib.h>
#include <unistd.h>
-#include <locale.h>
-
-#include <fstream>
+#include <stdlib.h>
#include "apt-extracttemplates.h"
@@ -137,7 +137,7 @@ bool DebFile::DoItem(Item &I, int &Fd)
// DebFile::Process examine element in package and copy /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DebFile::Process(Item &I, const unsigned char *data,
+bool DebFile::Process(Item &/*I*/, const unsigned char *data,
unsigned long size, unsigned long pos)
{
switch (Which)
@@ -212,7 +212,7 @@ bool DebFile::ParseInfo()
// ShowHelp - show a short help text /*{{{*/
// ---------------------------------------------------------------------
/* */
-int ShowHelp(void)
+static int ShowHelp(void)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
@@ -237,26 +237,28 @@ int ShowHelp(void)
// WriteFile - write the contents of the passed string to a file /*{{{*/
// ---------------------------------------------------------------------
/* */
-string WriteFile(const char *package, const char *prefix, const char *data)
+static string WriteFile(const char *package, const char *prefix, const char *data)
{
char fn[512];
- static int i;
std::string tempdir = GetTempDir();
- snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d",
+ snprintf(fn, sizeof(fn), "%s/%s.%s.XXXXXX",
_config->Find("APT::ExtractTemplates::TempDir",
tempdir.c_str()).c_str(),
- package, prefix, getpid(), i++);
+ package, prefix);
FileFd f;
if (data == NULL)
data = "";
-
- if (!f.Open(fn, FileFd::WriteTemp, 0600))
+ int fd = mkstemp(fn);
+ if (fd < 0) {
+ _error->Errno("ofstream::ofstream",_("Unable to mkstemp %s"),fn);
+ return string();
+ }
+ if (!f.OpenDescriptor(fd, FileFd::WriteOnly, FileFd::None, true))
{
_error->Errno("ofstream::ofstream",_("Unable to write to %s"),fn);
return string();
}
-
f.Write(data, strlen(data));
f.Close();
return fn;
@@ -265,7 +267,7 @@ string WriteFile(const char *package, const char *prefix, const char *data)
// WriteConfig - write out the config data from a debian package file /*{{{*/
// ---------------------------------------------------------------------
/* */
-void WriteConfig(const DebFile &file)
+static void WriteConfig(const DebFile &file)
{
string templatefile = WriteFile(file.Package.c_str(), "template", file.Template);
string configscript = WriteFile(file.Package.c_str(), "config", file.Config);
@@ -279,7 +281,7 @@ void WriteConfig(const DebFile &file)
// InitCache - initialize the package cache /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Go(CommandLine &CmdL)
+static bool Go(CommandLine &CmdL)
{
// Initialize the apt cache
MMap *Map = 0;
diff --git a/cmdline/apt-extracttemplates.h b/cmdline/apt-extracttemplates.h
index 6d07a09c2..9cc3f5f25 100644
--- a/cmdline/apt-extracttemplates.h
+++ b/cmdline/apt-extracttemplates.h
@@ -11,11 +11,12 @@
#define _APTEXTRACTTEMPLATE_H_
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/pkgcache.h>
#include <apt-pkg/dirstream.h>
#include <string>
+class pkgCache;
+
class DebFile : public pkgDirStream
{
FileFd File;
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 3bdc63217..e7fd4bfb8 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -27,66 +27,67 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/algorithms.h>
#include <apt-pkg/aptconfiguration.h>
-#include <apt-pkg/error.h>
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cacheset.h>
+#include <apt-pkg/clean.h>
#include <apt-pkg/cmndline.h>
-#include <apt-pkg/init.h>
+#include <apt-pkg/debmetaindex.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/error.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/indexfile.h>
+#include <apt-pkg/indexrecords.h>
+#include <apt-pkg/init.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/versionmatch.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/metaindex.h>
#include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexfile.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/sourcelist.h>
+#include <apt-pkg/srcrecords.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/upgrade.h>
-#include <apt-pkg/metaindex.h>
-#include <apt-pkg/indexrecords.h>
+#include <apt-private/acqprogress.h>
+#include <apt-private/private-cacheset.h>
+#include <apt-private/private-cachefile.h>
+#include <apt-private/private-cmndline.h>
#include <apt-private/private-download.h>
#include <apt-private/private-install.h>
-#include <apt-private/private-upgrade.h>
+#include <apt-private/private-main.h>
+#include <apt-private/private-moo.h>
#include <apt-private/private-output.h>
-#include <apt-private/private-cacheset.h>
#include <apt-private/private-update.h>
-#include <apt-private/private-cmndline.h>
-#include <apt-private/private-moo.h>
+#include <apt-private/private-upgrade.h>
#include <apt-private/private-utils.h>
-#include <apt-pkg/debmetaindex.h>
-
-#include <apt-private/acqprogress.h>
-
-#include <set>
-#include <fstream>
-#include <sstream>
-
-#include <locale.h>
-#include <langinfo.h>
-#include <termios.h>
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.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 <apt-private/private-output.h>
-#include <apt-private/private-main.h>
+#include <unistd.h>
+#include <algorithm>
+#include <fstream>
+#include <iostream>
+#include <set>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -97,7 +98,7 @@ using namespace std;
// ---------------------------------------------------------------------
/* This used to be inlined in DoInstall, but with the advent of regex package
name matching it was split out.. */
-bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
+static bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
pkgProblemResolver &Fix,bool Remove,bool BrokenFix,
bool AllowFail = true)
{
@@ -138,7 +139,7 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache,
// helper that can go wit hthe next ABI break
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13)
-std::string MetaIndexFileNameOnDisk(metaIndex *metaindex)
+static std::string MetaIndexFileNameOnDisk(metaIndex *metaindex)
{
// FIXME: this cast is the horror, the horror
debReleaseIndex *r = (debReleaseIndex*)metaindex;
@@ -159,7 +160,7 @@ std::string MetaIndexFileNameOnDisk(metaIndex *metaindex)
// GetReleaseForSourceRecord - Return Suite for the given srcrecord /*{{{*/
// ---------------------------------------------------------------------
/* */
-std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
+static std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
pkgSrcRecords::Parser *Parse)
{
// try to find release
@@ -194,7 +195,7 @@ std::string GetReleaseForSourceRecord(pkgSourceList *SrcList,
// FindSrc - Find a source record /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
+static pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
pkgSrcRecords &SrcRecs,string &Src,
CacheFile &CacheFile)
{
@@ -430,7 +431,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
}
/*}}}*/
/* mark packages as automatically/manually installed. {{{*/
-bool DoMarkAuto(CommandLine &CmdL)
+static bool DoMarkAuto(CommandLine &CmdL)
{
bool Action = true;
int AutoMarkChanged = 0;
@@ -475,7 +476,7 @@ bool DoMarkAuto(CommandLine &CmdL)
// DoDSelectUpgrade - Do an upgrade by following dselects selections /*{{{*/
// ---------------------------------------------------------------------
/* Follows dselect's selections */
-bool DoDSelectUpgrade(CommandLine &CmdL)
+static bool DoDSelectUpgrade(CommandLine &)
{
CacheFile Cache;
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
@@ -551,7 +552,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// DoClean - Remove download archives /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DoClean(CommandLine &CmdL)
+static bool DoClean(CommandLine &)
{
std::string const archivedir = _config->FindDir("Dir::Cache::archives");
std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
@@ -599,7 +600,7 @@ class LogCleaner : public pkgArchiveCleaner
};
};
-bool DoAutoClean(CommandLine &CmdL)
+static bool DoAutoClean(CommandLine &)
{
// Lock the archive directory
FileFd Lock;
@@ -623,7 +624,7 @@ bool DoAutoClean(CommandLine &CmdL)
/*}}}*/
// DoDownload - download a binary /*{{{*/
// ---------------------------------------------------------------------
-bool DoDownload(CommandLine &CmdL)
+static bool DoDownload(CommandLine &CmdL)
{
CacheFile Cache;
if (Cache.ReadOnlyOpen() == false)
@@ -696,7 +697,7 @@ bool DoDownload(CommandLine &CmdL)
// ---------------------------------------------------------------------
/* Opening automatically checks the system, this command is mostly used
for debugging */
-bool DoCheck(CommandLine &CmdL)
+static bool DoCheck(CommandLine &)
{
CacheFile Cache;
Cache.Open();
@@ -715,7 +716,7 @@ struct DscFile
string Dsc;
};
-bool DoSource(CommandLine &CmdL)
+static bool DoSource(CommandLine &CmdL)
{
CacheFile Cache;
if (Cache.Open(false) == false)
@@ -740,7 +741,7 @@ bool DoSource(CommandLine &CmdL)
pkgAcquire Fetcher;
Fetcher.SetLog(&Stat);
- DscFile *Dsc = new DscFile[CmdL.FileSize()];
+ SPtrArray<DscFile> Dsc = new DscFile[CmdL.FileSize()];
// insert all downloaded uris into this set to avoid downloading them
// twice
@@ -761,7 +762,6 @@ bool DoSource(CommandLine &CmdL)
pkgSrcRecords::Parser *Last = FindSrc(*I,Recs,SrcRecs,Src,Cache);
if (Last == 0) {
- delete[] Dsc;
return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
}
@@ -795,7 +795,6 @@ bool DoSource(CommandLine &CmdL)
// Back track
vector<pkgSrcRecords::File> Lst;
if (Last->Files(Lst) == false) {
- delete[] Dsc;
return false;
}
@@ -858,7 +857,6 @@ bool DoSource(CommandLine &CmdL)
struct statvfs Buf;
string OutputDir = ".";
if (statvfs(OutputDir.c_str(),&Buf) != 0) {
- delete[] Dsc;
if (errno == EOVERFLOW)
return _error->WarningE("statvfs",_("Couldn't determine free space in %s"),
OutputDir.c_str());
@@ -873,7 +871,6 @@ bool DoSource(CommandLine &CmdL)
|| unsigned(Stat.f_type) != RAMFS_MAGIC
#endif
) {
- delete[] Dsc;
return _error->Error(_("You don't have enough free space in %s"),
OutputDir.c_str());
}
@@ -895,7 +892,6 @@ bool DoSource(CommandLine &CmdL)
{
for (unsigned I = 0; I != J; I++)
ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str());
- delete[] Dsc;
return true;
}
@@ -906,7 +902,6 @@ bool DoSource(CommandLine &CmdL)
for (; I != Fetcher.UriEnd(); ++I)
cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
- delete[] Dsc;
return true;
}
@@ -914,14 +909,12 @@ bool DoSource(CommandLine &CmdL)
bool Failed = false;
if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
{
- delete[] Dsc;
return _error->Error(_("Failed to fetch some archives."));
}
if (_config->FindB("APT::Get::Download-only",false) == true)
{
c1out << _("Download complete and in download only mode") << endl;
- delete[] Dsc;
return true;
}
@@ -970,6 +963,12 @@ bool DoSource(CommandLine &CmdL)
string buildopts = _config->Find("APT::Get::Host-Architecture");
if (buildopts.empty() == false)
buildopts = "-a" + buildopts + " ";
+
+ // get all active build profiles
+ std::string const profiles = APT::Configuration::getBuildProfilesString();
+ if (profiles.empty() == false)
+ buildopts.append(" -P").append(profiles).append(" ");
+
buildopts.append(_config->Find("DPkg::Build-Options","-b -uc"));
// Call dpkg-buildpackage
@@ -989,7 +988,6 @@ bool DoSource(CommandLine &CmdL)
_exit(0);
}
- delete[] Dsc;
// Wait for the subprocess
int Status = 0;
@@ -1010,7 +1008,7 @@ bool DoSource(CommandLine &CmdL)
// ---------------------------------------------------------------------
/* This function will look at the build depends list of the given source
package and install the necessary packages to make it true, or fail. */
-bool DoBuildDep(CommandLine &CmdL)
+static bool DoBuildDep(CommandLine &CmdL)
{
CacheFile Cache;
@@ -1404,7 +1402,7 @@ bool DoBuildDep(CommandLine &CmdL)
* pool/ next to the deb itself)
* Example return: "pool/main/a/apt/apt_0.8.8ubuntu3"
*/
-string GetChangelogPath(CacheFile &Cache,
+static string GetChangelogPath(CacheFile &Cache,
pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver)
{
@@ -1431,7 +1429,7 @@ string GetChangelogPath(CacheFile &Cache,
* apt-get changelog mplayer-doc:
* http://packages.medibuntu.org/pool/non-free/m/mplayer/mplayer_1.0~rc4~try1.dsfg1-1ubuntu1+medibuntu1.changelog
*/
-bool GuessThirdPartyChangelogUri(CacheFile &Cache,
+static bool GuessThirdPartyChangelogUri(CacheFile &Cache,
pkgCache::PkgIterator Pkg,
pkgCache::VerIterator Ver,
string &out_uri)
@@ -1456,7 +1454,7 @@ bool GuessThirdPartyChangelogUri(CacheFile &Cache,
/*}}}*/
// DownloadChangelog - Download the changelog /*{{{*/
// ---------------------------------------------------------------------
-bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher,
+static bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher,
pkgCache::VerIterator Ver, string targetfile)
/* Download a changelog file for the given package version to
* targetfile. This will first try the server from Apt::Changelogs::Server
@@ -1514,7 +1512,7 @@ bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher,
/*}}}*/
// DoChangelog - Get changelog from the command line /*{{{*/
// ---------------------------------------------------------------------
-bool DoChangelog(CommandLine &CmdL)
+static bool DoChangelog(CommandLine &CmdL)
{
CacheFile Cache;
if (Cache.ReadOnlyOpen() == false)
@@ -1578,7 +1576,7 @@ bool DoChangelog(CommandLine &CmdL)
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp(CommandLine &CmdL)
+static bool ShowHelp(CommandLine &)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
@@ -1674,7 +1672,7 @@ bool ShowHelp(CommandLine &CmdL)
// SigWinch - Window size change signal handler /*{{{*/
// ---------------------------------------------------------------------
/* */
-void SigWinch(int)
+static void SigWinch(int)
{
// Riped from GNU ls
#ifdef TIOCGWINSZ
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
new file mode 100644
index 000000000..2c1107d90
--- /dev/null
+++ b/cmdline/apt-helper.cc
@@ -0,0 +1,125 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* #####################################################################
+ apt-helper - cmdline helpers
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#include <config.h>
+
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/cmndline.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/acquire.h>
+#include <apt-pkg/acquire-item.h>
+
+#include <apt-private/acqprogress.h>
+#include <apt-private/private-output.h>
+#include <apt-private/private-download.h>
+#include <apt-private/private-cmndline.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <apti18n.h>
+ /*}}}*/
+
+static bool DoDownloadFile(CommandLine &CmdL)
+{
+ if (CmdL.FileSize() <= 2)
+ return _error->Error(_("Must specify at least one pair url/filename"));
+
+
+ pkgAcquire Fetcher;
+ AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
+ Fetcher.Setup(&Stat);
+ std::string download_uri = CmdL.FileList[1];
+ std::string targetfile = CmdL.FileList[2];
+ std::string hash;
+ if (CmdL.FileSize() > 3)
+ hash = CmdL.FileList[3];
+ new pkgAcqFile(&Fetcher, download_uri, hash, 0, "desc", "short-desc",
+ "dest-dir-ignored", targetfile);
+ Fetcher.Run();
+ bool Failed = false;
+ if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true ||
+ FileExists(targetfile) == false)
+ return _error->Error(_("Download Failed"));
+ return true;
+}
+
+static bool ShowHelp(CommandLine &)
+{
+ ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
+ COMMON_ARCH,__DATE__,__TIME__);
+
+ if (_config->FindB("version") == true)
+ return true;
+
+ std::cout <<
+ _("Usage: apt-helper [options] command\n"
+ " apt-helper [options] download-file uri target-path\n"
+ "\n"
+ "apt-helper is a internal helper for apt\n"
+ "\n"
+ "Commands:\n"
+ " download-file - download the given uri to the target-path\n"
+ "\n"
+ " This APT helper has Super Meep Powers.\n");
+ return true;
+}
+
+
+int main(int argc,const char *argv[]) /*{{{*/
+{
+ CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp},
+ {"download-file", &DoDownloadFile},
+ {0,0}};
+
+ std::vector<CommandLine::Args> Args = getCommandArgs(
+ "apt-download", CommandLine::GetCommand(Cmds, argc, argv));
+
+ // Set up gettext support
+ setlocale(LC_ALL,"");
+ textdomain(PACKAGE);
+
+ // Parse the command line and initialize the package library
+ CommandLine CmdL(Args.data(),_config);
+ if (pkgInitConfig(*_config) == false ||
+ CmdL.Parse(argc,argv) == false ||
+ pkgInitSystem(*_config,_system) == false)
+ {
+ if (_config->FindB("version") == true)
+ ShowHelp(CmdL);
+ _error->DumpErrors();
+ return 100;
+ }
+
+ // See if the help should be shown
+ if (_config->FindB("help") == true ||
+ _config->FindB("version") == true ||
+ CmdL.FileSize() == 0)
+ {
+ ShowHelp(CmdL);
+ return 0;
+ }
+
+ InitOutput();
+
+ // Match the operation
+ CmdL.DispatchArg(Cmds);
+
+ // Print any errors or warnings found during parsing
+ bool const Errors = _error->PendingError();
+ if (_config->FindI("quiet",0) > 0)
+ _error->DumpErrors();
+ else
+ _error->DumpErrors(GlobalError::DEBUG);
+ return Errors == true ? 100 : 0;
+}
+ /*}}}*/
diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc
index bf5b8c1fe..b85c07c33 100644
--- a/cmdline/apt-internal-solver.cc
+++ b/cmdline/apt-internal-solver.cc
@@ -20,7 +20,15 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/upgrade.h>
-
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
+
+#include <string.h>
+#include <iostream>
+#include <list>
+#include <string>
#include <unistd.h>
#include <cstdio>
@@ -30,7 +38,7 @@
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp(CommandLine &CmdL) {
+static bool ShowHelp(CommandLine &) {
ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc
index d3a3a780b..ed348358a 100644
--- a/cmdline/apt-mark.cc
+++ b/cmdline/apt-mark.cc
@@ -11,20 +11,31 @@
#include <apt-pkg/cacheset.h>
#include <apt-pkg/cmndline.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
#include <apt-pkg/init.h>
-#include <apt-pkg/strutl.h>
#include <apt-pkg/pkgsystem.h>
-#include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.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 <apt-private/private-cmndline.h>
-#include <algorithm>
#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
#include <fcntl.h>
-
-#include <apt-private/private-cmndline.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <algorithm>
+#include <fstream>
+#include <iostream>
+#include <string>
+#include <vector>
#include <apti18n.h>
/*}}}*/
@@ -35,7 +46,7 @@ ostream c1out(0);
ostream c2out(0);
ofstream devnull("/dev/null");
/* DoAuto - mark packages as automatically/manually installed {{{*/
-bool DoAuto(CommandLine &CmdL)
+static bool DoAuto(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -82,7 +93,7 @@ bool DoAuto(CommandLine &CmdL)
/* DoMarkAuto - mark packages as automatically/manually installed {{{*/
/* Does the same as DoAuto but tries to do it exactly the same why as
the python implementation did it so it can be a drop-in replacement */
-bool DoMarkAuto(CommandLine &CmdL)
+static bool DoMarkAuto(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -119,7 +130,7 @@ bool DoMarkAuto(CommandLine &CmdL)
}
/*}}}*/
/* ShowAuto - show automatically installed packages (sorted) {{{*/
-bool ShowAuto(CommandLine &CmdL)
+static bool ShowAuto(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -159,7 +170,7 @@ bool ShowAuto(CommandLine &CmdL)
}
/*}}}*/
/* DoHold - mark packages as hold by dpkg {{{*/
-bool DoHold(CommandLine &CmdL)
+static bool DoHold(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -335,7 +346,7 @@ bool DoHold(CommandLine &CmdL)
}
/*}}}*/
/* ShowHold - show packages set on hold in dpkg status {{{*/
-bool ShowHold(CommandLine &CmdL)
+static bool ShowHold(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
@@ -372,7 +383,7 @@ bool ShowHold(CommandLine &CmdL)
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ShowHelp(CommandLine &CmdL)
+static bool ShowHelp(CommandLine &)
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc
index 46989044e..c2b11890a 100644
--- a/cmdline/apt-sortpkgs.cc
+++ b/cmdline/apt-sortpkgs.cc
@@ -25,9 +25,9 @@
#include <vector>
#include <algorithm>
-
-#include <locale.h>
-#include <unistd.h>
+#include <stdio.h>
+#include <iostream>
+#include <string>
#include <apti18n.h>
/*}}}*/
@@ -62,7 +62,7 @@ struct PkgName /*{{{*/
// DoIt - Sort a single file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DoIt(string InFile)
+static bool DoIt(string InFile)
{
FileFd Fd(InFile,FileFd::ReadOnly);
pkgTagFile Tags(&Fd);
@@ -142,7 +142,7 @@ bool DoIt(string InFile)
// ShowHelp - Show the help text /*{{{*/
// ---------------------------------------------------------------------
/* */
-int ShowHelp()
+static int ShowHelp()
{
ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 7ef9060aa..4813861a4 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -11,39 +11,12 @@
// Include Files /*{{{*/
#include<config.h>
-#include <cassert>
-#include <locale.h>
-#include <iostream>
-#include <unistd.h>
-#include <errno.h>
-#include <regex.h>
-#include <stdio.h>
-#include <iomanip>
-#include <algorithm>
-
-
+#include <apt-pkg/cmndline.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/cachefile.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/hashes.h>
-
-#include <apti18n.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/configuration.h>
#include <apt-private/private-list.h>
#include <apt-private/private-search.h>
@@ -55,13 +28,16 @@
#include <apt-private/private-upgrade.h>
#include <apt-private/private-show.h>
#include <apt-private/private-main.h>
-#include <apt-private/private-utils.h>
#include <apt-private/private-sources.h>
- /*}}}*/
+#include <unistd.h>
+#include <iostream>
+#include <vector>
+#include <apti18n.h>
+ /*}}}*/
-bool ShowHelp(CommandLine &CmdL)
+static bool ShowHelp(CommandLine &)
{
ioprintf(c1out,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
COMMON_ARCH,__DATE__,__TIME__);
@@ -94,7 +70,7 @@ int main(int argc, const char *argv[]) /*{{{*/
{
CommandLine::Dispatch Cmds[] = {
// query
- {"list",&List},
+ {"list",&DoList},
{"search", &FullTextSearch},
{"show", &APT::Cmd::ShowPackage},
@@ -133,7 +109,7 @@ int main(int argc, const char *argv[]) /*{{{*/
}
// some different defaults
- _config->CndSet("DPkgPM::Progress", "1");
+ _config->CndSet("DPkg::Progress-Fancy", "1");
_config->CndSet("Apt::Color", "1");
_config->CndSet("APT::Get::Upgrade-Allow-New", true);
diff --git a/cmdline/makefile b/cmdline/makefile
index f89192e10..c4a249cd6 100644
--- a/cmdline/makefile
+++ b/cmdline/makefile
@@ -47,6 +47,13 @@ LIB_MAKES = apt-pkg/makefile
SOURCE = apt-mark.cc
include $(PROGRAM_H)
+# The apt-helper
+PROGRAM=apt-helper
+SLIBS = -lapt-pkg -lapt-private $(INTLLIBS)
+LIB_MAKES = apt-pkg/makefile
+SOURCE = apt-helper.cc
+include $(PROGRAM_H)
+
# The apt-report-mirror-failure program
#SOURCE=apt-report-mirror-failure
#TO=$(BIN)