summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2015-05-22 14:17:04 +0200
committerMichael Vogt <mvo@ubuntu.com>2015-05-22 14:17:04 +0200
commit68be2fbb252a71303046e2ca7866cd659a91b585 (patch)
treed9ad50c5fa43943c409fed2e7e8d476f4603fd42 /cmdline
parente29a7a394cfd41e8bad81535e0a8c07654f34bf6 (diff)
parent15901516326737a67f2a9af26cd7e434162de019 (diff)
Merge remote-tracking branch 'upstream/debian/sid' into debian/sid
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-get.cc28
-rw-r--r--cmdline/apt-helper.cc35
-rw-r--r--cmdline/apt-key.in2
3 files changed, 40 insertions, 25 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index cfa79339b..a28537712 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -797,13 +797,13 @@ static bool DoSource(CommandLine &CmdL)
}
// Back track
- vector<pkgSrcRecords::File> Lst;
- if (Last->Files(Lst) == false) {
+ vector<pkgSrcRecords::File2> Lst;
+ if (Last->Files2(Lst) == false) {
return false;
}
// Load them into the fetcher
- for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
+ for (vector<pkgSrcRecords::File2>::const_iterator I = Lst.begin();
I != Lst.end(); ++I)
{
// Try to guess what sort of file it is we are getting.
@@ -832,22 +832,26 @@ static bool DoSource(CommandLine &CmdL)
queued.insert(Last->Index().ArchiveURI(I->Path));
// check if we have a file with that md5 sum already localy
- if(!I->MD5Hash.empty() && FileExists(flNotDir(I->Path)))
- {
- FileFd Fd(flNotDir(I->Path), FileFd::ReadOnly);
- MD5Summation sum;
- sum.AddFD(Fd.Fd(), Fd.Size());
- Fd.Close();
- if((string)sum.Result() == I->MD5Hash)
+ std::string localFile = flNotDir(I->Path);
+ if (FileExists(localFile) == true)
+ if(I->Hashes.VerifyFile(localFile) == true)
{
ioprintf(c1out,_("Skipping already downloaded file '%s'\n"),
- flNotDir(I->Path).c_str());
+ localFile.c_str());
continue;
}
+
+ // see if we have a hash (Acquire::ForceHash is the only way to have none)
+ HashString const * const hs = I->Hashes.find(NULL);
+ if (hs == NULL && _config->FindB("APT::Get::AllowUnauthenticated",false) == false)
+ {
+ ioprintf(c1out, "Skipping download of file '%s' as requested hashsum is not available for authentication\n",
+ localFile.c_str());
+ continue;
}
new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
- I->MD5Hash,I->Size,
+ hs != NULL ? hs->toStr() : "", I->FileSize,
Last->Index().SourceInfo(*Last,*I),Src);
}
}
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index dd43ea1bc..63f70983c 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -48,23 +48,34 @@ static bool DoDownloadFile(CommandLine &CmdL)
if (CmdL.FileSize() <= 2)
return _error->Error(_("Must specify at least one pair url/filename"));
-
pkgAcquire Fetcher;
AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
Fetcher.Setup(&Stat);
- std::string download_uri = CmdL.FileList[1];
- std::string targetfile = CmdL.FileList[2];
- std::string hash;
- if (CmdL.FileSize() > 3)
- hash = CmdL.FileList[3];
- // we use download_uri as descr and targetfile as short-descr
- new pkgAcqFile(&Fetcher, download_uri, hash, 0, download_uri, targetfile,
- "dest-dir-ignored", targetfile);
- Fetcher.Run();
+
+ size_t fileind = 0;
+ std::vector<std::string> targetfiles;
+ while (fileind + 2 <= CmdL.FileSize())
+ {
+ std::string download_uri = CmdL.FileList[fileind + 1];
+ std::string targetfile = CmdL.FileList[fileind + 2];
+ std::string hash;
+ if (CmdL.FileSize() > fileind + 3)
+ hash = CmdL.FileList[fileind + 3];
+ // we use download_uri as descr and targetfile as short-descr
+ new pkgAcqFile(&Fetcher, download_uri, hash, 0, download_uri, targetfile,
+ "dest-dir-ignored", targetfile);
+ targetfiles.push_back(targetfile);
+ fileind += 3;
+ }
+
bool Failed = false;
- if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true ||
- FileExists(targetfile) == false)
+ if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
return _error->Error(_("Download Failed"));
+ if (targetfiles.empty() == false)
+ for (std::vector<std::string>::const_iterator f = targetfiles.begin(); f != targetfiles.end(); ++f)
+ if (FileExists(*f) == false)
+ return _error->Error(_("Download Failed"));
+
return true;
}
diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in
index 0774cf4b7..b4e071000 100644
--- a/cmdline/apt-key.in
+++ b/cmdline/apt-key.in
@@ -180,7 +180,7 @@ update() {
remove_key_from_keyring() {
local GPG="$GPG_CMD --keyring $1"
# check if the key is in this keyring: the key id is in the 5 column at the end
- if ! $GPG --with-colons --list-keys 2>&1 | grep -q "^pub:[^:]*:[^:]*:[^:]*:[0-9A-F]\+$2:"; then
+ if ! $GPG --with-colons --list-keys 2>&1 | grep -q "^pub:[^:]*:[^:]*:[^:]*:[0-9A-F]*$2:"; then
return
fi
if [ ! -w "$1" ]; then