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 /*{{{*/
// ---------------------------------------------------------------------
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,
Tmp->Uri = LookupTag(Message,"URI");
Tmp->DestFile = LookupTag(Message,"FileName");
+ Tmp->ExpectedMD5 = LookupTag(Message,"ExpectedMD5");
if (StrToTime(LookupTag(Message,"Last-Modified"),Tmp->LastModified) == false)
Tmp->LastModified = 0;
Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false);
string DestFile;
time_t LastModified;
bool IndexFile;
+ string ExpectedMD5;
};
struct FetchResult
/*
* TODO:
- * - send expected checksum to the mirror method so that
- some checking/falling back can be done here already
- use pkgAcquire::Custom600Header() for this? what about gpgv
- failures?
+ * - what about gpgv failures? better standard format for errors
+ to send back to LP
#OR#
* - implement it at the pkgAcquire::Item::Failed() level but then
- we need to send back what uri exactly was failing
-
+ we need to send back what uri exactly was failing
+ [mvo: the problem with this approach is ::Failed() is not really
+ called for all failures :/ e.g. md5sum mismatch in a archive
+ is not]
* - 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
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
+ std::cerr << "\nReportMirrorFailure: "
+ << Queue->Uri
+ << " FailCode: "
+ << FailCode << std::endl;
+}
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);
#: 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:86
+#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:92
#, c-format
msgid "Unable to read %s"
msgstr ""
msgstr ""
#: apt-pkg/contrib/cdromutl.cc:149 apt-pkg/acquire.cc:427 apt-pkg/clean.cc:44
-#: methods/mirror.cc:92
+#: methods/mirror.cc:98
#, c-format
msgid "Unable to change to %s"
msgstr ""
msgid "rename failed, %s (%s -> %s)."
msgstr ""
-#: apt-pkg/acquire-item.cc:236 apt-pkg/acquire-item.cc:945
+#: apt-pkg/acquire-item.cc:237 apt-pkg/acquire-item.cc:946
msgid "MD5Sum mismatch"
msgstr ""
-#: apt-pkg/acquire-item.cc:640
+#: apt-pkg/acquire-item.cc:641
msgid "There is no public key available for the following key IDs:\n"
msgstr ""
-#: apt-pkg/acquire-item.cc:753
+#: apt-pkg/acquire-item.cc:754
#, 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:812
+#: apt-pkg/acquire-item.cc:813
#, 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:848
+#: apt-pkg/acquire-item.cc:849
#, c-format
msgid ""
"The package index files are corrupted. No Filename: field for package %s."
msgstr ""
-#: apt-pkg/acquire-item.cc:935
+#: apt-pkg/acquire-item.cc:936
msgid "Size mismatch"
msgstr ""