summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-09-05 14:47:22 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-09-05 14:47:22 +0200
commit30b683f4f3021cd191ffef04bfaf2deb65820a52 (patch)
treeb58771461581111f7bbbfd8d3e8eba012dc776ff /apt-pkg
parente6e893903869635ab7ee3200f654129b08717ded (diff)
parent8c782efd93342c6119e8ba2ff6989b7a164b7f3d (diff)
Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc4
-rw-r--r--apt-pkg/cachefile.cc3
-rw-r--r--apt-pkg/contrib/proxy.cc82
-rw-r--r--apt-pkg/contrib/proxy.h16
-rw-r--r--apt-pkg/contrib/strutl.cc9
-rw-r--r--apt-pkg/deb/deblistparser.cc6
-rw-r--r--apt-pkg/deb/dpkgpm.cc13
-rw-r--r--apt-pkg/depcache.cc3
-rw-r--r--apt-pkg/packagemanager.cc49
9 files changed, 169 insertions, 16 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 0ec151050..eee1097e9 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -376,7 +376,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
Desc.URI = Target->URI + ".diff/Index";
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(Target->URI) + string(".DiffIndex");
+ DestFile += URItoFileName(Desc.URI);
if(Debug)
std::clog << "pkgAcqDiffIndex: " << Desc.URI << std::endl;
@@ -412,7 +412,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
string pkgAcqDiffIndex::Custom600Headers() const
{
string Final = _config->FindDir("Dir::State::lists");
- Final += URItoFileName(RealURI) + string(".IndexDiff");
+ Final += URItoFileName(Desc.URI);
if(Debug)
std::clog << "Custom600Header-IMS: " << Final << std::endl;
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 0fd40106f..ea3d45480 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -143,6 +143,9 @@ bool pkgCacheFile::BuildDepCache(OpProgress *Progress)
if (DCache != NULL)
return true;
+ if (BuildPolicy(Progress) == false)
+ return false;
+
DCache = new pkgDepCache(Cache,Policy);
if (_error->PendingError() == true)
return false;
diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
new file mode 100644
index 000000000..b58db8478
--- /dev/null
+++ b/apt-pkg/contrib/proxy.cc
@@ -0,0 +1,82 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ Proxy - Proxy releated functions
+
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#include<apt-pkg/configuration.h>
+#include<apt-pkg/error.h>
+#include<apt-pkg/fileutl.h>
+#include<apt-pkg/strutl.h>
+
+#include<iostream>
+#include <unistd.h>
+
+#include "proxy.h"
+
+
+// AutoDetectProxy - auto detect proxy /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool AutoDetectProxy(URI &URL)
+{
+ // we support both http/https debug options
+ bool Debug = _config->FindB("Debug::Acquire::"+URL.Access,false);
+
+ // option is "Acquire::http::Proxy-Auto-Detect" but we allow the old
+ // name without the dash ("-")
+ std::string AutoDetectProxyCmd = _config->Find("Acquire::"+URL.Access+"::Proxy-Auto-Detect",
+ _config->Find("Acquire::"+URL.Access+"::ProxyAutoDetect"));
+
+ if (AutoDetectProxyCmd.empty())
+ return true;
+
+ if (Debug)
+ std::clog << "Using auto proxy detect command: " << AutoDetectProxyCmd << std::endl;
+
+ int Pipes[2] = {-1,-1};
+ if (pipe(Pipes) != 0)
+ return _error->Errno("pipe", "Failed to create Pipe");
+
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ close(Pipes[0]);
+ dup2(Pipes[1],STDOUT_FILENO);
+ SetCloseExec(STDOUT_FILENO,false);
+
+ std::string foo = URL;
+ const char *Args[4];
+ Args[0] = AutoDetectProxyCmd.c_str();
+ Args[1] = foo.c_str();
+ Args[2] = 0;
+ execv(Args[0],(char **)Args);
+ std::cerr << "Failed to exec method " << Args[0] << std::endl;
+ _exit(100);
+ }
+ char buf[512];
+ int InFd = Pipes[0];
+ close(Pipes[1]);
+ int res = read(InFd, buf, sizeof(buf)-1);
+ ExecWait(Process, "ProxyAutoDetect", true);
+
+ if (res < 0)
+ return _error->Errno("read", "Failed to read");
+ if (res == 0)
+ return _error->Warning("ProxyAutoDetect returned no data");
+
+ // add trailing \0
+ buf[res] = 0;
+
+ if (Debug)
+ std::clog << "auto detect command returned: '" << buf << "'" << std::endl;
+
+ if (strstr(buf, URL.Access.c_str()) == buf)
+ _config->Set("Acquire::"+URL.Access+"::proxy::"+URL.Host, _strstrip(buf));
+
+ return true;
+}
+ /*}}}*/
diff --git a/apt-pkg/contrib/proxy.h b/apt-pkg/contrib/proxy.h
new file mode 100644
index 000000000..2cbcd07b4
--- /dev/null
+++ b/apt-pkg/contrib/proxy.h
@@ -0,0 +1,16 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ Proxy - Proxy operations
+
+ ##################################################################### */
+ /*}}}*/
+#ifndef PKGLIB_PROXY_H
+#define PKGLIB_PROXY_H
+
+class URI;
+bool AutoDetectProxy(URI &URL);
+
+
+#endif
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 7948673dc..9238966cd 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -711,9 +711,12 @@ string LookupTag(const string &Message,const char *Tag,const char *Default)
then returns the result. Several varients on true/false are checked. */
int StringToBool(const string &Text,int Default)
{
- char *End;
- int Res = strtol(Text.c_str(),&End,0);
- if (End != Text.c_str() && Res >= 0 && Res <= 1)
+ char *ParseEnd;
+ int Res = strtol(Text.c_str(),&ParseEnd,0);
+ // ensure that the entire string was converted by strtol to avoid
+ // failures on "apt-cache show -a 0ad" where the "0" is converted
+ const char *TextEnd = Text.c_str()+Text.size();
+ if (ParseEnd == TextEnd && Res >= 0 && Res <= 1)
return Res;
// Check for positives
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 30ae91cca..3e0d3a791 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -108,7 +108,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
{
unsigned char MA;
string const MultiArch = Section.FindS("Multi-Arch");
- if (MultiArch.empty() == true)
+ if (MultiArch.empty() == true || MultiArch == "no")
MA = pkgCache::Version::None;
else if (MultiArch == "same") {
if (ArchitectureAll() == true)
@@ -793,8 +793,8 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
Start = ParseDepends(Start,Stop,Package,Version,Op);
if (Start == 0)
return _error->Error("Problem parsing Provides line");
- if (Op != pkgCache::Dep::NoOp) {
- _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
+ if (Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals) {
+ _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.c_str());
} else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
if (NewProvidesAllArch(Ver, Package, Version) == false)
return false;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 2dcdf916f..8295a7c1e 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -621,15 +621,15 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
{
if(action == "error")
{
- d->progress->Error(list[1], PackagesDone, PackagesTotal,
+ d->progress->Error(pkgname, PackagesDone, PackagesTotal,
list[3]);
pkgFailures++;
- WriteApportReport(list[1].c_str(), list[3].c_str());
+ WriteApportReport(pkgname.c_str(), list[3].c_str());
return;
}
else if(action == "conffile-prompt")
{
- d->progress->ConffilePrompt(list[1], PackagesDone, PackagesTotal,
+ d->progress->ConffilePrompt(pkgname, PackagesDone, PackagesTotal,
list[3]);
return;
}
@@ -1662,9 +1662,10 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
// do not report dpkg I/O errors, this is a format string, so we compare
// the prefix and the suffix of the error with the dpkg error message
vector<string> io_errors;
- io_errors.push_back(string("failed to read on buffer copy for %s"));
- io_errors.push_back(string("failed in write on buffer copy for %s"));
- io_errors.push_back(string("short read on buffer copy for %s"));
+ io_errors.push_back(string("failed to read"));
+ io_errors.push_back(string("failed to write"));
+ io_errors.push_back(string("failed to seek"));
+ io_errors.push_back(string("unexpected end of file or stream"));
for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); ++I)
{
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 492d16029..16282df21 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -663,10 +663,11 @@ void pkgDepCache::Update(OpProgress *Prog)
{
iUsrSize = 0;
iDownloadSize = 0;
- iDelCount = 0;
iInstCount = 0;
+ iDelCount = 0;
iKeepCount = 0;
iBrokenCount = 0;
+ iPolicyBrokenCount = 0;
iBadCount = 0;
// Perform the depends pass
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index d9df28ba3..e4cd1dc3b 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -373,6 +373,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
std::list<DepIterator> needConfigure;
do
{
+ // Check each dependency and see if anything needs to be done
+ // so that it can be configured
Changed = false;
for (DepIterator D = instVer.DependsList(); D.end() == false; )
{
@@ -384,7 +386,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
continue;
Bad = true;
- // Check for dependencies that have not been unpacked, probably due to loops.
+ // the first pass checks if we its all good, i.e. if we have
+ // to do anything at all
for (DepIterator Cur = Start; true; ++Cur)
{
SPtrArray<Version *> VList = Cur.AllTargets();
@@ -413,6 +416,47 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure" << std::endl;
Bad = false;
}
+ }
+
+ if (Cur == End || Bad == false)
+ break;
+ }
+
+ // this dependency is in a good state, so we can stop
+ if (Bad == false)
+ {
+ if (Debug)
+ std::clog << OutputInDepth(Depth) << "Found ok dep " << D.TargetPkg() << std::endl;
+ continue;
+ }
+
+ // Check for dependencies that have not been unpacked,
+ // probably due to loops.
+ for (DepIterator Cur = Start; true; ++Cur)
+ {
+ SPtrArray<Version *> VList = Cur.AllTargets();
+
+ for (Version **I = VList; *I != 0; ++I)
+ {
+ VerIterator Ver(Cache,*I);
+ PkgIterator DepPkg = Ver.ParentPkg();
+
+ // Check if the current version of the package is available and will satisfy this dependency
+ if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true &&
+ List->IsFlag(DepPkg,pkgOrderList::Removed) == false &&
+ DepPkg.State() == PkgIterator::NeedsNothing)
+ continue;
+
+ // Check if the version that is going to be installed will satisfy the dependency
+ if (Cache[DepPkg].InstallVer != *I || List->IsNow(DepPkg) == false)
+ continue;
+
+ if (PkgLoop == true)
+ {
+ if (Debug)
+ std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure" << std::endl;
+ Bad = false;
+ }
else
{
if (Debug)
@@ -420,6 +464,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
if (NonLoopingSmart(UNPACK_IMMEDIATE, Pkg, DepPkg, Depth, PkgLoop, &Bad, &Changed) == false)
return false;
}
+ // at this point we either unpacked a Dep or we are in a loop,
+ // no need to unpack a second one
break;
}
@@ -436,6 +482,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack (1) for %s, aborting", Pkg.FullName().c_str());
} while (Changed == true);
+ // now go over anything that needs configuring
Bad = false, Changed = false, i = 0;
do
{