summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc67
-rw-r--r--apt-pkg/acquire-method.cc247
-rw-r--r--apt-pkg/acquire-method.h3
-rw-r--r--apt-pkg/acquire-worker.cc11
-rw-r--r--apt-pkg/algorithms.cc35
-rw-r--r--apt-pkg/cacheiterators.h1
-rw-r--r--apt-pkg/cacheset.h26
-rw-r--r--apt-pkg/cdrom.cc88
-rw-r--r--apt-pkg/contrib/cdromutl.cc16
-rw-r--r--apt-pkg/contrib/error.cc2
-rw-r--r--apt-pkg/contrib/mmap.cc8
-rw-r--r--apt-pkg/contrib/netrc.cc12
-rw-r--r--apt-pkg/deb/deblistparser.cc2
-rw-r--r--apt-pkg/deb/debmetaindex.cc5
-rw-r--r--apt-pkg/deb/dpkgpm.cc5
-rw-r--r--apt-pkg/depcache.cc134
-rw-r--r--apt-pkg/indexcopy.cc10
-rw-r--r--apt-pkg/orderlist.cc18
-rw-r--r--apt-pkg/packagemanager.cc44
-rw-r--r--apt-pkg/packagemanager.h2
-rw-r--r--apt-pkg/pkgcache.cc46
-rw-r--r--apt-pkg/pkgcache.h6
-rw-r--r--apt-pkg/pkgcachegen.cc5
-rw-r--r--apt-pkg/policy.cc14
24 files changed, 452 insertions, 355 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 39b9feff2..998c42dc4 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -271,6 +271,14 @@ void pkgAcqSubIndex::Done(string Message,unsigned long Size,string Md5Hash, /*{{
string FinalFile = _config->FindDir("Dir::State::lists")+URItoFileName(Desc.URI);
+ /* Downloaded invalid transindex => Error (LP: #346386) (Closes: #627642) */
+ indexRecords SubIndexParser;
+ if (FileExists(DestFile) == true && !SubIndexParser.Load(DestFile)) {
+ Status = StatError;
+ ErrorText = SubIndexParser.ErrorText;
+ return;
+ }
+
// sucess in downloading the index
// rename the index
if(Debug)
@@ -894,6 +902,27 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
ReportMirrorFailure("HashChecksumFailure");
return;
}
+
+ /* Verify the index file for correctness (all indexes must
+ * have a Package field) (LP: #346386) (Closes: #627642) */
+ {
+ FileFd fd(DestFile, FileFd::ReadOnly);
+ pkgTagSection sec;
+ pkgTagFile tag(&fd);
+
+ if (_error->PendingError() || !tag.Step(sec)) {
+ Status = StatError;
+ _error->DumpErrors();
+ Rename(DestFile,DestFile + ".FAILED");
+ return;
+ } else if (!sec.Exists("Package")) {
+ Status = StatError;
+ ErrorText = ("Encountered a section with no Package: header");
+ Rename(DestFile,DestFile + ".FAILED");
+ return;
+ }
+ }
+
// Done, move it into position
string FinalFile = _config->FindDir("Dir::State::lists");
FinalFile += URItoFileName(RealURI);
@@ -1330,6 +1359,16 @@ void pkgAcqMetaIndex::AuthDone(string Message) /*{{{*/
/*}}}*/
void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/
{
+#if 0
+ /* Reject invalid, existing Release files (LP: #346386) (Closes: #627642)
+ * FIXME: Disabled; it breaks unsigned repositories without hashes */
+ if (!verify && FileExists(DestFile) && !MetaIndexParser->Load(DestFile))
+ {
+ Status = StatError;
+ ErrorText = MetaIndexParser->ErrorText;
+ return;
+ }
+#endif
for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin();
Target != IndexTargets->end();
Target++)
@@ -1493,6 +1532,12 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
LookupTag(Message,"Message").c_str());
RunScripts("APT::Update::Auth-Failure");
return;
+ } else if (LookupTag(Message,"Message").find("NODATA") != string::npos) {
+ /* Invalid signature file, reject (LP: #346386) (Closes: #627642) */
+ _error->Error(_("GPG error: %s: %s"),
+ Desc.Description.c_str(),
+ LookupTag(Message,"Message").c_str());
+ return;
} else {
_error->Warning(_("GPG error: %s: %s"),
Desc.Description.c_str(),
@@ -1502,6 +1547,26 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
ReportMirrorFailure("GPGFailure");
}
+ /* Always move the meta index, even if gpgv failed. This ensures
+ * that PackageFile objects are correctly filled in */
+ if (FileExists(DestFile)) {
+ string FinalFile = _config->FindDir("Dir::State::lists");
+ FinalFile += URItoFileName(RealURI);
+ /* InRelease files become Release files, otherwise
+ * they would be considered as trusted later on */
+ if (SigFile == DestFile) {
+ RealURI = RealURI.replace(RealURI.rfind("InRelease"), 9,
+ "Release");
+ FinalFile = FinalFile.replace(FinalFile.rfind("InRelease"), 9,
+ "Release");
+ SigFile = FinalFile;
+ }
+ Rename(DestFile,FinalFile);
+ chmod(FinalFile.c_str(),0644);
+
+ DestFile = FinalFile;
+ }
+
// No Release file was present, or verification failed, so fall
// back to queueing Packages files without verification
QueueIndexes(false);
@@ -1625,7 +1690,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
// Select a source
if (QueueNext() == false && _error->PendingError() == false)
- _error->Error(_("I wasn't able to locate file for the %s package. "
+ _error->Error(_("I wasn't able to locate a file for the %s package. "
"This might mean you need to manually fix this package."),
Version.ParentPkg().Name());
}
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index fb45d9ee7..e9e102488 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -23,9 +23,7 @@
#include <apt-pkg/hashes.h>
#include <iostream>
-#include <stdarg.h>
#include <stdio.h>
-#include <unistd.h>
#include <sys/signal.h>
/*}}}*/
@@ -36,32 +34,28 @@ using namespace std;
/* This constructs the initialization text */
pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags)
{
- char S[300] = "";
- char *End = S;
- strcat(End,"100 Capabilities\n");
- sprintf(End+strlen(End),"Version: %s\n",Ver);
+ std::cout << "100 Capabilities\n"
+ << "Version: " << Ver << "\n";
if ((Flags & SingleInstance) == SingleInstance)
- strcat(End,"Single-Instance: true\n");
-
+ std::cout << "Single-Instance: true\n";
+
if ((Flags & Pipeline) == Pipeline)
- strcat(End,"Pipeline: true\n");
-
+ std::cout << "Pipeline: true\n";
+
if ((Flags & SendConfig) == SendConfig)
- strcat(End,"Send-Config: true\n");
+ std::cout << "Send-Config: true\n";
if ((Flags & LocalOnly) == LocalOnly)
- strcat(End,"Local-Only: true\n");
+ std::cout <<"Local-Only: true\n";
if ((Flags & NeedsCleanup) == NeedsCleanup)
- strcat(End,"Needs-Cleanup: true\n");
+ std::cout << "Needs-Cleanup: true\n";
if ((Flags & Removable) == Removable)
- strcat(End,"Removable: true\n");
- strcat(End,"\n");
+ std::cout << "Removable: true\n";
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
+ std::cout << "\n" << std::flush;
SetNonBlock(STDIN_FILENO,true);
@@ -94,13 +88,11 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
if (*I == '\n')
*I = ' ';
}
-
- char S[1024];
- char *End = S;
+
if (Queue != 0)
{
- End += snprintf(S,sizeof(S)-50,"400 URI Failure\nURI: %s\n"
- "Message: %s %s\n",Queue->Uri.c_str(), Err.c_str(), IP.c_str());
+ std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n"
+ << "Message: " << Err << " " << IP << "\n";
// Dequeue
FetchItem *Tmp = Queue;
Queue = Queue->Next;
@@ -109,22 +101,17 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
QueueBack = Queue;
}
else
- {
- End += snprintf(S,sizeof(S)-50,"400 URI Failure\nURI: <UNKNOWN>\n"
- "Message: %s\n",Err.c_str());
- }
+ std::cout << "400 URI Failure\nURI: <UNKNOWN>\nMessage: " << Err << "\n";
+
if(FailReason.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"FailReason: %s\n",FailReason.c_str());
+ std::cout << "FailReason: " << FailReason << "\n";
if (UsedMirror.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"UsedMirror: %s\n",UsedMirror.c_str());
- // Set the transient flag
+ std::cout << "UsedMirror: " << UsedMirror << "\n";
+ // Set the transient flag
if (Transient == true)
- strcat(S,"Transient-Failure: true\n\n");
- else
- strcat(S,"\n");
-
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
+ std::cout << "Transient-Failure: true\n";
+
+ std::cout << "\n" << std::flush;
}
/*}}}*/
// AcqMethod::URIStart - Indicate a download is starting /*{{{*/
@@ -134,27 +121,22 @@ void pkgAcqMethod::URIStart(FetchResult &Res)
{
if (Queue == 0)
abort();
-
- char S[1024] = "";
- char *End = S;
-
- End += snprintf(S,sizeof(S),"200 URI Start\nURI: %s\n",Queue->Uri.c_str());
+
+ std::cout << "200 URI Start\n"
+ << "URI: " << Queue->Uri << "\n";
if (Res.Size != 0)
- End += snprintf(End,sizeof(S)-4 - (End - S),"Size: %lu\n",Res.Size);
-
+ std::cout << "Size: " << Res.Size << "\n";
+
if (Res.LastModified != 0)
- End += snprintf(End,sizeof(S)-4 - (End - S),"Last-Modified: %s\n",
- TimeRFC1123(Res.LastModified).c_str());
-
+ std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
+
if (Res.ResumePoint != 0)
- End += snprintf(End,sizeof(S)-4 - (End - S),"Resume-Point: %lu\n",
- Res.ResumePoint);
+ std::cout << "Resume-Point: " << Res.ResumePoint << "\n";
+
if (UsedMirror.empty() == false)
- End += snprintf(End,sizeof(S)-4 - (End - S),"UsedMirror: %s\n",UsedMirror.c_str());
-
- strcat(End,"\n");
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
+ std::cout << "UsedMirror: " << UsedMirror << "\n";
+
+ std::cout << "\n" << std::flush;
}
/*}}}*/
// AcqMethod::URIDone - A URI is finished /*{{{*/
@@ -164,76 +146,65 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
{
if (Queue == 0)
abort();
-
- char S[1024] = "";
- char *End = S;
-
- End += snprintf(S,sizeof(S),"201 URI Done\nURI: %s\n",Queue->Uri.c_str());
+
+ std::cout << "201 URI Done\n"
+ << "URI: " << Queue->Uri << "\n";
if (Res.Filename.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Filename: %s\n",Res.Filename.c_str());
-
+ std::cout << "Filename: " << Res.Filename << "\n";
+
if (Res.Size != 0)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Size: %lu\n",Res.Size);
-
+ std::cout << "Size: " << Res.Size << "\n";
+
if (Res.LastModified != 0)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Last-Modified: %s\n",
- TimeRFC1123(Res.LastModified).c_str());
+ std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
if (Res.MD5Sum.empty() == false)
- {
- End += snprintf(End,sizeof(S)-50 - (End - S),"MD5-Hash: %s\n",Res.MD5Sum.c_str());
- End += snprintf(End,sizeof(S)-50 - (End - S),"MD5Sum-Hash: %s\n",Res.MD5Sum.c_str());
- }
+ std::cout << "MD5-Hash: " << Res.MD5Sum << "\n"
+ << "MD5Sum-Hash: " << Res.MD5Sum << "\n";
if (Res.SHA1Sum.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"SHA1-Hash: %s\n",Res.SHA1Sum.c_str());
+ std::cout << "SHA1-Hash: " << Res.SHA1Sum << "\n";
if (Res.SHA256Sum.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"SHA256-Hash: %s\n",Res.SHA256Sum.c_str());
+ std::cout << "SHA256-Hash: " << Res.SHA256Sum << "\n";
if (UsedMirror.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"UsedMirror: %s\n",UsedMirror.c_str());
- if (Res.GPGVOutput.size() > 0)
- End += snprintf(End,sizeof(S)-50 - (End - S),"GPGVOutput:\n");
- for (vector<string>::iterator I = Res.GPGVOutput.begin();
- I != Res.GPGVOutput.end(); I++)
- End += snprintf(End,sizeof(S)-50 - (End - S), " %s\n", (*I).c_str());
+ std::cout << "UsedMirror: " << UsedMirror << "\n";
+ if (Res.GPGVOutput.empty() == false)
+ {
+ std::cout << "GPGVOutput:\n";
+ for (vector<string>::const_iterator I = Res.GPGVOutput.begin();
+ I != Res.GPGVOutput.end(); ++I)
+ std::cout << " " << *I << "\n";
+ }
if (Res.ResumePoint != 0)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Resume-Point: %lu\n",
- Res.ResumePoint);
+ std::cout << "Resume-Point: " << Res.ResumePoint << "\n";
if (Res.IMSHit == true)
- strcat(End,"IMS-Hit: true\n");
- End = S + strlen(S);
-
+ std::cout << "IMS-Hit: true\n";
+
if (Alt != 0)
{
if (Alt->Filename.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-Filename: %s\n",Alt->Filename.c_str());
-
+ std::cout << "Alt-Filename: " << Alt->Filename << "\n";
+
if (Alt->Size != 0)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-Size: %lu\n",Alt->Size);
-
+ std::cout << "Alt-Size: " << Alt->Size << "\n";
+
if (Alt->LastModified != 0)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-Last-Modified: %s\n",
- TimeRFC1123(Alt->LastModified).c_str());
-
+ std::cout << "Alt-Last-Modified: " << TimeRFC1123(Alt->LastModified) << "\n";
+
if (Alt->MD5Sum.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-MD5-Hash: %s\n",
- Alt->MD5Sum.c_str());
+ std::cout << "Alt-MD5-Hash: " << Alt->MD5Sum << "\n";
if (Alt->SHA1Sum.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-SHA1-Hash: %s\n",
- Alt->SHA1Sum.c_str());
+ std::cout << "Alt-SHA1-Hash: " << Alt->SHA1Sum << "\n";
if (Alt->SHA256Sum.empty() == false)
- End += snprintf(End,sizeof(S)-50 - (End - S),"Alt-SHA256-Hash: %s\n",
- Alt->SHA256Sum.c_str());
-
+ std::cout << "Alt-SHA256-Hash: " << Alt->SHA256Sum << "\n";
+
if (Alt->IMSHit == true)
- strcat(End,"Alt-IMS-Hit: true\n");
+ std::cout << "Alt-IMS-Hit: true\n";
}
-
- strcat(End,"\n");
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
+
+ std::cout << "\n" << std::flush;
// Dequeue
FetchItem *Tmp = Queue;
@@ -249,13 +220,10 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
to be ackd */
bool pkgAcqMethod::MediaFail(string Required,string Drive)
{
- char S[1024];
- snprintf(S,sizeof(S),"403 Media Failure\nMedia: %s\nDrive: %s\n\n",
+ fprintf(stdout, "403 Media Failure\nMedia: %s\nDrive: %s\n",
Required.c_str(),Drive.c_str());
+ std::cout << "\n" << std::flush;
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
-
vector<string> MyMessages;
/* Here we read messages until we find a 603, each non 603 message is
@@ -406,30 +374,34 @@ int pkgAcqMethod::Run(bool Single)
return 0;
}
/*}}}*/
-// AcqMethod::Log - Send a log message /*{{{*/
+// AcqMethod::PrintStatus - privately really send a log/status message /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgAcqMethod::Log(const char *Format,...)
+void pkgAcqMethod::PrintStatus(char const * const header, const char* Format,
+ va_list &args) const
{
string CurrentURI = "<UNKNOWN>";
if (Queue != 0)
CurrentURI = Queue->Uri;
-
+ if (UsedMirror.empty() == true)
+ fprintf(stdout, "%s\nURI: %s\nMessage: ",
+ header, CurrentURI.c_str());
+ else
+ fprintf(stdout, "%s\nURI: %s\nUsedMirror: %s\nMessage: ",
+ header, CurrentURI.c_str(), UsedMirror.c_str());
+ vfprintf(stdout,Format,args);
+ std::cout << "\n\n" << std::flush;
+}
+ /*}}}*/
+// AcqMethod::Log - Send a log message /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqMethod::Log(const char *Format,...)
+{
va_list args;
va_start(args,Format);
-
- // sprintf the description
- char S[1024];
- unsigned int Len = snprintf(S,sizeof(S)-4,"101 Log\n"
- "URI: %s\n"
- "UsedMirror: %s\n"
- "Message: ", UsedMirror.c_str(),
- CurrentURI.c_str());
- vsnprintf(S+Len,sizeof(S)-4-Len,Format,args);
- strcat(S,"\n\n");
-
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
+ PrintStatus("101 Log", Format, args);
+ va_end(args);
}
/*}}}*/
// AcqMethod::Status - Send a status message /*{{{*/
@@ -437,26 +409,10 @@ void pkgAcqMethod::Log(const char *Format,...)
/* */
void pkgAcqMethod::Status(const char *Format,...)
{
- string CurrentURI = "<UNKNOWN>";
- if (Queue != 0)
- CurrentURI = Queue->Uri;
-
va_list args;
va_start(args,Format);
-
- // sprintf the description
- char S[1024];
- unsigned int Len = snprintf(S,sizeof(S)-4,"102 Status\n"
- "URI: %s\n"
- "UsedMirror: %s\n"
- "Message: ",UsedMirror.c_str(),
- CurrentURI.c_str());
-
- vsnprintf(S+Len,sizeof(S)-4-Len,Format,args);
- strcat(S,"\n\n");
-
- if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
- exit(100);
+ PrintStatus("102 Status", Format, args);
+ va_end(args);
}
/*}}}*/
// AcqMethod::Redirect - Send a redirect message /*{{{*/
@@ -465,16 +421,13 @@ void pkgAcqMethod::Status(const char *Format,...)
to keep the pipeline synchronized. */
void pkgAcqMethod::Redirect(const string &NewURI)
{
- string CurrentURI = "<UNKNOWN>";
+ std::cout << "103 Redirect\nURI: ";
if (Queue != 0)
- CurrentURI = Queue->Uri;
-
- char S[1024];
- snprintf(S, sizeof(S)-50, "103 Redirect\nURI: %s\nNew-URI: %s\n\n",
- CurrentURI.c_str(), NewURI.c_str());
-
- if (write(STDOUT_FILENO,S,strlen(S)) != (ssize_t)strlen(S))
- exit(100);
+ std::cout << Queue->Uri << "\n";
+ else
+ std::cout << "<UNKNOWN>\n";
+ std::cout << "New-URI: " << NewURI << "\n"
+ << "\n" << std::flush;
// Change the URI for the request.
Queue->Uri = NewURI;
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index 03851e823..72efa8065 100644
--- a/apt-pkg/acquire-method.h
+++ b/apt-pkg/acquire-method.h
@@ -23,6 +23,7 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/strutl.h>
+#include <stdarg.h>
class Hashes;
class pkgAcqMethod
@@ -78,6 +79,8 @@ class pkgAcqMethod
bool MediaFail(string Required,string Drive);
virtual void Exit() {};
+ void PrintStatus(char const * const header, const char* Format, va_list &args) const;
+
public:
enum CnfFlags {SingleInstance = (1<<0),
Pipeline = (1<<1), SendConfig = (1<<2),
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index ddd8e3101..75e03232a 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -287,10 +287,10 @@ bool pkgAcquire::Worker::RunMessages()
Log->Pulse(Owner->GetOwner());
OwnerQ->ItemDone(Itm);
- if (TotalSize != 0 &&
- (unsigned)atoi(LookupTag(Message,"Size","0").c_str()) != TotalSize)
- _error->Warning("Bizarre Error - File size is not what the server reported %s %lu",
- LookupTag(Message,"Size","0").c_str(),TotalSize);
+ unsigned long const ServerSize = atol(LookupTag(Message,"Size","0").c_str());
+ if (TotalSize != 0 && ServerSize != TotalSize)
+ _error->Warning("Size of file %s is not what the server reported %s %lu",
+ Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);
// see if there is a hash to verify
string RecivedHash;
@@ -309,8 +309,7 @@ bool pkgAcquire::Worker::RunMessages()
<< endl << endl;
}
}
- Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
- RecivedHash.c_str(), Config);
+ Owner->Done(Message, ServerSize, RecivedHash.c_str(), Config);
ItemDone();
// Log that we are done
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 0b4366e5e..2dae4258a 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -101,9 +101,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
DepIterator Start;
DepIterator End;
D.GlobOr(Start,End);
- if (Start->Type == pkgCache::Dep::Conflicts ||
- Start->Type == pkgCache::Dep::DpkgBreaks ||
- Start->Type == pkgCache::Dep::Obsoletes ||
+ if (Start.IsNegative() == true ||
End->Type == pkgCache::Dep::PreDepends)
{
if ((Sim[End] & pkgDepCache::DepGInstall) == 0)
@@ -647,12 +645,10 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
// Compute a single dependency element (glob or)
pkgCache::DepIterator Start = D;
pkgCache::DepIterator End = D;
- unsigned char State = 0;
for (bool LastOR = true; D.end() == false && LastOR == true;)
{
- State |= Cache[D];
LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
- D++;
+ ++D;
if (LastOR == true)
End = D;
}
@@ -697,9 +693,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
{
/* We let the algorithm deal with conflicts on its next iteration,
it is much smarter than us */
- if (Start->Type == pkgCache::Dep::Conflicts ||
- Start->Type == pkgCache::Dep::DpkgBreaks ||
- Start->Type == pkgCache::Dep::Obsoletes)
+ if (Start.IsNegative() == true)
break;
if (Debug == true)
@@ -928,9 +922,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
if a package has a dep on another package that cant be found */
SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
if (*VList == 0 && (Flags[I->ID] & Protected) != Protected &&
- Start->Type != pkgCache::Dep::Conflicts &&
- Start->Type != pkgCache::Dep::DpkgBreaks &&
- Start->Type != pkgCache::Dep::Obsoletes &&
+ Start.IsNegative() == false &&
Cache[I].NowBroken() == false)
{
if (InOr == true)
@@ -955,10 +947,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
at is not the currently selected version of the
package, which means it is not necessary to
remove/keep */
- if (Cache[Pkg].InstallVer != Ver &&
- (Start->Type == pkgCache::Dep::Conflicts ||
- Start->Type == pkgCache::Dep::DpkgBreaks ||
- Start->Type == pkgCache::Dep::Obsoletes))
+ if (Cache[Pkg].InstallVer != Ver && Start.IsNegative() == true)
{
if (Debug)
clog << " Conflicts//Breaks against version "
@@ -976,9 +965,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
fiddle with the VList package */
if (Scores[I->ID] <= Scores[Pkg->ID] ||
((Cache[Start] & pkgDepCache::DepNow) == 0 &&
- End->Type != pkgCache::Dep::Conflicts &&
- End->Type != pkgCache::Dep::DpkgBreaks &&
- End->Type != pkgCache::Dep::Obsoletes))
+ End.IsNegative() == false))
{
// Try a little harder to fix protected packages..
if ((Flags[I->ID] & Protected) == Protected)
@@ -1085,10 +1072,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
}
// Hm, nothing can possibly satisify this dep. Nuke it.
- if (VList[0] == 0 &&
- Start->Type != pkgCache::Dep::Conflicts &&
- Start->Type != pkgCache::Dep::DpkgBreaks &&
- Start->Type != pkgCache::Dep::Obsoletes &&
+ if (VList[0] == 0 &&
+ Start.IsNegative() == false &&
(Flags[I->ID] & Protected) != Protected)
{
bool Installed = Cache[I].Install();
@@ -1134,9 +1119,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
Change = true;
if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0)
{
- if (J->Dep->Type == pkgCache::Dep::Conflicts ||
- J->Dep->Type == pkgCache::Dep::DpkgBreaks ||
- J->Dep->Type == pkgCache::Dep::Obsoletes)
+ if (J->Dep.IsNegative() == true)
{
if (Debug == true)
clog << " Fixing " << I.FullName(false) << " via remove of " << J->Pkg.FullName(false) << endl;
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 8f9f811da..0c9813c6d 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -287,6 +287,7 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
inline PkgIterator ParentPkg() const {return PkgIterator(*Owner,Owner->PkgP + Owner->VerP[S->ParentVer].ParentPkg);};
inline bool Reverse() const {return Type == DepRev;};
bool IsCritical() const;
+ bool IsNegative() const;
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets() const;
bool SmartTargetPkg(PkgIterator &Result) const;
diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h
index e690d660c..eb4f04d72 100644
--- a/apt-pkg/cacheset.h
+++ b/apt-pkg/cacheset.h
@@ -135,7 +135,7 @@ public: /*{{{*/
static APT::PackageSet FromTask(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static APT::PackageSet FromTask(pkgCacheFile &Cache, std::string const &pattern) {
CacheSetHelper helper;
- return APT::PackageSet::FromTask(Cache, pattern, helper);
+ return FromTask(Cache, pattern, helper);
}
/** \brief returns all packages in the cache whose name matchs a given pattern
@@ -149,7 +149,7 @@ public: /*{{{*/
static APT::PackageSet FromRegEx(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper);
static APT::PackageSet FromRegEx(pkgCacheFile &Cache, std::string const &pattern) {
CacheSetHelper helper;
- return APT::PackageSet::FromRegEx(Cache, pattern, helper);
+ return FromRegEx(Cache, pattern, helper);
}
/** \brief returns all packages specified by a string
@@ -160,7 +160,7 @@ public: /*{{{*/
static APT::PackageSet FromString(pkgCacheFile &Cache, std::string const &string, CacheSetHelper &helper);
static APT::PackageSet FromString(pkgCacheFile &Cache, std::string const &string) {
CacheSetHelper helper;
- return APT::PackageSet::FromString(Cache, string, helper);
+ return FromString(Cache, string, helper);
}
/** \brief returns a package specified by a string
@@ -171,7 +171,7 @@ public: /*{{{*/
static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &string, CacheSetHelper &helper);
static pkgCache::PkgIterator FromName(pkgCacheFile &Cache, std::string const &string) {
CacheSetHelper helper;
- return APT::PackageSet::FromName(Cache, string, helper);
+ return FromName(Cache, string, helper);
}
/** \brief returns all packages specified on the commandline
@@ -184,7 +184,7 @@ public: /*{{{*/
static APT::PackageSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline, CacheSetHelper &helper);
static APT::PackageSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
CacheSetHelper helper;
- return APT::PackageSet::FromCommandLine(Cache, cmdline, helper);
+ return FromCommandLine(Cache, cmdline, helper);
}
struct Modifier {
@@ -215,7 +215,7 @@ public: /*{{{*/
std::list<PackageSet::Modifier> const &mods,
unsigned short const &fallback) {
CacheSetHelper helper;
- return APT::PackageSet::GroupedFromCommandLine(Cache, cmdline,
+ return GroupedFromCommandLine(Cache, cmdline,
mods, fallback, helper);
}
@@ -309,10 +309,10 @@ public: /*{{{*/
static APT::VersionSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline,
APT::VersionSet::Version const &fallback) {
CacheSetHelper helper;
- return APT::VersionSet::FromCommandLine(Cache, cmdline, fallback, helper);
+ return FromCommandLine(Cache, cmdline, fallback, helper);
}
static APT::VersionSet FromCommandLine(pkgCacheFile &Cache, const char **cmdline) {
- return APT::VersionSet::FromCommandLine(Cache, cmdline, CANDINST);
+ return FromCommandLine(Cache, cmdline, CANDINST);
}
static APT::VersionSet FromString(pkgCacheFile &Cache, std::string pkg,
@@ -321,10 +321,10 @@ public: /*{{{*/
static APT::VersionSet FromString(pkgCacheFile &Cache, std::string pkg,
APT::VersionSet::Version const &fallback) {
CacheSetHelper helper;
- return APT::VersionSet::FromString(Cache, pkg, fallback, helper);
+ return FromString(Cache, pkg, fallback, helper);
}
static APT::VersionSet FromString(pkgCacheFile &Cache, std::string pkg) {
- return APT::VersionSet::FromString(Cache, pkg, CANDINST);
+ return FromString(Cache, pkg, CANDINST);
}
/** \brief returns all versions specified for the package
@@ -338,10 +338,10 @@ public: /*{{{*/
static APT::VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P,
APT::VersionSet::Version const &fallback) {
CacheSetHelper helper;
- return APT::VersionSet::FromPackage(Cache, P, fallback, helper);
+ return FromPackage(Cache, P, fallback, helper);
}
static APT::VersionSet FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &P) {
- return APT::VersionSet::FromPackage(Cache, P, CANDINST);
+ return FromPackage(Cache, P, CANDINST);
}
struct Modifier {
@@ -364,7 +364,7 @@ public: /*{{{*/
std::list<VersionSet::Modifier> const &mods,
unsigned short const &fallback) {
CacheSetHelper helper;
- return APT::VersionSet::GroupedFromCommandLine(Cache, cmdline,
+ return GroupedFromCommandLine(Cache, cmdline,
mods, fallback, helper);
}
/*}}}*/
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 36a1d7f12..2a914c665 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -155,7 +155,11 @@ bool pkgCdrom::FindPackages(string CD,
break;
if (chdir(CD.c_str()) != 0)
- return _error->Errno("chdir","Unable to change to %s",CD.c_str());
+ {
+ _error->Errno("chdir","Unable to change to %s", CD.c_str());
+ closedir(D);
+ return false;
+ }
};
closedir(D);
@@ -257,8 +261,10 @@ bool pkgCdrom::DropRepeats(vector<string> &List,const char *Name)
Inodes[I] = Buf.st_ino;
}
- if (_error->PendingError() == true)
+ if (_error->PendingError() == true) {
+ delete[] Inodes;
return false;
+ }
// Look for dups
for (unsigned int I = 0; I != List.size(); I++)
@@ -513,7 +519,8 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
- if(log) {
+ if (log != NULL)
+ {
msg.str("");
ioprintf(msg, _("Using CD-ROM mount point %s\nMounting CD-ROM\n"),
CDROM.c_str());
@@ -523,7 +530,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
return _error->Error("Failed to mount the cdrom.");
// Hash the CD to get an ID
- if(log)
+ if (log != NULL)
log->Update(_("Identifying.. "));
@@ -533,10 +540,12 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
return false;
}
- msg.str("");
- ioprintf(msg, "[%s]\n",ident.c_str());
- log->Update(msg.str());
-
+ if (log != NULL)
+ {
+ msg.str("");
+ ioprintf(msg, "[%s]\n",ident.c_str());
+ log->Update(msg.str());
+ }
// Read the database
Configuration Database;
@@ -547,7 +556,8 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
return _error->Error("Unable to read the cdrom database %s",
DFile.c_str());
}
- if(log) {
+ if (log != NULL)
+ {
msg.str("");
ioprintf(msg, _("Stored label: %s\n"),
Database.Find("CD::"+ident).c_str());
@@ -555,8 +565,10 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/
}
// Unmount and finish
- if (_config->FindB("APT::CDROM::NoMount",false) == false) {
- log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+ if (_config->FindB("APT::CDROM::NoMount",false) == false)
+ {
+ if (log != NULL)
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
UnmountCdrom(CDROM);
}
@@ -572,7 +584,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (CDROM[0] == '.')
CDROM= SafeGetCWD() + '/' + CDROM;
- if(log) {
+ if(log != NULL)
+ {
log->SetTotal(STEP_LAST);
msg.str("");
ioprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str());
@@ -592,11 +605,12 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
// Unmount the CD and get the user to put in the one they want
if (_config->FindB("APT::CDROM::NoMount",false) == false)
{
- if(log)
+ if(log != NULL)
log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT);
UnmountCdrom(CDROM);
- if(log) {
+ if(log != NULL)
+ {
log->Update(_("Waiting for disc...\n"), STEP_WAIT);
if(!log->ChangeCdrom()) {
// user aborted
@@ -605,26 +619,29 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
}
// Mount the new CDROM
- log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT);
+ if(log != NULL)
+ log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT);
+
if (MountCdrom(CDROM) == false)
return _error->Error("Failed to mount the cdrom.");
}
// Hash the CD to get an ID
- if(log)
+ if(log != NULL)
log->Update(_("Identifying.. "), STEP_IDENT);
string ID;
if (IdentCdrom(CDROM,ID) == false)
{
- log->Update("\n");
+ if (log != NULL)
+ log->Update("\n");
return false;
}
- if(log)
+ if(log != NULL)
+ {
log->Update("["+ID+"]\n");
-
- if(log)
log->Update(_("Scanning disc for index files..\n"),STEP_SCAN);
-
+ }
+
// Get the CD structure
vector<string> List;
vector<string> SourceList;
@@ -634,7 +651,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
string InfoDir;
if (FindPackages(CDROM,List,SourceList, SigList,TransList,InfoDir,log) == false)
{
- log->Update("\n");
+ if (log != NULL)
+ log->Update("\n");
return false;
}
@@ -661,7 +679,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
DropRepeats(SourceList,"Sources");
DropRepeats(SigList,"Release.gpg");
DropRepeats(TransList,"");
- if(log) {
+ if(log != NULL) {
msg.str("");
ioprintf(msg, _("Found %zu package indexes, %zu source indexes, "
"%zu translation indexes and %zu signatures\n"),
@@ -698,7 +716,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
- if(log) {
+ if(log != NULL)
+ {
msg.str("");
ioprintf(msg, _("Found label '%s'\n"), Name.c_str());
log->Update(msg.str());
@@ -710,7 +729,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (_config->FindB("APT::CDROM::Rename",false) == true ||
Name.empty() == true)
{
- if(!log)
+ if(log == NULL)
{
if (_config->FindB("APT::CDROM::NoMount",false) == false)
UnmountCdrom(CDROM);
@@ -743,13 +762,13 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
*J = '_';
Database.Set("CD::" + ID,Name);
- if(log) {
+ if(log != NULL)
+ {
msg.str("");
ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str());
log->Update(msg.str());
+ log->Update(_("Copying package lists..."), STEP_COPY);
}
-
- log->Update(_("Copying package lists..."), STEP_COPY);
// take care of the signatures and copy them if they are ok
// (we do this before PackageCopy as it modifies "List" and "SourceList")
SigVerify SignVerify;
@@ -774,16 +793,15 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
if (WriteDatabase(Database) == false)
return false;
- if(log) {
+ if(log != NULL)
log->Update(_("Writing new source list\n"), STEP_WRITE);
- }
if (WriteSourceList(Name,List,false) == false ||
WriteSourceList(Name,SourceList,true) == false)
return false;
}
// Print the sourcelist entries
- if(log)
+ if(log != NULL)
log->Update(_("Source list entries for this disc are:\n"));
for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
@@ -796,7 +814,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
return _error->Error("Internal error");
}
- if(log) {
+ if(log != NULL)
+ {
msg.str("");
msg << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
@@ -814,7 +833,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
return _error->Error("Internal error");
}
- if(log) {
+ if(log != NULL) {
msg.str("");
msg << "deb-src cdrom:[" << Name << "]/" << string(*I,0,Space) <<
" " << string(*I,Space+1) << endl;
@@ -824,7 +843,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/
// Unmount and finish
if (_config->FindB("APT::CDROM::NoMount",false) == false) {
- log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
+ if (log != NULL)
+ log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST);
UnmountCdrom(CDROM);
}
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 83c324f54..821e6d688 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -20,7 +20,6 @@
#include <apti18n.h>
#include <sys/wait.h>
-#include <sys/errno.h>
#include <sys/statvfs.h>
#include <dirent.h>
#include <fcntl.h>
@@ -206,8 +205,11 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
Hash.Add(Dir->d_name);
};
- if (chdir(StartDir.c_str()) != 0)
- return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
+ if (chdir(StartDir.c_str()) != 0) {
+ _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
+ closedir(D);
+ return false;
+ }
closedir(D);
// Some stats from the fsys
@@ -236,7 +238,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
}
/*}}}*/
-// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
+// FindMountPointForDevice - Find mountpoint for the given device /*{{{*/
string FindMountPointForDevice(const char *devnode)
{
char buf[255];
@@ -254,7 +256,10 @@ string FindMountPointForDevice(const char *devnode)
while ( fgets(buf, sizeof(buf), f) != NULL) {
if (strncmp(buf, devnode, strlen(devnode)) == 0) {
if(TokSplitString(' ', buf, out, 10))
+ {
+ fclose(f);
return string(out[1]);
+ }
}
}
fclose(f);
@@ -263,5 +268,4 @@ string FindMountPointForDevice(const char *devnode)
return string();
}
-
-
+ /*}}}*/
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index fe50e606b..18810d2a4 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -107,6 +107,7 @@ bool GlobalError::InsertErrno(MsgType type, const char* Function,
msgSize = n + 1;
else
msgSize *= 2;
+ free(S);
return true;
}
@@ -160,6 +161,7 @@ bool GlobalError::Insert(MsgType type, const char* Description,
msgSize = n + 1;
else
msgSize *= 2;
+ free(S);
return true;
}
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 9945b1606..19381ae47 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -237,11 +237,19 @@ DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long const &WorkSpace,
if ((this->Flags & Fallback) != Fallback) {
// Set the permissions.
int Prot = PROT_READ;
+#ifdef MAP_ANONYMOUS
int Map = MAP_PRIVATE | MAP_ANONYMOUS;
+#else
+ int Map = MAP_PRIVATE | MAP_ANON;
+#endif
if ((this->Flags & ReadOnly) != ReadOnly)
Prot |= PROT_WRITE;
if ((this->Flags & Public) == Public)
+#ifdef MAP_ANONYMOUS
Map = MAP_SHARED | MAP_ANONYMOUS;
+#else
+ Map = MAP_SHARED | MAP_ANON;
+#endif
// use anonymous mmap() to get the memory
Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0);
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index d8027fc24..34f472ee1 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -160,10 +160,10 @@ void maybe_add_auth (URI &Uri, string NetRCFile)
{
char login[64] = "";
char password[64] = "";
- char *netrcfile = strdupa (NetRCFile.c_str ());
+ char *netrcfile = strdup(NetRCFile.c_str());
// first check for a generic host based netrc entry
- char *host = strdupa (Uri.Host.c_str ());
+ char *host = strdup(Uri.Host.c_str());
if (host && parsenetrc (host, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
@@ -173,13 +173,16 @@ void maybe_add_auth (URI &Uri, string NetRCFile)
<< std::endl;
Uri.User = string (login);
Uri.Password = string (password);
+ free(netrcfile);
+ free(host);
return;
}
+ free(host);
// if host did not work, try Host+Path next, this will trigger
// a lookup uri.startswith(host) in the netrc file parser (because
// of the "/"
- char *hostpath = strdupa (string(Uri.Host+Uri.Path).c_str ());
+ char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str());
if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
@@ -189,8 +192,9 @@ void maybe_add_auth (URI &Uri, string NetRCFile)
<< std::endl;
Uri.User = string (login);
Uri.Password = string (password);
- return;
}
+ free(netrcfile);
+ free(hostpath);
}
}
}
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 4be626741..b59ae8896 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -487,7 +487,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
// Parse off the package name
const char *I = Start;
for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
- *I != ',' && *I != '|'; I++);
+ *I != ',' && *I != '|' && *I != '[' && *I != ']'; I++);
// Malformed, no '('
if (I != Stop && *I == ')')
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index a6edab6b9..a91cc34e9 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -195,11 +195,14 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
}
}
+ std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
+ if (lang.empty() == true)
+ return IndexTargets;
+
// get the Translations:
// - if its a dists-style repository get the i18n/Index first
// - if its flat try to acquire files by guessing
if (Dist[Dist.size() - 1] == '/') {
- std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
for (std::set<std::string>::const_iterator s = sections.begin();
s != sections.end(); ++s) {
for (std::vector<std::string>::const_iterator l = lang.begin();
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 01808be24..b37980b7e 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -391,8 +391,9 @@ void pkgDPkgPM::DoTerminalPty(int master)
{
// this happens when the child is about to exit, we
// give it time to actually exit, otherwise we run
- // into a race
- usleep(500000);
+ // into a race so we sleep for half a second.
+ struct timespec sleepfor = { 0, 500000000 };
+ nanosleep(&sleepfor, NULL);
return;
}
if(len <= 0)
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 07803d7bf..e9fa097aa 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -70,7 +70,7 @@ void pkgDepCache::ActionGroup::release()
cache.MarkAndSweep();
}
- released = false;
+ released = true;
}
}
@@ -339,8 +339,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
/* Check simple depends. A depends -should- never self match but
we allow it anyhow because dpkg does. Technically it is a packaging
bug. Conflicts may never self match */
- if (Dep.TargetPkg() != Dep.ParentPkg() ||
- (Dep->Type != Dep::Conflicts && Dep->Type != Dep::DpkgBreaks && Dep->Type != Dep::Obsoletes))
+ if (Dep.TargetPkg() != Dep.ParentPkg() || Dep.IsNegative() == false)
{
PkgIterator Pkg = Dep.TargetPkg();
// Check the base package
@@ -370,8 +369,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
{
/* Provides may never be applied against the same package (or group)
if it is a conflicts. See the comment above. */
- if (P.OwnerPkg()->Group == Pkg->Group &&
- (Dep->Type == Dep::Conflicts || Dep->Type == Dep::DpkgBreaks))
+ if (P.OwnerPkg()->Group == Pkg->Group && Dep.IsNegative() == true)
continue;
// Check if the provides is a hit
@@ -549,8 +547,8 @@ void pkgDepCache::AddStates(const PkgIterator &Pkg,int Add)
// Not installed
if (Pkg->CurrentVer == 0)
{
- if (State.Mode == ModeDelete &&
- (State.iFlags | Purge) == Purge && Pkg.Purge() == false)
+ if (State.Mode == ModeDelete &&
+ (State.iFlags & Purge) == Purge && Pkg.Purge() == false)
iDelCount += Add;
if (State.Mode == ModeInstall)
@@ -594,9 +592,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
/* Invert for Conflicts. We have to do this twice to get the
right sense for a conflicts group */
- if (D->Type == Dep::Conflicts ||
- D->Type == Dep::DpkgBreaks ||
- D->Type == Dep::Obsoletes)
+ if (D.IsNegative() == true)
State = ~State;
// Add to the group if we are within an or..
@@ -607,9 +603,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
Group = 0;
// Invert for Conflicts
- if (D->Type == Dep::Conflicts ||
- D->Type == Dep::DpkgBreaks ||
- D->Type == Dep::Obsoletes)
+ if (D.IsNegative() == true)
State = ~State;
}
}
@@ -742,9 +736,7 @@ void pkgDepCache::Update(OpProgress *Prog)
Group = 0;
// Invert for Conflicts
- if (D->Type == Dep::Conflicts ||
- D->Type == Dep::DpkgBreaks ||
- D->Type == Dep::Obsoletes)
+ if (D.IsNegative() == true)
State = ~State;
}
}
@@ -774,9 +766,7 @@ void pkgDepCache::Update(DepIterator D)
State = DependencyState(D);
// Invert for Conflicts
- if (D->Type == Dep::Conflicts ||
- D->Type == Dep::DpkgBreaks ||
- D->Type == Dep::Obsoletes)
+ if (D.IsNegative() == true)
State = ~State;
RemoveStates(D.ParentPkg());
@@ -1088,7 +1078,22 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
*/
if (IsImportantDep(Start) == false)
continue;
-
+
+ /* If we are in an or group locate the first or that can
+ succeed. We have already cached this.. */
+ for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors)
+ ++Start;
+ if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer && Start.IsNegative() == false)
+ {
+ if(DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl;
+ if (Start.IsCritical() == false)
+ continue;
+ // if the dependency was critical, we can't install it, so remove it again
+ MarkDelete(Pkg,false,Depth + 1, false);
+ return;
+ }
+
/* Check if any ImportantDep() (but not Critical) were added
* since we installed the package. Also check for deps that
* were satisfied in the past: for instance, if a version
@@ -1096,57 +1101,49 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
* package should follow that Recommends rather than causing the
* dependency to be removed. (bug #470115)
*/
- bool isNewImportantDep = false;
- bool isPreviouslySatisfiedImportantDep = false;
- if(!ForceImportantDeps && !Start.IsCritical())
+ if (Pkg->CurrentVer != 0 && ForceImportantDeps == false && Start.IsCritical() == false)
{
- bool found=false;
- VerIterator instVer = Pkg.CurrentVer();
- if(!instVer.end())
+ bool isNewImportantDep = true;
+ bool isPreviouslySatisfiedImportantDep = false;
+ for (DepIterator D = Pkg.CurrentVer().DependsList(); D.end() != true; ++D)
+ {
+ //FIXME: Should we handle or-group better here?
+ // We do not check if the package we look for is part of the same or-group
+ // we might find while searching, but could that really be a problem?
+ if (D.IsCritical() == true || IsImportantDep(D) == false ||
+ Start.TargetPkg() != D.TargetPkg())
+ continue;
+
+ isNewImportantDep = false;
+
+ while ((D->CompareOp & Dep::Or) != 0)
+ ++D;
+
+ isPreviouslySatisfiedImportantDep = (((*this)[D] & DepGNow) != 0);
+ if (isPreviouslySatisfiedImportantDep == true)
+ break;
+ }
+
+ if(isNewImportantDep == true)
+ {
+ if (DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "new important dependency: "
+ << Start.TargetPkg().FullName() << std::endl;
+ }
+ else if(isPreviouslySatisfiedImportantDep == true)
+ {
+ if (DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on "
+ << Start.TargetPkg().FullName() << std::endl;
+ }
+ else
{
- for (DepIterator D = instVer.DependsList(); D.end() != true; D++)
- {
- //FIXME: deal better with or-groups(?)
- if(IsImportantDep(D) && !D.IsCritical() &&
- Start.TargetPkg() == D.TargetPkg())
- {
- if(!isPreviouslySatisfiedImportantDep)
- {
- DepIterator D2 = D;
- while((D2->CompareOp & Dep::Or) != 0)
- ++D2;
-
- isPreviouslySatisfiedImportantDep =
- (((*this)[D2] & DepGNow) != 0);
- }
-
- found=true;
- }
- }
- // this is a new dep if it was not found to be already
- // a important dep of the installed pacakge
- isNewImportantDep = !found;
+ if (DebugAutoInstall == true)
+ std::clog << OutputInDepth(Depth) << "ignore old unsatisfied important dependency on "
+ << Start.TargetPkg().FullName() << std::endl;
+ continue;
}
}
- if(isNewImportantDep)
- if(DebugAutoInstall == true)
- std::clog << OutputInDepth(Depth) << "new important dependency: "
- << Start.TargetPkg().Name() << std::endl;
- if(isPreviouslySatisfiedImportantDep)
- if(DebugAutoInstall == true)
- std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on "
- << Start.TargetPkg().Name() << std::endl;
-
- // skip important deps if the package is already installed
- if (Pkg->CurrentVer != 0 && Start.IsCritical() == false
- && !isNewImportantDep && !isPreviouslySatisfiedImportantDep
- && !ForceImportantDeps)
- continue;
-
- /* If we are in an or group locate the first or that can
- succeed. We have already cached this.. */
- for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; Ors--)
- Start++;
/* This bit is for processing the possibilty of an install/upgrade
fixing the problem */
@@ -1212,8 +1209,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
/* For conflicts we just de-install the package and mark as auto,
Conflicts may not have or groups. For dpkg's Breaks we try to
upgrade the package. */
- if (Start->Type == Dep::Conflicts || Start->Type == Dep::Obsoletes ||
- Start->Type == Dep::DpkgBreaks)
+ if (Start.IsNegative() == true)
{
for (Version **I = List; *I != 0; I++)
{
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index c2ee1c347..064fb007c 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -75,7 +75,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
// Open the package file
FileFd Pkg;
- if (FileExists(*I + GetFileName()) == true)
+ if (RealFileExists(*I + GetFileName()) == true)
{
Pkg.Open(*I + GetFileName(),FileFd::ReadOnly);
FileSize = Pkg.Size();
@@ -532,7 +532,7 @@ bool SigVerify::Verify(string prefix, string file, indexRecords *MetaIndex)
// we skip non-existing files in the verifcation to support a cdrom
// with no Packages file (just a Package.gz), see LP: #255545
// (non-existing files are not considered a error)
- if(!FileExists(prefix+file))
+ if(!RealFileExists(prefix+file))
{
_error->Warning(_("Skipping nonexistent file %s"), string(prefix+file).c_str());
return true;
@@ -601,7 +601,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
string const release = *I+"Release";
// a Release.gpg without a Release should never happen
- if(FileExists(release) == false)
+ if(RealFileExists(release) == false)
{
delete MetaIndex;
continue;
@@ -681,7 +681,7 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileGPG,
std::vector<string> keyrings;
if (DirectoryExists(trustedPath))
keyrings = GetListOfFilesInDir(trustedPath, "gpg", false, true);
- if (FileExists(trustedFile) == true)
+ if (RealFileExists(trustedFile) == true)
keyrings.push_back(trustedFile);
std::vector<const char *> Args;
@@ -788,7 +788,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
// Open the package file
FileFd Pkg;
- if (FileExists(*I) == true)
+ if (RealFileExists(*I) == true)
{
Pkg.Open(*I,FileFd::ReadOnly);
FileSize = Pkg.Size();
diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc
index d5bd19581..ba43bc757 100644
--- a/apt-pkg/orderlist.cc
+++ b/apt-pkg/orderlist.cc
@@ -490,7 +490,7 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver)
bool Res = true;
for (PrvIterator P = Ver.ProvidesList(); P.end() == false; P++)
Res &= (this->*F)(P.ParentPkg().RevDependsList());
- return true;
+ return Res;
}
/*}}}*/
// OrderList::VisitProvides - Visit all of the providing packages /*{{{*/
@@ -507,15 +507,11 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)
continue;
- if (D->Type != pkgCache::Dep::Conflicts &&
- D->Type != pkgCache::Dep::DpkgBreaks &&
- D->Type != pkgCache::Dep::Obsoletes &&
+ if (D.IsNegative() == false &&
Cache[Pkg].InstallVer != *I)
continue;
- if ((D->Type == pkgCache::Dep::Conflicts ||
- D->Type == pkgCache::Dep::DpkgBreaks ||
- D->Type == pkgCache::Dep::Obsoletes) &&
+ if (D.IsNegative() == true &&
(Version *)Pkg.CurrentVer() != *I)
continue;
@@ -647,9 +643,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
{
/* Forward critical dependencies MUST be correct before the
package can be unpacked. */
- if (D->Type != pkgCache::Dep::Conflicts &&
- D->Type != pkgCache::Dep::DpkgBreaks &&
- D->Type != pkgCache::Dep::Obsoletes &&
+ if (D.IsNegative() == false &&
D->Type != pkgCache::Dep::PreDepends)
continue;
@@ -1077,9 +1071,7 @@ bool pkgOrderList::CheckDep(DepIterator D)
/* Conflicts requires that all versions are not present, depends
just needs one */
- if (D->Type != pkgCache::Dep::Conflicts &&
- D->Type != pkgCache::Dep::DpkgBreaks &&
- D->Type != pkgCache::Dep::Obsoletes)
+ if (D.IsNegative() == false)
{
/* Try to find something that does not have the after flag set
if at all possible */
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 4c655cb7b..fe9f6eb68 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -319,6 +319,17 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
}
+ if (Cache[Pkg].InstVerIter(Cache)->MultiArch == pkgCache::Version::Same)
+ for (PkgIterator P = Pkg.Group().PackageList();
+ P.end() == false; P = Pkg.Group().NextPkg(P))
+ {
+ if (Pkg == P || List->IsFlag(P,pkgOrderList::Configured) == true ||
+ Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
+ (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
+ continue;
+ SmartConfigure(P);
+ }
+
// Sanity Check
if (List->IsFlag(Pkg,pkgOrderList::Configured) == false)
return _error->Error(_("Could not perform immediate configuration on '%s'. "
@@ -475,21 +486,28 @@ bool pkgPackageManager::SmartRemove(PkgIterator Pkg)
/* This performs the task of handling pre-depends. */
bool pkgPackageManager::SmartUnPack(PkgIterator Pkg)
{
+ return SmartUnPack(Pkg, true);
+}
+bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate)
+{
// Check if it is already unpacked
if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
Cache[Pkg].Keep() == true)
{
List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
- if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
+ if (Immediate == true &&
+ List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
if (SmartConfigure(Pkg) == false)
return _error->Error(_("Could not perform immediate configuration on already unpacked '%s'. "
"Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg.Name());
return true;
}
+ VerIterator const instVer = Cache[Pkg].InstVerIter(Cache);
+
/* See if this packages install version has any predependencies
that are not met by 'now' packages. */
- for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList();
+ for (DepIterator D = instVer.DependsList();
D.end() == false; )
{
// Compute a single dependency element (glob or)
@@ -575,20 +593,32 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg)
// Check for reverse conflicts.
if (CheckRConflicts(Pkg,Pkg.RevDependsList(),
- Cache[Pkg].InstVerIter(Cache).VerStr()) == false)
+ instVer.VerStr()) == false)
return false;
- for (PrvIterator P = Cache[Pkg].InstVerIter(Cache).ProvidesList();
+ for (PrvIterator P = instVer.ProvidesList();
P.end() == false; P++)
CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion());
+ List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
+
+ if (instVer->MultiArch == pkgCache::Version::Same)
+ for (PkgIterator P = Pkg.Group().PackageList();
+ P.end() == false; P = Pkg.Group().NextPkg(P))
+ {
+ if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true ||
+ Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer &&
+ (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall))
+ continue;
+ SmartUnPack(P, false);
+ }
+
if(Install(Pkg,FileNames[Pkg->ID]) == false)
return false;
- List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
-
// Perform immedate configuration of the package.
- if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
+ if (Immediate == true &&
+ List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
if (SmartConfigure(Pkg) == false)
return _error->Error(_("Could not perform immediate configuration on '%s'. "
"Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2);
diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h
index efd2cfac6..053b4dc13 100644
--- a/apt-pkg/packagemanager.h
+++ b/apt-pkg/packagemanager.h
@@ -69,7 +69,9 @@ class pkgPackageManager : protected pkgCache::Namespace
// Install helpers
bool ConfigureAll();
bool SmartConfigure(PkgIterator Pkg);
+ //FIXME: merge on abi break
bool SmartUnPack(PkgIterator Pkg);
+ bool SmartUnPack(PkgIterator Pkg, bool const Immediate);
bool SmartRemove(PkgIterator Pkg);
bool EarlyRemove(PkgIterator Pkg);
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index c6326abf1..38e4e904e 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -211,12 +211,18 @@ pkgCache::PkgIterator pkgCache::SingleArchFindPkg(const string &Name)
// ---------------------------------------------------------------------
/* Returns 0 on error, pointer to the package otherwise */
pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
- if (MultiArchCache() == false)
- return SingleArchFindPkg(Name);
size_t const found = Name.find(':');
if (found == string::npos)
- return FindPkg(Name, "native");
+ {
+ if (MultiArchCache() == false)
+ return SingleArchFindPkg(Name);
+ else
+ return FindPkg(Name, "native");
+ }
string const Arch = Name.substr(found+1);
+ /* Beware: This is specialcased to handle pkg:any in dependencies as
+ these are linked to virtual pkg:any named packages with all archs.
+ If you want any arch from a given pkg, use FindPkg(pkg,arch) */
if (Arch == "any")
return FindPkg(Name, "any");
return FindPkg(Name.substr(0, found), Arch);
@@ -228,7 +234,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
if (MultiArchCache() == false) {
if (Arch == "native" || Arch == "all" || Arch == "any" ||
- Arch == _config->Find("APT::Architecture"))
+ Arch == NativeArch())
return SingleArchFindPkg(Name);
else
return PkgIterator(*this,0);
@@ -322,15 +328,15 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
if (Arch == "any")
return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage);
- static string const myArch = _config->Find("APT::Architecture");
+ char const* const myArch = Owner->NativeArch();
/* Most of the time the package for our native architecture is
the one we add at first to the cache, but this would be the
last one we check, so we do it now. */
if (Arch == "native" || Arch == myArch || Arch == "all") {
- Arch = myArch;
pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
- if (stringcasecmp(Arch, Owner->StrP + Pkg->Arch) == 0)
+ if (strcasecmp(myArch, Owner->StrP + Pkg->Arch) == 0)
return PkgIterator(*Owner, Pkg);
+ Arch = myArch;
}
/* Iterate over the list to find the matching arch
@@ -503,7 +509,8 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
{
string fullname = Name();
if (Pretty == false ||
- (strcmp(Arch(), "all") != 0 && _config->Find("APT::Architecture") != Arch()))
+ (strcmp(Arch(), "all") != 0 &&
+ strcmp(Owner->NativeArch(), Arch()) != 0))
return fullname.append(":").append(Arch());
return fullname;
}
@@ -514,15 +521,24 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
conflicts (including dpkg's Breaks fields). */
bool pkgCache::DepIterator::IsCritical() const
{
- if (S->Type == pkgCache::Dep::Conflicts ||
- S->Type == pkgCache::Dep::DpkgBreaks ||
- S->Type == pkgCache::Dep::Obsoletes ||
+ if (IsNegative() == true ||
S->Type == pkgCache::Dep::Depends ||
S->Type == pkgCache::Dep::PreDepends)
return true;
return false;
}
/*}}}*/
+// DepIterator::IsNegative - Returns true if the dep is a negative one /*{{{*/
+// ---------------------------------------------------------------------
+/* Some dependencies are positive like Depends and Recommends, others
+ are negative like Conflicts which can and should be handled differently */
+bool pkgCache::DepIterator::IsNegative() const
+{
+ return S->Type == Dep::DpkgBreaks ||
+ S->Type == Dep::Conflicts ||
+ S->Type == Dep::Obsoletes;
+}
+ /*}}}*/
// DepIterator::SmartTargetPkg - Resolve dep target pointers w/provides /*{{{*/
// ---------------------------------------------------------------------
/* This intellegently looks at dep target packages and tries to figure
@@ -600,9 +616,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
continue;
- if ((S->Type == pkgCache::Dep::Conflicts ||
- S->Type == pkgCache::Dep::DpkgBreaks ||
- S->Type == pkgCache::Dep::Obsoletes) &&
+ if (IsNegative() == true &&
ParentPkg() == I.ParentPkg())
continue;
@@ -617,9 +631,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
continue;
- if ((S->Type == pkgCache::Dep::Conflicts ||
- S->Type == pkgCache::Dep::DpkgBreaks ||
- S->Type == pkgCache::Dep::Obsoletes) &&
+ if (IsNegative() == true &&
ParentPkg() == I.OwnerPkg())
continue;
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index d654a2976..1b1743724 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -215,6 +215,7 @@ class pkgCache /*{{{*/
private:
bool MultiArchEnabled;
PkgIterator SingleArchFindPkg(const string &Name);
+ inline char const * const NativeArch() const;
};
/*}}}*/
// Header structure /*{{{*/
@@ -649,6 +650,11 @@ struct pkgCache::StringItem
map_ptrloc NextItem; // StringItem
};
/*}}}*/
+
+
+inline char const * const pkgCache::NativeArch() const
+ { return StrP + HeaderP->Architecture; };
+
#include <apt-pkg/cacheiterators.h>
inline pkgCache::GrpIterator pkgCache::GrpBegin()
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index b0ee04554..9820fde81 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -479,7 +479,8 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
// Set the name, arch and the ID
Pkg->Name = Grp->Name;
Pkg->Group = Grp.Index();
- map_ptrloc const idxArch = WriteUniqString((Arch == "all") ? _config->Find("APT::Architecture") : Arch.c_str());
+ // all is mapped to the native architecture
+ map_ptrloc const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : WriteUniqString(Arch.c_str());
if (unlikely(idxArch == 0))
return false;
Pkg->Arch = idxArch;
@@ -783,7 +784,7 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
// We do not add self referencing provides
if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
- (PkgArch == "all" && _config->Find("APT::Architecture") == Ver.ParentPkg().Arch())))
+ (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0)))
return true;
// Get a structure
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 94c7fd4af..2cc2e5e39 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -216,10 +216,22 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
P->Data = Data;
return;
}
+
+ // Allow pinning by wildcards
+ // TODO: Maybe we should always prefer specific pins over non-
+ // specific ones.
+ if (Name[0] == '/' || Name.find_first_of("*[?") != string::npos)
+ {
+ pkgVersionMatch match(Data, Type);
+ for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() != true; ++G)
+ if (match.ExpressionMatches(Name, G.Name()))
+ CreatePin(Type, G.Name(), Data, Priority);
+ return;
+ }
// Get a spot to put the pin
pkgCache::GrpIterator Grp = Cache->FindGrp(Name);
- for (pkgCache::PkgIterator Pkg = Grp.FindPkg("any");
+ for (pkgCache::PkgIterator Pkg = Grp.PackageList();
Pkg.end() != true; Pkg = Grp.NextPkg(Pkg))
{
Pin *P = 0;