summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-05-07 17:45:10 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-05-07 17:45:10 +0000
commit94dc9d7d8bbf2f1351db26e4532327c6784ead96 (patch)
treede7a2193f47268c7974812604fb44b211b31040e /apt-pkg
parent6cb30d01f8e247e85966ba8ad657453d73598527 (diff)
parent61abe43c0b6c74ef561c093bbd0c0d4626558655 (diff)
* merge with matt, search for the right patch next instead of applying them in order
Patches applied: * apt@packages.debian.org/apt--main--0--patch-77 Merge apt--mvo--0 * apt@packages.debian.org/apt--main--0--patch-78 Update changelog * apt@packages.debian.org/apt--main--0--patch-79 Merge michael.vogt@ubuntu.com--2005/apt--mvo--0 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-14 * changelog entry for 0.6.34ubuntu1 added, MinAge default is 2 days now * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-15 * merged with matts tree * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-16 * changelog updated * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-17 * whitespace change to add incomplete log for last patch * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-18 * honor "Acquire::gpgv::Options" in apt-cdrom too * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-19 * corrected a incorrect use of string().c_str() (thanks to mdz!) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-20 * supress output when /var/cache/apt/archives is empty; break when min-age is reached * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-21 * changed distro to "experimental", changed version number to 0.6.36
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc56
-rw-r--r--apt-pkg/acquire-item.h2
-rw-r--r--apt-pkg/indexcopy.cc34
3 files changed, 73 insertions, 19 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 5d741af6f..81636902e 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -142,7 +142,7 @@ void pkgAcquire::Item::Rename(string From,string To)
pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
string URI,string URIDesc,string ShortDesc,
string ExpectedMD5, vector<DiffInfo> diffs)
- : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5), needed_files(diffs)
+ : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5), available_patches(diffs)
{
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
@@ -171,7 +171,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
return;
}
- if(needed_files.size() == 0)
+ if(available_patches.size() == 0)
QueueDiffIndex(URI);
else
QueueNextDiff();
@@ -261,7 +261,8 @@ bool pkgAcqIndexDiffs::ApplyDiff(string PatchFile)
if (Process == 0)
{
chdir(_config->FindDir("Dir::State::lists").c_str());
- string cmd = "(zcat " + PatchFile + "; echo \"wq\" ) | red " + FinalFile + " >/dev/null 2>/dev/null";
+ // for some reason "red" fails with the pdiffs from p.d.o/~aba ?!?
+ string cmd = "(zcat " + PatchFile + "; echo \"wq\" ) | /bin/ed " + FinalFile + " >/dev/null 2>/dev/null";
if(Debug)
std::clog << "Runing: " << cmd << std::endl;
res = system(cmd.c_str());
@@ -277,16 +278,35 @@ bool pkgAcqIndexDiffs::ApplyDiff(string PatchFile)
bool pkgAcqIndexDiffs::QueueNextDiff()
{
- // FIXME: don't use the needed_files[0] but check sha1 and search
- // for the right patch in needed_files
- // -> and rename needed_files to "available_patches"
+ // calc sha1 of the just patched file
+ string FinalFile = _config->FindDir("Dir::State::lists");
+ FinalFile += URItoFileName(RealURI);
+
+ FileFd fd(FinalFile, FileFd::ReadOnly);
+ SHA1Summation SHA1;
+ SHA1.AddFD(fd.Fd(), fd.Size());
+ string local_sha1 = string(SHA1.Result());
+
+ // see if we have a patch for it, the patch list must be ordered
+ for(vector<DiffInfo>::iterator I=available_patches.begin();
+ I != available_patches.end(); I++) {
+ // if the patch does not fit, it's not interessting
+ if((*I).sha1 != local_sha1)
+ available_patches.erase(I);
+ }
+
+ // error checking and falling back if no patch was found
+ if(available_patches.size() == 0) {
+ Failed("", NULL);
+ return false;
+ }
- // queue diff
- Desc.URI = string(RealURI) + string(".diff/") + needed_files[0].file + string(".gz");
- Desc.Description = needed_files[0].file + string(".pdiff");
+ // queue the right diff
+ Desc.URI = string(RealURI) + string(".diff/") + available_patches[0].file + string(".gz");
+ Desc.Description = available_patches[0].file + string(".pdiff");
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(RealURI + string(".diff/") + needed_files[0].file);
+ DestFile += URItoFileName(RealURI + string(".diff/") + available_patches[0].file);
if(Debug)
std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
@@ -341,7 +361,7 @@ bool pkgAcqIndexDiffs::ParseIndexDiff(string IndexDiffFile)
if(found) {
if(Debug)
std::clog << "Need to get diff: " << d.file << std::endl;
- needed_files.push_back(d);
+ available_patches.push_back(d);
}
}
// no information how to get the patches, bail out
@@ -353,7 +373,7 @@ bool pkgAcqIndexDiffs::ParseIndexDiff(string IndexDiffFile)
} else {
// queue the diffs
new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedMD5, needed_files);
+ ExpectedMD5, available_patches);
Finish();
return true;
}
@@ -394,11 +414,11 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,
// sucess in downloading a diff
if(Desc.URI.find(".diff") != string::npos) {
ApplyDiff(DestFile);
- needed_files.erase(needed_files.begin());
+ available_patches.erase(available_patches.begin());
- if(needed_files.size() > 0) {
+ if(available_patches.size() > 0) {
new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
- ExpectedMD5, needed_files);
+ ExpectedMD5, available_patches);
} else {
Finish(true);
return;
@@ -618,6 +638,12 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
// File was already in place. It needs to be re-verified
// because Release might have changed, so Move it into partial
Rename(Final,DestFile);
+ // unlink the file and do not try to use I-M-S and Last-Modified
+ // if the users proxy is broken
+ if(_config->FindB("Acquire::BrokenProxy", false) == true) {
+ std::cerr << "forcing re-get of the signature file as requested" << std::endl;
+ unlink(DestFile.c_str());
+ }
}
QueueURI(Desc);
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 6c78f33ef..8d58a39ba 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -99,7 +99,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
string sha1;
unsigned long size;
};
- vector<DiffInfo> needed_files;
+ vector<DiffInfo> available_patches;
public:
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 4b6ac5ce0..1f65062f7 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -593,17 +593,45 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
// verify the gpg signature of "Release"
// gpg --verify "*I+Release.gpg", "*I+Release"
+ const char *Args[400];
+ unsigned int i = 0;
+
string gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
string pubringpath = _config->Find("Apt::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg");
+ string releasegpg = *I+"Release.gpg";
+ string release = *I+"Release";
+
+ Args[i++] = gpgvpath.c_str();
+ Args[i++] = "--keyring";
+ Args[i++] = pubringpath.c_str();
+ Configuration::Item const *Opts;
+ Opts = _config->Tree("Acquire::gpgv::Options");
+ if (Opts != 0)
+ {
+ Opts = Opts->Child;
+ for (; Opts != 0; Opts = Opts->Next)
+ {
+ if (Opts->Value.empty() == true)
+ continue;
+ Args[i++] = Opts->Value.c_str();
+ if(i >= 390) {
+ _error->Error("Argument list from Acquire::gpgv::Options too long. Exiting.");
+ return false;
+ }
+ }
+ }
+
+ Args[i++] = releasegpg.c_str();
+ Args[i++] = release.c_str();
+ Args[i++] = NULL;
+
pid_t pid = ExecFork();
if(pid < 0) {
_error->Error("Fork failed");
return false;
}
if(pid == 0) {
- execlp(gpgvpath.c_str(), gpgvpath.c_str(), "--keyring",
- pubringpath.c_str(), string(*I+"Release.gpg").c_str(),
- string(*I+"Release").c_str(), NULL);
+ execvp(gpgvpath.c_str(), (char**)Args);
}
if(!ExecWait(pid, "gpgv")) {
_error->Warning("Signature verification failed for: %s",