Status = StatError;
Dequeue();
}
+
+ // report mirror failure back to LP if we actually use a mirror
+ if(!UsedMirror.empty())
+ ReportMirrorFailure(ErrorText);
}
/*}}}*/
// Acquire::Item::Start - Item has begun to download /*{{{*/
{
// We just downloaded something..
string FileName = LookupTag(Message,"Filename");
+ UsedMirror = LookupTag(Message,"UsedMirror");
if (Complete == false && FileName == DestFile)
{
if (Owner->Log != 0)
if (FileSize == 0)
FileSize= Size;
-
Status = StatDone;
ErrorText = string();
Owner->Dequeue(this);
}
/*}}}*/
+void pkgAcquire::Item::ReportMirrorFailure(string FailCode)
+{
+ // report that Queue->Uri failed
+#if 0
+ std::cerr << "\nReportMirrorFailure: "
+ << UsedMirror
+ << " FailCode: "
+ << FailCode << std::endl;
+#endif
+ const char *Args[40];
+ unsigned int i = 0;
+ string report = _config->Find("Methods::Mirror::ProblemReporting",
+ "/usr/bin/apt-report-mirror-failure");
+ if(!FileExists(report))
+ return;
+ Args[i++] = report.c_str();
+ Args[i++] = UsedMirror.c_str();
+ Args[i++] = FailCode.c_str();
+ pid_t pid = ExecFork();
+ if(pid < 0)
+ {
+ _error->Error("ReportMirrorFailure Fork failed");
+ return;
+ }
+ else if(pid == 0)
+ {
+ execvp(report.c_str(), (char**)Args);
+ }
+ if(!ExecWait(pid, "report-mirror-failure"))
+ {
+ _error->Warning("Couldn't report problem to '%s'",
+ _config->Find("Acquire::Mirror::ReportFailures").c_str());
+ }
+}
+
+
// AcqIndex::AcqIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The package file is added to the queue and a second class is
struct stat Buf;
if (stat(Final.c_str(),&Buf) != 0)
return "\nIndex-File: true";
- if(ExpectedMD5 != "")
- return "\nExpectedMD5: " + ExpectedMD5;
return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
}
/*}}}*/
}
}
/*}}}*/
-// ---------------------------------------------------------------------
-string pkgAcqArchive::Custom600Headers()
-{
- if(MD5 != "")
- return "\nExpectedMD5: " + MD5;
- return "";
-}
// AcqArchive::IsTrusted - Determine whether this archive comes from a
// trusted source /*{{{*/
// ---------------------------------------------------------------------
unsigned long ID;
bool Complete;
bool Local;
+ string UsedMirror;
// Number of queues we are inserted into
unsigned int QueueCounter;
pkgAcquire *GetOwner() {return Owner;};
virtual bool IsTrusted() {return false;};
+ // report mirror problems
+ void ReportMirrorFailure(string FailCode);
+
Item(pkgAcquire *Owner);
virtual ~Item();
};
virtual string ShortDesc() {return Desc.ShortDesc;};
virtual void Finished();
virtual bool IsTrusted();
- virtual string Custom600Headers();
pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
pkgRecords *Recs,pkgCache::VerIterator const &Version,
}
char S[1024];
+ char *End = S;
if (Queue != 0)
{
- snprintf(S,sizeof(S)-50,"400 URI Failure\nURI: %s\n"
- "Message: %s %s\n",Queue->Uri.c_str(),Err.c_str(),
- FailExtra.c_str());
-
+ 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());
// Dequeue
FetchItem *Tmp = Queue;
Queue = Queue->Next;
QueueBack = Queue;
}
else
- snprintf(S,sizeof(S)-50,"400 URI Failure\nURI: <UNKNOWN>\n"
- "Message: %s %s\n",Err.c_str(),
- FailExtra.c_str());
-
+ {
+ End += snprintf(S,sizeof(S)-50,"400 URI Failure\nURI: <UNKNOWN>\n"
+ "Message: %s\n",Err.c_str());
+ }
+ if(FailReason.empty() == false)
+ End += snprintf(End,sizeof(S)-50 - (End - S),"FailReason: %s\n",FailReason.c_str());
+ if (UsedMirror.empty() == false)
+ End += snprintf(End,sizeof(S)-50 - (End - S),"UsedMirror: %s\n",UsedMirror.c_str());
// Set the transient flag
if (Transient == true)
strcat(S,"Transient-Failure: true\n\n");
End += snprintf(End,sizeof(S)-50 - (End - S),"MD5-Hash: %s\n",Res.MD5Sum.c_str());
if (Res.SHA1Sum.empty() == false)
End += snprintf(End,sizeof(S)-50 - (End - S),"SHA1-Hash: %s\n",Res.SHA1Sum.c_str());
+ 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();
vector<string> Messages;
FetchItem *Queue;
FetchItem *QueueBack;
- string FailExtra;
+ string FailReason;
+ string UsedMirror;
+ string IP;
// Handlers for messages
virtual bool Configuration(string Message);
virtual void Exit() {};
public:
-
enum CnfFlags {SingleInstance = (1<<0),
Pipeline = (1<<1), SendConfig = (1<<2),
LocalOnly = (1<<3), NeedsCleanup = (1<<4),
void Status(const char *Format,...);
int Run(bool Single = false);
- inline void SetFailExtraMsg(string Msg) {FailExtra = Msg;};
+ inline void SetFailReason(string Msg) {FailReason = Msg;};
+ inline void SetIP(string aIP) {IP = aIP;};
pkgAcqMethod(const char *Ver,unsigned long Flags = 0);
virtual ~pkgAcqMethod() {};
--- /dev/null
+#!/usr/bin/python
+
+import sys
+import urllib
+import apt_pkg
+
+print "apt-report-mirror-failure"
+
+apt_pkg.init()
+url = apt_pkg.Config.Find("Acquire::Mirror::ReportFailures",
+ "http://people.ubuntu.com:9000/mirror-failure")
+ #"http://localhost:9000/mirror-failure")
+if not url:
+ sys.exit(0)
+
+data = {}
+data['url'] = sys.argv[1]
+data['error'] = sys.argv[2]
+f = urllib.urlopen(url, urllib.urlencode(data))
+f.read()
+f.close()
+
+
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <sstream>
// Internet stuff
#include <netinet/in.h>
wrong this will get tacked onto the end of the error message */
if (LastHostAddr->ai_next != 0)
{
- char Name2[NI_MAXHOST + NI_MAXSERV + 10];
- snprintf(Name2,sizeof(Name2),_("[IP: %s %s]"),Name,Service);
- Owner->SetFailExtraMsg(string(Name2));
- }
- else
- Owner->SetFailExtraMsg("");
+ std::stringstream ss;
+ ioprintf(ss, _("[IP: %s %s]"),Name,Service);
+ Owner->SetIP(ss.str());
+ }
// Get a socket
if ((Fd = socket(Addr->ai_family,Addr->ai_socktype,
/* This implements a timeout for connect by opening the connection
nonblocking */
if (WaitFd(Fd,true,TimeOut) == false) {
- Owner->SetFailExtraMsg("\nFailReason: Timeout");
+ Owner->SetFailReason("Timeout");
return _error->Error(_("Could not connect to %s:%s (%s), "
"connection timed out"),Host.c_str(),Service,Name);
}
{
errno = Err;
if(errno == ECONNREFUSED)
- Owner->SetFailExtraMsg("\nFailReason: ConnectionRefused");
+ Owner->SetFailReason("ConnectionRefused");
return _error->Errno("connect",_("Could not connect to %s:%s (%s)."),Host.c_str(),
Service,Name);
}
if (Res == EAI_AGAIN)
{
- Owner->SetFailExtraMsg("\nFailReason: TmpResolveFailure");
+ Owner->SetFailReason("TmpResolveFailure");
return _error->Error(_("Temporary failure resolving '%s'"),
Host.c_str());
}
*
* TODO:
* what about gpgv failures? this should call-out to the problem reporting
- script, but we need to know what mirror was used
+ script, but we need to know what mirror was used -> just run pkgAcquire::Item::ReportMirrorFailure()
* better standard format for errors to send back
* - implement failure reporting at the pkgAcquire::Item::Failed() level
but then we need to send back what uri exactly was failing
* - deal with runing as non-root because we can't write to the lists
dir then -> use the cached mirror file
* - better method to download than having a pkgAcquire interface here
- * - magicmarker is (a bit) evil, maybe just use a similar approach as in
+ * - magicmarker is evil, maybe just use a similar approach as in
clean and read the sources.list and use the GetURI() method to find
the prefix?
* support more than http
getline(in, Mirror);
if(Debug)
cerr << "Using mirror: " << Mirror << endl;
+
+ UsedMirror = Mirror;
return true;
}
void MirrorMethod::Fail(string Err,bool Transient)
{
- // FIXME: queue next mirror?
- ReportMirrorFailure(Err);
-
if(Queue->Uri.find("http://") != string::npos)
Queue->Uri.replace(0,Mirror.size(), BaseUri);
pkgAcqMethod::Fail(Err, Transient);
void MirrorMethod::URIDone(FetchResult &Res,FetchResult *Alt)
{
- // FIXME: queue next mirror?
- if(Queue->ExpectedMD5 != "" && Res.MD5Sum != Queue->ExpectedMD5)
- ReportMirrorFailure("499 Hash mismatch");
-
if(Queue->Uri.find("http://") != string::npos)
Queue->Uri.replace(0,Mirror.size(), BaseUri);
pkgAcqMethod::URIDone(Res, Alt);
}
-void MirrorMethod::ReportMirrorFailure(string FailCode)
-{
- // report that Queue->Uri failed
-#if 0
- std::cerr << "\nReportMirrorFailure: "
- << Queue->Uri
- << " FailCode: "
- << FailCode << std::endl;
-#endif
- const char *Args[40];
- unsigned int i = 0;
- string report = _config->Find("Methods::Mirror::ProblemReporting",
- "/usr/lib/apt/report-mirror-failure");
- Args[i++] = report.c_str();
- Args[i++] = Queue->Uri.c_str();
- Args[i++] = FailCode.c_str();
- pid_t pid = ExecFork();
- if(pid < 0)
- {
- _error->Error("ReportMirrorFailure Fork failed");
- return;
- }
- else if(pid == 0)
- {
- execvp(report.c_str(), (char**)Args);
- }
- if(!ExecWait(pid, "report-mirror-failure"))
- {
- _error->Warning("Couldn't report problem to '%s'",
- _config->Find("Acquire::Mirror::ReportFailures").c_str());
- }
-}
int main()
{
bool GetMirrorFile(string uri);
bool SelectMirror();
bool Clean(string dir);
- void ReportMirrorFailure(string FailCode);
// we need to overwrite those to transform the url back
virtual void Fail(string Why, bool Transient = false);
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-01-24 12:51+0100\n"
+"POT-Creation-Date: 2007-01-24 17:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "Calculating upgrade... "
msgstr ""
-#: cmdline/apt-get.cc:1716 methods/ftp.cc:702 methods/connect.cc:101
+#: cmdline/apt-get.cc:1716 methods/ftp.cc:702 methods/connect.cc:100
msgid "Failed"
msgstr ""
#: apt-inst/extract.cc:467 apt-pkg/contrib/configuration.cc:750
#: apt-pkg/contrib/cdromutl.cc:153 apt-pkg/sourcelist.cc:324
-#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:96
+#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:99
#, c-format
msgid "Unable to read %s"
msgstr ""
msgid "Unable to invoke "
msgstr ""
-#: methods/connect.cc:64
+#: methods/connect.cc:65
#, c-format
msgid "Connecting to %s (%s)"
msgstr ""
-#: methods/connect.cc:71
+#: methods/connect.cc:72
#, c-format
msgid "[IP: %s %s]"
msgstr ""
-#: methods/connect.cc:80
+#: methods/connect.cc:79
#, c-format
msgid "Could not create a socket for %s (f=%u t=%u p=%u)"
msgstr ""
-#: methods/connect.cc:86
+#: methods/connect.cc:85
#, c-format
msgid "Cannot initiate the connection to %s:%s (%s)."
msgstr ""
-#: methods/connect.cc:93
+#: methods/connect.cc:92
#, c-format
msgid "Could not connect to %s:%s (%s), connection timed out"
msgstr ""
-#: methods/connect.cc:108
+#: methods/connect.cc:107
#, c-format
msgid "Could not connect to %s:%s (%s)."
msgstr ""
#. We say this mainly because the pause here is for the
#. ssh connection that is still going
-#: methods/connect.cc:136 methods/rsh.cc:425
+#: methods/connect.cc:135 methods/rsh.cc:425
#, c-format
msgid "Connecting to %s"
msgstr ""
-#: methods/connect.cc:167
+#: methods/connect.cc:166
#, c-format
msgid "Could not resolve '%s'"
msgstr ""
-#: methods/connect.cc:173
+#: methods/connect.cc:172
#, c-format
msgid "Temporary failure resolving '%s'"
msgstr ""
-#: methods/connect.cc:176
+#: methods/connect.cc:175
#, c-format
msgid "Something wicked happened resolving '%s:%s' (%i)"
msgstr ""
-#: methods/connect.cc:223
+#: methods/connect.cc:222
#, c-format
msgid "Unable to connect to %s %s:"
msgstr ""
msgstr ""
#: apt-pkg/contrib/cdromutl.cc:149 apt-pkg/acquire.cc:427 apt-pkg/clean.cc:44
-#: methods/mirror.cc:102
+#: methods/mirror.cc:105
#, c-format
msgid "Unable to change to %s"
msgstr ""
msgid "IO Error saving source cache"
msgstr ""
-#: apt-pkg/acquire-item.cc:126
+#: apt-pkg/acquire-item.cc:128
#, c-format
msgid "rename failed, %s (%s -> %s)."
msgstr ""
-#: apt-pkg/acquire-item.cc:237 apt-pkg/acquire-item.cc:946
+#: apt-pkg/acquire-item.cc:275 apt-pkg/acquire-item.cc:984
msgid "MD5Sum mismatch"
msgstr ""
-#: apt-pkg/acquire-item.cc:641
+#: apt-pkg/acquire-item.cc:679
msgid "There is no public key available for the following key IDs:\n"
msgstr ""
-#: apt-pkg/acquire-item.cc:754
+#: apt-pkg/acquire-item.cc:792
#, c-format
msgid ""
"I wasn't able to locate a file for the %s package. This might mean you need "
"to manually fix this package. (due to missing arch)"
msgstr ""
-#: apt-pkg/acquire-item.cc:813
+#: apt-pkg/acquire-item.cc:851
#, c-format
msgid ""
"I wasn't able to locate file for the %s package. This might mean you need to "
"manually fix this package."
msgstr ""
-#: apt-pkg/acquire-item.cc:849
+#: apt-pkg/acquire-item.cc:887
#, c-format
msgid ""
"The package index files are corrupted. No Filename: field for package %s."
msgstr ""
-#: apt-pkg/acquire-item.cc:936
+#: apt-pkg/acquire-item.cc:974
msgid "Size mismatch"
msgstr ""